GdPicture.NET.14
Tells to redraw annotations.
The bounding box of the region to redraw.
The index of the annotation to redraw. -1 means all annotations.
Applies GdPicture/XMP annotation to a PDF document.
The PDF to burn the annotations.
True to generate annots into the page Annot dictionary, False otherwise to generate postscript in page contents Stream.
Used when annotMode parameter is set to true. Specifies if standard PDF annotation subtypes must be used, otherwise private GdPicture subtypes are set.
Handles rendering instructions for annotation painting purpose.
Saves the state of the current graphics context (path state and attributes).
Restores previously saved graphics context (path state and attributes).
Appends a transformation matrix for subsequent drawing operations.
Sets the RGB color used for subsequent filling operations.
Clips a region specified by a rectangle from the original canvas.
Sets the blending mode used for subsequent drawing operations.
Sets the opacity value used for subsequent drawing operations.
Fills a path.
Draws an image.
Specifies a custom annotation painting.
Specifies one command for annotation appeance rendering.
Remove a file. Can throw exception.
Specifies the native licensor key string for a GdPictureFeatures enum value.
Used by the licensing system to map enum values to native library feature keys.
The native licensor key string (e.g., "gdp_image_conversion").
Initializes a new instance with the specified licensor key.
The native licensor key string.
The feature enum value (GdPictureFeatures or DocuViewareFeatures).
The type of the feature enum (GdPictureFeatures or DocuViewareFeatures).
Specifies the name of the implementation method.
If not specified, defaults to {MethodName}_Implementation.
Use nameof() for compile-time safety.
[RequiresLicense(GdPictureFeatures.OCR, ImplementationMethod = nameof(SetImage_Impl))]
public partial GdPictureStatus SetImage(int ImageID);
private GdPictureStatus SetImage_Impl(int ImageID) { ... }
The features that may be conditionally checked (as objects to support both enum types).
The type of the feature enum.
Initializes a new instance specifying which GdPicture features may be checked.
The GdPicture features that this method may conditionally validate.
Initializes a new instance specifying which DocuVieware features may be checked.
The DocuVieware features that this method may conditionally validate.
Internal helper class for mapping features to licensor keys.
This class is used by the ToolkitUnlocker to dynamically build the mapping from enum attributes.
Validates cryptographic tokens returned from native license checks.
Implements HMAC-SHA256 signature verification with anti-replay protection.
Validates a cryptographic token from the native layer.
Token string in format: featureHash:timestamp:nonce:signature
The feature string that should be validated
True if token is valid, false otherwise
Generates a random nonce for use in token requests.
Gets the derived secret key for HMAC computation.
Called by generated validator classes.
Checks and registers a nonce for anti-replay protection.
Returns true if nonce is new, false if already used.
Called by generated validator classes.
Derives the secret key using PBKDF2 key derivation function.
Must match the C++ implementation exactly.
Tracks feature evaluation in demo mode for telemetry purposes.
Called by generated license validators when a feature is accessed in demo mode.
Gets the license feature key string for a given GdPictureFeatures enum value.
The GdPictureFeatures enum value to look up.
The license feature key string, or null if not found.
The OcrOutputDocx class offers several flavors of text output for the ocr result.
The constructor initializes members with the provided parameters.
the flag indicating whether to keep line breaks or not.
Output writes the Ocr results to the file.
The array with the ocr result.
The path to the output file.
Starts a block.
The block.
Ends a block.
Starts a paragraph.
The paragraph.
Ends a paragraph.
Starts a text line.
The text line.
Ends a text line.
Starts a word.
The word.
Ends a word.
Fires a character.
The word.
The character.
The flag indicating whether the current block should be skipped or not.
The helper for the docx output.
The flag indicating whether the current line is the first line of the current paragraph or not.
The flag indicating whether the current word is the first word of the current line or not.
The OcrTableOutputXlsx class offers several flavors of table output for the ocr result.
The constructor initializes members with the provided parameters.
Contains all the available options to save ocr as spreadsheet
The constructor initializes members with the provided parameters.
Contains all the available options to save ocr as spreadsheet
Indicates the table index to convert as xlsx, if equal -1, all tables are rendered
Output writes the Ocr results to the file.
The array with the ocr result.
The path to the output file.
Indicates the table index to convert as xlsx, if equal -1, all tables are rendered
Indicates where to start the table on the xlsx sheet, it is ignored if preserveTablePosition is true
Indicates where to start the table on the xlsx sheet, it is ignored if preserveTablePosition is true
Indicates whether to keep all the table on the same page or not
Indicates whether to keep the table position on the xlsx sheet or not
Builds a GraphicsPath object from a GdPicturePath object.
The GdPicturePath object. Can be null or empty.
Filling mode, a member of the GdPictureFillMode enumeration.
Always returns a GraphicsPath object, even if the path parameter is null or empty.
Builds a GraphicsPath object from a GdPicturePath object.
The GdPicturePath object. Can be null or empty.
Filling mode, a member of the GdPictureFillMode enumeration.
If the GdPictureStatus returned by the method is OK, always returns a GraphicsPath handle, even if the path parameter is null or empty.
A member of the GdPictureStatus enumeration.
The AnnotationManager class provides all the necessary handling of the GdPictureXMP annotations in your files.
Using this class, you can create or load annotations, change their properties and save them directly to your document.
The initialisation of the AnnotationManager object is possible from more sources, like GdViewer control, GdPictureImage object or GdPicturePDF class and others.
AnnotationManager Constructor
How to create and dispose of the AnnotationManager object.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("test.tif") = GdPictureStatus.OK Then
MessageBox.Show("The number of pages: " + annotationManager.PageCount, "AnnotationManager")
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if (annotationManager.InitFromFile("test.tif") == GdPictureStatus.OK)
{
MessageBox.Show("The number of pages: " + annotationManager.PageCount, "AnnotationManager");
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager");
annotationManager.Dispose();
Bridges the AnnotationConverter (which lives in GdPicture.NET.PDF) to the AnnotationManager
(which lives in toolkit). Registers static handlers on AnnotationConverterXMPHooks so that
the PDF-layer ImportDataFromXMP / ExportDataToXMP code paths can delegate the actual XMP
serialization to AnnotationManager without taking a hard dependency on the toolkit.
This event is raised right after the currently processed page has been successfully created and saved. It is only applied when the initial document is image-based.
Please check the corresponded for given parameters.
The event is only raised when processing documents based on images using the or the methods and its overloads.
The event is not raised, if your initial document is in PDF or TXT format and you are saving it using the method and its overloads.
The event is not raised using the method and its overloads as well.
Be aware that the event is only raised using the SaveDocumentToPDF methods or the SaveDocumentToTIFF methods,
if your initial document is image-based (neither PDF nor TXT). The event is not raised when using the SaveDocumentToJPEG methods.
How to add this event to your AnnotationManager object.
'We assume that the annotationManager object has been integrated into your application.
Friend WithEvents annotationManager As GdPicture14.AnnotationManager
'Add the event.
AddHandler annotationManager.SavingProgress, AddressOf annotationManager_SavingProgress
'Define the event.
Sub annotationManager_SavingProgress(ByVal PageNo As Integer, ByVal PageCount As Integer) Handles annotationManager.SavingProgress
'Do your stuff here.
End Sub
//We assume that the annotationManager object has been integrated into your application.
//Add the event.
annotationManager.SavingProgress += annotationManager_SavingProgress;
//Define the event.
void annotationManager_SavingProgress(int PageNo, int PageCount)
{
//Do your stuff here.
}
The page number of the currently processed page. It is a value from 1 to PageCount.
The total number of pages to be saved.
This event is raised when a custom annotation is to be rendered. Your custom ModelID identifier, that you have defined when adding the custom annotation,
should be used internally in this event to render the required annotation, as it is demontrated in the Example section below.
Please check the corresponded for given parameters.
The bounding box for the annotation appearance, that you need to follow, is defined by values x, y, w, h, where x and y define the coordinates of the
top-left corner of the box as x = (Annot.Left - Annot.Width) / 2, y = (Annot.Top - Annot.Height) / 2, w defines the width of the box as w = Annot.Width and y
defines the height of the box as y = Annot.Height.The measurement unit used for specified dimensions and sizes is expressed in inches.
The rotation, if any, is handled by the component, which automatically sets the required transformation.
Be aware that this event is not supported by the COM Interop edition.
You can find the use of this event in our Annotations Sample here.
Please respect the annotation bounding box coordinates and sizes expressed in inches, as they are described in the Summary section above.
How to add this event to your AnnotationManager object.
This example introduces two custom annotations - the triangle one with the ModelID = 1 and the cross one with the ModelID = 2.
'We assume that the annotationManager object has been integrated into your application.
Friend WithEvents annotationManager As GdPicture14.AnnotationManager
'Add the event.
AddHandler annotationManager.OnCustomAnnotationPaint, AddressOf annotationManager_OnCustomAnnotationPaint
'Define the event.
Sub annotationManager_OnCustomAnnotationPaint(ByVal Annot As GdPicture14.Annotations.AnnotationCustom, ByVal g As System.Drawing.Graphics) Handles annotationManager.OnCustomAnnotationPaint
Select Case Annot.ModelID
Case 1 'triangle annotation
Using gp As New Drawing.Drawing2D.GraphicsPath
gp.AddLine(New PointF(Annot.Left - Annot.Width / 2, Annot.Top + Annot.Height / 2), New PointF(Annot.Left, Annot.Top - Annot.Height / 2))
gp.AddLine(New PointF(Annot.Left, Annot.Top - Annot.Height / 2), New PointF(Annot.Left + Annot.Width / 2, Annot.Top + Annot.Height / 2))
gp.CloseFigure()
g.DrawPath(New Pen(Brushes.Red, 0.1), gp)
End Using
Case 2 'cross annotation
g.DrawLine(New Pen(Brushes.Red, 0.1), New PointF(Annot.Left - Annot.Width / 2, Annot.Top - Annot.Height / 2), New PointF(Annot.Left + Annot.Width / 2, Annot.Top + Annot.Height / 2))
g.DrawLine(New Pen(Brushes.Red, 0.1), New PointF(Annot.Left - Annot.Width / 2, Annot.Top + Annot.Height / 2), New PointF(Annot.Left + Annot.Width / 2, Annot.Top - Annot.Height / 2))
End Select
End Sub
//We assume that the annotationManager object has been integrated into your application.
//Add the event.
annotationManager.OnCustomAnnotationPaint += annotationManager_OnCustomAnnotationPaint;
//Define the event.
void annotationManager_OnCustomAnnotationPaint(GdPicture14.Annotations.AnnotationCustom Annot, System.Drawing.Graphics g)
{
switch (Annot.ModelID)
{
case 1:
using (System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath())
{
gp.AddLine(new PointF(Annot.Left - Annot.Width / 2, Annot.Top + Annot.Height / 2), new PointF(Annot.Left, Annot.Top - Annot.Height / 2));
gp.AddLine(new PointF(Annot.Left, Annot.Top - Annot.Height / 2), new PointF(Annot.Left + Annot.Width / 2, Annot.Top + Annot.Height / 2));
gp.CloseFigure();
g.DrawPath(new Pen(System.Drawing.Brushes.Red, 0.1f), gp);
}
break;
case 2:
g.DrawLine(new Pen(System.Drawing.Brushes.Red, 0.1f), new PointF(Annot.Left - Annot.Width / 2, Annot.Top - Annot.Height / 2), new PointF(Annot.Left + Annot.Width / 2, Annot.Top + Annot.Height / 2));
g.DrawLine(new Pen(System.Drawing.Brushes.Red, 0.1f), new PointF(Annot.Left - Annot.Width / 2, Annot.Top + Annot.Height / 2), new PointF(Annot.Left + Annot.Width / 2, Annot.Top - Annot.Height / 2));
break;
default: break;
}
}
The custom annotation object to render.
The device object used to render the custom annotation appearance.
Gets the page number of the currently selected page of the document handled by this AnnotationManager object. The pages are numbered starting from 1.
The current page number.
Please note that the pages are numbered starting from 1. Likewise, you have to select the required page before starting any page related action with the handled document.
Finding out the currently selected page in the handled document.
Using annotationManager As AnnotationManager = New AnnotationManager()
annotationManager.InitFromFile("test.pdf")
Dim message As String = "The number of pages: " + annotationManager.PageCount
message = message + vbCrLf + "The current page: " + annotationManager.CurrentPage
MessageBox.Show(message, "CurrentPage", MessageBoxButtons.OK, MessageBoxIcon.Information)
annotationManager.Close()
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
annotationManager.InitFromFile("test.pdf");
string message = "The number of pages: " + annotationManager.PageCount;
message += "\nThe current page: " + annotationManager.CurrentPage;
MessageBox.Show(message, "CurrentPage", MessageBoxButtons.OK, MessageBoxIcon.Information);
annotationManager.Close();
}
Gets the total number of pages in the document currently handled by this AnnotationManager object.
Be aware that you have to select the required page before starting any page related action with the handled document.
How to find out the number of pages in the currently handled document.
Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("test.pdf") = GdPictureStatus.OK Then
Dim message As String = "The number of pages: " + annotationManager.PageCount
For p As Integer = 1 To annotationManager.PageCount - 1
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
message = message + vbCrLf + "The page nr." + p + " contains " + annotCount.ToString() + " annotations."
Else
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount")
Exit For
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount")
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then MessageBox.Show(message, "AnnotationManager.PageCount")
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("test.pdf") == GdPictureStatus.OK)
{
string message = "The number of pages: " + annotationManager.PageCount;
for (int p = 1; p < annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
message = message + "\nThe page nr." + p + " contains " + annotCount.ToString() + " annotations.";
}
else
{
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount");
break;
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount");
break;
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
MessageBox.Show(message, "AnnotationManager.PageCount");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.PageCount");
}
Selects the page to be operated further in the document currently handled by this AnnotationManager object.
It is always necessary to select the required page before handling the document.
The required page number. It must be a value from 1 to the value of the property.
Please ensure that you have selected the proper page before starting any page related action with the handled document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to select a required page in a handled document.
Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("test.pdf") = GdPictureStatus.OK Then
Dim message As String = "The number of pages: " + annotationManager.PageCount
For p As Integer = 1 To annotationManager.PageCount - 1
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
message = message + vbCrLf + "The page nr." + p + " contains " + annotCount.ToString() + " annotations."
Else
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
Exit For
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then MessageBox.Show(message, "AnnotationManager.SelectPage")
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("test.pdf") == GdPictureStatus.OK)
{
string message = "The number of pages: " + annotationManager.PageCount;
for (int p = 1; p < annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
message = message + "\nThe page nr." + p + " contains " + annotCount.ToString() + " annotations.";
}
else
{
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
break;
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
break;
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
MessageBox.Show(message, "AnnotationManager.SelectPage");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
}
Forces the AnnotationManager object to save GdPicture/XMP annotations to the currently selected page of the handled document.
Be aware that annotations are always treated relative to the current page.
This method only attaches rendered annotations to the currently selected page while keeping them in the GdPicture/XMP format.
You need to use the method to permanently include them into the page content.
This method is applied internally automatically on each page change.
Be aware that this method is applied internally always when you change the page using the method.
Just to inform you that saving annotations keeps them in the GdPicture/XMP format alongside with the document.
Please use the method if you want to permanently incorporate the annotations to be part of the document content.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the newly added annotation to the currently selected page of the handled document.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) = GdPictureStatus.OK Then
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveAnnotationsToPage")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage")
End If
Else
MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) == GdPictureStatus.OK)
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveAnnotationsToPage");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage");
}
else
MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToPage");
annotationManager.Dispose();
Closes the current AnnotationManager object by releasing the loaded document and all related annotations data.
It is a good practice to call this method when you complete all the necessary annotation handling of the document.
Be aware that neither document nor annotations are associated with this AnnotationManager object after closing it anymore.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
AnnotationManager Constructor
How to close the current AnnotationManager after adding an anotation to a file.
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
If annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) <> GdPictureStatus.OK Then
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close")
End If
Else
MessageBox.Show("Annotations can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close")
End If
status = annotationManager.GetStat() 'Last known status before closing the annotation manager.
annotationManager.Close()
Else
status = annotationManager.GetStat()
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + status.ToString(), "AnnotationManager.Close")
End If
If status = GdPictureStatus.OK Then
'We assume that the GdViewer1 control has been integrated into your application.
GdViewer1.DisplayFromFile("image_approved.jpg")
annotationManager = GdViewer1.GetAnnotationManager()
End If
GdPictureStatus status = GdPictureStatus.OK;
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if (annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK)
{
if (annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) != GdPictureStatus.OK)
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close");
}
else
MessageBox.Show("Annotations can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Close");
status = annotationManager.GetStat(); //Last known status before closing the annotation manager.
annotationManager.Close();
}
else
{
status = annotationManager.GetStat();
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + status.ToString(), "AnnotationManager.Close");
}
if (status == GdPictureStatus.OK)
{
//We assume that the GdViewer1 control has been integrated into your application.
GdViewer1.DisplayFromFile("image_approved.jpg");
annotationManager = GdViewer1.GetAnnotationManager();
}
Initializes the current AnnotationManager object from a file according to a file path you have specified.
The document previously handled by this AnnotationManager object will automatically close.
All document formats currently supported by the toolkit are listed here.
Be aware that the AnnotationManager object only handles GdPicture/XMP annotations contained in the source document.
This method requires the Annotations component to run.
The file path of the source document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to initialize the AnnotationManager object from a JPEG file.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("test.jpeg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToJPEG("test_approved.jpeg") = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromFile")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromFile")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromFile")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromFile")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("test.jpeg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToJPEG("test_approved.jpeg") == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromFile");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromFile");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromFile");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromFile");
annotationManager.Dispose();
Initializes the current AnnotationManager object from an instantiated Stream object according to what you have specified.
The document previously handled by this AnnotationManager object will automatically close.
All document formats currently supported by the toolkit are listed here.
Be aware that the AnnotationManager object only handles GdPicture/XMP annotations contained in the source document.
This method requires the Annotations component to run.
Initializes the current AnnotationManager object from an instantiated Stream object according to what you have specified.
A System.IO.Stream object. This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to initialize the AnnotationManager object from a JPG file using a stream.
Dim annotationManager As AnnotationManager = New AnnotationManager()
Dim file As System.IO.Stream = New System.IO.FileStream("image.jpg", System.IO.FileMode.Open)
If (annotationManager.InitFromStream(file) = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToPDF("approved.pdf") = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromStream")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream")
End If
annotationManager.Dispose()
file.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
System.IO.Stream file = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open);
if ((annotationManager.InitFromStream(file) == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToPDF("approved.pdf") == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromStream");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream");
annotationManager.Dispose();
file.Dispose();
Initializes the current AnnotationManager object from an instantiated Stream object according to what you have specified.
The document previously handled by this AnnotationManager will automatically close.
This method is useful for files, that have no header information in their internal structure, like text files or .svg files,
as you can specify their file name to allow the toolkit with certainty to recognize the document format of the file to load.
All document formats currently supported by the toolkit are listed here.
Be aware that the AnnotationManager object only handles GdPicture/XMP annotations contained in the source document.
This method requires the Annotations component to run.
Initializes the current AnnotationManager object from an instantiated Stream object according to what you have specified.
A System.IO.Stream object. This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.
The file name of the document, that is stored in the Stream parameter, for example myfile.svg.
The toolkit will automatically recognize the document format based on the file name to be able to load the required file.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to initialize the AnnotationManager object from a SVG file using a stream.
Dim annotationManager As AnnotationManager = New AnnotationManager()
Dim filename As String = "image.svg"
Dim file As System.IO.Stream = New System.IO.FileStream(filename, System.IO.FileMode.Open)
If (annotationManager.InitFromStream(file, filename) = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToTIFF("image_approved.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromStream")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream")
End If
annotationManager.Dispose()
file.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
String filename = "image.svg";
System.IO.Stream file = new System.IO.FileStream(filename, System.IO.FileMode.Open);
if ((annotationManager.InitFromStream(file, filename) == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToTIFF("image_approved.tif", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromStream");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromStream");
annotationManager.Dispose();
file.Dispose();
Initializes the current AnnotationManager object from a PDF document handled by a specified GdPicturePDF object.
The document previously handled by this AnnotationManager object will automatically close.
Be aware that the AnnotationManager object only handles GdPicture/XMP annotations contained in the source PDF document.
This method requires the Annotations component to run.
The GdPicturePDF object that handles a required PDF document.
This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to initialize the AnnotationManager object from already initialized GdPicturePDF object.
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (gdpicturePDF.LoadFromFile("annots.pdf", False) = GdPictureStatus.OK) AndAlso
(annotationManager.InitFromGdPicturePDF(gdpicturePDF) = GdPictureStatus.OK) Then
For p As Integer = 1 To gdpicturePDF.GetPageCount()
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annot As GdPicture14.Annotations.Annotation = Nothing
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
For i As Integer = 0 To annotCount - 1
annot = annotationManager.GetAnnotationFromIdx(i)
If (annotationManager.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Tag = "changed by GdPicture"
Else
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then
If annotationManager.SaveAnnotationsToPage() <> GdPictureStatus.OK Then Exit For
End If
Else
Exit For
End If
Next
If (annotationManager.GetStat() = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToPDF("annots_changed.pdf") = GdPictureStatus.OK) Then MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromGdPicturePDF")
If annotationManager.GetStat() <> GdPictureStatus.OK Then MessageBox.Show("The example has failed. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPicturePDF")
annotationManager.Close()
Else
MessageBox.Show("Objects can't be initialized properly.", "AnnotationManager.InitFromGdPicturePDF")
End If
annotationManager.Dispose()
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
AnnotationManager annotationManager = new AnnotationManager();
if ((gdpicturePDF.LoadFromFile("annots.pdf", false) == GdPictureStatus.OK) &&
(annotationManager.InitFromGdPicturePDF(gdpicturePDF) == GdPictureStatus.OK))
{
for (int p = 1; p <= gdpicturePDF.GetPageCount(); p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
GdPicture14.Annotations.Annotation annot = null;
int annotCount = annotationManager.GetAnnotationCount();
for (int i = 0; i < annotCount; i++)
{
annot = annotationManager.GetAnnotationFromIdx(i);
if ((annotationManager.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Tag = "changed by GdPicture";
}
else break;
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
if (annotationManager.SaveAnnotationsToPage() != GdPictureStatus.OK) break;
}
else break;
}
if ((annotationManager.GetStat() == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToPDF("annots_changed.pdf") == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.GetAnnotationFromIdx");
if (annotationManager.GetStat() != GdPictureStatus.OK)
MessageBox.Show("The example has failed. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationFromIdx");
annotationManager.Close();
}
else
MessageBox.Show("Objects can't be initialized properly.", "AnnotationManager.GetAnnotationFromIdx");
annotationManager.Dispose();
gdpicturePDF.Dispose();
Initializes the current AnnotationManager object from a previously instantiated GdViewer object.
The document previously handled by this AnnotationManager object will automatically close.
This method only initialises the AnnotationManager object, it means this AnnotationManager object will not be connected to the source GdViewer object.
You need to use the method to have these objects linked for further usage, for example, when deleting annotations.
Be aware that the AnnotationManager object only handles GdPicture/XMP annotations available through the source GdViewer object.
The GdViewer object that handles the source document.
This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to initialize the AnnotationManager object from already initialized GdViewer object.
'We assume that the GdViewer1 control has been integrated into your application.
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK) AndAlso
(GdViewer1.DisplayFromGdPicturePDF(gdpicturePDF) = GdPictureStatus.OK) Then
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromGdViewer(GdViewer1) = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
annotationManager.SaveAnnotationsToPage()
stamp.Dispose()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdViewer")
End If
End If
annotationManager.Close()
GdViewer1.Redraw()
End If
//We assume that the GdViewer1 control has been integrated into your application.
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK) &&
(GdViewer1.DisplayFromGdPicturePDF(gdpicturePDF) == GdPictureStatus.OK))
{
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromGdViewer(GdViewer1) == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
annotationManager.SaveAnnotationsToPage();
stamp.Dispose();
}
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdViewer");
}
annotationManager.Close();
GdViewer1.Redraw();
}
Initializes the current AnnotationManager object from a required GdPictureImage object identified by an unique image identifier.
The document previously handled by this AnnotationManager object will automatically close.
Be aware that the AnnotationManager object only handles GdPicture/XMP annotations contained in the source image.
This method requires the Annotations component to run.
A unique image identifier of the GdPictureImage object representing the required image.
You can obtain this identifier, for example, using methods of the class when creating the image resource.
Be aware that this object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to initialize the AnnotationManager object from already initialized GdPictureImage object.
Dim oImage As GdPictureImaging = New GdPictureImaging()
Dim annotationManager As AnnotationManager = New AnnotationManager()
Dim imageID As Integer = oImage.CreateGdPictureImageFromFile("image.tiff")
If (oImage.GetStat() = GdPictureStatus.OK) AndAlso
(annotationManager.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToTIFF("image_approved.tiff", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromGdPictureImage")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPictureImage")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPictureImage")
End If
annotationManager.Close()
Else
MessageBox.Show("Objects can't be initialized properly.", "AnnotationManager.InitFromGdPictureImage")
End If
annotationManager.Dispose()
oImage.ReleaseGdPictureImage(imageID)
oImage.Dispose()
GdPictureImaging oImage = new GdPictureImaging();
AnnotationManager annotationManager = new AnnotationManager();
int imageID = oImage.CreateGdPictureImageFromFile("image.tiff");
if ((oImage.GetStat() == GdPictureStatus.OK) &&
(annotationManager.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToTIFF("image_approved.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromGdPictureImage");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPictureImage");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPictureImage");
annotationManager.Close();
}
else
MessageBox.Show("Objects can't be initialized properly.", "AnnotationManager.InitFromGdPictureImage");
annotationManager.Dispose();
oImage.ReleaseGdPictureImage(imageID);
oImage.Dispose();
Returns the number of all GdPicture/XMP annotation objects contained within the selected page of the document currently handled by this AnnotationManager object.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.You can regularly apply the method to determine if this method has been successful.
This method requires the Annotations component to run.
The number of all GdPicture/XMP annotation objects included within the selected page of the handled document.
How to find out the number of GdPicture/XMP annotations within the handled document.
Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("test.pdf") = GdPictureStatus.OK Then
Dim message As String = "The number of pages: " + annotationManager.PageCount
For p As Integer = 1 To annotationManager.PageCount - 1
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
message = message + vbCrLf + "The page nr." + p + " contains " + annotCount.ToString() + " annotations."
Else
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
Exit For
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then MessageBox.Show(message, "AnnotationManager.SelectPage")
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("test.pdf") == GdPictureStatus.OK)
{
string message = "The number of pages: " + annotationManager.PageCount;
for (int p = 1; p < annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
message = message + "\nThe page nr." + p + " contains " + annotCount.ToString() + " annotations.";
}
else
{
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
break;
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
break;
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
MessageBox.Show(message, "AnnotationManager.SelectPage");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SelectPage");
}
Returns a required GdPicture/XMP annotation object specified by its index related to the selected page of the document currently handled by this AnnotationManager object.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
The required GdPicture/XMP annotation object of the type GdPicture14.Annotations.Annotation. The method can be subsequently used to determine if this method has been successful.
How to get the required annotation object specified by its index within the selected page.
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (gdpicturePDF.LoadFromFile("annots.pdf", False) = GdPictureStatus.OK) AndAlso
(annotationManager.InitFromGdPicturePDF(gdpicturePDF) = GdPictureStatus.OK) Then
For p As Integer = 1 To gdpicturePDF.GetPageCount()
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annot As GdPicture14.Annotations.Annotation = Nothing
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
For i As Integer = 0 To annotCount - 1
annot = annotationManager.GetAnnotationFromIdx(i)
If (annotationManager.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Tag = "changed by GdPicture"
Else
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then
If annotationManager.SaveAnnotationsToPage() <> GdPictureStatus.OK Then Exit For
End If
Else
Exit For
End If
Next
If (annotationManager.GetStat() = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToPDF("annots_changed.pdf") = GdPictureStatus.OK) Then MessageBox.Show("Finished successfully!", "AnnotationManager.InitFromGdPicturePDF")
If annotationManager.GetStat() <> GdPictureStatus.OK Then MessageBox.Show("The example has failed. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.InitFromGdPicturePDF")
annotationManager.Close()
Else
MessageBox.Show("Objects can't be initialized properly.", "AnnotationManager.InitFromGdPicturePDF")
End If
annotationManager.Dispose()
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
AnnotationManager annotationManager = new AnnotationManager();
if ((gdpicturePDF.LoadFromFile("annots.pdf", false) == GdPictureStatus.OK) &&
(annotationManager.InitFromGdPicturePDF(gdpicturePDF) == GdPictureStatus.OK))
{
for (int p = 1; p <= gdpicturePDF.GetPageCount(); p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
GdPicture14.Annotations.Annotation annot = null;
int annotCount = annotationManager.GetAnnotationCount();
for (int i = 0; i < annotCount; i++)
{
annot = annotationManager.GetAnnotationFromIdx(i);
if ((annotationManager.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Tag = "changed by GdPicture";
}
else break;
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
if (annotationManager.SaveAnnotationsToPage() != GdPictureStatus.OK) break;
}
else break;
}
if ((annotationManager.GetStat() == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToPDF("annots_changed.pdf") == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.GetAnnotationFromIdx");
if (annotationManager.GetStat() != GdPictureStatus.OK)
MessageBox.Show("The example has failed. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationFromIdx");
annotationManager.Close();
}
else
MessageBox.Show("Objects can't be initialized properly.", "AnnotationManager.GetAnnotationFromIdx");
annotationManager.Dispose();
gdpicturePDF.Dispose();
Returns an index of the specified GdPicture/XMP annotation object within the selected page of the document currently handled by this AnnotationManager object.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The required GdPictureXMP annotation object.
Please ensure that the returned value is valid annotation index, which means it is greater then -1, before using it further.
Be aware that annotations are always treated relative to the selected page.
An index of the specified GdPicture/XMP annotation object. The method can be subsequently used to determine if this method has been successful.
The returned value is between 0 and -1 if the specified annotation has been found
or -1 if the specified annotation has not been found within the selected page.
How to get an index of the newly added annotation.
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim annotXML As String = ""
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
Dim annotIdx As Integer = annotationManager.GetAnnotationIdx(stamp)
If annotationManager.GetStat() = GdPictureStatus.OK Then
annotXML = annotationManager.GetAnnotationXML(annotIdx)
If annotationManager.GetStat() = GdPictureStatus.OK Then
status = annotationManager.SaveDocumentToPDF("source_stamped.pdf")
End If
Else
status = annotationManager.GetStat()
End If
Else
status = annotationManager.GetStat()
End If
stamp.Dispose()
End If
annotationManager.Close()
If status = GdPictureStatus.OK Then
If (annotationManager.InitFromFile("dest.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.Annotation = annotationManager.AddAnnotationFromXML(annotXML)
If annot IsNot Nothing Then status = annotationManager.SaveAnnotationsToPage()
If status = GdPictureStatus.OK Then
status = annotationManager.SaveDocumentToPDF("dest_stamped.pdf")
End If
Else
status = annotationManager.GetStat()
End If
End If
annotationManager.Close()
Else
status = annotationManager.GetStat()
End If
If status = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationIdx")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationIdx")
End If
annotationManager.Dispose()
GdPictureStatus status = GdPictureStatus.OK;
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
string annotXML = "";
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if (annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK)
{
int annotIdx = annotationManager.GetAnnotationIdx(stamp);
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
annotXML = annotationManager.GetAnnotationXML(annotIdx);
if (annotationManager.GetStat() == GdPictureStatus.OK)
status = annotationManager.SaveDocumentToPDF("source_stamped.pdf");
}
else status = annotationManager.GetStat();
}
else status = annotationManager.GetStat();
stamp.Dispose();
}
annotationManager.Close();
if (status == GdPictureStatus.OK)
{
if ((annotationManager.InitFromFile("dest.pdf") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.Annotation annot = annotationManager.AddAnnotationFromXML(annotXML);
if (annot != null)
status = annotationManager.SaveAnnotationsToPage();
if (status == GdPictureStatus.OK)
status = annotationManager.SaveDocumentToPDF("dest_stamped.pdf");
}
else status = annotationManager.GetStat();
}
annotationManager.Close();
}
else status = annotationManager.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationIdx");
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationIdx");
annotationManager.Dispose();
Returns an array of GdPicture/XMP annotations, sorted by their Z-order, which are contained on the selected page of the document
currently handled by this AnnotationManager object.Be aware that this method only handles GdPicture/XMP annotations.
Likewise, annotations are always treated relative to the selected page.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
An array of sorted Annotation objects by their Z-order contained on the currently selected page.
How to get the annotations contained on the current page sorted by their Z-order.
Using annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("annots.jpeg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim message As String = "Done!" + vbCrLf
Dim annots As GdPicture14.Annotations.Annotation() = annotationManager.GetOrderedAnnotations()
If annotationManager.GetStat() = GdPictureStatus.OK Then
For i As Integer = 0 To annots.Count() - 1
message += annots(i).GetType().ToString() + " Z: " + annots(i).Zorder + vbCrLf
'Or you can change the annotations Z-order here as you need.
Next
MessageBox.Show(message, "AnnotationManager.GetOrderedAnnotations")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetOrderedAnnotations")
End If
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetOrderedAnnotations")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if ((annotationManager.InitFromFile("annots.jpeg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
string message = "Done!\n";
GdPicture14.Annotations.Annotation[] annots = annotationManager.GetOrderedAnnotations();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
for (int i = 0; i < annots.Count(); i++)
{
message += annots[i].GetType() + " Z: " + annots[i].Zorder + "\n";
//Or you can change the annotations Z - order here as you need.
}
MessageBox.Show(message, "AnnotationManager.GetOrderedAnnotations");
}
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetOrderedAnnotations");
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetOrderedAnnotations");
}
Changes the current value of an annotation property, which is defined by its name, to a newly specified value. The GdPicture/XMP annotation object
is specified by its index and relates to the selected page of the document currently handled by this AnnotationManager object.
This method has been initially introduced for the COM interop edition.
Please refer to the Annotations Namespace for the .NET edition to determine available annotation properties and explore them for each particular class.
All annotations classes share their properties from the main Annotation class and add their own properties to the individual classes according to the annotation type.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
The name of a required annotation property as a string, for example, "FillColor".
The new value to apply for the specified annotation property.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.At the same, be aware that the method only handles GdPicture/XMP annotations.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the value of the required property of the specified annotation.
Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK Then
For p As Integer = 1 To annotationManager.PageCount
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
For a As Integer = 0 To annotCount - 1
Dim value As Object = annotationManager.GetAnnotationPropertyValue(a, "Tag")
Dim tagValue As String = ""
If value IsNot Nothing Then
tagValue = CStr(value)
If tagValue.Equals("delete") Then
If annotationManager.DeleteAnnotation(a) <> GdPictureStatus.OK Then Exit For
Else
tagValue += " checked"
value = CObj(tagValue)
If annotationManager.SetAnnotationPropertyValue(a, "Tag", value) <> GdPictureStatus.OK Then Exit For
End If
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then annotationManager.SaveAnnotationsToPage()
If annotationManager.GetStat() <> GdPictureStatus.OK Then Exit For
Else
Exit For
End If
Else
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then
If annotationManager.SaveDocumentToPDF("dest.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.SetAnnotationPropertyValue")
Else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK)
{
for (int p = 1; p <= annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
for (int a = 0; a < annotCount; a++)
{
object value = annotationManager.GetAnnotationPropertyValue(a, "Tag");
string tagValue = "";
if (value != null)
{
tagValue = (string)value;
if (tagValue.Equals("delete"))
{
if (annotationManager.DeleteAnnotation(a) != GdPictureStatus.OK) break;
}
else
{
tagValue += " checked";
value = (object)tagValue;
if (annotationManager.SetAnnotationPropertyValue(a, "Tag", value) != GdPictureStatus.OK) break;
}
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
annotationManager.SaveAnnotationsToPage();
if (annotationManager.GetStat() != GdPictureStatus.OK) break;
}
else break;
}
else break;
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (annotationManager.SaveDocumentToPDF("dest.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.SetAnnotationPropertyValue");
else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue");
}
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationPropertyValue");
}
Returns the current value of a required annotation property of a GdPicture/XMP annotation object specified by its index related to the selected page
of the document currently handled by this AnnotationManager object.This method has been initially introduced for the COM interop edition.
Please refer to the Annotations Namespace for the .NET edition to determine available annotation properties and explore them for each particular class.
All annotations classes share their properties from the main Annotation class and add their own properties to the individual classes according to the annotation type.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
The name of a required annotation property as a string, for example, "FillColor".
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page. At the same, be aware that the method only handles GdPicture/XMP annotations.
The value of the specified property or an empty object. The method can be subsequently used to determine if this method has been successful.
How to get the value of the required property of the specified annotation.
Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK Then
For p As Integer = 1 To annotationManager.PageCount
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
For a As Integer = 0 To annotCount - 1
Dim value As Object = annotationManager.GetAnnotationPropertyValue(a, "Tag")
Dim tagValue As String = ""
If value IsNot Nothing Then
tagValue = CStr(value)
If tagValue.Equals("delete") Then
If annotationManager.DeleteAnnotation(a) <> GdPictureStatus.OK Then Exit For
Else
tagValue += " checked"
value = CObj(tagValue)
If annotationManager.SetAnnotationPropertyValue(a, "Tag", value) <> GdPictureStatus.OK Then Exit For
End If
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then annotationManager.SaveAnnotationsToPage()
If annotationManager.GetStat() <> GdPictureStatus.OK Then Exit For
Else
Exit For
End If
Else
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then
If annotationManager.SaveDocumentToPDF("dest.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationPropertyValue")
Else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationPropertyValue")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationPropertyValue")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationType")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK)
{
for (int p = 1; p <= annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
for (int a = 0; a < annotCount; a++)
{
object value = annotationManager.GetAnnotationPropertyValue(a, "Tag");
string tagValue = "";
if (value != null)
{
tagValue = (string)value;
if (tagValue.Equals("delete"))
{
if (annotationManager.DeleteAnnotation(a) != GdPictureStatus.OK) break;
}
else
{
tagValue += " checked";
value = (object)tagValue;
if (annotationManager.SetAnnotationPropertyValue(a, "Tag", value) != GdPictureStatus.OK) break;
}
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
annotationManager.SaveAnnotationsToPage();
if (annotationManager.GetStat() != GdPictureStatus.OK) break;
}
else break;
}
else break;
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (annotationManager.SaveDocumentToPDF("dest.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationPropertyValue");
else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationPropertyValue");
}
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationPropertyValue");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationType");
}
Returns the type of a required GdPicture/XMP annotation object specified by its index related to the selected page of the document currently handled by this AnnotationManager object.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
A member of the GdPictureAnnotationType enumeration. The method can be subsequently used to determine if this method has been successful.
How to determine the type of the specified annotation.
Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK Then
For p As Integer = 1 To annotationManager.PageCount
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
For a As Integer = 0 To annotCount - 1
Dim type As GdPicture14.Annotations.Annotation.GdPictureAnnotationType = annotationManager.GetAnnotationType(a)
If annotationManager.GetStat() = GdPictureStatus.OK Then
If type = GdPicture14.Annotations.Annotation.GdPictureAnnotationType.AnnotationTypeRubberStamp Then
Dim annot As GdPicture14.Annotations.Annotation = annotationManager.GetAnnotationFromIdx(a)
If annot IsNot Nothing Then
If annot.Visible Then annot.Rotation = 45
End If
End If
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then annotationManager.SaveAnnotationsToPage()
If annotationManager.GetStat() <> GdPictureStatus.OK Then Exit For
Else
Exit For
End If
Else
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then
If annotationManager.SaveDocumentToPDF("dest.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationType")
Else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationType")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationType")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationType")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK)
{
for (int p = 1; p <= annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
for (int a = 0; a < annotCount; a++)
{
GdPicture14.Annotations.Annotation.GdPictureAnnotationType type = annotationManager.GetAnnotationType(a);
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (type == GdPicture14.Annotations.Annotation.GdPictureAnnotationType.AnnotationTypeRubberStamp)
{
GdPicture14.Annotations.Annotation annot = annotationManager.GetAnnotationFromIdx(a);
if (annot != null)
{
if (annot.Visible) annot.Rotation = 45;
}
}
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
annotationManager.SaveAnnotationsToPage();
if (annotationManager.GetStat() != GdPictureStatus.OK) break;
}
else break;
}
else break;
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (annotationManager.SaveDocumentToPDF("dest.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationType");
else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationType");
}
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationType");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationType");
}
Gets both the horizontal and the vertical flip states of a required GdPicture/XMP annotation object specified by its index related to the selected page
of the document currently handled by this AnnotationManager object.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
Output parameter. Returns true, if the specified annotation is flipped horizontally; otherwise it returns false.
Output parameter. Returns true, if the specified annotation is flipped vertically; otherwise it returns false.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
At the same, be aware that the method only handles GdPicture/XMP annotations.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to flip all line arrow annotations to their opposite flip states in the loaded file.
Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("arrow.jpeg") = GdPictureStatus.OK Then
For p As Integer = 1 To annotationManager.PageCount
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
For a As Integer = 0 To annotCount - 1
Dim type As GdPicture14.Annotations.Annotation.GdPictureAnnotationType = annotationManager.GetAnnotationType(a)
If annotationManager.GetStat() = GdPictureStatus.OK Then
If type = GdPicture14.Annotations.Annotation.GdPictureAnnotationType.AnnotationTypeLineArrow Then
Dim flipx As Boolean = False, flipy As Boolean = False
If annotationManager.GetAnnotationFlipState(a, flipx, flipy) = GdPictureStatus.OK Then
annotationManager.SetAnnotationFlipState(a, Not flipx, Not flipy)
End If
End If
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then annotationManager.SaveAnnotationsToPage()
If annotationManager.GetStat() <> GdPictureStatus.OK Then Exit For
Else
Exit For
End If
Else
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then
If annotationManager.SaveDocumentToJPEG("arrow_flipped.jpeg", 75) = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationFlipState")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationFlipState")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationFlipState")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationFlipState")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("arrow.jpeg") == GdPictureStatus.OK)
{
for (int p = 1; p <= annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
for (int a = 0; a < annotCount; a++)
{
GdPicture14.Annotations.Annotation.GdPictureAnnotationType type = annotationManager.GetAnnotationType(a);
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (type == GdPicture14.Annotations.Annotation.GdPictureAnnotationType.AnnotationTypeLineArrow)
{
bool flipx = false, flipy = false;
if (annotationManager.GetAnnotationFlipState(a, ref flipx, ref flipy) == GdPictureStatus.OK)
annotationManager.SetAnnotationFlipState(a, !flipx, !flipy);
}
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
annotationManager.SaveAnnotationsToPage();
if (annotationManager.GetStat() != GdPictureStatus.OK) break;
}
else break;
}
else break;
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (annotationManager.SaveDocumentToJPEG("arrow_dest.jpeg", 75) == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationFlipState");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationFlipState");
}
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationFlipState");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationFlipState");
}
Sets both the horizontal and the vertical flip states of a required GdPicture/XMP annotation object specified by its index related to the selected page
of the document currently handled by this AnnotationManager object.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
Set this parameter to true if you want to flip the specified annotation horizontally; otherwise set it to false.
Set this parameter to true if you want to flip the specified annotation vertically; otherwise set it to false.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
At the same, be aware that the method only handles GdPicture/XMP annotations.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to flip all line arrow annotations to their opposite flip states in the loaded file.
Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("arrow.jpeg") = GdPictureStatus.OK Then
For p As Integer = 1 To annotationManager.PageCount
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
For a As Integer = 0 To annotCount - 1
Dim type As GdPicture14.Annotations.Annotation.GdPictureAnnotationType = annotationManager.GetAnnotationType(a)
If annotationManager.GetStat() = GdPictureStatus.OK Then
If type = GdPicture14.Annotations.Annotation.GdPictureAnnotationType.AnnotationTypeLineArrow Then
Dim flipx As Boolean = False, flipy As Boolean = False
If annotationManager.GetAnnotationFlipState(a, flipx, flipy) = GdPictureStatus.OK Then
annotationManager.SetAnnotationFlipState(a, Not flipx, Not flipy)
End If
End If
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then annotationManager.SaveAnnotationsToPage()
If annotationManager.GetStat() <> GdPictureStatus.OK Then Exit For
Else
Exit For
End If
Else
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then
If annotationManager.SaveDocumentToJPEG("arrow_flipped.jpeg", 75) = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.SetAnnotationFlipState")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationFlipState")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationFlipState")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationFlipState")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("arrow.jpeg") == GdPictureStatus.OK)
{
for (int p = 1; p <= annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
for (int a = 0; a < annotCount; a++)
{
GdPicture14.Annotations.Annotation.GdPictureAnnotationType type = annotationManager.GetAnnotationType(a);
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (type == GdPicture14.Annotations.Annotation.GdPictureAnnotationType.AnnotationTypeLineArrow)
{
bool flipx = false, flipy = false;
if (annotationManager.GetAnnotationFlipState(a, ref flipx, ref flipy) == GdPictureStatus.OK)
annotationManager.SetAnnotationFlipState(a, !flipx, !flipy);
}
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
annotationManager.SaveAnnotationsToPage();
if (annotationManager.GetStat() != GdPictureStatus.OK) break;
}
else break;
}
else break;
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (annotationManager.SaveDocumentToJPEG("arrow_dest.jpeg", 75) == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.SetAnnotationFlipState");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationFlipState");
}
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationFlipState");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SetAnnotationFlipState");
}
Returns an index of the first GdPicture/XMP comment annotation, if any exists, that is attached to a GdPicture/XMP annotation object specified by its index
related to the selected page of the document currently handled by this AnnotationManager object.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
Please ensure that the returned value is valid annotation index, which means it is greater then -1, before using it further.
Be aware that annotations are always treated relative to the selected page.
An index of the first GdPicture/XMP comment annotation, if exists, that is attached to the GdPicture/XMP annotation according to the given index.
The method can be subsequently used to determine if this method has been successful.
The returned value is between 0 and -1 if the annotation with the given index includes a comment annotation,
or -1 if no comment annotation is attached to the given annotation.
How to find out the first comment of the specified annotation, if some comments are attached.
Using annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
Dim annot As GdPicture14.Annotations.Annotation = Nothing
Dim comment As GdPicture14.Annotations.AnnotationComment = Nothing
For a As Integer = 0 To annotCount - 1
annot = annotationManager.GetAnnotationFromIdx(a)
If annot IsNot Nothing Then
Dim annotType As GdPicture14.Annotations.Annotation.GdPictureAnnotationType = annotationManager.GetAnnotationType(a)
Dim commentIdx As Integer = annotationManager.GetFirstAnnotationCommentIdx(a)
If (annotationManager.GetStat() = GdPictureStatus.OK) AndAlso (commentIdx > -1) Then
comment = CType(annotationManager.GetAnnotationFromIdx(commentIdx), GdPicture14.Annotations.AnnotationComment)
If comment IsNot Nothing Then
MessageBox.Show("The type of the annotation with comment: " + annotType + vbCrLf + "The first comment:" + vbCrLf + comment.Text, "AnnotationManager.GetFirstAnnotationCommentIdx")
Else
MessageBox.Show("Something goes wrong.", "AnnotationManager.GetFirstAnnotationCommentIdx")
End If
'Else This annotation does not include any comment.
End If
Else
MessageBox.Show("Something goes wrong.", "AnnotationManager.GetFirstAnnotationCommentIdx")
End If
Next
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetFirstAnnotationCommentIdx")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if ((annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
int annotCount = annotationManager.GetAnnotationCount();
GdPicture14.Annotations.Annotation annot = null;
GdPicture14.Annotations.AnnotationComment comment = null;
for (int a = 0; a < annotCount; a++)
{
annot = annotationManager.GetAnnotationFromIdx(a);
if (annot != null)
{
GdPicture14.Annotations.Annotation.GdPictureAnnotationType annotType = annotationManager.GetAnnotationType(a);
int commentIdx = annotationManager.GetFirstAnnotationCommentIdx(a);
if ((annotationManager.GetStat()== GdPictureStatus.OK) && (commentIdx>-1))
{
comment = (GdPicture14.Annotations.AnnotationComment)annotationManager.GetAnnotationFromIdx(commentIdx);
if (comment != null)
MessageBox.Show("The type of the annotation with comment: " + annotType + "\nThe first comment:\n" + comment.Text, "AnnotationManager.GetFirstAnnotationCommentIdx");
else
MessageBox.Show("Something goes wrong.", "AnnotationManager.GetFirstAnnotationCommentIdx");
}
//else This annotation does not include any comment.
}
else
MessageBox.Show("Something goes wrong.", "AnnotationManager.GetFirstAnnotationCommentIdx");
}
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetFirstAnnotationCommentIdx");
}
Removes a required GdPicture/XMP annotation object specified by its index related to the selected page of the document currently handled by this AnnotationManager object.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to delete the specified annotation.
'We assume that the GdViewer1 control has been integrated into your application.
Dim oAnnotationManager As AnnotationManager = GdViewer1.GetAnnotationManager()
Dim status As GdPictureStatus = oAnnotationManager.SelectPage(GdViewer1.CurrentPage)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = oAnnotationManager.GetAnnotationCount()
For i As Integer = 1 To annotCount
status = oAnnotationManager.DeleteAnnotation(0)
If status <> GdPictureStatus.OK Then Exit For
Next
End If
MessageBox.Show("Done! Status: " + status.ToString(), "AnnotationManager.DeleteAnnotation")
//We assume that the GdViewer1 control has been integrated into your application.
AnnotationManager oAnnotationManager = GdViewer1.GetAnnotationManager();
GdPictureStatus status = oAnnotationManager.SelectPage(GdViewer1.CurrentPage);
if (status == GdPictureStatus.OK)
{
int annotCount = oAnnotationManager.GetAnnotationCount();
for (int i = 1; i <= annotCount; i++)
{
status = oAnnotationManager.DeleteAnnotation(0);
if (status != GdPictureStatus.OK)
break;
}
}
MessageBox.Show("Done! Status: " + status.ToString(), "AnnotationManager.DeleteAnnotation");
Using annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK Then
For p As Integer = 1 To annotationManager.PageCount
If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
If annotationManager.GetStat() = GdPictureStatus.OK Then
For a As Integer = 0 To annotCount - 1
Dim value As Object = annotationManager.GetAnnotationPropertyValue(a, "Tag")
Dim tagValue As String = ""
If value IsNot Nothing Then
tagValue = CStr(value)
If tagValue.Equals("delete") Then
If annotationManager.DeleteAnnotation(a) <> GdPictureStatus.OK Then Exit For
Else
tagValue += " checked"
value = CObj(tagValue)
If annotationManager.SetAnnotationPropertyValue(a, "Tag", value) <> GdPictureStatus.OK Then Exit For
End If
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then annotationManager.SaveAnnotationsToPage()
If annotationManager.GetStat() <> GdPictureStatus.OK Then Exit For
Else
Exit For
End If
Else
Exit For
End If
Next
If annotationManager.GetStat() = GdPictureStatus.OK Then
If annotationManager.SaveDocumentToPDF("dest.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.DeleteAnnotation")
Else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if (annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK)
{
for (int p = 1; p <= annotationManager.PageCount; p++)
{
if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
for (int a = 0; a < annotCount; a++)
{
object value = annotationManager.GetAnnotationPropertyValue(a, "Tag");
string tagValue = "";
if (value != null)
{
tagValue = (string)value;
if (tagValue.Equals("delete"))
{
if (annotationManager.DeleteAnnotation(a) != GdPictureStatus.OK) break;
}
else
{
tagValue += " checked";
value = (object)tagValue;
if (annotationManager.SetAnnotationPropertyValue(a, "Tag", value) != GdPictureStatus.OK) break;
}
}
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
annotationManager.SaveAnnotationsToPage();
if (annotationManager.GetStat() != GdPictureStatus.OK) break;
}
else break;
}
else break;
}
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
if (annotationManager.SaveDocumentToPDF("dest.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.DeleteAnnotation");
else
MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation");
}
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation");
}
Adds a new GdPicture/XMP annotation from an XML definition on the selected page of the document currently handled by this AnnotationManager object.
You can use the method to obtain an annotation XML data.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
A properly formatted string containing the annotation definition in XML format.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP Annotation object. The newly added GdPicture/XMP annotation.
How to add an annotation from previously initialized XML string.
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim annotXML As String = ""
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
Dim annotIdx As Integer = annotationManager.GetAnnotationIdx(stamp)
If annotationManager.GetStat() = GdPictureStatus.OK Then
annotXML = annotationManager.GetAnnotationXML(annotIdx)
If annotationManager.GetStat() = GdPictureStatus.OK Then
status = annotationManager.SaveDocumentToPDF("source_stamped.pdf")
End If
Else
status = annotationManager.GetStat()
End If
Else
status = annotationManager.GetStat()
End If
stamp.Dispose()
End If
annotationManager.Close()
If status = GdPictureStatus.OK Then
If (annotationManager.InitFromFile("dest.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.Annotation = annotationManager.AddAnnotationFromXML(annotXML)
If annot IsNot Nothing Then status = annotationManager.SaveAnnotationsToPage()
If status = GdPictureStatus.OK Then
status = annotationManager.SaveDocumentToPDF("dest_stamped.pdf")
End If
Else
status = annotationManager.GetStat()
End If
End If
annotationManager.Close()
Else
status = annotationManager.GetStat()
End If
If status = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationIdx")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationIdx")
End If
annotationManager.Dispose()
GdPictureStatus status = GdPictureStatus.OK;
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
string annotXML = "";
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if (annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK)
{
int annotIdx = annotationManager.GetAnnotationIdx(stamp);
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
annotXML = annotationManager.GetAnnotationXML(annotIdx);
if (annotationManager.GetStat() == GdPictureStatus.OK)
status = annotationManager.SaveDocumentToPDF("source_stamped.pdf");
}
else status = annotationManager.GetStat();
}
else status = annotationManager.GetStat();
stamp.Dispose();
}
annotationManager.Close();
if (status == GdPictureStatus.OK)
{
if ((annotationManager.InitFromFile("dest.pdf") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.Annotation annot = annotationManager.AddAnnotationFromXML(annotXML);
if (annot != null)
status = annotationManager.SaveAnnotationsToPage();
if (status == GdPictureStatus.OK)
status = annotationManager.SaveDocumentToPDF("dest_stamped.pdf");
}
else status = annotationManager.GetStat();
}
annotationManager.Close();
}
else status = annotationManager.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.AddAnnotationFromXML");
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddAnnotationFromXML");
annotationManager.Dispose();
Adds and attaches a new GdPicture/XMP comment annotation to already existing annotation located on the selected page of the document
currently handled by this AnnotationManager object according to the parameters you have specified.
A comment annotation enables users to share information (comments, answers, reviews) related to the connected annotation.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeComment. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
The unique identifier of the existing annotation object to which the new comment is related.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationComment object. The newly added GdPicture/XMP comment annotation.
How to add a comment annotation to each ruler annotation in the handled file.
Using annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("test.jpeg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
Dim annot As GdPicture14.Annotations.Annotation = Nothing
For a As Integer = 0 To annotCount - 1
annot = annotationManager.GetAnnotationFromIdx(a)
If annot IsNot Nothing Then
Dim type As GdPicture14.Annotations.Annotation.GdPictureAnnotationType = annotationManager.GetAnnotationType(a)
If type = GdPicture14.Annotations.Annotation.GdPictureAnnotationType.AnnotationTypeRuler Then
Dim comment As GdPicture14.Annotations.AnnotationComment = annotationManager.AddCommentAnnot(annot.Guid, annot.Left, annot.Top, 1, 1)
If comment IsNot Nothing Then
comment.Text = "To be customized."
End If
End If
End If
Next
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToJPEG("test_reviewed.jpeg", 75) = GdPictureStatus.OK) Then
MessageBox.Show("Done!", "AnnotationManager.AddCommentAnnot")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddCommentAnnot")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddCommentAnnot")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if ((annotationManager.InitFromFile("test.jpeg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
int annotCount = annotationManager.GetAnnotationCount();
GdPicture14.Annotations.Annotation annot = null;
for (int a = 0; a < annotCount; a++)
{
annot = annotationManager.GetAnnotationFromIdx(a);
if (annot != null)
{
GdPicture14.Annotations.Annotation.GdPictureAnnotationType type = annotationManager.GetAnnotationType(a);
if (type == GdPicture14.Annotations.Annotation.GdPictureAnnotationType.AnnotationTypeRuler)
{
GdPicture14.Annotations.AnnotationComment comment = annotationManager.AddCommentAnnot(annot.Guid, annot.Left, annot.Top, 1, 1);
if (comment != null)
{
comment.Text = "To be customized.";
}
}
}
}
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToJPEG("test_reviewed.jpeg", 75) == GdPictureStatus.OK))
MessageBox.Show("Done!", "AnnotationManager.AddCommentAnnot");
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddCommentAnnot");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddCommentAnnot");
}
Adds a new GdPicture/XMP custom annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified.
Custom annotations are identified through the ModelID identifier, which you subsequently have to use in the event.
This event renders the required annotation according to what you specify for each ModelID inside the event respecting the defined dimensions.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeCustom. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
A private identifier specifying the model of the custom annotation. You need to handle this identifier using
the event to render the desired custom annotation appearance.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
You can also find the use of this method in our Annotations Sample here.
Just to inform you that custom annotations are not supported by the COM Interop edition.
A GdPicture/XMP AnnotationCustom object. The newly added GdPicture/XMP custom annotation.
How to add custom annotations to your document.
'We assume that the GdViewer control has been integrated into your application.
If GdViewer1.DisplayFromFile("custom.pdf") = GdPictureStatus.OK Then
'We assume that the annotationManager object has been integrated into your application as well,
'together with the proper definition of annotationManager_OnCustomAnnotationPaint() event.
annotationManager = GdViewer1.GetAnnotationManager();
If (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim modelsCount As Integer = 2
Dim x As Single = 1, y As Single = 1, w As Single = 1, h As Single = 1, dist As Single = 2
For modelID As Integer = 1 To modelsCount
Dim annot As GdPicture14.Annotations.AnnotationCustom = annotationManager.AddCustomAnnot(modelID, x, y + (modelID - 1) * dist, w, h)
If annot IsNot Nothing Then
annot.Tag = "GdPicture custom annotation"
End If
Next
'The BurnAnnotationsToPage() method renders your custom anotations on the page using the annotationManager_OnCustomAnnotationPaint() event.
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True, False) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToPDF("custom.pdf") = GdPictureStatus.OK) Then
'You also need to implement the GdViewer1_OnCustomAnnotationPaint() event, in the same way,
'to be able to see the added custom annotations in the viewer.
GdViewer1.Refresh()
End If
End If
If annotationManager.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddCustomAnnot")
End If
Else
MessageBox.Show("Error! Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddCustomAnnot")
End If
//We assume that the GdViewer control has been integrated into your application.
if (GdViewer1.DisplayFromFile("custom.pdf") == GdPictureStatus.OK)
{
//We assume that the annotationManager object has been integrated into your application as well,
//together with the proper definition of annotationManager_OnCustomAnnotationPaint() event.
annotationManager = GdViewer1.GetAnnotationManager();
if ((annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
int modelsCount = 2;
float x = 1, y = 1, w = 1, h = 1, dist = 2;
for (int modelID = 1; modelID <= modelsCount; modelID++)
{
GdPicture14.Annotations.AnnotationCustom annot = annotationManager.AddCustomAnnot(modelID, x, y+(modelID-1)*dist, w, h);
if (annot != null)
{
annot.Tag = "GdPicture custom annotation";
}
}
//The BurnAnnotationsToPage() method renders your custom anotations on the page using the annotationManager_OnCustomAnnotationPaint() event.
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true, false) == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToPDF("custom.pdf") == GdPictureStatus.OK))
{
//You also need to implement the GdViewer1_OnCustomAnnotationPaint() event, in the same way,
//to be able to see the added custom annotations in the viewer.
GdViewer1.Refresh();
}
}
if (annotationManager.GetStat() != GdPictureStatus.OK)
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddCustomAnnot");
}
else
MessageBox.Show("Error! Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddCustomAnnot");
Adds a new GdPicture/XMP rectangle annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. This annotation represents a filled and bordered rectangle drawn with the specified colors.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeRectangle. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP rectangle annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required border color of the newly added rectangle annotation.
A color object that defines the required background color of the newly added rectangle annotation.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationRectangle object. The newly added GdPicture/XMP rectangle annotation.
How to add a rectangle annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim left As Single = 1, top As Single = 1, width As Single = 5, height As Single = 3, dist As Single = 0.2F
Dim annotRect As GdPicture14.Annotations.AnnotationRectangle = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRect IsNot Nothing) Then
annotRect.Author = "GdPicture"
annotRect.BorderWidth = 0.05F
annotRect.Opacity = 0.85F
End If
annotRect.Dispose()
If annotMgr.BurnAnnotationsToPage(True) = GdPictureStatus.OK Then
Dim annotRuler As GdPicture14.Annotations.AnnotationRuler = annotMgr.AddRulerAnnot(Color.Blue, left, top - dist, left + width, top - dist,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRuler IsNot Nothing) Then
annotRuler.Author = "GdPicture"
annotRuler.BorderWidth = 0.02F
annotRuler.FontSize = 10
annotRuler.Opacity = 1
End If
annotRuler.Dispose()
annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left + width + dist, top, left + width + dist, top + height,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRuler IsNot Nothing) Then
annotRuler.Author = "GdPicture"
annotRuler.BorderWidth = 0.02F
annotRuler.FontSize = 10
annotRuler.Opacity = 1
End If
annotRuler.Dispose()
End If
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("rectangle.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("rectangle.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddRectangleAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float left = 1, top = 1, width = 5, height = 3, dist = 0.2f;
GdPicture14.Annotations.AnnotationRectangle annotRect = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRect != null))
{
annotRect.Author = "GdPicture";
annotRect.BorderWidth = 0.05f;
annotRect.Opacity = 0.85f;
}
annotRect.Dispose();
if (annotMgr.BurnAnnotationsToPage(true) == GdPictureStatus.OK)
{
GdPicture14.Annotations.AnnotationRuler annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left, top - dist, left + width, top - dist,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRuler != null))
{
annotRuler.Author = "GdPicture";
annotRuler.BorderWidth = 0.02f;
annotRuler.FontSize = 10;
annotRuler.Opacity = 1;
}
annotRuler.Dispose();
annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left + width + dist, top, left + width + dist, top + height,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRuler != null))
{
annotRuler.Author = "GdPicture";
annotRuler.BorderWidth = 0.02f;
annotRuler.FontSize = 10;
annotRuler.Opacity = 1;
}
annotRuler.Dispose();
}
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("rectangle.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("rectangle.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddRectangleAnnot");
Adds a new GdPicture/XMP rectangle highlighter annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. This annotation highlights a defined rectangle area with the specified color.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeRectangleHighlighter. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP rectangle highlighter annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required background color (a color for highlighting) of the newly added rectangle highlighter annotation.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationRectangleHighlighter object. The newly added GdPicture/XMP rectangle highlighter annotation.
How to use a rectangle highlighter to permanently highlight found text.
'We assume that the GdViewer1 control has been integrated into your application.
If GdViewer1.DisplayFromFile("text_to_search.txt") = GdPictureStatus.OK Then
Dim annotMgr As AnnotationManager = GdViewer1.GetAnnotationManager()
If (annotMgr IsNot Nothing) AndAlso (annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim text_to_find As String = "GdPicture"
Dim occurrence As Integer = 1
Dim left As Single = 0, top As Single = 0, width As Single = 0, height As Single = 0
Dim text_found As Boolean = False
GdViewer1.RemoveAllRegions()
While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, True, left, top, width, height)
text_found = True
Dim annotRectH As GdPicture14.Annotations.AnnotationRectangleHighlighter = annotMgr.AddRectangleHighlighterAnnot(Color.Yellow, left, top, width, height)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRectH IsNot Nothing) Then
annotRectH.Author = "GdPicture"
annotRectH.Tag = "Highligher"
End If
annotRectH.Dispose()
GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow)
occurrence = occurrence + 1
End While
If text_found Then
If (annotMgr.SaveAnnotationsToPage() <> GdPictureStatus.OK) OrElse
(annotMgr.BurnAnnotationsToPage(True) <> GdPictureStatus.OK) OrElse
(annotMgr.SaveDocumentToJPEG("text_highlighted.jpg", 75) <> GdPictureStatus.OK) Then
MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot")
End If
GdViewer1.Redraw()
Else
MessageBox.Show("The given text has not been found.", "AnnotationManager.AddRectangleHighlighterAnnot")
End If
Else
MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddRectangleHighlighterAnnot")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot")
End If
//We assume that the GdViewer1 control has been integrated into your application.
if (GdViewer1.DisplayFromFile("text_to_search.txt") == GdPictureStatus.OK)
{
AnnotationManager annotMgr = GdViewer1.GetAnnotationManager();
if ((annotMgr != null) && (annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
string text_to_find = "GdPicture";
int occurrence = 1;
float left = 0, top = 0, width = 0, height = 0;
bool text_found = false;
GdViewer1.RemoveAllRegions();
while (GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, true, ref left, ref top, ref width, ref height))
{
text_found = true;
GdPicture14.Annotations.AnnotationRectangleHighlighter annotRectH = annotMgr.AddRectangleHighlighterAnnot(Color.Yellow, left, top, width, height);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRectH != null))
{
annotRectH.Author = "GdPicture";
annotRectH.Tag = "Highligher";
}
annotRectH.Dispose();
GdViewer1.AddRegionInches("Region" + occurrence.ToString(), left, top, width, height, ForegroundMixMode.ForegroundMixModeMASKPEN, Color.Yellow);
occurrence = occurrence + 1;
}
if (text_found)
{
if ((annotMgr.SaveAnnotationsToPage() != GdPictureStatus.OK) ||
(annotMgr.BurnAnnotationsToPage(true) != GdPictureStatus.OK) ||
(annotMgr.SaveDocumentToJPEG("text_highlighted.jpg", 75) != GdPictureStatus.OK))
MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot");
GdViewer1.Redraw();
}
else
MessageBox.Show("The given text has not been found.", "AnnotationManager.AddRectangleHighlighterAnnot");
}
else
MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddRectangleHighlighterAnnot");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddRectangleHighlighterAnnot");
Adds a new GdPicture/XMP ellipse annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. This annotation represents a filled and bordered ellipse or circle drawn with the specified colors.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeEllipse. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP ellipse annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required border color of the newly added ellipse annotation.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationEllipse object. The newly added GdPicture/XMP ellipse annotation.
How to add an ellipse annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim left As Single = 4, top As Single = 2
Dim annotEllipse As GdPicture14.Annotations.AnnotationEllipse = annotMgr.AddEllipseAnnot(Color.BlueViolet, left, top, left + 2, top + 1)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotEllipse IsNot Nothing) Then
annotEllipse.Author = "GdPicture"
annotEllipse.BorderWidth = 0.1F
annotEllipse.Opacity = 0.8F
annotEllipse.Fill = True
annotEllipse.FillColor = Color.MediumVioletRed
End If
annotEllipse.Dispose()
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("ellipse.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("ellipse.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddEllipseAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float left = 4, top = 2;
GdPicture14.Annotations.AnnotationEllipse annotEllipse = annotMgr.AddEllipseAnnot(Color.BlueViolet, left, top, left + 2, top + 1);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotEllipse != null))
{
annotEllipse.Author = "GdPicture";
annotEllipse.BorderWidth = 0.1f;
annotEllipse.Opacity = 0.8f;
annotEllipse.Fill = true;
annotEllipse.FillColor = Color.MediumVioletRed;
}
annotEllipse.Dispose();
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("ellipse.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("ellipse.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddEllipseAnnot");
Adds a new GdPicture/XMP line annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified.
A line annotation presents a single straight line drawn with the defined color, which uses the flat cap style on both its ending points.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeLine. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP line annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required color of the newly added line annotation.
It corresponds to the AnnotationLine.StrokeColor property.
The horizontal (X) coordinate of the starting point of the drawn line, in inches.
The vertical (Y) coordinate of the starting point of the drawn line, in inches.
The horizontal (X) coordinate of the ending point of the drawn line, in inches.
The vertical (Y) coordinate of the ending point of the drawn line, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationLine object. The newly added GdPicture/XMP line annotation.
How to use a line annotation to permanently underline found text.
'We assume that the GdViewer1 control has been integrated into your application.
If GdViewer1.DisplayFromFile("text_to_search.txt") = GdPictureStatus.OK Then
Dim annotMgr As AnnotationManager = GdViewer1.GetAnnotationManager()
If (annotMgr IsNot Nothing) AndAlso (annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim text_to_find As String = "GdPicture"
Dim occurrence As Integer = 1
Dim left As Single = 0, top As Single = 0, width As Single = 0, height As Single = 0
Dim text_found As Boolean = False
GdViewer1.RemoveAllRegions()
While GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, True, left, top, width, height)
text_found = True
Dim annotLine As GdPicture14.Annotations.AnnotationLine = annotMgr.AddLineAnnot(Color.Blue, left, top + height, left + width, top + height)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotLine IsNot Nothing) Then
annotLine.Author = "GdPicture"
annotLine.BorderWidth = 0.05F
annotLine.Tag = "Line"
End If
annotLine.Dispose()
occurrence = occurrence + 1
End While
If text_found Then
If (annotMgr.SaveAnnotationsToPage() <> GdPictureStatus.OK) OrElse
(annotMgr.BurnAnnotationsToPage(True) <> GdPictureStatus.OK) OrElse
(annotMgr.SaveDocumentToJPEG("text_lines.jpg", 75) <> GdPictureStatus.OK) Then
MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddLineAnnot")
End If
GdViewer1.Redraw()
Else
MessageBox.Show("The given text has not been found.", "AnnotationManager.AddLineAnnot")
End If
Else
MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddLineAnnot")
End If
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddLineAnnot")
End If
//We assume that the GdViewer1 control has been integrated into your application.
if (GdViewer1.DisplayFromFile("text_to_search.txt") == GdPictureStatus.OK)
{
AnnotationManager annotMgr = GdViewer1.GetAnnotationManager();
if ((annotMgr != null) && (annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
string text_to_find = "GdPicture";
int occurrence = 1;
float left = 0, top = 0, width = 0, height = 0;
bool text_found = false;
GdViewer1.RemoveAllRegions();
while (GdViewer1.SearchText(GdViewer1.CurrentPage, text_to_find, occurrence, true, ref left, ref top, ref width, ref height))
{
text_found = true;
GdPicture14.Annotations.AnnotationLine annotLine = annotMgr.AddLineAnnot(Color.Blue, left, top+height, left+width, top+height);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotLine != null))
{
annotLine.Author = "GdPicture";
annotLine.BorderWidth = 0.05f;
annotLine.Tag = "Line";
}
annotLine.Dispose();
occurrence = occurrence + 1;
}
if (text_found)
{
if ((annotMgr.SaveAnnotationsToPage() != GdPictureStatus.OK) ||
(annotMgr.BurnAnnotationsToPage(true) != GdPictureStatus.OK) ||
(annotMgr.SaveDocumentToJPEG("text_lines.jpg", 75) != GdPictureStatus.OK))
MessageBox.Show("An error occurred when saving the file. Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddLineAnnot");
GdViewer1.Redraw();
}
else
MessageBox.Show("The given text has not been found.", "AnnotationManager.AddLineAnnot");
}
else
MessageBox.Show("The AnnotationManager can't be initialized.", "AnnotationManager.AddLineAnnot");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddLineAnnot");
Adds a new GdPicture/XMP ruler annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified.
A ruler annotation depicts a single drawn line from the defined starting point to the defined ending point showing its length in the specified measurement unit.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeRuler. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP ruler annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required color of the newly added ruler annotation.
It is the color of the ruler's drawn line and it corresponds to the AnnotationRuler.StrokeColor property.
The horizontal (X) coordinate of the starting point, in inches, where the ruler's line starts.
The vertical (Y) coordinate of the starting point, in inches, where the ruler's line starts.
The horizontal (X) coordinate of the ending point, in inches, where the ruler's line ends.
The vertical (Y) coordinate of the ending point, in inches, where the ruler's line ends.
The measurement unit of the newly added ruler. The ruler presents its current length in the defined unit at the end of the drawn line.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationRuler object. The newly added GdPicture/XMP ruler annotation.
How to add a ruler annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim left As Single = 1, top As Single = 1, width As Single = 5, height As Single = 3, dist As Single = 0.2F
Dim annotRect As GdPicture14.Annotations.AnnotationRectangle = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRect IsNot Nothing) Then
annotRect.Author = "GdPicture"
annotRect.BorderWidth = 0.05F
annotRect.Opacity = 0.85F
End If
annotRect.Dispose()
If annotMgr.BurnAnnotationsToPage(True) = GdPictureStatus.OK Then
Dim annotRuler As GdPicture14.Annotations.AnnotationRuler = annotMgr.AddRulerAnnot(Color.Blue, left, top - dist, left + width, top - dist,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRuler IsNot Nothing) Then
annotRuler.Author = "GdPicture"
annotRuler.BorderWidth = 0.02F
annotRuler.FontSize = 10
annotRuler.Opacity = 1
End If
annotRuler.Dispose()
annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left + width + dist, top, left + width + dist, top + height,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRuler IsNot Nothing) Then
annotRuler.Author = "GdPicture"
annotRuler.BorderWidth = 0.02F
annotRuler.FontSize = 10
annotRuler.Opacity = 1
End If
annotRuler.Dispose()
End If
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("rulerannot.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("rulerannot.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddRulerAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float left = 1, top = 1, width = 5, height = 3, dist = 0.2f;
GdPicture14.Annotations.AnnotationRectangle annotRect = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRect != null))
{
annotRect.Author = "GdPicture";
annotRect.BorderWidth = 0.05f;
annotRect.Opacity = 0.85f;
}
annotRect.Dispose();
if (annotMgr.BurnAnnotationsToPage(true) == GdPictureStatus.OK)
{
GdPicture14.Annotations.AnnotationRuler annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left, top - dist, left + width, top - dist,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRuler != null))
{
annotRuler.Author = "GdPicture";
annotRuler.BorderWidth = 0.02f;
annotRuler.FontSize = 10;
annotRuler.Opacity = 1;
}
annotRuler.Dispose();
annotRuler = annotMgr.AddRulerAnnot(Color.Blue, left + width + dist, top, left + width + dist, top + height,
GdPicture14.Annotations.Annotation.UnitMode.Centimeter);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRuler != null))
{
annotRuler.Author = "GdPicture";
annotRuler.BorderWidth = 0.02f;
annotRuler.FontSize = 10;
annotRuler.Opacity = 1;
}
annotRuler.Dispose();
}
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("rulerannot.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("rulerannot.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddRulerAnnot");
Adds a new GdPicture/XMP poly ruler annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified.
A poly ruler annotation consists of several connected lines presenting its entire length in the specified measurement unit.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypePolyRuler. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP poly ruler annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required color of the newly added poly ruler annotation.
It is the color of the ruler's drawn line and it corresponds to the AnnotationPolyRuler.StrokeColor property.
An array of points, in inches, which determines the poly ruler line segments.
The measurement unit of the newly added poly ruler. The poly ruler presents its current length in the defined unit at the end of the drawn line.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationPolyRuler object. The newly added GdPicture/XMP poly ruler annotation.
How to add a poly ruler annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim left As Single = 1, top As Single = 1, width As Single = 5, height As Single = 3
Dim annotRect As GdPicture14.Annotations.AnnotationRectangle = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotRect IsNot Nothing) Then
annotRect.Author = "GdPicture"
annotRect.BorderWidth = 0.1F
annotRect.Opacity = 0.85F
End If
annotRect.Dispose()
If annotMgr.BurnAnnotationsToPage(True) = GdPictureStatus.OK Then
Dim points As PointF() = New PointF(4) {New PointF(left, top), New PointF(left + width, top),
New PointF(left + width, top + height),
New PointF(left, top + height), New PointF(left, top)}
Dim annotPolyRuler As GdPicture14.Annotations.AnnotationPolyRuler = annotMgr.AddPolyRulerAnnot(Color.Blue, points, GdPicture14.Annotations.Annotation.UnitMode.Inch)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotPolyRuler IsNot Nothing) Then
annotPolyRuler.Author = "GdPicture"
annotPolyRuler.BorderWidth = 0.02F
annotPolyRuler.FontSize = 14
annotPolyRuler.FontStyle = System.Drawing.FontStyle.Bold
annotPolyRuler.ForeColor = Color.Red
annotPolyRuler.Opacity = 1
End If
annotPolyRuler.Dispose()
End If
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("polyruler.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("polyruler.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddPolyRulerAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float left = 1, top = 1, width = 5, height = 3;
GdPicture14.Annotations.AnnotationRectangle annotRect = annotMgr.AddRectangleAnnot(Color.SteelBlue, Color.LightBlue, left, top, width, height);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotRect != null))
{
annotRect.Author = "GdPicture";
annotRect.BorderWidth = 0.1f;
annotRect.Opacity = 0.85f;
}
annotRect.Dispose();
if (annotMgr.BurnAnnotationsToPage(true) == GdPictureStatus.OK)
{
PointF[] points = new PointF[5] { new PointF(left, top), new PointF(left + width, top),
new PointF(left + width, top + height),
new PointF(left, top + height), new PointF(left, top)};
GdPicture14.Annotations.AnnotationPolyRuler annotPolyRuler = annotMgr.AddPolyRulerAnnot(Color.Blue, points, GdPicture14.Annotations.Annotation.UnitMode.Inch);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotPolyRuler != null))
{
annotPolyRuler.Author = "GdPicture";
annotPolyRuler.BorderWidth = 0.02f;
annotPolyRuler.FontSize = 14;
annotPolyRuler.FontStyle = System.Drawing.FontStyle.Bold;
annotPolyRuler.ForeColor = Color.Red;
annotPolyRuler.Opacity = 1;
}
annotPolyRuler.Dispose();
}
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("polyruler.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("polyruler.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddPolyRulerAnnot");
Adds a new GdPicture/XMP line arrow annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. This annotation depicts a straight line with an arrow on its ending point.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeLineArrow. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP line arrow annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required color of the newly added line arrow annotation.
It corresponds to the AnnotationLineArrow.StrokeColor property.
The horizontal (X) coordinate of the starting point of the drawn line, in inches.
The vertical (Y) coordinate of the starting point of the drawn line, in inches.
The horizontal (X) coordinate of the ending point of the drawn line, in inches, where the arrow is located.
The vertical (Y) coordinate of the ending point of the drawn line, in inches, where the arrow is located.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationLineArrow object. The newly added GdPicture/XMP line arrow annotation.
How to add a line arrow annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim left As Single = 1, top As Single = 1, width As Single = 5, dist As Single = 1
Dim annotArrow As GdPicture14.Annotations.AnnotationLineArrow = Nothing
For i As Integer = 0 To 2
annotArrow = annotMgr.AddLineArrowAnnot(Color.BlueViolet, left, top + i * dist, left + width - dist * i, top + dist * i)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotArrow IsNot Nothing) Then
annotArrow.Author = "GdPicture"
annotArrow.BorderWidth = 0.15F - i * 0.05F
annotArrow.Opacity = 1 - i * 0.25F
End If
annotArrow.Dispose()
Next
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("arrow.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("arrow.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddLineArrowAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float left = 1, top = 1, width = 5, dist = 1;
GdPicture14.Annotations.AnnotationLineArrow annotArrow = null;
for (int i = 0; i < 3; i++)
{
annotArrow = annotMgr.AddLineArrowAnnot(Color.BlueViolet, left, top + i*dist, left + width-dist*i, top+dist*i);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotArrow != null))
{
annotArrow.Author = "GdPicture";
annotArrow.BorderWidth = 0.15f - i*0.05f;
annotArrow.Opacity = 1 - i* 0.25f;
}
annotArrow.Dispose();
}
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("arrow.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("arrow.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddLineArrowAnnot");
Adds a new GdPicture/XMP freehand annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. A freehand annotation is a drawn line consisting of several connected line segments.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeFreeHand. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP freehand annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required color of the newly added freehand annotation.
It corresponds to the AnnotationFreeHand.StrokeColor property.
An array of points, in inches, which determines the line segments to be connected.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationFreeHand object. The newly added GdPicture/XMP freehand annotation.
How to add a freehand annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim px As Single = 5, py As Single = 1, dx As Single = 2, dy As Single = 2
Dim points1 As PointF() = New PointF(4) {New PointF(px, py), New PointF(px + dx, py), New PointF(px + dx / 2, py + dy / 2),
New PointF(px + 3 * dx / 2, py + dy), New PointF(px - dx, py + dy)}
Dim annot As GdPicture14.Annotations.AnnotationFreeHand = annotMgr.AddFreeHandAnnot(Color.SteelBlue, points1)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.BorderWidth = 0.1F
annot.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash
annot.Opacity = 0.5F
End If
annot.Dispose()
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("freehand.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("freehand.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float px = 5, py = 1, dx = 2, dy = 2;
PointF[] points1 = new PointF[5] { new PointF(px, py), new PointF(px+dx, py), new PointF(px+dx/2, py+dy/2),
new PointF(px+3*dx/2, py+dy), new PointF(px-dx, py+dy) };
GdPicture14.Annotations.AnnotationFreeHand annot = annotMgr.AddFreeHandAnnot(Color.SteelBlue, points1);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.BorderWidth = 0.1f;
annot.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
annot.Opacity = 0.5f;
}
annot.Dispose();
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("freehand.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("freehand.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandAnnot");
Adds a new GdPicture/XMP freehand highlighter annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters
you have specified. A freehand highlighter annotation is a drawn line consisting of several connected line segments, which highlights the covered area.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeFreeHandHighlighter. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP freehand highlighter annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required color of the newly added freehand annotation.
It corresponds to the AnnotationFreeHandHighlighter.StrokeColor property.
An array of points, in inches, which determines the line segments to be connected.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationFreeHandHighlighter object. The newly added GdPicture/XMP freehand highlighter annotation.
How to add a freehand highlighter annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim px As Single = 2, py As Single = 1, dx As Single = 0.25F, dy As Single = 0.25F
Dim annotText As GdPicture14.Annotations.AnnotationText = annotMgr.AddTextAnnot(px, py, 2, 2, "GdPicture")
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annotText IsNot Nothing) Then
annotText.FontSize = 20
End If
annotText.Dispose()
If (annotMgr.SaveAnnotationsToPage() <> GdPictureStatus.OK) OrElse
(annotMgr.BurnAnnotationsToPage(True) <> GdPictureStatus.OK) Then
GoTo with_error
End If
Dim points As PointF() = New PointF(6) {New PointF(px, py), New PointF(px + dx, py + dy), New PointF(px + 2 * dx, py),
New PointF(px + 3 * dx, py + dy), New PointF(px + 4 * dx, py),
New PointF(px + 5 * dx, py + dy), New PointF(px + 6 * dx, py)}
Dim annot As GdPicture14.Annotations.AnnotationFreeHandHighlighter = annotMgr.AddFreeHandHighlighterAnnot(Color.GreenYellow, points)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.BorderWidth = 0.1F
End If
annot.Dispose()
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("freehandhighlighter.jpeg", 75)
End If
End If
with_error:
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("freehandhighlighter.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandHighlighterAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float px = 2, py = 1, dx = 0.25f, dy = 0.25f;
GdPicture14.Annotations.AnnotationText annotText = annotMgr.AddTextAnnot(px, py, 2, 2, "GdPicture");
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annotText != null))
{
annotText.FontSize = 20;
}
annotText.Dispose();
if ((annotMgr.SaveAnnotationsToPage() != GdPictureStatus.OK) ||
(annotMgr.BurnAnnotationsToPage(true) != GdPictureStatus.OK))
{
goto with_error;
}
PointF[] points = new PointF[7] { new PointF(px, py), new PointF(px+dx, py+dy), new PointF(px+2*dx, py),
new PointF(px+3*dx, py+dy), new PointF(px+4*dx, py),
new PointF(px+5*dx, py+dy), new PointF(px+6*dx, py)};
GdPicture14.Annotations.AnnotationFreeHandHighlighter annot = annotMgr.AddFreeHandHighlighterAnnot(Color.GreenYellow, points);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.BorderWidth = 0.1f;
}
annot.Dispose();
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("freehandhighlighter.jpeg", 75);
}
with_error:
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("freehandhighlighter.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandHighlighterAnnot");
Adds a new GdPicture/XMP polygon annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. This annotation represents a filled and bordered polygon drawn with the specified colors.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypePolygon. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP polygon annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required border color of the newly added polygon annotation.
A color object that defines the required background color of the newly added polygon annotation.
An array of points, in inches, which determines the polygon vertices.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationPolygon object. The newly added GdPicture/XMP polygon annotation.
How to add a polygon annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso (annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim px As Single = 5, py As Single = 1, dx As Single = 2, dy As Single = 2
Dim points1 As PointF() = New PointF(4) { New PointF(px, py), New PointF(px + dx, py), New PointF(px + dx / 2, py + dy / 2),
New PointF(px + 3 * dx / 2, py + dy), New PointF(px - dx, py + dy) }
Dim annot As GdPicture14.Annotations.AnnotationPolygon = annotMgr.AddPolygonAnnot(Color.LightBlue, Color.SteelBlue, points1)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.BorderWidth = 0.2F
annot.Opacity = 0.8F
End If
annot.Dispose()
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("polygon.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("polygon.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddPolygonAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float px = 5, py = 1, dx = 2, dy = 2;
PointF[] points1 = new PointF[5] { new PointF(px, py), new PointF(px+dx, py), new PointF(px+dx/2, py+dy/2),
new PointF(px+3*dx/2, py+dy), new PointF(px-dx, py+dy) };
GdPicture14.Annotations.AnnotationPolygon annot = annotMgr.AddPolygonAnnot(Color.LightBlue, Color.SteelBlue, points1);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.BorderWidth = 0.2f;
annot.Opacity = 0.8f;
}
annot.Dispose();
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("polygon.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("polygon.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddPolygonAnnot");
Adds a new GdPicture/XMP freehand polygon annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters
you have specified. A freehand polygon is an arbitrary closed shape filled and bordered with the specified colors.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeFreeHandPolygon. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP freehand polygon annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required border color of the newly added freehand polygon annotation.
A color object that defines the required background color of the newly added freehand polygon annotation.
An array of points, in inches, which determines the polygon vertices.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationFreeHandPolygon object. The newly added GdPicture/XMP freehand polygon annotation.
How to add a freehand polygon annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso (annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim px As Single = 5, py As Single = 1, dx As Single = 2, dy As Single = 2
Dim points1 As PointF() = New PointF(4) { New PointF(px, py), New PointF(px + dx, py), New PointF(px + dx / 2, py + dy / 2),
New PointF(px + 3 * dx / 2, py + dy), New PointF(px - dx, py + dy) }
Dim annot As GdPicture14.Annotations.AnnotationPolygon = annotMgr.AddFreeHandPolygonAnnot(Color.LightBlue, Color.SteelBlue, points1)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.BorderWidth = 0.2F
annot.Opacity = 0.8F
End If
annot.Dispose()
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("freehandpolygon.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("freehandpolygon.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandPolygonAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float px = 5, py = 1, dx = 2, dy = 2;
PointF[] points1 = new PointF[5] { new PointF(px, py), new PointF(px+dx, py), new PointF(px+dx/2, py+dy/2),
new PointF(px+3*dx/2, py+dy), new PointF(px-dx, py+dy) };
GdPicture14.Annotations.AnnotationPolygon annot = annotMgr.AddFreeHandPolygonAnnot(Color.LightBlue, Color.SteelBlue, points1);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.BorderWidth = 0.2f;
annot.Opacity = 0.8f;
}
annot.Dispose();
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("freehandpolygon.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("freehandpolygon.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddFreeHandPolygonAnnot");
Adds a new GdPicture/XMP connected lines annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified.
A connected lines annotation depicts a polyline consisting of several straight lines. This method uses the round cap style on both polyline ending points.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeConnectedLines. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP connected lines annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required color of the newly added connected lines annotation.
It corresponds to the AnnotationConnectedLines.StrokeColor property.
An array of points, in inches, which determines the single line segments to be connected.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationConnectedLines object. The newly added GdPicture/XMP connected lines annotation.
How to add a connected lines annotations to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim px As Single = 3, py As Single = 1, dx As Single = 3, dy As Single = 2
Dim points1 As PointF() = New PointF(3) {New PointF(px, py), New PointF(px + dx / 2, py + dy), New PointF(dx / 2, py + dy), New PointF(px, py)}
Dim annot As GdPicture14.Annotations.AnnotationConnectedLines = annotMgr.AddConnectedLinesAnnot(Color.LightBlue, points1)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.BorderWidth = 0.2F
annot.Opacity = 1
End If
annot.Dispose()
Dim points2 As PointF() = New PointF(3) {New PointF(px + dx / 2 + 1, py), New PointF(px + dx / 2 + 1 + dx, py), New PointF(px + dx + 1, py + dy), New PointF(px + dx / 2 + 1, py)}
annot = annotMgr.AddConnectedLinesAnnot(Color.LightBlue, points2)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.BorderWidth = 0.2F
annot.Opacity = 1
End If
annot.Dispose()
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("lines.jpeg", 75)
End If
status = annotMgr.GetStat()
annotMgr.Close()
End If
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("lines.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddConnectedLinesAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
float px = 3, py = 1, dx = 3, dy = 2;
PointF[] points1 = new PointF[4] { new PointF(px, py), new PointF(px+dx/2, py+dy),
new PointF(dx/2, py+dy), new PointF(px, py)};
GdPicture14.Annotations.AnnotationConnectedLines annot = annotMgr.AddConnectedLinesAnnot(Color.LightBlue, points1);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.BorderWidth = 0.2f;
annot.Opacity = 1;
}
annot.Dispose();
PointF[] points2 = new PointF[4] { new PointF(px + dx / 2 + 1, py), new PointF(px + dx / 2 + 1 + dx, py),
new PointF(px + dx + 1, py+dy), new PointF(px+dx/2+1, py)};
annot = annotMgr.AddConnectedLinesAnnot(Color.LightBlue, points2);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.BorderWidth = 0.2f;
annot.Opacity = 1;
}
annot.Dispose();
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("lines.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("lines.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddConnectedLinesAnnot");
Adds a new GdPicture/XMP rubber stamp annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. This annotation shows a stamp mark of the specified stamp within the defined rectangle area.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeRubberStamp. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP rubber stamp annotation on the selected page of the document currently handled by this AnnotationManager object.
A color object that defines the required border color of the newly added rubber stamp annotation.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
The content of the newly added rubber stamp, that means the text to be displayed in the annotation bounding box.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationRubberStamp object. The newly added GdPicture/XMP rubber stamp annotation.
How to permanently add a rubber stamp annotation to the currently selected page of the handled document.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) = GdPictureStatus.OK Then
MessageBox.Show("Finished successfully!", "AnnotationManager.AddRubberStampAnnot")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddRubberStampAnnot")
End If
Else
MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddRubberStampAnnot")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddRubberStampAnnot")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddRubberStampAnnot")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) == GdPictureStatus.OK)
MessageBox.Show("Finished successfully!", "AnnotationManager.AddRubberStampAnnot");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddRubberStampAnnot");
}
else
MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddRubberStampAnnot");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddRubberStampAnnot");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddRubberStampAnnot");
annotationManager.Dispose();
Adds a new GdPicture/XMP link annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters
you have specified. A link annotation depicts the defined text, that points to a link destination, that means to a web site or to a page in the current document.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeLink. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
The text to render, means the displayed text, of the newly added link annotation.
The destination of the newly added link annotation, for example http://www.gdpicture.com or page:5. It corresponds to the AnnotationLink.Link property.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationLink object. The newly added GdPicture/XMP link annotation.
How to add a link annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.AnnotationLink = annotMgr.AddLinkAnnot(1, 1, 5, 0.5F, "ORPALIS", "www.orpalis.com")
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.FontStyle = System.Drawing.FontStyle.Italic
annot.ForeColor = Color.CadetBlue
annot.Opacity = 0.8F
End If
annot.Dispose()
annot = annotMgr.AddLinkAnnot(1, 3, 5, 0.5F, "GdPicture", "www.gdpicture.com")
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.ForeColor = Color.BlueViolet
annot.FontStyle = System.Drawing.FontStyle.Regular
annot.Opacity = 0.8F
End If
annot.Dispose()
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("linkannot.jpeg", 75)
End If
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("linkannot.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddLinkAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationLink annot = annotMgr.AddLinkAnnot(1, 1, 5, 0.5f, "ORPALIS", "www.orpalis.com");
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.FontStyle = System.Drawing.FontStyle.Italic;
annot.ForeColor = Color.CadetBlue;
annot.Opacity = 0.8f;
}
annot.Dispose();
annot = annotMgr.AddLinkAnnot(1, 3, 5, 0.5f, "GdPicture", "www.gdpicture.com");
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.ForeColor = Color.BlueViolet;
annot.FontStyle = System.Drawing.FontStyle.Regular;
annot.Opacity = 0.8f;
}
annot.Dispose();
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("linkannot.jpeg", 75);
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("linkannot.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddLinkAnnot");
Adds a new GdPicture/XMP text annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. A text annotation writes the specified text within the defined rectangle area.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeText. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
The content of the newly added annotation, that means the text to be displayed in the annotation bounding box.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationText object. The newly added GdPicture/XMP text annotation.
How to add a text annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.AnnotationText = annotMgr.AddTextAnnot(1, 1, 4, 1, "This is some text introduced by the TextAnnotation added by GdPicture.")
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Alignment = System.Drawing.StringAlignment.Near
annot.Author = "GdPicture"
annot.Fill = True
annot.FillColor = Color.LightBlue
annot.FontSize = 16
annot.Opacity = 0.7F
annot.StrokeColor = Color.DarkBlue
End If
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("textannot.jpeg", 75)
End If
annot.Dispose()
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("textannot.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddTextAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationText annot = annotMgr.AddTextAnnot(1, 1, 4, 1, "This is some text introduced by the TextAnnotation added by GdPicture.");
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Alignment = System.Drawing.StringAlignment.Near;
annot.Author = "GdPicture";
annot.Fill = true;
annot.FillColor = Color.LightBlue;
annot.FontSize = 16;
annot.Opacity = 0.7f;
annot.StrokeColor = Color.DarkBlue;
}
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("textnote.jpeg", 75);
annot.Dispose();
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("textnote.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddTextAnnot");
Adds a new GdPicture/XMP sticky note annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. A sticky note annotation writes the specified text within the defined rectangle area, which can be filled and bordered.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeStickyNote. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.
Be aware that annotations are always treated relative to the currently selected page.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
The content of the newly added annotation, that means the text to be displayed in the annotation bounding box.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationStickyNote object. The newly added GdPicture/XMP sticky note annotation.
How to add a sticky note annotation to a newly created image.
Dim status As GdPictureStatus = GdPictureStatus.OK
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateNewGdPictureImage(1000, 1600, CShort(32), Color.White)
status = image.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageID <> 0) Then
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromGdPictureImage(imageID) = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.AnnotationStickyNote = annotMgr.AddStickyNoteAnnot(1, 1, 2, 2, "Sticky Note by GdPicture")
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Alignment = System.Drawing.StringAlignment.Center
annot.Author = "GdPicture"
annot.BorderWidth = 0.05F
annot.Fill = True
annot.FillColor = Color.LightBlue
annot.FontSize = 20
annot.Opacity = 0.7F
annot.StrokeColor = Color.DarkBlue
End If
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("stickynote.jpeg", 75)
End If
annot.Dispose()
End If
status = annotMgr.GetStat()
annotMgr.Close()
End Using
image.ReleaseGdPictureImage(imageID)
End If
End Using
'We assume that the GdViewer1 control has been integrated into your application.
If status = GdPictureStatus.OK Then
GdViewer1.DisplayFromFile("stickynote.jpeg")
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddStickyNoteAnnot")
End If
GdPictureStatus status = GdPictureStatus.OK;
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateNewGdPictureImage(1000, 1600, 32, Color.White);
status = image.GetStat();
if ((status == GdPictureStatus.OK) && (imageID != 0))
{
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromGdPictureImage(imageID) == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationStickyNote annot = annotMgr.AddStickyNoteAnnot(1, 1, 2, 2, "Sticky Note by GdPicture");
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Alignment = System.Drawing.StringAlignment.Center;
annot.Author = "GdPicture";
annot.BorderWidth = 0.05f;
annot.Fill = true;
annot.FillColor = Color.LightBlue;
annot.FontSize = 20;
annot.Opacity = 0.7f;
annot.StrokeColor = Color.DarkBlue;
}
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("stickynote.jpeg", 75);
annot.Dispose();
}
status = annotMgr.GetStat();
annotMgr.Close();
}
image.ReleaseGdPictureImage(imageID);
}
}
//We assume that the GdViewer1 control has been integrated into your application.
if (status == GdPictureStatus.OK)
GdViewer1.DisplayFromFile("stickynote.jpeg");
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.AddStickyNoteAnnot");
Adds a new GdPicture/XMP embedded image annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. This annotation embeds the specified image on the page within the defined rectangle area.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeEmbeddedImage. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP embedded image annotation on the selected page of the document currently handled by this AnnotationManager object.
A Bitmap object. The required image to render as an annotation.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationEmbeddedImage object. The newly added GdPicture/XMP embedded image annotation.
How to add an embedded image annotation from the bitmap on the currently selected page of the handled document.
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromFile("source.tiff") = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim image As System.Drawing.Bitmap = New System.Drawing.Bitmap("annot.bmp")
If image IsNot Nothing Then
Dim annot As GdPicture14.Annotations.AnnotationEmbeddedImage = annotMgr.AddEmbeddedImageAnnot(image, 0.5F, 0.5F, 2, 3)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.Opacity = 0.8F
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToTIFF("dest.tiff", TiffCompression.TiffCompressionAUTO)
End If
End If
annot.Dispose()
Else
MessageBox.Show("Error when loading an image bitmap!", "AnnotationManager.AddEmbeddedImageAnnot")
End If
image.Dispose()
End If
If annotMgr.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnot")
Else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot")
End If
annotMgr.Close()
End Using
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromFile("source.tiff") == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
System.Drawing.Bitmap image = new System.Drawing.Bitmap("annot.bmp");
if (image != null)
{
GdPicture14.Annotations.AnnotationEmbeddedImage annot = annotMgr.AddEmbeddedImageAnnot(image, 0.5f, 0.5f, 2, 3);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.Opacity = 0.8f;
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToTIFF("dest.tiff", TiffCompression.TiffCompressionAUTO);
}
annot.Dispose();
}
else
MessageBox.Show("Error when loading an image bitmap!", "AnnotationManager.AddEmbeddedImageAnnot");
image.Dispose();
}
if (annotMgr.GetStat() == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnot");
else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot");
annotMgr.Close();
}
Adds a new GdPicture/XMP embedded image annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters
you have specified. This annotation embeds the image from a bitmap file stored in base64 string on the page within the defined rectangle area.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeEmbeddedImage. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.Be aware that annotations are always treated relative to the currently selected page.
A base64 encoded string containing the data of the image to render as an annotation.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationEmbeddedImage object. The newly added GdPicture/XMP embedded image annotation.
How to add an embedded image annotation from the string on the currently selected page of the handled document.
Using annotMgr As AnnotationManager = New AnnotationManager()
'We assume you have an image resource in a Base64 string here.
Dim image As String = "Your image in Base64 encoded string"
If (annotMgr.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.AnnotationEmbeddedImage = annotMgr.AddEmbeddedImageAnnotFromBase64(image, 0.5F, 0.5F, 2, 3)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.Opacity = 0.8F
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then annotMgr.SaveDocumentToPDF("dest.pdf")
End If
annot.Dispose()
End If
If annotMgr.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnotFromBase64")
Else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnotFromBase64")
End If
annotMgr.Close()
End Using
using (AnnotationManager annotMgr = new AnnotationManager())
{
//We assume you have an image resource in a Base64 string here.
string image = "Your image in Base64 encoded string";
if ((annotMgr.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationEmbeddedImage annot = annotMgr.AddEmbeddedImageAnnotFromBase64(image, 0.5f, 0.5f, 2, 3);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.Opacity = 0.8f;
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToPDF("dest.pdf");
}
annot.Dispose();
}
if (annotMgr.GetStat() == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnotFromBase64");
else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnotFromBase64");
annotMgr.Close();
}
Adds a new GdPicture/XMP embedded image annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. This annotation embeds the specified image on the page within the defined rectangle area.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeEmbeddedImage. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.Be aware that annotations are always treated relative to the currently selected page.
The file path of the image resource to render as an annotation.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationEmbeddedImage object. The newly added GdPicture/XMP embedded image annotation.
How to add an embedded image annotation from a file on the currently selected page of the handled document.
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromFile("source.tiff") = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.AnnotationEmbeddedImage = annotMgr.AddEmbeddedImageAnnot("annot.jpg", 0.5F, 0.5F, 2, 3)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.Opacity = 0.8F
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToTIFF("dest.tiff", TiffCompression.TiffCompressionAUTO)
End If
End If
annot.Dispose()
End If
If annotMgr.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnot")
Else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot")
End If
annotMgr.Close()
End Using
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromFile("source.tiff") == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationEmbeddedImage annot = annotMgr.AddEmbeddedImageAnnot("annot.jpeg", 0.5f, 0.5f, 2, 3);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.Opacity = 0.8f;
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToTIFF("dest.tiff", TiffCompression.TiffCompressionAUTO);
}
annot.Dispose();
}
if (annotMgr.GetStat() == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnot");
else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot");
annotMgr.Close();
}
Adds a new GdPicture/XMP embedded image annotation on the selected page of the document currently handled by this AnnotationManager object
according to the parameters you have specified. This annotation embeds the specified image on the page within the defined rectangle area.
The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeEmbeddedImage. You can change the annotation properties
directly using the class right after the successful creation of the annotation object.Be aware that annotations are always treated relative to the currently selected page.
Adds a new GdPicture/XMP embedded image annotation on the selected page of the document currently handled by this AnnotationManager object.
A unique image identifier of the GdPictureImage object representing the required image to render as an annotation.
You can obtain this identifier, for example, using methods of the class when creating the image resource.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
You can regularly apply the method to determine if this method has been successful.
A GdPicture/XMP AnnotationEmbeddedImage object. The newly added GdPicture/XMP embedded image annotation.
How to add an embedded image annotation on the currently selected page of the handled document.
Using annotMgr As AnnotationManager = New AnnotationManager()
If (annotMgr.InitFromFile("source.jpeg") = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Using image As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = image.CreateGdPictureImageFromFile("annotation.jpeg")
If image.GetStat() = GdPictureStatus.OK Then
Dim annot As GdPicture14.Annotations.AnnotationEmbeddedImage = annotMgr.AddEmbeddedImageAnnot(imageID, 0.5F, 0.5F, 2, 3)
If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
annot.Author = "GdPicture"
annot.Opacity = 0.8F
If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
annotMgr.SaveDocumentToJPEG("dest.jpeg", 80)
End If
End If
annot.Dispose()
image.ReleaseGdPictureImage(imageID)
Else
MessageBox.Show("Error! Status: " + image.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot")
End If
End Using
End If
If annotMgr.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnot")
Else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot")
End If
annotMgr.Close()
End Using
using (AnnotationManager annotMgr = new AnnotationManager())
{
if ((annotMgr.InitFromFile("source.jpeg") == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
using (GdPictureImaging image = new GdPictureImaging())
{
int imageID = image.CreateGdPictureImageFromFile("annotation.jpeg");
if (image.GetStat() == GdPictureStatus.OK)
{
GdPicture14.Annotations.AnnotationEmbeddedImage annot = annotMgr.AddEmbeddedImageAnnot(imageID, 0.5f, 0.5f, 2, 3);
if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
{
annot.Author = "GdPicture";
annot.Opacity = 0.8f;
if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
annotMgr.SaveDocumentToJPEG("dest.jpeg", 80);
}
annot.Dispose();
image.ReleaseGdPictureImage(imageID);
}
else
MessageBox.Show("Error! Status: " + image.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot");
}
}
if (annotMgr.GetStat() == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnot");
else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot");
annotMgr.Close();
}
Saves the document currently handled by this AnnotationManager object to a file in PDF format according to a file path you have specified. The document is saved
with full GdPicture/XMP annotation support.
Please consider using the method before saving, if you expect, that your annotations will be included in the document content,
for example for printing or to disable their editing.The event is raised after each successfully saved page, when processing the image-based documents,
in other words if you are saving the multi-page TIFF file to PDF document.
The file path including the full document name, where the resulting PDF document will be saved.
Just to remind you that if you want to permanently incorporate the annotations to be part of the document content, you need to use the method before saving the document.
The event is raised, when processing the image-based documents using this method.
Be aware that if the resulting file path is the same as the initial file path, then the GdPictureStatus.AccessDenied is returned.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the handled document to a PDF formatted file.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("test.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToPDF("test_approved.pdf") = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToPDF")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("test.pdf") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToPDF("test_approved.pdf") == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToPDF");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF");
annotationManager.Dispose();
Saves the document currently handled by this AnnotationManager object in PDF format to an instantiated Stream object according to what you have specified. The document is saved with full GdPicture/XMP annotation support.
Please consider using the method before saving, if you expect, that your annotations will be included in the document content,
for example for printing or to disable their editing.The event is raised after each successfully saved page, when processing the image-based documents,
in other words if you are saving the multi-page TIFF file to PDF document.
Saves the document handled by this AnnotationManager object to a file in PDF format with full GdPicture XMP annotation suppport.
A System.IO.Stream object where the resulting PDF document will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Just to remind you that if you want to permanently incorporate the annotations to be part of the document content, you need to use the method before saving the document.The event is raised, when processing the image-based documents using this method.The output stream should be open for writing and should be closed/disposed by the user as well.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the handled document to a PDF formatted file using a stream.
Using annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("test.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
Dim oFileStream As System.IO.FileStream = New System.IO.FileStream("test_approved.pdf", System.IO.FileMode.Create)
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToPDF(oFileStream) = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToPDF")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF")
End If
oFileStream.Dispose()
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if ((annotationManager.InitFromFile("test.pdf") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
System.IO.FileStream oFileStream = new System.IO.FileStream("test_approved.pdf", System.IO.FileMode.Create);
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToPDF(oFileStream) == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToPDF");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF");
oFileStream.Dispose();
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToPDF");
}
Saves the document currently handled by this AnnotationManager object to a file in TIFF format according to a file path you have specified. The file is saved with full GdPicture/XMP annotation support.
Please consider using the method before saving, if you expect, that your annotations will be included in the document content.
The event is raised after each successfully saved page.
The file path including the full document name, where the resulting TIFF file will be saved.
A member of the TiffCompression enumeration. Specifies the compression method to be used to compress the resulting TIFF file.
Just to remind you that if you want to permanently incorporate the annotations to be part of the document content, you need to use the method before saving the file.
The event is raised when processing documents using this method.
Be aware that if the resulting file path is the same as the initial file path for multi-page TIFF files, then the GdPictureStatus.AccessDenied is returned.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the handled document to a TIFF formatted file.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.tif") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(true) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToTIFF("image_approved.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToTIFF")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToTIFF("image_approved.tif", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToTIFF");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF");
annotationManager.Dispose();
Saves the document currently handled by this AnnotationManager object in TIFF format to an instantiated Stream object according to what you have specified. The document is saved with full GdPicture/XMP annotation support.
Please consider using the method before saving, if you expect, that your annotations will be included in the document content.The event is raised after each successfully saved page.
Saves the document handled by this AnnotationManager object to a file in TIFF format with full GdPicture XMP annotation suppport.
A System.IO.Stream object where the resulting TIFF file will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
A member of the TiffCompression enumeration. Specifies the compression method to be used to compress the resulting TIFF file.
Just to remind you that if you want to permanently incorporate the annotations to be part of the document content, you need to use the method before saving the file.The event is raised when processing documents using this method.The output stream should be open for writing and should be closed/disposed by the user as well.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the handled document to a TIFF formatted file using a stream.
Using annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
Dim oFileStream As System.IO.FileStream = New System.IO.FileStream("image_approved.tif", System.IO.FileMode.Create)
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToTIFF(oFileStream, TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToTIFF")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF")
End If
oFileStream.Dispose()
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
System.IO.FileStream oFileStream = new System.IO.FileStream("image_approved.tif", System.IO.FileMode.Create);
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToTIFF(oFileStream, TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToTIFF");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF");
oFileStream.Dispose();
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToTIFF");
}
Saves the document handled by this AnnotationManager object to a file in JPEG format according to a file path you have specified. The file is saved with full GdPicture/XMP annotation support.
Please consider using the method before saving, if you expect, that your annotations will be included in the document content.
The file path including the full document name, where the resulting JPEG file will be saved.
The compression quality level from 0 to 100 to be used to compress the resulting JPEG file. 0 means worse quality and better compression, 100 means the best quality and worse compression.
Just to remind you that if you want to permanently incorporate the annotations to be part of the document content, you need to use the method before saving the file.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the handled document to a JPEG formatted file.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(true) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToJPEG")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToJPEG");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
annotationManager.Dispose();
Saves the document handled by this AnnotationManager object in JPEG format to an instantiated Stream object according to what you have specified. The document is saved with full GdPicture/XMP annotation support.
Please consider using the method before saving, if you expect, that your annotations will be included in the document content.
Saves the document handled by this AnnotationManager object to a file in JPEG format with full GdPicture XMP annotation suppport.
A System.IO.Stream object where the resulting JPEG file will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
The compression quality level from 0 to 100 to be used to compress the resulting JPEG file. 0 means worse quality and better compression, 100 means the best quality and worse compression.
Just to remind you that if you want to permanently incorporate the annotations to be part of the document content, you need to use the method before saving the file.The output stream should be open for writing and should be closed/disposed by the user as well.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the handled document to a JPEG formatted file using a stream.
Using annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("test.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
Dim oFileStream As System.IO.FileStream = New System.IO.FileStream("test_approved.jpg", System.IO.FileMode.Create)
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToJPEG(oFileStream, 75) = GdPictureStatus.OK) Then
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToJPEG")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
End If
oFileStream.Dispose()
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
if ((annotationManager.InitFromFile("test.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
System.IO.FileStream oFileStream = new System.IO.FileStream("test_approved.jpg", System.IO.FileMode.Create);
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToJPEG(oFileStream, 75) == GdPictureStatus.OK))
MessageBox.Show("Finished successfully!", "AnnotationManager.SaveDocumentToJPEG");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
oFileStream.Dispose();
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveDocumentToJPEG");
}
Saves the GdPicture/XMP annotation part of the selected page of the document currently handled by this AnnotationManager object in XML format to a file
according to a file path you have specified.Be aware that this method only handles GdPicture/XMP annotations.
Likewise, annotations are always treated relative to the selected page.
Saves the GdPicture/XMP annotation part of the selected page of the document handled by this AnnotationManager object in XML format to a file or to a stream.
The file path of the XML formatted file to create and save all GdPicture/XMP annotations from the selected page.
Be aware that this method only handles GdPicture/XMP annotations contained within the currently selected page.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to transfer GdPicture/XMP annotations from one jpg file to another.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image1.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveAnnotationsToXMP("annots.xml") = GdPictureStatus.OK) Then
annotationManager.Close()
If (annotationManager.InitFromFile("image2.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMP("annots.xml") = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image2.jpg", 75) = GdPictureStatus.OK Then MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMP")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMP")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMP")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image1.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.SaveAnnotationsToXMP("annots.xml") == GdPictureStatus.OK))
{
annotationManager.Close();
if ((annotationManager.InitFromFile("image2.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMP("annots.xml") == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image2.jpg", 75) == GdPictureStatus.OK) MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMP");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMP");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMP");
annotationManager.Dispose();
Saves the GdPicture/XMP annotation part of the selected page of the document currently handled by this AnnotationManager object in XML format
to an instantiated Stream object according to what you have specified.Be aware that this method only handles GdPicture/XMP annotations.
Likewise, annotations are always treated relative to the selected page.
Saves the GdPicture/XMP annotation part of the selected page of the document handled by this AnnotationManager object in XML format to a file or to a stream.
A System.IO.Stream object where all GdPicture/XMP annotations from the selected page will be saved to.
This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
The output stream should be open for writing and should be closed/disposed of by the user as well.
Be aware that this method only handles GdPicture/XMP annotations contained within the currently selected page.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to transfer GdPicture/XMP annotations from one jpg file to another.
Dim annotStream As System.IO.MemoryStream = New System.IO.MemoryStream()
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image1.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveAnnotationsToXMP(annotStream) = GdPictureStatus.OK) Then
annotationManager.Close()
If (annotationManager.InitFromFile("image2.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMP(annotStream) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image2.jpg", 75) = GdPictureStatus.OK Then MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMP")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMP")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMP")
End If
annotationManager.Dispose()
annotStream.Dispose()
System.IO.MemoryStream annotStream = new System.IO.MemoryStream();
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image1.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.SaveAnnotationsToXMP(annotStream) == GdPictureStatus.OK))
{
annotationManager.Close();
if ((annotationManager.InitFromFile("image2.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMP(annotStream) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image2.jpg", 75) == GdPictureStatus.OK) MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMP");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMP");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMP");
annotationManager.Dispose();
annotStream.Dispose();
Saves the annotation data of the required GdPicture/XMP annotation object, that is specified by its index related to the selected page of the handled document,
to an XML formatted string. You can subsequently use the method to add the exactly same annotation wherever you need.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
A string containing the annotation definition in XML format. The method can be subsequently used to determine if this method has been successful.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
How to get an annotation data as an XML formatted string.
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim annotXML As String = ""
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
Dim annotIdx As Integer = annotationManager.GetAnnotationIdx(stamp)
If annotationManager.GetStat() = GdPictureStatus.OK Then
annotXML = annotationManager.GetAnnotationXML(annotIdx)
If annotationManager.GetStat() = GdPictureStatus.OK Then
status = annotationManager.SaveDocumentToPDF("source_stamped.pdf")
End If
Else
status = annotationManager.GetStat()
End If
Else
status = annotationManager.GetStat()
End If
stamp.Dispose()
End If
annotationManager.Close()
If status = GdPictureStatus.OK Then
If (annotationManager.InitFromFile("dest.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.Annotation = annotationManager.AddAnnotationFromXML(annotXML)
If annot IsNot Nothing Then status = annotationManager.SaveAnnotationsToPage()
If status = GdPictureStatus.OK Then
status = annotationManager.SaveDocumentToPDF("dest_stamped.pdf")
End If
Else
status = annotationManager.GetStat()
End If
End If
annotationManager.Close()
Else
status = annotationManager.GetStat()
End If
If status = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationIdx")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationIdx")
End If
annotationManager.Dispose()
GdPictureStatus status = GdPictureStatus.OK;
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
string annotXML = "";
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if (annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK)
{
int annotIdx = annotationManager.GetAnnotationIdx(stamp);
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
annotXML = annotationManager.GetAnnotationXML(annotIdx);
if (annotationManager.GetStat() == GdPictureStatus.OK)
status = annotationManager.SaveDocumentToPDF("source_stamped.pdf");
}
else status = annotationManager.GetStat();
}
else status = annotationManager.GetStat();
stamp.Dispose();
}
annotationManager.Close();
if (status == GdPictureStatus.OK)
{
if ((annotationManager.InitFromFile("dest.pdf") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.Annotation annot = annotationManager.AddAnnotationFromXML(annotXML);
if (annot != null)
status = annotationManager.SaveAnnotationsToPage();
if (status == GdPictureStatus.OK)
status = annotationManager.SaveDocumentToPDF("dest_stamped.pdf");
}
else status = annotationManager.GetStat();
}
annotationManager.Close();
}
else status = annotationManager.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.GetAnnotationXML");
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationXML");
annotationManager.Dispose();
Renders the appearance of a specific annotation into a GdPicture image.
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to -1.
The rendering zoom level. IE: 1 means 100%, 2 means 200%...
A GdPicture image identifier in case of success, 0 if failure.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Saves the GdPicture/XMP annotation part of the selected page of the document currently handled by this AnnotationManager object to a Base64 encoded string.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document.
Annotations are always treated relative to the currently selected page.
This method requires the Annotations component to run.
A Base64 encoded string containing the annotations data of the selected page in the handled document.
How to transfer GdPicture/XMP annotations from one JPEG file to another using a Base64 encoded string.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image1.jpeg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim annotBase As String = annotationManager.SaveAnnotationsToXMPBase64()
If annotationManager.GetStat() = GdPictureStatus.OK Then
annotationManager.Close()
If (annotationManager.InitFromFile("image2.jpeg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMPBase64(annotBase) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image2_updated.jpeg", 75) = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPBase64")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image1.jpeg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
string annotBase = annotationManager.SaveAnnotationsToXMPBase64();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
annotationManager.Close();
if ((annotationManager.InitFromFile("image2.jpeg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMPBase64(annotBase) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image2_updated.jpeg", 75) == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPBase64");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64");
annotationManager.Dispose();
Saves the GdPicture/XMP annotation part of all pages of the document currently handled by this AnnotationManager object to a Base64 encoded string.
Be aware that this method only handles GdPicture/XMP annotations.
This method requires the Annotations component to run.
A Base64 encoded string containing the annotations data of all pages in the handled document.
How to transfer GdPicture/XMP annotations from one PDF document to another using a Base64 encoded string.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK Then
Dim annotBase As String = annotationManager.SaveAnnotationsToXMPBase64Ex()
If annotationManager.GetStat() = GdPictureStatus.OK Then
annotationManager.Close()
If (annotationManager.InitFromFile("dest.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMPBase64(annotBase) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToPDF("dest_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPBase64Ex")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64Ex")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64Ex")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64Ex")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if (annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK)
{
string annotBase = annotationManager.SaveAnnotationsToXMPBase64Ex();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
annotationManager.Close();
if ((annotationManager.InitFromFile("dest.pdf") == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMPBase64(annotBase) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToPDF("dest_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPBase64Ex");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64Ex");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64Ex");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPBase64Ex");
annotationManager.Dispose();
Saves the GdPicture/XMP annotation part of all pages of the document currently handled by this AnnotationManager object in XML format to a file
according to a file path you have specified.Be aware that this method only handles GdPicture/XMP annotations.
This method requires the Annotations component to run.
The file path of the XML formatted file to create and save all GdPicture/XMP annotations from the handled document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to transfer GdPicture/XMP annotations from one PDF document to another.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.SaveAnnotationsToXMPEx("annots.xml") = GdPictureStatus.OK) Then
annotationManager.Close()
If (annotationManager.InitFromFile("dest.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMP("annots.xml") = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToPDF("dest_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPEx")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPEx")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPEx")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
(annotationManager.SaveAnnotationsToXMPEx("annots.xml") == GdPictureStatus.OK))
{
annotationManager.Close();
if ((annotationManager.InitFromFile("dest.pdf") == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMP("annots.xml") == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToPDF("dest_updated.pdf") == GdPictureStatus.OK) MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPEx");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPEx");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPEx");
annotationManager.Dispose();
Saves the GdPicture/XMP annotation part of all pages of the document currently handled by this AnnotationManager object in XML format
to an instantiated Stream object according to what you have specified.Be aware that this method only handles GdPicture/XMP annotations.
Saves the GdPicture/XMP annotation part of all pages of the document handled by this AnnotationManager object in XML format to a file or to a stream.
A System.IO.Stream object where all GdPicture/XMP annotations from the selected page will be saved to.
This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
The output stream should be open for writing and should be closed/disposed of by the user as well.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to transfer GdPicture/XMP annotations from one TIFF file to another using a stream.
Dim annotStream As System.IO.MemoryStream = New System.IO.MemoryStream()
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("source.tiff") = GdPictureStatus.OK) AndAlso
(annotationManager.SaveAnnotationsToXMP(annotStream) = GdPictureStatus.OK) Then
annotationManager.Close()
If (annotationManager.InitFromFile("dest.tiff") = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMP(annotStream) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToTIFF("dest_updated.tiff", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPEx")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPEx")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPEx")
End If
annotationManager.Dispose()
annotStream.Dispose()
System.IO.MemoryStream annotStream = new System.IO.MemoryStream();
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("source.tiff") == GdPictureStatus.OK) &&
(annotationManager.SaveAnnotationsToXMPEx(annotStream) == GdPictureStatus.OK))
{
annotationManager.Close();
if ((annotationManager.InitFromFile("dest.tiff") == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMP(annotStream) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToTIFF("dest_updated.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.SaveAnnotationsToXMPEx");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPEx");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.SaveAnnotationsToXMPEx");
annotationManager.Dispose();
annotStream.Dispose();
Loads the GdPicture/XMP annotations from a specified Base64 encoded string, that has been previously generated using the method
or the method. The loaded annotations are subsequently applied to the document currently handled by this AnnotationManager object
to the selected page or all pages, respectively. This means that the loaded annotations will replace the current annotations presented in the document.
Be aware that this method only handles GdPicture/XMP annotations.
A Base64 encoded string of the annotations data to load.
Be aware that the loaded annotations will replace the current annotations presented in the document.
For adding new annotations you can use the method.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to transfer GdPicture/XMP annotations from one PDF document to another using a Base64 encoded string.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK Then
Dim annotBase As String = annotationManager.SaveAnnotationsToXMPBase64Ex()
If annotationManager.GetStat() = GdPictureStatus.OK Then
annotationManager.Close()
If (annotationManager.InitFromFile("dest.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMPBase64(annotBase) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToPDF("dest_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMPBase64")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMPBase64")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMPBase64")
End If
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMPBase64")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if (annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK)
{
string annotBase = annotationManager.SaveAnnotationsToXMPBase64Ex();
if (annotationManager.GetStat() == GdPictureStatus.OK)
{
annotationManager.Close();
if ((annotationManager.InitFromFile("dest.pdf") == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMPBase64(annotBase) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToPDF("dest_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMPBase64");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMPBase64");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMPBase64");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMPBase64");
annotationManager.Dispose();
Loads the GdPicture/XMP annotations from a specified XML formatted file, that has been previously generated using the method
or the method. The loaded annotations are subsequently applied to the document currently handled by this AnnotationManager object
to the selected page or all pages, respectively. This means that the loaded annotations will replace the current annotations presented in the document.
Be aware that this method only handles GdPicture/XMP annotations.
Loads the GdPicture/XMP annotations from a properly formatted file or stream and subsequently applies them to the document currently handled by this AnnotationManager object.
The file path of the properly formatted XML file to load.
Be aware that the loaded annotations will replace the current annotations presented in the document.
For adding new annotations you can use the method.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to transfer GdPicture/XMP annotations from one jpg file to another.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image1.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveAnnotationsToXMP("annots.xml") = GdPictureStatus.OK) Then
annotationManager.Close()
If (annotationManager.InitFromFile("image2.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMP("annots.xml") = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image2.jpg", 75) = GdPictureStatus.OK Then MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMP")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image1.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.SaveAnnotationsToXMP("annots.xml") == GdPictureStatus.OK))
{
annotationManager.Close();
if ((annotationManager.InitFromFile("image2.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMP("annots.xml") == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image2.jpg", 75) == GdPictureStatus.OK) MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMP");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP");
annotationManager.Dispose();
Loads the GdPicture/XMP annotations from an instantiated Stream object containing XML formatted data, that has been previously generated
using the method or the method.
The loaded annotations are subsequently applied to the document currently handled by this AnnotationManager object to the selected page or all pages, respectively.
This means that the loaded annotations will replace the current annotations presented in the document.
Be aware that this method only handles GdPicture/XMP annotations.
Loads the GdPicture/XMP annotations from a properly formatted XML file or stream and subsequently applies them to the document currently handled by this AnnotationManager object.
A System.IO.Stream object containing the properly formatted XML annotations data.
This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
The input stream should remain open and can only be closed/disposed of by the user as well.
Be aware that the loaded annotations will replace the current annotations presented in the document.
For adding new annotations you can use the method.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to transfer GdPicture/XMP annotations from one jpg file to another.
Dim annotStream As System.IO.MemoryStream = New System.IO.MemoryStream()
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image1.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.SaveAnnotationsToXMP(annotStream) = GdPictureStatus.OK) Then
annotationManager.Close()
If (annotationManager.InitFromFile("image2.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMP(annotStream) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image2.jpg", 75) = GdPictureStatus.OK Then MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMP")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP")
End If
annotationManager.Close()
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP")
End If
annotationManager.Dispose()
annotStream.Dispose()
System.IO.MemoryStream annotStream = new System.IO.MemoryStream();
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image1.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.SaveAnnotationsToXMP(annotStream) == GdPictureStatus.OK))
{
annotationManager.Close();
if ((annotationManager.InitFromFile("image2.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMP(annotStream) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image2.jpg", 75) == GdPictureStatus.OK) MessageBox.Show("Done!", "AnnotationManager.LoadAnnotationsFromXMP");
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP");
annotationManager.Close();
}
else MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.LoadAnnotationsFromXMP");
annotationManager.Dispose();
annotStream.Dispose();
Validates GdPicture/XMP annotations from a stream containing annotations data previously generated by the method
or the method.Using this method you can very quickly check out if the specified stream is properly formatted
and it can be used for further applying of annotations. Please note, that this method is static and therefore it does not depend on any document.
Be aware that this method only handles GdPicture/XMP annotations.
A System.IO.Stream object containing the annotations data. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
The input stream should remain open and can only be closed/disposed of by the user as well.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to validate GdPicture/XMP annotations for their further use.
Dim annotStream As System.IO.Stream = New System.IO.FileStream("annots.xml", System.IO.FileMode.Open)
Dim status As GdPictureStatus = AnnotationManager.ValidateAnnotations(annotStream)
annotStream.Dispose()
'Annotations were validated successfully.
If status = GdPictureStatus.OK Then
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
(annotationManager.LoadAnnotationsFromXMP("annots.xml") = GdPictureStatus.OK) AndAlso
(annotationManager.SaveDocumentToPDF("dest.pdf") = GdPictureStatus.OK) Then
MessageBox.Show("Done!", "AnnotationManager.ValidateAnnotations")
Else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.ValidateAnnotations")
End If
annotationManager.Dispose()
End If
System.IO.Stream annotStream = new System.IO.FileStream("annots.xml", System.IO.FileMode.Open);
GdPictureStatus status = AnnotationManager.ValidateAnnotations(annotStream);
annotStream.Dispose();
//Annotations were validated successfully.
if (status == GdPictureStatus.OK)
{
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
(annotationManager.LoadAnnotationsFromXMP("annots.xml") == GdPictureStatus.OK) &&
(annotationManager.SaveDocumentToPDF("dest.pdf") == GdPictureStatus.OK))
MessageBox.Show("Done!", "AnnotationManager.ValidateAnnotations");
else
MessageBox.Show("Error! Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.ValidateAnnotations");
annotationManager.Dispose();
}
Rotates clockwise by a specified angle all GdPicture/XMP annotations contained within the selected page of the document currently handled by this AnnotationManager object.
The coordinate system of the currently selected page is used to determine the rotation direction.
Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.
This method requires the Annotations component to run.
The rotation angle, in degrees, determining the clockwise rotation. This parameter can only be set to 90, 180, 270; otherwise the method will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to rotate all annotations on the selected page.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
If annotationManager.RotateAnnotations(90) = GdPictureStatus.OK Then
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image_rotated.jpg", 75) = GdPictureStatus.OK Then
MessageBox.Show("Finished successfully!", "AnnotationManager.RotateAnnotations")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.RotateAnnotations")
End If
Else
MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.RotateAnnotations")
End If
Else
MessageBox.Show("Annotations can't be rotated. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.RotateAnnotations")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.RotateAnnotations")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
if (annotationManager.RotateAnnotations(90) == GdPictureStatus.OK)
{
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image_rotated.jpg", 75) == GdPictureStatus.OK)
MessageBox.Show("Finished successfully!", "AnnotationManager.RotateAnnotations");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.RotateAnnotations");
}
else
MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.RotateAnnotations");
}
else
MessageBox.Show("Annotations can't be rotated. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.RotateAnnotations");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.RotateAnnotations");
annotationManager.Dispose();
Burn, in other words flatten, the GdPicture/XMP annotations into the selected page of the document currently handled by this AnnotationManager object.
Burning (flattening) annotations means simply including them directly into the content of the page, to which they belong, so they are not more editable.
This will permanently write an annotation into the document, so it is not considered as an annotation anymore.
Please note, that this method uses vector graphics when drawing annotations. To burn your custom annotations,
please use the method and set the VectorMode parameter to false.
Burn, in other words flatten, the GdPicture/XMP annotations into the selected page of the document currently handled by this AnnotationManager object.
Set this parameter to true, if you want to remove the initial annotation blob content from the file, otherwise set it to false.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document. Annotations are always treated relative to the currently selected page.
Be aware that you need to use the method to burn (rasterize) your custom annotations.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to burn annotations to all pages in the handled document.
'We assume that the GdViewer1 control has been integrated into your application
'and you have annotate the displayed document.
Dim oAnnotationManager As AnnotationManager = GdViewer1.GetAnnotationManager()
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 1 To oAnnotationManager.PageCount
status = oAnnotationManager.SelectPage(i)
If status = GdPictureStatus.OK Then
status = oAnnotationManager.BurnAnnotationsToPage(True)
If status <> GdPictureStatus.OK Then Exit For
Else
Exit For
End If
Next
If status <> GdPictureStatus.OK Then
MessageBox.Show("Annotations can't be burned. Status: " + status.ToString(), "AnnotationManager.BurnAnnotationsToPage")
End If
//We assume that the GdViewer1 control has been integrated into your application
//and you have annotate the displayed document.
AnnotationManager oAnnotationManager = GdViewer1.GetAnnotationManager();
GdPictureStatus status = GdPictureStatus.OK;
for (int i = 1; i <= oAnnotationManager.PageCount; i++)
{
status = oAnnotationManager.SelectPage(i);
if (status == GdPictureStatus.OK)
{
status = oAnnotationManager.BurnAnnotationsToPage(true);
if (status != GdPictureStatus.OK) break;
}
else
break;
}
if (status != GdPictureStatus.OK)
MessageBox.Show("Annotations can't be burned. Status: " + status.ToString(), "AnnotationManager.BurnAnnotationsToPage");
Burn, in other words flatten, the GdPicture/XMP annotations into the selected page of the document currently handled by this AnnotationManager object.
Burning (flattening) annotations means simply including them directly into the content of the page, to which they belong, so they are not more editable.
This will permanently write an annotation into the document, so it is not considered as an annotation anymore.This method doesn't support custom annotations burning.
Burn, in other words flatten, the GdPicture/XMP annotations into the selected page of the document currently handled by this AnnotationManager object.
Set this parameter to true, if you want to remove the initial annotation blob content from the file, otherwise set it to false.
A member of the GdPictureOutputIntent enumeration. Specifies the intent of the produced page after flattening.
The default value is GdPictureOutputIntent.IntentColor. Other intents produce smaller page size.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document. Annotations are always treated relative to the currently selected page.
Be aware that this method doesn't support custom annotations burning. You can find out in the example for
the method how to burn annotations to all pages in your document.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to burn annotations to the currently selected page of the handled document.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("image.jpg") = GdPictureStatus.OK) AndAlso
(annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
If stamp IsNot Nothing Then
stamp.Rotation = 20
If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
(annotationManager.BurnAnnotationsToPage(True, GdPictureOutputIntent.IntentPalletized) = GdPictureStatus.OK) Then
If annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) = GdPictureStatus.OK Then
MessageBox.Show("Finished successfully!", "AnnotationManager.BurnAnnotationsToPage")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage")
End If
Else
MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage")
End If
stamp.Dispose()
Else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("image.jpg") == GdPictureStatus.OK) &&
(annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
if (stamp != null)
{
stamp.Rotation = 20;
if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
(annotationManager.BurnAnnotationsToPage(true, GdPictureOutputIntent.IntentPalletized) == GdPictureStatus.OK))
{
if (annotationManager.SaveDocumentToJPEG("image_approved.jpg", 75) == GdPictureStatus.OK)
MessageBox.Show("Finished successfully!", "AnnotationManager.BurnAnnotationsToPage");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage");
}
else
MessageBox.Show("Annotations can't be saved or burned. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage");
stamp.Dispose();
}
else
MessageBox.Show("The rubber stamp annotation can't be created. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage");
annotationManager.Dispose();
Burn, in other words flatten, the GdPicture/XMP annotations into the selected page of the document currently handled by this AnnotationManager object.
Burning (flattening) annotations means simply including them directly into the content of the page, to which they belong, so they are not more editable.
This will permanently write an annotation into the document, so it is not considered as an annotation anymore.This method supports custom annotations burning by setting the VectorMode parameter to false.
In other words, this way annotations are drawn using raster graphics (rasterized) on the page.
Burn, in other words flatten, the GdPicture/XMP annotations into the selected page of the document currently handled by this AnnotationManager object.
Set this parameter to true, if you want to remove the initial annotation blob content from the file, otherwise set it to false.
Determines, if annotations data are rendered in vector format (means using vector graphics) on the page. Setting this parameter to false
is only suitable for burning annotations into PDF documents in order to rasterize them on the page, that means to produce image-based page content.
At the same, custom annotations can only be burned if the VectorMode parameter is set to false using the same approach.
Please ensure that you have selected the proper page before starting any annotation related action with the handled document. Annotations are always treated relative to the currently selected page.
To burn your custom annotations, please set the VectorMode paramater to false using this method. You can find out in the example
for the method how to burn annotations to all pages in your document.
This method requires the Annotations component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to burn your annotations (specifically custom annotations) contained in your PDF document using rasterization.
Using annotationManager As AnnotationManager = New AnnotationManager()
'We assume that you have already annotated your source document.
If annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK Then
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 1 To annotationManager.PageCount
status = annotationManager.SelectPage(i)
If status = GdPictureStatus.OK Then
'Burning annotations to page using rasterization.
status = annotationManager.BurnAnnotationsToPage(True, False)
If status <> GdPictureStatus.OK Then Exit For
Else
Exit For
End If
Next
If status = GdPictureStatus.OK Then
If annotationManager.SaveDocumentToPDF("dest.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.BurnAnnotationsToPage")
Else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage")
End If
Else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.BurnAnnotationsToPage")
End If
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage")
End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
//We assume that you have already annotated your source document.
if (annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
for (int i = 1; i <= annotationManager.PageCount; i++)
{
status = annotationManager.SelectPage(i);
if (status == GdPictureStatus.OK)
{
//Burning annotations to page using rasterization.
status = annotationManager.BurnAnnotationsToPage(true, false);
if (status != GdPictureStatus.OK) break;
}
else
break;
}
if (status == GdPictureStatus.OK)
{
if (annotationManager.SaveDocumentToPDF("dest.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.BurnAnnotationsToPage");
else
MessageBox.Show("The file can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage");
}
else
MessageBox.Show("Error! Status: " + status.ToString(), "AnnotationManager.BurnAnnotationsToPage");
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.BurnAnnotationsToPage");
}
Returns the status of the last executed operation with the current AnnotationManager object.
Use this method in the combination with all those, which return a value instead of a status, such as method in the example below.
A member of the GdPictureStatus enumeration. If the last executed AnnotationManager method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve the status of the last executed method.
Dim annotationManager As AnnotationManager = New AnnotationManager()
Dim status As GdPictureStatus = annotationManager.InitFromFile("test.jpg")
If status = GdPictureStatus.OK Then
status = annotationManager.SelectPage(1)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = annotationManager.GetAnnotationCount()
status = annotationManager.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The number of annotations: " + annotCount.ToString(), "AnnotationManager.GetStat")
Else
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + status.ToString(), "AnnotationManager.GetStat")
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), "AnnotationManager.GetStat")
End If
annotationManager.Close()
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + status.ToString(), "AnnotationManager.GetStat")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
GdPictureStatus status = annotationManager.InitFromFile("test.jpg");
if (status == GdPictureStatus.OK)
{
status = annotationManager.SelectPage(1);
if (status == GdPictureStatus.OK)
{
int annotCount = annotationManager.GetAnnotationCount();
status = annotationManager.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The number of annotations: " + annotCount.ToString(), "AnnotationManager.GetStat");
}
else
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + status.ToString(), "AnnotationManager.GetStat");
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), "AnnotationManager.GetStat");
annotationManager.Close();
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + status.ToString(), "AnnotationManager.GetStat");
annotationManager.Dispose();
Disposes already used AnnotationManager object completely. All related resources used by this object are released.
You can also reuse the AnnotationManager object simply by using the method and subsequently initialize it from another source.
AnnotationManager Constructor
How to create and dispose of the AnnotationManager object.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("test.tif") = GdPictureStatus.OK Then
MessageBox.Show("The number of pages: " + annotationManager.PageCount, "AnnotationManager.Dispose")
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Dispose")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if (annotationManager.InitFromFile("test.tif") == GdPictureStatus.OK)
{
MessageBox.Show("The number of pages: " + annotationManager.PageCount, "AnnotationManager.Dispose");
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.Dispose");
annotationManager.Dispose();
A standard constructor for the AnnotationManager class. It initializes an instance of the AnnotationManager class.
You can also reuse the AnnotationManager object simply by using the method and subsequently initialize it from another source.
How to create and dispose of the AnnotationManager object.
Dim annotationManager As AnnotationManager = New AnnotationManager()
If annotationManager.InitFromFile("test.tif") = GdPictureStatus.OK Then
MessageBox.Show("The number of pages: " + annotationManager.PageCount, "AnnotationManager")
Else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager")
End If
annotationManager.Dispose()
AnnotationManager annotationManager = new AnnotationManager();
if (annotationManager.InitFromFile("test.tif") == GdPictureStatus.OK)
{
MessageBox.Show("The number of pages: " + annotationManager.PageCount, "AnnotationManager");
}
else
MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager");
annotationManager.Dispose();
Each unit is one pixel.
Each unit is 1 inch.
Each unit is 1 centimeter.
Each unit is 1 millimeter.
Custom unit.
Specifies the annotation unique identifier.
The date and time, expressed as the Coordinated Universal Time, when the annotation was created. IE: "29-Mar-11 12:36 PM".
The date and time, expressed as the Coordinated Universal Time, when the annotation was modified. IE: "29-Mar-11 12:36 PM".
Determines whether the annotation is visible for purposes of on-screen display and user interaction.
The annotation may be printed (depending on the value of the Printable property).
The rotation of the annotation, in degrees, in the range [0;360].
Specifies the the order in which the annotation is rendered from front to back. The annotation having the higher Zorder will be displayed in front of all others.
Stores arbitrary value that can be used to store optional information about the annotation.
Stores arbitrary public value that can be used to store optional information about the annotation.
In DocuVieware, the content of this property will be transferred to the client side in order to be queried by the JavaScript API.
Specifies the title of the annotation.
The name of the author who created the annotation.
The subject of the annotation, if any.
Left position, in inches, of the middle point of the bounding box of the annotation.
Top position, in inches, of the middle point of the bounding box of the annotation.
Width, in inches, of the bounding box of the annotation.
Height, in inches, of the bounding box of the annotation.
Specifies if the annotation can be edited in design time.
Specifies if the annotation can be deleted in design time.
Specifies if the annotation can be rotated in design time.
Specifies if the annotation can be resized in design time.
Specifies if the annotation can be moved in design time.
Specifies if the annotation can be selected in design time.
Specifies if the annotation can be commented in design time.
Specifies if the annotation is selected.
Specifies if the annotation is rendered during printing process.
Specifies if during burning process, the annotation is prevented to be rendered.
Returns the type of the annotation.
A member of the GdPictureAnnotationType enumeration.
Specifies if the text of the annotation can be edited in design time.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
Determines if the annotation must have the same width and height.
Determines if the annotation must retain its content aspect ratio.
The width, in inches, of each lines in stroking operations.
Determines if the annotation must be stroked or not.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
The radius factor used to draw rounded borders, in the range [0;1]. 0 means: 0% rounded borders, 1 means 100% rounded.
The destination of the link. Can be an uri or a page destination.
The syntax of page destinations is page:[page destination]. IE: use 'page:5' to set the target to the page 5 of the document.
The text to display.
The name of the font to be used to render the text.
The size of the font, in points, to be used to render the text.
Defines whether the annotation is automatically resized to display its entire contents.
The style of the font to be used to render the text.
The style of the font to be used to render the hovered text.
The width of the arrow, in inches.
The height of the arrow, in inches.
Specifies if the arrow must be filled or not.
Defines the color of the font.
Defines the color of the font when the text is hovered.
Defines the vertical alignment of the text.
Defines the scale of the ruler.
Defines the horizontal alignment of the text.
Defines the number of ticks per unit to display.
Defines the measurement unit used. If set to Custom, the value of the MeasurementUnitCustomString property will be used as prefix into the annotation appearance,
and the distance will be computed with this formula: distance = inche distance * Scale.
Defines the custom measurement unit string.
Defines the cap style used at the end of lines drawn.
Defines the the join style for the ends of two consecutive lines drawn.
Determines the dash style for stroking operations.
The points of the path of the annotation.
Specifies the parent annotation unique identifier.
Specifies the next annotation unique identifier.
Specifies if the comment allows review or not.
Specifies if the comment allows answers or not.
Specifies the comment review status.
Method to override if the child class inheriting from annotation has disposable content
Specifies the parent annotation unique identifier.
Specifies the next annotation unique identifier.
Specifies if the comment review status can be changed or not.
Specifies if the comment can be answered or not.
Defines the comment review status.
The text to display.
Defines the color of the font.
The name of the font to be used to render the text.
The style of the font to be used to render the text.
The size of the font to be used to render the text.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
A private identifier defining the model of the annotation.
Determines if the annotation must have the same width and height.
Determines if the annotation must have the same width and height.
The points of the path of the annotation.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
The width, in inches, of each lines in stroking operations.
Determines the dash style for stroking operations.
Determines the cap style for stroking operations when DashStyle is different of Solid. Cap is used at the end of the dashes that make up dashed lines drawn.
Determines if the annotation must be stroked or not.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
The width, in inches, of each lines in stroking operations.
Determines if the annotation must retain the image aspect ratio.
Determines the dash style for stroking operations.
Determines the cap style for stroking operations when DashStyle is different of Solid. Cap is used at the end of the dashes that make up dashed lines drawn.
Determines if the annotation must be stroked or not.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
The radius factor used to draw rounded borders, in the range [0;1]. 0 means: 0% rounded borders, 1 means 100% rounded.
The initial annotation image, in RAW base 64 form. Internally used for caching purpose.
The image to be rendered.
The points of the path of the annotation.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
The width, in inches, of each lines in stroking operations.
Determines the dash style for stroking operations.
Defines the cap style used at the end of path drawn and the cap style for stroking operations when DashStyle is different of Solid. Cap is used at the end of the dashes that make up dashed path drawn.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
The points of the path of the annotation.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
The width, in inches, of each lines in stroking operations.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
The width, in inches, of each lines in stroking operations.
Determines the dash style for stroking operations.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Defines the cap style used at the end of lines drawn.
The width of the arrow, in inches.
The height of the arrow, in inches.
Specifies if the arrow must be filled or not.
Defines the color of the font when the text is hovered.
The style of the font to be used to render the hovered text.
The destination of the link. Can be an uri or a page destination.
The syntax of page desinations is page:[page destination]. IE: use 'page:5' to set the target to the page 5 of the document.
The points of the path of the annotation.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
The width, in inches, of each lines in stroking operations.
Determines the dash style for stroking operations.
Determines the cap style for stroking operations when DashStyle is different of Solid. Cap is used at the end of the dashes that make up dashed lines drawn.
Determines if the annotation must be stroked or not.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
Defines the measurement unit used. If set to Custom, the value of the MeasurementUnitCustomString property will be used as prefix into the annotation appearance,
and the distance will be computed with this formula: distance = inche distance * Scale.
Defines the custom measurement unit string..
The name of the font to be used to render the text.
The style of the font to be used to render the text.
The size of the font to be used to render the text.
Defines the color of the font.
Defines the scale of the ruler.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
Determines if the annotation must have the same width and height.
The width, in inches, of each lines in stroking operations.
Determines the dash style for stroking operations.
Determines the cap style for stroking operations when DashStyle is different of Solid. Cap is used at the end of the dashes that make up dashed lines drawn.
Determines if the annotation must be stroked or not.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
The radius factor used to draw rounded borders, in the range [0;1]. 0 means: 0% rounded borders, 1 means 100% rounded.
The color to be used for filling the annotation.
Determines if the annotation must have the same width and height.
The title of the annotation.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
Determines if the annotation must have the same width and height.
The width, in inches, of each lines in stroking operations.
Determines the dash style for stroking operations.
Determines if the annotation must be stroked or not.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
The radius factor used to draw rounded borders, in the range [0;1]. 0 means: 0% rounded borders, 1 means 100% rounded.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
The width, in inches, of each lines in stroking operations.
Determines the dash style for stroking operations.
Determines the cap style for stroking operations when DashStyle is different of Solid. Cap is used at the end of the dashes that make up dashed lines drawn.
Determines if the annotation must be stroked or not.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
The text to display.
The radius factor used to draw rounded borders, in the range [0;1]. 0 means: 0% rounded borders, 1 means 100% rounded.
The name of the font to be used to render the text.
Please note, that the size of the annotations text is automatically computed based on the annotations boundaries.
Therefore this annotation does not need to have the FontSize property.
The style of the font to be used to render the text.
Please note, that the size of the annotations text is automatically computed based on the annotations boundaries.
Therefore this annotation does not need to have the FontSize property.
Defines the color of the font.
Defines the measurement unit used. If set to Custom, the value of the MeasurementUnitCustomString property will be used as prefix into the annotation appearance,
and the distance will be computed with this formula: distance = inche distance * Scale.
Defines the custom measurement unit string..
Defines the number of ticks per unit to display.
The name of the font to be used to render the text.
The style of the font to be used to render the text.
The size of the font to be used to render the text.
Defines the color of the font.
Defines the scale of the ruler.
Specifies if the text of the annotation can be edited in design time.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
Determines if the annotation must be stroked or not.
The width, in inches, of each lines in stroking operations.
Determines the dash style for stroking operations.
Determines the cap style for stroking operations when DashStyle is different of Solid. Cap is used at the end of the dashes that make up dashed lines drawn.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Defines the horizontal alignment of the text.
Defines the vertical alignment of the text.
The text to display.
The name of the font to be used to render the text.
The style of the font to be used to render the text.
The size of the font to be used to render the text.
Defines whether the annotation is automatically resized to display its entire contents.
Defines the color of the font.
Specifies if the text of the annotation can be edited in design time.
Opacity (or blending level) of the annotation in the range [0;1]. 0 means full transparency, 1 means full opacity.
The width, in inches, of each lines in stroking operations.
Determines the dash style for stroking operations.
Determines the cap style for stroking operations when DashStyle is different of Solid. Cap is used at the end of the dashes that make up dashed lines drawn.
Determines if the annotation must be stroked or not.
The color to be used for line painting of the annotation.
The width of the stroked line is determined by the BorderWidth parameter.
Determines if the annotation must be filled or not.
The color to be used for filling the annotation.
The radius factor used to draw rounded borders, in the range [0;1]. 0 means: 0% rounded borders, 1 means 100% rounded.
The text to display.
The name of the font to be used to render the text.
The style of the font to be used to render the text.
The size of the font to be used to render the text.
Defines the color of the font.
Defines whether the annotation is automatically resized to display its entire contents.
Defines the horizontal alignment of the text.
Defines the vertical alignment of the text.
The GdPictureDocumentConverter class provides the document conversion from wide variety of document formats.
It is used as a wrapper class to allow you easily load, save and convert the files of different types.
Please find all the currently supported input document formats listed here.
Saving the source DOCX document as the resulting PDF document.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
' Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
' Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5)
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
// Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5);
}
Specifies the timeout of the subsequent conversion process, in milliseconds.
Default value is -1, which means no timeout.
Specifies the name of the person who created the document.
Specifies the document’s title.
Specifies the subject of the document.
Specifies the name of the application (for example, PaperScan) that produced the document.
Specifies medatada of the produced document that must be represented in Extensible Markup Language (XML).
Specifies keywords associated with the document.
Sets the rendering resolution to be used when converting vector content to raster content, if any is included in the currently loaded document.
The default value is 200.
Converting and saving a PDF document to a TIFF image file along with specifying the required DPI.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF)
If status = GdPictureStatus.OK Then
'Setting the required rasterization parameter.
gdpictureDocumentConverter.RasterizationDPI = 300
status = gdpictureDocumentConverter.SaveAsTIFF("drawing_image.tiff", TiffCompression.TiffCompressionAUTO)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF);
if (status == GdPictureStatus.OK)
{
//Setting the required rasterization parameter.
gdpictureDocumentConverter.RasterizationDPI = 300;
status = gdpictureDocumentConverter.SaveAsTIFF("drawing_image.tiff", TiffCompression.TiffCompressionAUTO);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies that xls and xlsx sheets should be split into pages according to the PageSetup element of each sheet.
The default value is false.
Loading and converting a .docx document showing the revisions.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.SplitExcelSheetsIntoPages = True
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsxx", GdPicture14.DocumentFormat.DocumentFormatXLSX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.SplitExcelSheetsIntoPages = true;
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies that the xls and xlsx headers and footers should be rendered.
The default value is false.
Loading and converting a .xlsx document rendering headers and footers.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.RenderSheetHeadersAndFooters = True
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsxx", GdPicture14.DocumentFormat.DocumentFormatXLSX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.RenderSheetHeadersAndFooters = true;
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
If no print area are found the whole sheets will be rendered
Decimal value indicating the maximum width of the sheet content, in millimeters. Maximum content width ignores margins.
When multiple pages are required to render a sheet, the content width will be the sum of the content width of each page.
If set to zero or less, no limitation will be applied.
The default value is 0 (no limitation).
Loading and converting a .xlsx with SpreadsheetMaximumContentWidthPerSheet and SpreadsheetMaximumContentHeightPerSheet set to 7000.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.SpreadsheetMaximumContentWidthPerSheet = 7000
gdpictureDocumentConverter.SpreadsheetMaximumContentHeightPerSheet = 7000
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("Failed to save file. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("Failed to load file. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.SpreadsheetMaximumContentWidthPerSheet = 7000;
gdpictureDocumentConverter.SpreadsheetMaximumContentHeightPerSheet = 7000;
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("Failed to save file. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("Failed to load file. Status: " + status.ToString(), "GdPicture");
}
}
Decimal value indicating the maximum height of the sheet content, in millimeters. Maximum content height ignores header and footer height.
When multiple pages are required to render a sheet, the content height will be the sum of the content height of each page.
If set to zero or less, no limitation will be applied.
The default value is 0 (no limitation).
Loading and converting a .xlsx with SpreadsheetMaximumContentWidthPerSheet and SpreadsheetMaximumContentHeightPerSheet set to 7000.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.SpreadsheetMaximumContentWidthPerSheet = 7000
gdpictureDocumentConverter.SpreadsheetMaximumContentHeightPerSheet = 7000
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("Failed to save file. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("Failed to load file. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.SpreadsheetMaximumContentWidthPerSheet = 7000;
gdpictureDocumentConverter.SpreadsheetMaximumContentHeightPerSheet = 7000;
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("Failed to save file. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("Failed to load file. Status: " + status.ToString(), "GdPicture");
}
}
Specifies the maximum page width in millimeters.
A value of zero or less indicates no width limitation.
The default value is 1800.
Loading and converting a .xlsx with SpreadsheetMaximumPageWidth and SpreadsheetMaximumPageHeight set to 3000.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.SpreadsheetMaximumPageWidth = 3000
gdpictureDocumentConverter.SpreadsheetMaximumPageHeight = 3000
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("Failed to save file. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("Failed to load file. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.SpreadsheetMaximumPageWidth = 3000;
gdpictureDocumentConverter.SpreadsheetMaximumPageHeight = 3000;
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("Failed to save file. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("Failed to load file. Status: " + status.ToString(), "GdPicture");
}
}
Specifies the maximum page height in millimeters.
A value of zero or less indicates no height limitation.
The default value is 2800.
Loading and converting a .xlsx with SpreadsheetMaximumPageWidth and SpreadsheetMaximumPageHeight set to 4000.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.SpreadsheetMaximumPageWidth = 4000
gdpictureDocumentConverter.SpreadsheetMaximumPageHeight = 4000
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("Failed to save file. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("Failed to load file. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.SpreadsheetMaximumPageWidth = 4000;
gdpictureDocumentConverter.SpreadsheetMaximumPageHeight = 4000;
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("Failed to save file. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("Failed to load file. Status: " + status.ToString(), "GdPicture");
}
}
For spreadsheet, specifies that for each sheets only the print areas must be rendered.
If no print area are found the whole sheets will be rendered
The default value is false.
Loading and converting a .xlsx with SpreadsheetRenderOnlyPrintArea enabled.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.SpreadsheetRenderOnlyPrintArea = True
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.SpreadsheetRenderOnlyPrintArea = true;
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_xlsx.xlsx", GdPicture14.DocumentFormat.DocumentFormatXLSX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Gets or sets the mode used to handle document markup during conversion.
Specifies whether tiff encoder is using Exif rotate flag to handle page rotations.
Default value is true.
Specifies whether pdf encoder is applying linearization (aka fast web view).
Default value is false.
Sets the scheme to be used to compress bitonal image data when converting/saving the currently loaded document to PDF format.
A member of the PdfCompression enumeration. The default value is PdfCompression.PdfCompressionJBIG2.
Setting up the required image compression.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("input.tif", GdPicture14.DocumentFormat.DocumentFormatTIFF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
'Set the required compression parameter here.
gdpictureDocumentConverter.PdfBitonalImageCompression = PdfCompression.PdfCompressionCCITT4
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("input.tif", GdPicture14.DocumentFormat.DocumentFormatTIFF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
//Set the required compression parameter here.
gdpictureDocumentConverter.PdfBitonalImageCompression = PdfCompression.PdfCompressionCCITT4;
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies the threshold value for the JBIG2 encoder pattern matching and substitution between 0 and 1. Any number lower than 1 may lead to lossy compression.
Default value is 0.75.
Sets the scheme to be used to compress color image data when converting/saving the currently loaded document to PDF format.
A member of the PdfCompression enumeration. The default value is PdfCompression.PdfCompressionJPEG.
Setting up the required image compression.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
'Set the required compression parameter here.
gdpictureDocumentConverter.PdfColorImageCompression = PdfCompression.PdfCompressionJPEG
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
//Set the required compression parameter here.
gdpictureDocumentConverter.PdfColorImageCompression = PdfCompression.PdfCompressionJPEG;
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Sets the level of quality used to compress images with a lossy compression scheme, which are embedded in the newly produced PDF document
when converting/saving the currently loaded document to PDF format.
It must be a value from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression.
The default value is 75.
Setting up the level of quality for image compression.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
'Set the required level of quality here.
gdpictureDocumentConverter.PdfImageQuality = 50
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
//Set the required level of quality here.
gdpictureDocumentConverter.PdfImageQuality = 50;
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies if the converter shall use additional Deflate compression for JPEG images in PDF output.
The default value is false.
Disable Deflate for JPEG images in PDF output.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG)
gdpictureDocumentConverter.PdfUseDeflateOnJPEG = True
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_7)
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG);
gdpictureDocumentConverter.PdfUseDeflateOnJPEG = true;
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_7);
}
Enables or disables the automatic color detection feature when converting/saving the currently loaded document to PDF format.
The purpose is to automatically detect the original color of documents scanned in color mode and convert the B/W and/or grayscale ones
to the appropriate bpp (bits-per-pixel) encoding. The result is allowing preservation of image quality while considerably reducing the file size.
The default value is false.
Re-compressing an existing PDF document using color detection.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.LoadFromFile("input.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF)
gdpictureDocumentConverter.PdfEnableColorDetection = True
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_7)
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.LoadFromFile("input.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF);
gdpictureDocumentConverter.PdfEnableColorDetection = true;
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_7);
}
Sets the level of quality used to compress images with a lossy compression scheme, which are embedded in the newly produced DOCX document
when converting/saving the currently loaded document to DOCX format.
It must be a value from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression.
The default value is 75.
Setting up the level of quality for image compression.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
'Set the required level of quality here.
gdpictureDocumentConverter.DocxImageQuality = 50
status = gdpictureDocumentConverter.SaveAsDOCX("output.docx")
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
//Set the required level of quality here.
gdpictureDocumentConverter.DocxImageQuality = 50;
status = gdpictureDocumentConverter.SaveAsDOCX("output.docx");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies if the ICC profile should be preserved during the conversion if it's present in the loaded document.
The default value is true.
Enable ICC profile durring the conversion.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG)
gdpictureDocumentConverter.EnableICC = True
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_7)
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.LoadFromFile("input.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG);
gdpictureDocumentConverter.EnableICC = true;
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_7);
}
Specifies the page width, in points, of the resulting document when converting from the source txt file.
The default value is 595, which is the A4 document width.
The default value is 595.
Converting a text file to a PDF document specifying custom properties for the layout of the resulting document.
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Set the text and document properties to be used for the resulting file.
gdpictureDocumentConverter.TxtFontFamily = "Times New Roman";
gdpictureDocumentConverter.TxtFontSize = 16;
gdpictureDocumentConverter.TxtFontBold = true;
gdpictureDocumentConverter.TxtFontItalic = false;
gdpictureDocumentConverter.TxtHorizontalTextAlignment = TextAlignment.TextAlignmentCenter;
gdpictureDocumentConverter.TxtPageHeight = 842; // A3 page size
gdpictureDocumentConverter.TxtPageWidth = 1191; // A3 page size
gdpictureDocumentConverter.TxtPageMarginTop = 20;
gdpictureDocumentConverter.TxtPageMarginBottom = 20;
gdpictureDocumentConverter.TxtPageMarginLeft = 20;
gdpictureDocumentConverter.TxtPageMarginRight = 20;
using (Stream inputStream = File.Open("input.txt", System.IO.FileMode.Open))
{
using (Stream outputStream = File.Create("output.pdf"))
{
gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatTXT, outputStream, PdfConformance.PDF1_5);
}
}
}
Specifies the page height, in points, of the resulting document when converting from the source txt file.
Default value is 842, which is the A4 document height.
The default value is 842.
Converting a text file to a PDF document specifying custom properties for the layout of the resulting document.
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Set the text and document properties to be used for the resulting file.
gdpictureDocumentConverter.TxtFontFamily = "Times New Roman";
gdpictureDocumentConverter.TxtFontSize = 16;
gdpictureDocumentConverter.TxtFontBold = true;
gdpictureDocumentConverter.TxtFontItalic = false;
gdpictureDocumentConverter.TxtHorizontalTextAlignment = TextAlignment.TextAlignmentCenter;
gdpictureDocumentConverter.TxtPageHeight = 842; // A3 page size
gdpictureDocumentConverter.TxtPageWidth = 1191; // A3 page size
gdpictureDocumentConverter.TxtPageMarginTop = 20;
gdpictureDocumentConverter.TxtPageMarginBottom = 20;
gdpictureDocumentConverter.TxtPageMarginLeft = 20;
gdpictureDocumentConverter.TxtPageMarginRight = 20;
using (Stream inputStream = File.Open("input.txt", System.IO.FileMode.Open))
{
using (Stream outputStream = File.Create("output.pdf"))
{
gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatTXT, outputStream, PdfConformance.PDF1_5);
}
}
}
Specifies the left page margin, in points, of the resulting document when converting from the source txt file.
The default value is 10.
Specifies the top page margin, in points, of the resulting document when converting from the source txt file.
The default value is 10.
Specifies the right page margin, in points, of the resulting document when converting from the source txt file.
The default value is 10.
Specifies the bottom page margin, in points, of the resulting document when converting from the source txt file.
The default value is 10.
Specifies the horizontal text alignment of the resulting document when converting from the source txt file.
Default value is TextAlignment.TextAlignmentNear.
A member of the TextAlignment enumeration. The default value is TextAlignment.TextAlignmentNear.
Specifies the text size, in points, to be used for the resulting document when converting from the source txt file.
The default value is 12.
Specifies the name of the font to be used for the resulting document when converting from the source txt file.
The default value is SystemFontsManager.GetDefaultSystemUnicodeFont().
Specifies whether the font used for the resulting document when converting from the source txt file must have a bold style.
The default value is false.
Specifies whether the font used for the resulting document when converting from the source txt file must have an italic style.
The default value is false.
Specifies the page width, in points, of the resulting document when converting from the source html file.
The default value is 1440.
The default value is 1440.
Converting an HTML page to a PDF document specifying custom properties for the layout of the resulting document.
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Set the text and document properties to be used for the resulting file.
gdpictureDocumentConverter.HtmlPageHeight = 842; // A3 page size
gdpictureDocumentConverter.HtmlPageWidth = 1191; // A3 page size
gdpictureDocumentConverter.HtmlPageMarginTop = 10;
gdpictureDocumentConverter.HtmlPageMarginBottom = 10;
gdpictureDocumentConverter.HtmlPageMarginLeft = 10;
gdpictureDocumentConverter.HtmlPageMarginRight = 10;
using (Stream inputStream = File.Open("input.html", System.IO.FileMode.Open))
{
using (Stream outputStream = File.Create("output.pdf"))
{
gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatHTML, outputStream, PdfConformance.PDF1_5);
}
}
}
Specifies the page height, in points, of the resulting document when converting from the source html file.
Default value is 810.
The default value is 810.
Converting an HTML page to a PDF document specifying custom properties for the layout of the resulting document.
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Set the text and document properties to be used for the resulting file.
gdpictureDocumentConverter.HtmlPageHeight = 842; // A3 page size
gdpictureDocumentConverter.HtmlPageWidth = 1191; // A3 page size
gdpictureDocumentConverter.HtmlPageMarginTop = 10;
gdpictureDocumentConverter.HtmlPageMarginBottom = 10;
gdpictureDocumentConverter.HtmlPageMarginLeft = 10;
gdpictureDocumentConverter.HtmlPageMarginRight = 10;
using (Stream inputStream = File.Open("input.html", System.IO.FileMode.Open))
{
using (Stream outputStream = File.Create("output.pdf"))
{
gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatHTML, outputStream, PdfConformance.PDF1_5);
}
}
}
Specifies the left page margin, in points, of the resulting document when converting from the source html file.
The default value is 0.
Specifies the top page margin, in points, of the resulting document when converting from the source html file.
The default value is 0.
Specifies the right page margin, in points, of the resulting document when converting from the source html file.
The default value is 0.
Specifies the bottom page margin, in points, of the resulting document when converting from the source html file.
The default value is 0.
Give any CSS @page size declared in the page priority over what is declared in HtmlPageWidth and HtmlPageHeight.
If set to false, the renderer will scale the content to fit the paper size.
The default value is false.
Specifies whether the output document should contain a single page.
If set to true, the is ignored.
The default value is true.
Specifies a type of a media to emulate.
The default value is
Specify additionnals flags or settings to browser instance at process creation time.
How to deactivate Chrome sandbox
using GdPictureDocumentConverter conv = new();
conv.HTMLDefaultBrowserStartupArguments = new[] { "--no-sandbox" };
var st = conv.LoadFromHttp(new Uri("https://avepdf.com/fr"));
if (st != GdPictureStatus.OK)
{
throw new Exception("Convert from http Failed !");
}
st = conv.SaveAsPDF(TestFiles.pdfHttpOutput);
if (st != GdPictureStatus.OK)
{
throw new Exception("Saved from http Failed !");
}
The default value is null
Specify JavaScript code to execute once the page is loaded and before the print to PDF step
using GdPictureDocumentConverter conv = new();
conv.HTMLCustomJavaScript = "window.title = 'Hello World!'";
var st = conv.LoadFromHttp(new Uri("https://avepdf.com/fr"));
if (st != GdPictureStatus.OK)
{
throw new Exception("Convert from http Failed !");
}
st = conv.SaveAsPDF(TestFiles.pdfHttpOutput);
if (st != GdPictureStatus.OK)
{
throw new Exception("Saved from http Failed !");
}
The default value is null
Specify a delay in milliseconds before the print to PDF step
Whether to generate tagged (accessible) PDF.
Whether to hide the headless mode in the HTTP User-Agent header or not, preserving the real UA browser name.
The default value is true
Sets the viewport height size to use when converting.
Sets the viewport width size to use when converting.
Scale of the webpage rendering. Defaults to 1.
Specify whether the browser should emulate internet disconnection by blocking network access.
Allows overriding user agent with the given string.
Sets given cookies.
Specifies whether to always send extra HTTP headers with the requests from this page.
Switches script execution in the page.
Custom CSS to add in the page before the print to PDF step.
Specifies whether images should be included when converting to markup formats (Markdown, HTML).
When set to true, images are extracted from the source document and embedded in the output.
The default value is false.
Absolute path to the folder where external resources (images, attachments) should be written
when converting to markup formats (Markdown, HTML). When null, resources are embedded inline
(e.g. base64) by the underlying generator.
When true, the Markdown converter emits a unique HTML-comment marker
at the start of every page (<!-- nutrient-page-start: N -->,
1-indexed). The markers are invisible in rendered HTML but allow
downstream tooling to slice the markdown reliably back into per-page
chunks. Off by default; only honored by .
Specifies the page width, in points, of the resulting document when converting from the source Email file.
The default value is 792.
The default value is 792.
Converting an Email document (.msg and .eml supported) to a PDF document specifying custom properties for the layout of the resulting document.
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Set the text and document properties to be used for the resulting file.
gdpictureDocumentConverter.EmailPageHeight = 612; // A3 page size
gdpictureDocumentConverter.EmailPageWidth = 1191; // A3 page size
gdpictureDocumentConverter.EmailPageMarginTop = 10;
gdpictureDocumentConverter.EmailPageMarginBottom = 10;
gdpictureDocumentConverter.EmailPageMarginLeft = 10;
gdpictureDocumentConverter.EmailPageMarginRight = 10;
using (Stream inputStream = File.Open("input.eml", System.IO.FileMode.Open))
{
using (Stream outputStream = File.Create("output.pdf"))
{
gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatEmail, outputStream, PdfConformance.PDF1_5);
}
}
}
Specifies whether the width should be automatically adjusted to fit the content of the resulting document when converting from the source Email file.
Default value is false.
Defines the load event to wait for before printing the page to PDF.
Default set to .
Better fidelity can be obtained by setting .
Specifies the page height, in points, of the resulting document when converting from the source Email file.
Default value is 1080.
The default value is 1080.
Converting an Email document (.msg and .eml supported) to a PDF document specifying custom properties for the layout of the resulting document.
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Set the text and document properties to be used for the resulting file.
gdpictureDocumentConverter.EmailPageHeight = 612; // A3 page size
gdpictureDocumentConverter.EmailPageWidth = 1191; // A3 page size
gdpictureDocumentConverter.EmailPageMarginTop = 10;
gdpictureDocumentConverter.EmailPageMarginBottom = 10;
gdpictureDocumentConverter.EmailPageMarginLeft = 10;
gdpictureDocumentConverter.EmailPageMarginRight = 10;
using (Stream inputStream = File.Open("input.eml", System.IO.FileMode.Open))
{
using (Stream outputStream = File.Create("output.pdf"))
{
gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatEmail, outputStream, PdfConformance.PDF1_5);
}
}
}
Specifies the left page margin, in points, of the resulting document when converting from the source Email file.
The default value is 10.
Specifies the top page margin, in points, of the resulting document when converting from the source Email file.
The default value is 10.
Specifies the right page margin, in points, of the resulting document when converting from the source Email file.
The default value is 10.
Specifies the bottom page margin, in points, of the resulting document when converting from the source Email file.
The default value is 10.
Specify whether if the output document should contains one page
If set to True, the is ignored.
The default value is true.
Specify JavaScript code to execute once the page is loaded and before the print to PDF step
using GdPictureDocumentConverter conv = new();
conv.HTMLCustomJavaScript = "window.title = 'Hello World!'";
var st = conv.LoadFromFile("c:\myfile.eml");
if (st != GdPictureStatus.OK)
{
throw new Exception("Convert from http Failed !");
}
st = conv.SaveAsPDF(TestFiles.pdfHttpOutput);
if (st != GdPictureStatus.OK)
{
throw new Exception("Saved from http Failed !");
}
The default value is null
Specifies whether the email header should be injected in the output document.
Default value is true.
Specifies individual pages or page intervals related to the loaded document for further processing.
The required page numbers need to be defined in the matching pattern, for example use the string of "1-5" for pages 1 to 5, or use the
string of "1,5,6" to specify pages 1 and 5 and 6. You can use the string of "1,5,8-12" to specify pages 1, 5, 8 and all pages from page 8 to page 12, etc.
The default value is the string of "*", which means all pages.
The first example shows you how to load only the first page of the source document you want to convert.
The second example shows you how to convert and save only the first page of the loaded source document.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
'Only the first page is loaded.
gdpictureDocumentConverter.PageRange = "1"
'Please try to use also a multi-page document.
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
status = gdpictureDocumentConverter.SaveAsPDF("load_first_page.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
//Only the first page is loaded.
gdpictureDocumentConverter.PageRange = "1";
//Please try to use also a multi-page document.
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
status = gdpictureDocumentConverter.SaveAsPDF("load_first_page.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
'Please try to use also a multi-page document.
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
'Only the first page is saved.
gdpictureDocumentConverter.PageRange = "1"
status = gdpictureDocumentConverter.SaveAsPDF("save_first_page.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
//Please try to use also a multi-page document.
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
//Only the first page is saved.
gdpictureDocumentConverter.PageRange = "1";
status = gdpictureDocumentConverter.SaveAsPDF("save_first_page.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies if present GdPictureAnnotations objects in the loaded document should be copied before further processing.
For PDF document format, copying annotations means, that firstly they are copied into their native format (xmp metadata)
and secondly, they are converted to PDF annotations to allow other PDF viewers render their appearance.
The default value is false.
Loading and converting only the first page of the source document with copied annotations on that page.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.LoadOnlyFirstPage = True
'Please try to use also a multi-page document.
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
gdpictureDocumentConverter.DropGdPictureAnnotations = True
status = gdpictureDocumentConverter.SaveAsPDF("first_page_dropped_annots.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.LoadOnlyFirstPage = true;
//Please try to use also a multi-page document.
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
gdpictureDocumentConverter.DropGdPictureAnnotations = true;
status = gdpictureDocumentConverter.SaveAsPDF("first_page_dropped_annots.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies that all executed actions with the loaded document will be processed using only the first page of the document.
The default value is false.
Loading and converting only the first page of the source document.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.LoadOnlyFirstPage = True
'Please try to use also a multi-page document.
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
gdpictureDocumentConverter.DropGdPictureAnnotations = True
status = gdpictureDocumentConverter.SaveAsPDF("first_page_dropped_annots.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.LoadOnlyFirstPage = true;
//Please try to use also a multi-page document.
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
gdpictureDocumentConverter.DropGdPictureAnnotations = true;
status = gdpictureDocumentConverter.SaveAsPDF("first_page_dropped_annots.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies that headers/footers in Office documents should be rendered with half transparency.
The default value is false.
Loading and converting a .docx document with headerr/footer in half-transparency.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
gdpictureDocumentConverter.HalfTransparentHeaderFooter = True
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.HalfTransparentHeaderFooter = true;
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
status = gdpictureDocumentConverter.SaveAsPDF("Converted.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies the spreadsheet page width in millimeters. If width is not positive, the page width specified in the document will be used instead.
The addition of left and right page margin must be lower than page width.
The default value is 0 (use document default).
Specifies the spreadsheet page height in millimeters. If height is not positive, the page height specified in the document will be used instead.
The addition of top and bottom page margin must be lower than page height.
The default value is 0 (use document default).
Specifies the spreadsheet left margin width in millimeters. If width is negative, the margin specified in the document will be used instead.
The addition of left and right page margin must be lower than page width.
The default value is -1 (use document default).
Specifies the spreadsheet top margin height in millimeters. If height is negative, the margin specified in the document will be used instead.
The addition of top and bottom page margin must be lower than page height.
The default value is -1 (use document default).
Specifies the spreadsheet right margin width in millimeters. If width is negative, the margin specified in the document will be used instead.
The addition of left and right page margin must be lower than page width.
The default value is -1 (use document default).
Specifies the spreadsheet bottom margin height in millimeters. If height is negative, the margin specified in the document will be used instead.
The addition of top and bottom page margin must be lower than page height.
The default value is -1 (use document default).
Specifies the DPI for images when converting them to PDF format. This property allows overriding the default DPI of the images used in the conversion process.
The default value of this property is 0, which means the DPI of the original image will be preserved in the converted PDF, and no overriding will occur.
Converting and saving a JPEG image to a single PDF document.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("image.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
gdpictureDocumentConverter.PdfImageQuality = 50
gdpictureDocumentConverter.PdfForceImageDPI = 72
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("image.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
gdpictureDocumentConverter.PdfImageQuality = 50;
gdpictureDocumentConverter.PdfForceImageDPI = 72;
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
Specifies the source for PDF document outline (bookmarks) when converting Office documents to PDF.
When set to (default), the PDF outline is created from document headings (Heading 1, Heading 2, etc.).
When set to , the PDF outline is created from Word bookmarks defined in the document.
The default value is .
Gets a value indicating whether the document content has been truncated.
Gets or sets the preferred language for email (EML and MSG) document conversion, as a BCP 47 language tag (e.g. "fr-FR", "en-US").
Controls date/time formatting and label translations in the converted document.
The default value is "en-US".
This method loads the source document according to a file path you have specified.
The file path of the source document.
A member of the DocumentFormat enumeration. Specifies a file format of the input document.
Supported input document formats are listed here .
You can use a value of GdPicture14.DocumentFormat.DocumentFormatUNKNOWN if you are not sure about the document's format.
The document's first page is automatically set as the current page after loading.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
GdPictureDocumentConverter Constructor
Saving the source DOCX document as the resulting PDF document.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
' Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
' Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5)
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
// Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5);
}
This method saves the font informations within the document to a xml file stream you have specified.
The file path of the xml output.
the font informations will be saved only if there is at least 1 missing font
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Outputting .
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
' Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
Using outputStream as Stream = File.Open("fontsOutput.xml", FileMode.Create)
{
converter.SaveDocumentFontsInfo(outputStream);
}
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
using (Stream outputStream = File.Open("fontsOutput.xml", FileMode.Create))
{
converter.SaveDocumentFontsInfo(outputStream);
}
}
This method saves the font informations within the document to a xml file stream you have specified.
The stream to write the xml output to.
the font informations will be saved only if there is at least 1 missing font
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Outputting .
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
' Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
Using outputStream as Stream = File.Open("fontsOutput.xml", FileMode.Create)
{
converter.SaveDocumentFontsInfo(outputStream);
}
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
using (Stream outputStream = File.Open("fontsOutput.xml", FileMode.Create))
{
converter.SaveDocumentFontsInfo(outputStream);
}
}
This method loads the source document from a previously instantiated stream object according to what you have specified.
A stream object. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.
A member of the DocumentFormat enumeration. Specifies a file format of the input document.
Supported input document formats are listed here.
The document's first page is automatically set as the current page after loading.
Keep noted that the input stream should remain open and can only be closed/disposed by the user after a call to GdPictureDocumentConverter.CloseDocument() is made.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
GdPictureDocumentConverter Constructor
Saving the source TXT document as the resulting PDF document using a stream.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
Using fileStream As System.IO.Stream = New System.IO.FileStream("input.txt", System.IO.FileMode.Open)
' Loading the source document.
gdpictureDocumentConverter.LoadFromStream(fileStream, GdPicture14.DocumentFormat.DocumentFormatTXT)
' Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5)
End Using
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
using (System.IO.Stream fileStream = new System.IO.FileStream("input.txt", System.IO.FileMode.Open))
{
// Loading the source document.
gdpictureDocumentConverter.LoadFromStream(fileStream, GdPicture14.DocumentFormat.DocumentFormatTXT);
// Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5);
}
}
This method loads the source document from an http uri.
A System.Uri object. This source to load the content from.
A member of the DocumentFormat enumeration. Specifies a file format of the input document.
Supported input document formats are listed here.
The document's first page is automatically set as the current page after loading.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
GdPictureDocumentConverter Constructor
This method converts and saves (in other words, creates a brand new destination document) the currently loaded document to an instantiated stream object
according to what you have specified. The output document format is PDF.The PDF conformance level of the saved PDF document is set according to the parameter specified by you.
These methods convert and save the currently loaded document to a stream or to a file according to what you have specified. The output document format is PDF.
You can also specify the PDF conformance level of the resulting PDF document.
A stream object where the current document is saved to as a PDF document. This output stream must be initialized before it can be sent into this method
and it should stay open for subsequent use.
If the output stream is not opened for writing, the method will fail returning the GdPictureStatus.InvalidParameter status.
A member of the PdfConformance enumeration. Specifies the required conformance to the PDF or PDF/A standard of the saved PDF document.
You can use the value of the PdfConformance.PDF to save the file as a common PDF document.
Keep noted that the output stream should be open for writing and should be closed/disposed by the user as well.
If you use the value of the PdfConformance.PDF, the library will create the PDF document conformed to the lowest PDF version (version 1.3 is the minimum)
based on what the output PDF document will contain.para>
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Converting and saving a JPEG image to a single PDF document using a stream.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("image.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
gdpictureDocumentConverter.PdfImageQuality = 50
Dim oFileStream As New System.IO.FileStream("output.pdf", System.IO.FileMode.Create)
status = gdpictureDocumentConverter.SaveAsPDF(oFileStream, PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
oFileStream.Dispose()
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("image.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
gdpictureDocumentConverter.PdfImageQuality = 50;
System.IO.FileStream oFileStream = new System.IO.FileStream("output.pdf", System.IO.FileMode.Create);
status = gdpictureDocumentConverter.SaveAsPDF(oFileStream, PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
oFileStream.Dispose();
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
This method converts the specified document from an instantiated input stream object to a single PDF document and saves the resulting file
into an instantiated output stream object according to what you have specified.
The PDF version or the PDF conformance level of the resulting PDF document is set according to the given Conformance parameter.
A member of the PdfConformance enumeration. Specifies the required PDF version or conformance to the PDF or PDF/A standard of the resuting PDF document.
A member of the DocumentFormat enumeration. Specifies a file format of the input document.
Supported input document formats are listed here.
You can use a value of GdPicture14.DocumentFormat.DocumentFormatUNKNOWN if you are not sure about the document's format.
An input stream object. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.
This stream should be open for reading and should be closed/disposed by the user as well.
An output stream object. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.
This stream should be open for writing and should be closed/disposed by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Converting an image file to a single PDF document.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
Using inputStream As Stream = File.Open("image.jpg", System.IO.FileMode.Open)
Using outputStream As Stream = File.Create("image.pdf")
gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatUNKNOWN, outputStream, PdfConformance.PDF1_5)
End Using
End Using
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
using (Stream inputStream = File.Open("image.jpg", System.IO.FileMode.Open))
{
using (Stream outputStream = File.Create("image.pdf"))
{
gdpictureDocumentConverter.ConvertToPDF(inputStream, GdPicture14.DocumentFormat.DocumentFormatUNKNOWN, outputStream, PdfConformance.PDF1_5);
}
}
}
This method combines all the specified input files to a single PDF document and saves the resulting file according to a file path you have specified.
The PDF version or the PDF conformance level of the resulting PDF document is set according to the given Conformance parameter.
These methods combines all the specified input files to a single PDF document and saves the resulting file to a stream or to a file according to what you have specified.
An array of strings defining the file paths of all the documents you want to combine.
The file path where the destination file will be saved. If the specified file already exists, it will be overwritten.
A member of the PdfConformance enumeration. Specifies the required PDF version or conformance to the PDF or PDF/A standard of the resulting PDF document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Combining multiple files of different formats to a single PDF document.
Dim inputFiles As IEnumerable(Of String) = New List(Of String)(New String() {"d:\image.jpg", "d:\document.pdf", "d:\image.tif", "d:\todo_list.xlsx"})
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
gdpictureDocumentConverter.CombineToPDF(inputFiles, "d:\merged.pdf", PdfConformance.PDF1_5)
End Using
IEnumerable<string> inputFiles = new List<string>(new string[] { "d:\\image.jpg", "d:\\document.pdf", "d:\\image.tif", "d:\\todo_list.xlsx" });
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.CombineToPDF(inputFiles, "d:\\merged.pdf", PdfConformance.PDF1_5);
}
This method combines all the specified input files to a single PDF document and saves the resulting file to an instantiated output stream object according to
what you have specified.
The PDF version or the PDF conformance level of the resulting PDF document is set according to the given Conformance parameter.
These methods combines all the specified input files to a single PDF document and saves the resulting file to a stream or to a file according to what you have specified.
An array of strings defining the file paths of all the documents you want to combine.
An output stream object. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.
This stream should be open for writing and should be closed/disposed by the user as well.
A member of the PdfConformance enumeration. Specifies the required PDF version or conformance to the PDF or PDF/A standard of the resulting PDF document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Combining multiple files of different formats to a single PDF document.
Dim inputFiles As IEnumerable(Of String) = New List(Of String)(New String() {"d:\image.jpg", "d:\document.pdf", "d:\image.tif", "d:\todo_list.xlsx"})
Using dstStream As Stream = File.Create("d:\merged.pdf")
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
gdpictureDocumentConverter.CombineToPDF(inputFiles, dstStream, PdfConformance.PDF1_5)
End Using
End Using
IEnumerable<string> inputFiles = new List<string>(new string[] { "d:\\image.jpg", "d:\\document.pdf", "d:\\image.tif", "d:\\todo_list.xlsx" });
using (Stream dstStream = File.Create("d:\\merged.pdf"))
{
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
gdpictureDocumentConverter.CombineToPDF(inputFiles, dstStream, PdfConformance.PDF1_5);
}
}
This method combines all the specified input files to a single PDF document and saves the resulting file to an instantiated output stream object according to
what you have specified.
The PDF version or the PDF conformance level of the resulting PDF document is set according to the given Conformance parameter.
These methods combines all the specified input files to a single PDF document and saves the resulting file to a stream or to a file according to what you have specified.
An array of Stream holding the documents you want to combine.
An output stream object. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.
This stream should be open for writing and should be closed/disposed by the user as well.
A member of the PdfConformance enumeration. Specifies the required PDF version or conformance to the PDF or PDF/A standard of the resulting PDF document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
This method converts and saves (in other words, creates a brand new destination document) the currently loaded document to a PDF document
according to a file path you have specified.
The PDF conformance level of the saved PDF document is set according to the parameter specified by you. Currently, this class doesn't provide a valid
conversion of existing PDF documents to PDF/A documents. For more details, please see the section Remarks below.
These methods convert and save the currently loaded document to a stream or to a file according to what you have specified. The output document format is PDF.
You can also specify the PDF conformance level of the resulting PDF document.
The file path where the destination document will save. If the specified file already exists, it will be overwritten.
A member of the PdfConformance enumeration. Specifies the required conformance to the PDF or PDF/A standard of the saved PDF document.
You can use the value of the PdfConformance.PDF to save the file as a common PDF document.
You have to specify a full file path with the correct file extension, which is "pdf".
If you use the value of the PdfConformance.PDF, the library will create the PDF document conformed to the lowest PDF version (version 1.3 is the minimum)
based on what the output PDF document will contain.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Converting and saving a JPEG image to a single PDF document.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("image.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicture")
gdpictureDocumentConverter.PdfImageQuality = 50
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("image.jpg", GdPicture14.DocumentFormat.DocumentFormatJPEG);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicture");
gdpictureDocumentConverter.PdfImageQuality = 50;
status = gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
This method converts and saves the currently loaded document to an instantiated stream object according to what you have specified. The output format is TIFF.
The resulting image will be compressed using the compression method according to your preference.
These methods convert and save the currently loaded document to a stream or to a file according to what you have specified. The output document format is TIFF.
You can also specify the compression method used to compress the resulting image.
A stream object where the current document is saved to as a TIFF image. This output stream must be initialized before it can be sent into this method and it should stay open for subsequent use.
If the output stream is not opened for both reading and writing, the method will fail returning the GdPictureStatus.InvalidParameter status.
A member of the TiffCompression enumeration. Specifies the compression method to be used to compress the resulting TIFF image.
Keep noted that the output stream should be open for both reading and writing and should be closed/disposed by the user as well.
The currently selected page remains selected after saving.
This method requires the Image Conversion component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Converting and saving a PDF document to a TIFF image file using a stream.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF)
If status = GdPictureStatus.OK Then
Dim oFileStream As New System.IO.FileStream("drawing_stream.tiff", System.IO.FileMode.Create)
status = gdpictureDocumentConverter.SaveAsTIFF(oFileStream, TiffCompression.TiffCompressionAUTO)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
oFileStream.Dispose()
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = new System.IO.FileStream("drawing_stream.tiff", System.IO.FileMode.Create);
status = gdpictureDocumentConverter.SaveAsTIFF(oFileStream, TiffCompression.TiffCompressionAUTO);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
oFileStream.Dispose();
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
This method converts and saves the currently loaded document to a TIFF image file according to a file path you have specified.
The resulting image will be compressed using the compression method according to your preference.
The file path where the destination image file will save. If the specified file already exists, it will be overwritten.
A member of the TiffCompression enumeration. Specifies the compression method to be used to compress the resulting TIFF image.
Keep noted that you have to specify a full file path with the correct file extension, which should be "tif" or "tiff".
The currently selected page remains selected after saving.
This method requires the Image Conversion component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Converting and saving a PDF document to a TIFF image file.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF)
If status = GdPictureStatus.OK Then
gdpictureDocumentConverter.RasterizationDPI = 300
status = gdpictureDocumentConverter.SaveAsTIFF("drawing_image.tiff", TiffCompression.TiffCompressionAUTO)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF);
if (status == GdPictureStatus.OK)
{
gdpictureDocumentConverter.RasterizationDPI = 300;
status = gdpictureDocumentConverter.SaveAsTIFF("drawing_image.tiff", TiffCompression.TiffCompressionAUTO);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
This method converts the currently loaded document to DOCX and saves it to an instantiated stream object.
These methods convert the currently loaded document to DOCX and save it to a stream or to a file according to what you have specified.
A stream object where the current document is saved to as a DOCX file. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.
If the output stream is not opened for both reading and writing, the method will fail returning the GdPictureStatus.InvalidParameter status.
Keep noted that the output stream should be open for both reading and writing and should be closed/disposed by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Converting and saving a PDF document to a DOCX file using a stream.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("input.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF)
If status = GdPictureStatus.OK Then
Dim oFileStream As New System.IO.FileStream("output.docx", System.IO.FileMode.Create)
gdpictureDocumentConverter.DocxImageQuality = 80
status = gdpictureDocumentConverter.SaveAsDOCX(oFileStream)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
oFileStream.Dispose()
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using GdPicture14;
using GdPictureDocumentConverter converter = new();
var status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
using var fs = new FileStream("output.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
status = converter.SaveAsDOCX(fs);
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a docx file");
This method converts the currently loaded document to XLSX and saves it to an instantiated stream object.
These methods convert the currently loaded document to XLSX and save it to a stream or to a file according to what you have specified.
A stream object where the current document is saved to as a XLSX file. This stream object must be initialized before it can be sent into this method and it should stay open for subsequent use.
If the output stream is not opened for both reading and writing, the method will fail returning the GdPictureStatus.InvalidParameter status.
Keep noted that the output stream should be open for both reading and writing and should be closed/disposed by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Converting and saving a PDF document to a XLSX file using a stream.
using GdPicture14;
using GdPictureDocumentConverter converter = new();
var status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
using var fs = new FileStream("output.xlsx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
status = converter.SaveAsXLSX(fs);
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a xlsx file");
This method converts the currently loaded document to PPTX and converts it to an instantiated stream object.
These methods convert the currently loaded document to PPTX and save it to a stream or to a file according to what you have specified.
A stream object where the current document will be saved to as a PPTX file. This stream object must be initialized before passing it to this method and it should stay open for subsequent use.
If the output stream is not opened for both reading and writing, the method will fail to return the status.
Note that the output stream should be open for both reading and writing and should be closed/disposed by the user once processing is complete.
A member of the enumeration. If processing is successful, then the return value is .
Converting and saving a PDF document to a PPTX file using a stream.
using GdPicture14;
using GdPictureDocumentConverter converter = new();
var status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
using var fs = new FileStream("output.pptx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
status = converter.SaveAsPPTX(fs);
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a pptx file");
This method converts the currently loaded document to DOCX and saves it to a specified file path.
The file path where the converted file will be saved. If the specified file already exists, it will be overwritten.
You have to specify a full file path, including the file extension (.docx).
A member of the enumeration. If processing is successful, then the return value is .
Converting and saving a PDF document to a DOCX file.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("input.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF)
If status = GdPictureStatus.OK Then
gdpictureDocumentConverter.DocxImageQuality = 80
status = gdpictureDocumentConverter.SaveAsDOCX("output.docx")
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using GdPicture14;
using GdPictureDocumentConverter converter = new();
GdPictureStatus status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
status = converter.SaveAsDOCX("output.docx");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a docx file");
This method converts the currently loaded document to XLSX and saves it to an instantiated stream object.
These methods convert the currently loaded document to XLSX and save it to a stream or to a file according to what you have specified.
The file path where the converted file will be saved. If the specified file already exists, it will be overwritten.
You have to specify a full file path, including the file extension (.xlsx).
A member of the enumeration. If processing is successful, then the return value is .
Converting and saving a PDF document to a XLSX file.
using GdPicture14;
using GdPictureDocumentConverter converter = new();
var status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
status = converter.SaveAsXLSX("output.xlsx");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a xlsx file");
This method converts the currently loaded document to PPTX and saves it to the specified file path.
These methods convert the currently loaded document to PPTX and saves it to a stream or to a file according to what you have specified.
The file path where the converted file will be saved. If the specified file already exists, it will be overwritten.
You have to specify a full file path, including the file extension (.pptx).
A member of the enumeration. If processing is successful, then the return value is .
Converting and saving a PDF document to a PPTX file using a stream.
using GdPicture14;
using GdPictureDocumentConverter converter = new();
var status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
status = converter.SaveAsPPTX("output.pptx");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a pptx file");
This method converts the currently loaded document to HTML and saves it to an instantiated stream object.
These methods convert the currently loaded document to HTML and save it to a stream or to a file according to what you have specified.
A stream object where the current document will be saved to as a HTML file. This stream object must be initialized before passing it to this method and it should stay open for subsequent use.
If the output stream is not opened for both reading and writing, the method will fail to return the status.
Note that the output stream should be open for both reading and writing and should be closed/disposed by the user once processing is complete.
A member of the enumeration. If processing is successful, then the return value is .
Converting and saving a PDF document to a HTML file using a stream.
using GdPicture14;
using GdPictureDocumentConverter converter = new();
var status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
using var fs = new FileStream("output.html", FileMode.OpenOrCreate, FileAccess.ReadWrite);
status = converter.SaveAsHTML(fs, HtmlLayoutType.PageLayout);
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a html file");
This method converts the currently loaded document to HTML and saves it to the specified file path.
These methods convert the currently loaded document to HTML and saves it to a stream or to a file according to what you have specified.
The file path where the converted file will be saved. If the specified file already exists, it will be overwritten.
You have to specify a full file path, including the file extension (.pptx).
A member of the enumeration. If processing is successful, then the return value is .
Converting and saving a PDF document to a HTML file using a stream.
using GdPicture14;
using GdPictureDocumentConverter converter = new();
var status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
status = converter.SaveAsHTML("output.html", HtmlLayoutType.PageLayout);
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a html file");
This method converts the currently loaded document to Markdown and saves it to an instantiated stream object.
These methods convert the currently loaded document to Markdown and save it to a stream or to a file according to what you have specified.
A stream object where the current document will be saved to as a Markdown file. This stream object must be initialized before passing it to this method and it should stay open for subsequent use.
If the output stream is not opened for both reading and writing, the method will fail to return the status.
Note that the output stream should be open for both reading and writing and should be closed/disposed by the user once processing is complete.
A member of the enumeration. If processing is successful, then the return value is .
Converting and saving a PDF document to a Markdown file using a stream.
using GdPicture14;
using GdPictureDocumentConverter converter = new();
var status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
using var fs = new FileStream("output.markdown", FileMode.OpenOrCreate, FileAccess.ReadWrite);
status = converter.SaveAsMarkDown(fs);
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a markdown file");
This method converts the currently loaded document to Markdown and saves it to the specified file path.
These methods convert the currently loaded document to Markdown and saves it to a stream or to a file according to what you have specified.
The file path where the converted file will be saved. If the specified file already exists, it will be overwritten.
You have to specify a full file path, including the file extension (.pptx).
A member of the enumeration. If processing is successful, then the return value is .
Converting and saving a PDF document to a Markdown file using a stream.
using GdPicture14;
using GdPictureDocumentConverter converter = new();
var status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
status = converter.SaveAsMarkDown("output.markdown");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a markdown file");
Closes the currently loaded document and releases any related resources from memory.
Instead of calling this method in most cases just ensure that the object is properly disposed.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
GdPictureDocumentConverter Constructor
Saving the source DOCX document as the resulting PDF document.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
' Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
' Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5)
' Closing the document.
gdpictureDocumentConverter.CloseDocument()
End Using
using GdPicture14;
using GdPictureDocumentConverter converter = new();
GdPictureStatus status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
status = converter.SaveAsDOCX("output.docx");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a docx file");
converter.CloseDocument();
This method converts and saves the currently loaded document to an instantiated stream object according to what you have specified. The output format is SVG.
Only the first page within page range is converted.
These methods convert and save the currently loaded document to a stream or to a file according to what you have specified. The output document format is SVG.
Only the first page within page range is converted.
A stream object where the current document is saved to as a SVG image. This output stream must be initialized before it can be sent into this method and it should stay open for subsequent use.
If the output stream is not opened for both reading and writing, the method will fail returning the GdPictureStatus.InvalidParameter status.
Keep noted that the output stream should be open for both reading and writing and should be closed/disposed by the user as well.
The currently selected page remains selected after saving.
In the process of converting to SVG, we do preserve vector content as much as possible. For example, paths and text will be converted to corresponding paths, considering the other parameters provided.
This method requires the Image Conversion component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Converting and saving a PDF document to a SVG image file using a stream.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF)
If status = GdPictureStatus.OK Then
Dim oFileStream As New System.IO.FileStream("drawing_stream.svg", System.IO.FileMode.Create)
status = gdpictureDocumentConverter.SaveAsSVG(oFileStream)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
oFileStream.Dispose()
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = new System.IO.FileStream("drawing_stream.svg");
status = gdpictureDocumentConverter.SaveAsSVG(oFileStream);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
oFileStream.Dispose();
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
This method converts and saves the currently loaded document to a SVG image file according to a file path you have specified.
Only the first page within page range is converted.
The file path where the destination image file will save. If the specified file already exists, it will be overwritten.
Keep noted that you have to specify a full file path with the correct file extension, which should be "svg".
The currently selected page remains selected after saving.
In the process of converting to SVG, we do preserve vector content as much as possible. For example, paths and text will be converted to corresponding paths, considering the other parameters provided.
This method requires the Image Conversion component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Converting and saving a PDF document to a SVG image file.
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF)
If status = GdPictureStatus.OK Then
gdpictureDocumentConverter.RasterizationDPI = 300
status = gdpictureDocumentConverter.SaveAsSVG("drawing_image.svg")
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "GdPicture")
Else
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
End If
Else
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("drawing.pdf", GdPicture14.DocumentFormat.DocumentFormatPDF);
if (status == GdPictureStatus.OK)
{
gdpictureDocumentConverter.RasterizationDPI = 300;
status = gdpictureDocumentConverter.SaveAsSVG("drawing_image.svg");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", "GdPicture");
}
else
{
MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
}
}
else
{
MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
}
}
This method disposes already used GdPictureDocumentConverter object completely. All related resources used by this object are released.
This method implicitly calls the CloseDocument() method.
GdPictureDocumentConverter Constructor
Saving the source DOCX document as the resulting PDF document.
Dim gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
' Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
' Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5)
' Disposing off the used object.
gdpictureDocumentConverter.Dispose()
GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter();
// Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
// Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5);
// Disposing off the used object.
gdpictureDocumentConverter.Dispose();
A standard constructor for the GdPictureDocumentConverter class. It initializes an instance of the GdPictureDocumentConverter class, which subsequently represents a wrapper for your file.
You will need this object to perform all available conversion operations with your file.
A newly created GdPictureDocumentConverter object does not automatically produce any file, even empty.
Saving the source DOCX document as the resulting PDF document.
Using gdpictureDocumentConverter As GdPictureDocumentConverter = New GdPictureDocumentConverter()
' Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
' Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5)
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
// Loading the source document.
gdpictureDocumentConverter.LoadFromFile("input.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
// Saving as the PDF document.
gdpictureDocumentConverter.SaveAsPDF("output.pdf", PdfConformance.PDF1_5);
}
The GdPictureDocumentUtilities class serves a useful purpose in providing additional utilities
and features allowing you to make use of all benefits the toolkit offers.
All methods of this class can be accessible from everywhere in your application, as they are static.
How to properly use methods of this class.
'Please use all methods of the class this way.
GdPictureDocumentUtilities.ForceGarbageCollection()
//Please use all methods of the class this way.
GdPictureDocumentUtilities.ForceGarbageCollection();
Initializes the toolkit.
It is suggested to call this method during the application initialization, preferably before any UI element construction.
Adds a specified location, defined by its path, from which asked system fonts are loaded during the whole application lifecycle.
This location is appended to the previously set locations. If you need to add more locations, simply call this method for each required location.
The new path to be added. Please use only one path in one method call.
You can apply this method several times if there is more than one location you need to specify.
How to add a custom location containing used fonts.
GdPictureDocumentUtilities.AddFontFolder("d:\\fonts")
GdPictureDocumentUtilities.AddFontFolder("d:\\fonts");
Adds a specified location, defined by its path, from which asked system fonts are loaded during the whole application lifecycle.
This location is appended to the previously set locations. If you need to add more locations, simply call this method for each required location.
The new path to be added. Please use only one path in one method call.
Specifies if the subdirectories should be included in the system fonts lookup.
You can apply this method several times if there is more than one location you need to specify.
How to add a custom location containing used fonts.
GdPictureDocumentUtilities.AddFontFolder("d:\\fonts", True)
GdPictureDocumentUtilities.AddFontFolder("d:\\fonts", true);
This method embeds a font in a .docx file.
The file name of the input document.
The file name of the output document, could be the same as the file name of the input document
The name of the font to embed.
The file name of the font to embed
True if the font file is used for a Bold or BoldItalic requested font.
True if the font file is used for a Italic or BoldItalic requested font.
A member of the GdPictureStatus enumeration.If the method has been successfully followed, then the return value is GdPictureStatus.OK.
GdPictureDocumentUtilities.EmbedFontInDocx(@"input_docx_missing_font.docx", @"output_docx_embedd_font.docx", @"FreeSans", @"input_font_FreeSansBoldOblique.otf", true, true)
GdPictureDocumentUtilities.EmbedFontInDocx(@"input_docx_missing_font.docx", @"output_docx_embedd_font.docx", @"FreeSans", @"input_font_FreeSansBoldOblique.otf", true, true);
Returns a GdPictureStatus member from a specified exception.
An Exception object.
A GdPictureStatus member corresponding tho the specified exception.
Specifies the TIFF image format that the toolkit must produce.
Specifies the tiff format. Use 0 for classic tiff or 1 for BigTIFF.
By default, the toolkit produces classic TIFF files. Using BigTIFF permits the creation of files larger than 4 GB in size.
Specifies a size of the internal browser pool.
The pool size. The default value used is 0 (disabled).
Activating the pool permits to speed-up HTML, MSG and EML input decoding.
If browser pooling is enabled, the ClearWebBrowserCache() method shall be called before the application exit in order to remove temporary data created.
Returns the size of the internal browser pool.
Use this method to specify a path to the browser being used to handle HTML, MSG and EML content as input in the toolkit scope.
Specifies the path of the web browser application. Use an empty string to disable HTML, MSG and EML input content support.
Currently supported browsers are Google chrome and google chrome portable.
If no browser is specified the toolkit will search one from the application binaries path and from the system applications.
Download the latest version of chrome headless shell and save it to the specified path, if the latest version is already present it'll return the path of the existing browser path.
The folder where the executable will be downloaded
The full path of the downloaded executable
In order to ensure the use of the latest revision of Chrome, we strongly advise to run this method regularly.
See more here.
var latestChromeDownloadPath = await GdPictureDocumentUtilities.FetchLatestChromeHeadlessShellAsync(Environment.CurrentDirectory);
GdPictureDocumentUtilities.SetWebBrowserPath(latestChromeDownloadPath);
using GdPictureDocumentConverter conv = new();
var status = conv.LoadFromHttp(new Uri("https://avepdf.com/"));
if (status != GdPictureStatus.OK)
{
throw new Exception($"Convert from http Failed ! ({status})");
}
status = conv.SaveAsPDF("output.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception($"Saved from http Failed ! ({status})");
}
Download the latest version of chrome headless shell and save it to the specified path, if the latest version is already present it'll return the path of the existent browser path.
The folder where the executable will be downloaded
The full path of the downloaded executable
In order to ensure the use of the latest revision of Chrome, we strongly advise to run this method regularly.
See more here.
var latestChromeDownloadPath = GdPictureDocumentUtilities.FetchLatestChromeHeadlessShell(Environment.CurrentDirectory);
GdPictureDocumentUtilities.SetWebBrowserPath(latestChromeDownloadPath);
using GdPictureDocumentConverter conv = new();
var status = conv.LoadFromHttp(new Uri("https://avepdf.com/"));
if (status != GdPictureStatus.OK)
{
throw new Exception($"Convert from http Failed ! ({status})");
}
status = conv.SaveAsPDF("output.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception($"Saved from http Failed ! ({status})");
}
Returns the path of the browser being used to handle HTML, MSG and EML content as input, if available.
If no browser was previously specified using the SetWebBrowserPath() method the toolkit will try to find one in the application binaries path and into the system.
The browser path.
Returns if a web browser is available.
A browser is required to support HTML, MSG and EML content as input into the whole toolkit scope.
Currently supported browsers are Google chrome and google chrome portable.
True if a browser is available, false otherwise.
Releases all browser instances stored in the pool and delete all cache content stored into temporary files.
Calling this method does not produce any effect if a previous call to SetWebBrowserPoolSize has not been made.
Calling this method releases browser instances sets in the pool. Therefore it is recommended to reduce the frequency of its usage to take benefit of the pooling mechanism.
Releases all cached content from memory such as parsed system fonts, pool contents and adaptive memory buffers.
How to completely release all cached content in one step.
GdPictureDocumentUtilities.EmptyCache()
GdPictureDocumentUtilities.EmptyCache();
Sets the specified folder, where temporary files generated by the toolkit are stored during the whole application lifecycle.
The default value is the path of the current user's temporary folder.
The new path of the required cache folder.
How to set a custom cache folder.
GdPictureDocumentUtilities.SetCacheFolder("d:\\mycache")
GdPictureDocumentUtilities.SetCacheFolder("d:\\mycache");
Enables or disables the usage of the adaptive file caching mechanism integrated into the toolkit.
Enabling this mechanism can be particularly useful when manipulating, cloning or merging large documents.
The feature is available in both 32-bit and 64-bit mode of the toolkit.
Set this parameter to true if you want to enable the adaptive file caching mechanism. Otherwise set it to false. The default value is true.
How to disable the adaptive file caching mechanism.
GdPictureDocumentUtilities.SetAdaptiveFileCachingMechanism(False)
GdPictureDocumentUtilities.SetAdaptiveFileCachingMechanism(false);
Forces an immediate garbage collection. Please use this method if you try to recover all memory that is inaccessible.
How to force an immediate garbage collection.
GdPictureDocumentUtilities.ForceGarbageCollection()
GdPictureDocumentUtilities.ForceGarbageCollection();
Releases all GdPicture image allocated by the Toolkit.
This method should only be used to diagnoze memory leaks.
The number of GdPicture image disposed.
How to release all previously allocated GdPictureImage objects from memory.
GdPictureDocumentUtilities.ReleaseAllGdPictureImages()
GdPictureDocumentUtilities.ReleaseAllGdPictureImages();
Returns if the provided DocumentFormat is an image format (raster or vector).
A member of the DocumentFormat enumeration.
True if the provided document format is considered as image format by the toolkit.
Determines the document format in accordance with the specified file path of that document.
Be aware that this method uses the file itself to obtain the known document format either from the file extension or the document content.
If the file does not exist on the specified file path, the returned format is unknown.
Please refer to the method to obtain the document format based only on the file name.
Determines the format of your document according to the specified parameters.
The full file path of the specified document. If the specified file does not exist, the returned format is unknown.
The method firstly favors popular formats by their extension. Secondly, it validates the file content to find the proper document format.
A member of the DocumentFormat enumeration. The format of the specified document.
How to properly retrieve the document format of a specified file.
Dim documentFormat As GdPicture14.DocumentFormat = GdPictureDocumentUtilities.GetDocumentFormat("d:\\documents\\document.docx")
GdPicture14.DocumentFormat documentFormat = GdPictureDocumentUtilities.GetDocumentFormat("d:\\documents\\document.docx");
Determines the format of a required document from a previously instantiated Stream object.
The method firstly favors popular formats by their extension. Secondly, it validates the file content to find the proper document format.
Determines the format of your document according to the specified parameters.
A System.IO.Stream object. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
At the same, the provided stream object must support seeking, otherwise the method will fail.
Please note that the specified stream should remain open during running this method and it needs to be closed by the user as well.
At the same, the provided stream must support seeking, otherwise the method returns the GdPicture14.DocumentFormat.DocumentFormatUNKNOWN.
A member of the DocumentFormat enumeration. The format of the specified document.
How to properly retrieve the format of an image file stored within a stream.
Using fileStream As New FileStream("input.tif", FileMode.Open)
Dim documentFormat As GdPicture14.DocumentFormat = GdPictureDocumentUtilities.GetDocumentFormat(fileStream)
fileStream.Close()
End Using
using (FileStream fileStream = new FileStream("input.tif", FileMode.Open))
{
GdPicture14.DocumentFormat documentFormat = GdPictureDocumentUtilities.GetDocumentFormat(fileStream);
fileStream.Close();
}
Determines the format of a required document from a previously instantiated Stream object with the help of the original file name.
The method firstly favors popular formats by their extension. Secondly, it validates the file content to find the proper document format.
Determines the format of your document according to the specified parameters.
A System.IO.Stream object. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
At the same, the provided stream object must support seeking, otherwise the method will fail.
The name of the original file. This parameter can help the format detection algorithm to distinguish format using the same signature pattern.
Please note that the specified stream should remain open during running this method and it needs to be closed by the user as well.
At the same, the provided stream must support seeking, otherwise the method returns the GdPicture14.DocumentFormat.DocumentFormatUNKNOWN.
A member of the DocumentFormat enumeration. The format of the specified document.
How to properly retrieve the format of an image file stored within a stream using also the original file name.
Using fileStream As New FileStream("input.tif", FileMode.Open)
Dim documentFormat As GdPicture14.DocumentFormat = GdPictureDocumentUtilities.GetDocumentFormat(fileStream, "input.tif")
fileStream.Close()
End Using
using (FileStream fileStream = new FileStream("input.tif", FileMode.Open))
{
GdPicture14.DocumentFormat documentFormat = GdPictureDocumentUtilities.GetDocumentFormat(fileStream, "input.tif");
fileStream.Close();
}
Determines the document format in accordance with the specified file name of that document.
This method recognizes only the file extension to get the known document format.
Please use the method or its overloads to validate also the document content if the file extension is unknown or misleading.
The file name of the required document.
The method does not care about the full file path or the file itself as it only examines the file extension.
Be aware that this method only checks the file extension to identify the document format.
A member of the DocumentFormat enumeration. The format of the specified document.
How to properly retrieve the document format of a specified file.
Dim documentFormat As GdPicture14.DocumentFormat = GdPictureDocumentUtilities.GetDocumentFormatFromFileName("document.docx")
GdPicture14.DocumentFormat documentFormat = GdPictureDocumentUtilities.GetDocumentFormatFromFileName("document.docx");
Retrieves the format of a required document specified by its file path and the total number of pages of that document.
Retrieves the key information of a specified document, like the document format, the total number of pages and others.
The full file path of the specified document.
Output parameter. A member of the DocumentFormat enumeration. The format of the specified document.
Output parameter. The total number of pages of the specified document.
This method is based on the method when processing the specified file.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve basic information about the specified file.
Dim documentFormat As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN
Dim pagesCount As Integer = 0
Dim status As GdPictureStatus = GdPictureDocumentUtilities.GetDocumentPreview("D:\\documents\\document.docx", documentFormat, pagesCount)
If status = GdPictureStatus.OK Then
MessageBox.Show("Document Preview: " + vbCrLf + " format: " + GdPicture14.DocumentFormat.ToString() + vbCrLf + " number of pages: " + pagesCount.ToString(), "GdPicture")
Else
MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
GdPicture14.DocumentFormat documentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN;
int pagesCount = 0;
GdPictureStatus status = GdPictureDocumentUtilities.GetDocumentPreview("D:\\documents\\document.docx", ref documentFormat, ref pagesCount);
if (status == GdPictureStatus.OK)
MessageBox.Show("Document Preview: \n format: " + GdPicture14.DocumentFormat.ToString() + "\n number of pages: " + pagesCount.ToString(), "GdPicture");
else
MessageBox.Show("Error: " + status.ToString(), "GdPicture");
Retrieves the format of a required document and the total number of pages of that document. The specified document is accessible
from a previously instantiated Stream object.
Retrieves the key information of a specified document, like the document format, total number of pages etc.
A System.IO.Stream object. This stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use. At the same, the provided stream object must support seeking, otherwise the method will fail.
The name of the original file. It can be an empty string.
Providing this parameter can help the format detection algorithm to distinguish format using the same signature pattern.
Output parameter. A member of the DocumentFormat enumeration. The format of the specified document.
Output parameter. The total number of pages of the specified document.
This method is based on the method when processing the specified stream.
Be aware that the specified stream should remain open during running this method and it needs to be closed by the user as well.
At the same, the provided stream must support seeking, otherwise the method will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve basic information of an image file stored within a stream.
Using fileStream As FileStream = New FileStream("input.tif", FileMode.Open)
Dim documentFormat As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN
Dim pagesCount As Integer = 0
Dim status As GdPictureStatus = GdPictureDocumentUtilities.GetDocumentPreview(fileStream, "input.tif", documentFormat, pagesCount)
If status = GdPictureStatus.OK Then
MessageBox.Show("Document Preview: " + vbCrLf + " format: " + GdPicture14.DocumentFormat.ToString() + vbCrLf + " number of pages: " + pagesCount.ToString(), "GdPicture")
Else
MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
End Using
using (FileStream fileStream = new FileStream("input.tif", FileMode.Open))
{
GdPicture14.DocumentFormat documentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN;
int pagesCount = 0;
GdPictureStatus status = GdPictureDocumentUtilities.GetDocumentPreview(fileStream, "input.tif", ref documentFormat, ref pagesCount);
if (status == GdPictureStatus.OK)
MessageBox.Show("Document Preview: \n format: " + GdPicture14.DocumentFormat.ToString() + "\n number of pages: " + pagesCount.ToString(), "GdPicture");
else
MessageBox.Show("Error: " + status.ToString(), "GdPicture");
}
Retrieves the format of a required document specified by its file path, the total number of pages of that document and produces the thumbnail
of its first page according to the specified parameters.
Retrieves the key information of a specified document, like the document format, total number of pages etc.
The full file path of the specified document.
The required width of the generated thumbnail of the first page, in pixels.
The required height of the generated thumbnail of the first page, in pixels.
The required background color of the generated thumbnail, in ARGB format.
Output parameter. A member of the DocumentFormat enumeration. The format of the specified document.
Output parameter. The unique image identifier of a newly generated thumbnail image of the first page of the specified document.
Be aware that you need to subsequently release this image from memory using the method after you have used it.
Output parameter. The total number of pages of the specified document.
This method is based on the method when processing the specified file.
Be aware that you need to release the thumbnail's image resource from memory using the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve extended information about the specified file.
Dim documentFormat As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN
Dim thumbID As Integer = 0, pagesCount As Integer = 0
Dim status As GdPictureStatus = GdPictureDocumentUtilities.GetDocumentPreview("D:\\documents\\document.pdf", 100, 150, (Color.Aqua).ToArgb(), documentFormat, thumbID, pagesCount)
If status = GdPictureStatus.OK Then
MessageBox.Show("Document Preview: " + vbCrLf + " format: " + GdPicture14.DocumentFormat.ToString() + vbCrLf + " number of pages: " + pagesCount.ToString(), "GdPicture")
Else
MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
'Do your stuff with thumbID here.
GdPictureDocumentUtilities.DisposeImage(thumbID)
GdPicture14.DocumentFormat documentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN;
int thumbID = 0, pagesCount = 0;
GdPictureStatus status = GdPictureDocumentUtilities.GetDocumentPreview("D:\\documents\\document.pdf", 100, 150, (Color.Aqua).ToArgb(), ref documentFormat, ref thumbID, ref pagesCount);
if (status == GdPictureStatus.OK)
MessageBox.Show("Document Preview: \n format: " + GdPicture14.DocumentFormat.ToString() + "\n number of pages: " + pagesCount.ToString(), "GdPicture");
else
MessageBox.Show("Error: " + status.ToString(), "GdPicture");
//Do your stuff with thumbID here.
GdPictureDocumentUtilities.DisposeImage(thumbID);
Retrieves the format of a required document, the total number of pages of that document and produces the thumbnail of its first page
according to the specified parameters. The required document is accessible from a previously instantiated Stream object.
Retrieves the key information of a specified document, like the document format, total number of pages etc.
A System.IO.Stream object. This stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use. At the same, the provided stream object must support seeking, otherwise the method will fail.
The name of the original file. It can be an empty string.
Providing this parameter can help the format detection algorithm to distinguish format using the same signature pattern.
The required width of the generated thumbnail of the first page, in pixels.
The required height of the generated thumbnail of the first page, in pixels.
The required background color of the generated thumbnail, in ARGB format.
Output parameter. A member of the DocumentFormat enumeration. The format of the specified document.
Output parameter. The unique image identifier of a newly generated thumbnail image of the first page of the specified document.
Be aware that you need to subsequently release this image from memory using the method after you have used it.
Output parameter. The total number of pages of the specified document.
This method is based on the method when processing the specified stream.
Be aware that the specified stream should remain open during running this method and it needs to be closed by the user as well.
At the same, the provided stream must support seeking, otherwise the method will fail.
Likewise, you need to release the thumbnail's image resource from memory using the method.
This method requires the Image Conversion component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve extended information of an image file stored within a stream.
Using fileStream As FileStream = New FileStream("input.tif", FileMode.Open)
Dim documentFormat As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN
Dim thumbID As Integer = 0, pagesCount As Integer = 0
Dim status As GdPictureStatus = GdPictureDocumentUtilities.GetDocumentPreview(fileStream, "input.tif", 100, 150, (Color.Aqua).ToArgb(), documentFormat, thumbID, pagesCount)
If status = GdPictureStatus.OK Then
MessageBox.Show("Document Preview: " + vbCrLf + " format: " + GdPicture14.DocumentFormat.ToString() + vbCrLf + " number of pages: " + pagesCount.ToString(), "GdPicture")
Else
MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
'Do your stuff with thumbID here.
GdPictureDocumentUtilities.DisposeImage(thumbID)
End Using
using (FileStream fileStream = new FileStream("input.tif", FileMode.Open))
{
GdPicture14.DocumentFormat documentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN;
int thumbID = 0, pagesCount = 0;
GdPictureStatus status = GdPictureDocumentUtilities.GetDocumentPreview(fileStream, "input.tif", 100, 150, (Color.Aqua).ToArgb(), ref documentFormat, ref thumbID, ref pagesCount);
if (status == GdPictureStatus.OK)
MessageBox.Show("Document Preview: \n format: " + GdPicture14.DocumentFormat.ToString() + "\n number of pages: " + pagesCount.ToString(), "GdPicture");
else
MessageBox.Show("Error: " + status.ToString(), "GdPicture");
//Do your stuff with thumbID here.
GdPictureDocumentUtilities.DisposeImage(thumbID);
}
Retrieves the format of a required document, the total number of pages of that document and produces the thumbnail of its first page
according to the specified parameters. The required document is accessible from a previously instantiated Stream object.
Retrieves the key information of a specified document, like the document format, total number of pages etc.
A System.IO.Stream object. This stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use. At the same, the provided stream object must support seeking, otherwise the method will fail.
The name of the original file. It can be an empty string.
Providing this parameter can help the format detection algorithm to distinguish format using the same signature pattern.
The required width of the generated thumbnail of the first page, in pixels.
The required height of the generated thumbnail of the first page, in pixels.
The required background color of the generated thumbnail, in ARGB format.
Specifies if the size of the produced thumbnail is automatically adjusted to don't have any margin.
Output parameter. A member of the DocumentFormat enumeration. The format of the specified document.
Output parameter. The unique image identifier of a newly generated thumbnail image of the first page of the specified document.
Be aware that you need to subsequently release this image from memory using the method after you have used it.
Output parameter. The total number of pages of the specified document.
This method is based on the method when processing the specified stream.
Be aware that the specified stream should remain open during running this method and it needs to be closed by the user as well.
At the same, the provided stream must support seeking, otherwise the method will fail.
Likewise, you need to release the thumbnail's image resource from memory using the method.
This method requires the Image Conversion component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve extended information of an image file stored within a stream.
Using fileStream As FileStream = New FileStream("input.tif", FileMode.Open)
Dim documentFormat As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN
Dim thumbID As Integer = 0, pagesCount As Integer = 0
Dim status As GdPictureStatus = GdPictureDocumentUtilities.GetDocumentPreview(fileStream, "input.tif", 100, 150, (Color.Aqua).ToArgb(), documentFormat, thumbID, pagesCount)
If status = GdPictureStatus.OK Then
MessageBox.Show("Document Preview: " + vbCrLf + " format: " + GdPicture14.DocumentFormat.ToString() + vbCrLf + " number of pages: " + pagesCount.ToString(), "GdPicture")
Else
MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
'Do your stuff with thumbID here.
GdPictureDocumentUtilities.DisposeImage(thumbID)
End Using
using (FileStream fileStream = new FileStream("input.tif", FileMode.Open))
{
GdPicture14.DocumentFormat documentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN;
int thumbID = 0, pagesCount = 0;
GdPictureStatus status = GdPictureDocumentUtilities.GetDocumentPreview(fileStream, "input.tif", 100, 150, (Color.Aqua).ToArgb(), true, ref documentFormat, ref thumbID, ref pagesCount);
if (status == GdPictureStatus.OK)
MessageBox.Show("Document Preview: \n format: " + GdPicture14.DocumentFormat.ToString() + "\n number of pages: " + pagesCount.ToString(), "GdPicture");
else
MessageBox.Show("Error: " + status.ToString(), "GdPicture");
//Do your stuff with thumbID here.
GdPictureDocumentUtilities.DisposeImage(thumbID);
}
Releases a specified image and its corresponding image resource from memory. This method is particularly useful if you work with images
outside the class, for example if you are using the class.
The unique image identifier of the image resource to be released.
It is always a best practice to release images you have created once you have no use for them. You can find some our recommendations
in this Best Practices tutorial.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
How to dispose of the used image.
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
Dim imageCount As Integer = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
Dim imageID As Integer = 0
For i As Integer = 1 To imageCount
imageID = gdpicturePDF.ExtractPageImage(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
'Do your stuff with the extracted image here.
' ...
'Dispose of the image after you have used it.
If GdPictureDocumentUtilities.DisposeImage(imageID) <> GdPictureStatus.OK Then
MessageBox.Show("The disposal of the image has failed. Status: " + status.ToString(), "GdPicture")
End If
End If
Next
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("The first page doesn't contain any image.", "GdPicture")
Else
MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
End If
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", "GdPicture")
Else
MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
End If
Else
MessageBox.Show("The file can't be loaded.", "GdPicture")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
int imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
int imageID = 0;
for (int i = 1; i <= imageCount; i++)
{
imageID = gdpicturePDF.ExtractPageImage(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
//Do your stuff with the extracted image here.
//...
//Dispose of the image after you have used it.
if (GdPictureDocumentUtilities.DisposeImage(imageID) != GdPictureStatus.OK)
MessageBox.Show("The disposal of the image has failed. Status: " + status.ToString(), "GdPicture");
}
}
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("The first page doesn't contain any image.", "GdPicture");
else
MessageBox.Show("Error: " + status.ToString(), "GdPicture");
}
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", "GdPicture");
else
MessageBox.Show("Error: " + status.ToString(), "GdPicture");
}
}
else
MessageBox.Show("The file can't be loaded.", "GdPicture");
gdpicturePDF.Dispose();
Sets custom startup arguments for Chrome used in HTML conversion.
An array of strings representing the startup arguments to be passed to the the Chrome instances.
Sets a custom temporary folder path for Chrome engine used in HTML conversion.
The temporary folder path to be used by the Chrome instances.
Enables or disables the EML certificate (if applicable) during the conversion process, in some cases it can improve the performance of the conversion.
Specify whether if the validation is to be performed or not.
The GdPictureImaging class offers a huge amount of imaging features that GdPicture.NET toolkit provides.
It is used as a wrapper class to allow you easily operate with your image files of different formats.
Please find all the currently supported input document formats listed here.
You need to create an object of this class to fully work with your image files. This object subsequently represents a wrapper
for all the image resources you want to process. We recommend going with one GdPictureImaging object for all processing images.
This event is raised immediately after a bitmap has been transferred from the TWAIN device to GdPicture.
The transferred image may be used for previewing and filtering purposes but should be released from the memory at this stage.
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
A unique image identifier of the GdPicture image representing the image in use.
This method uses the best quality mode for scanning and will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true, to stop the recognition process after the first barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Start the barcode scanning process at the best quality to find all available 1D barcode symbols.
gdpictureImaging.Barcode1DReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
{
int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i));
}
}
// Release used resources.
gdpictureImaging.Barcode1DReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter according to your preference.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the Barcode1DReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
This method will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true, to stop the recognition process after the first barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the barcode scanning process to find all available 1D barcode symbols using the best speed.
gdpictureImaging.Barcode1DReaderDoScan(imageID, Barcode1DReaderScanMode.BestSpeed);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
{
int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i));
}
}
// Release used resources.
gdpictureImaging.Barcode1DReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter according to your preference as well as to specify the type of barcodes to be searched for.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the Barcode1DReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
A member or a combination of members of the Barcode1DReaderType enumeration.
This method will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true, to stop the recognition process after the first barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the barcode scanning process to find all available 1D barcode symbols using the best speed.
gdpictureImaging.Barcode1DReaderDoScan(imageID, Barcode1DReaderScanMode.BestSpeed);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
{
int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i));
}
}
// Release used resources.
gdpictureImaging.Barcode1DReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter as well as to specify the type of barcodes to be searched for. You can also define the required number of barcodes the engine should detect.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the Barcode1DReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
A member or a combination of members of the Barcode1DReaderType enumeration.
Default value is Barcode1DReaderType.Barcode1DReaderNone meaning to search for all known barcode symbologies.
Specifies if the barcode scanner shall returns corrupted barcode. False by default.
It is highly recommended to keep this option to False, otherwise invalid detected barcode can override valid barcode.
Therefore, you should use it only in a second attempt when the first detection process did not detect any barcode.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
If this is set to true and ExpectedCount > 0, the scanning process stops after first ExpectedCount barcodes were found.
Be aware when reading Code128 symbology, if barcode checksum is missing or wrong, the barcode will be recognized as corrupted. To return the value nonetheless, please set ReturnCorrupted to true.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Specify 1D barcode search types to be Code39 and Code128.
Barcode1DReaderType barcodeType = Barcode1DReaderType.Barcode1DReaderCode39 | Barcode1DReaderType.Barcode1DReaderCode128;
// Start the barcode scanning process. The ExpectedCount parameter is 0, all the barcodes should be retrieved.
gdpictureImaging.Barcode1DReaderDoScan(imageID, Barcode1DReaderScanMode.BestQuality, barcodeType, false, 0, false);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
{
int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i));
}
}
// Release used resources.
gdpictureImaging.Barcode1DReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter as well as to specify the type of barcodes to be searched for. You can also define the required number of barcodes the engine should detect.
With this method you may set the timeout parameter for the barcode scanning process.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the Barcode1DReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
A member or a combination of members of the Barcode1DReaderType enumeration.
Default value is Barcode1DReaderType.Barcode1DReaderNone meaning to search for all known barcode symbologies.
Specifies if the barcode scanner shall returns corrupted barcode. False by default.
It is highly recommended to keep this option to False, otherwise invalid detected barcode can override valid barcode.
Therefore, you should use it only in a second attempt when the first detection process did not detect any barcode.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
If this is set to true and ExpectedCount > 0, the scanning process stops after first ExpectedCount barcodes were found.
Specifies the timeout of the scanning for barcode process, in milliseconds. Default value is 0, which means no timeout.
Be aware when reading Code128 symbology, if barcode checksum is missing or wrong, the barcode will be recognized as corrupted. To return the value nonetheless, please set ReturnCorrupted to true.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Specify 1D barcode search types to be Code39 and Code128.
Barcode1DReaderType barcodeType = Barcode1DReaderType.Barcode1DReaderCode39 | Barcode1DReaderType.Barcode1DReaderCode128;
// Start the barcode scanning process. The ExpectedCount parameter is 0, all the barcodes should be retrieved.
// Timeout set at 2 seconds
gdpictureImaging.Barcode1DReaderDoScan(imageID, Barcode1DReaderScanMode.BestQuality, barcodeType, false, 0, false, 2000);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
{
int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i));
}
}
// Release used resources.
gdpictureImaging.Barcode1DReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of barcode detected by the Barcode1DReaderDoScan method.
The number of barcode detected.
This method is used in the "Barcode Recognition" Demo.
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Specify 1D barcode search types to be Code39 and Code128.
Barcode1DReaderType barcodeType = Barcode1DReaderType.Barcode1DReaderCode39 | Barcode1DReaderType.Barcode1DReaderCode128;
// Start the barcode scanning process. The ExpectedCount parameter is 0, all the barcodes should be retrieved.
gdpictureImaging.Barcode1DReaderDoScan(imageID, Barcode1DReaderScanMode.BestQuality, barcodeType, false, 0);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
{
int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i));
}
}
// Release used resources.
gdpictureImaging.Barcode1DReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the type of a barcode detected by the Barcode1DReaderDoScan method.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
A member of the Barcode1DReaderType enumeration.
This method is used in the "Barcode Recognition" Demo.
Returns if a recognized code 128 is UCC/EAN-128.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
True if the code is UCC/EAN-128, False otherwise.
UCC/EAN-128 is not a separate bar code symbology. It is a Code 128 bar code with a specific structure.
Returns the value of a barcode detected by the Barcode1DReaderDoScan method.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned
value.
The barcode data.
This method is used in the "Barcode Recognition" Demo.
For UCC / EAN-128 codes FNC1 control character is mapped to the <GS> char (ASCII code 29).
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Specify 1D barcode search types to be Code39 and Code128.
Barcode1DReaderType barcodeType = Barcode1DReaderType.Barcode1DReaderCode39 | Barcode1DReaderType.Barcode1DReaderCode128;
// Start the barcode scanning process. The ExpectedCount parameter is 0, all the barcodes should be retrieved.
gdpictureImaging.Barcode1DReaderDoScan(imageID, Barcode1DReaderScanMode.BestQuality, barcodeType, false, 0);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
{
int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i));
}
}
// Release used resources.
gdpictureImaging.Barcode1DReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the Barcode1DReaderDoScan method.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned
Flag to retrieve Febraban digital line. If the flag is set, for a Barcode1DReaderInterleaved2of5 barcode,
if the info consists in 44 digits, it is convertedm if possible, to a 47 or 48 digits Febraban line
value.
The barcode data.
This method is used in the "Barcode Recognition" Demo.
For UCC / EAN-128 codes FNC1 control character is mapped to the <GS> char (ASCII code 29).
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Specify 1D barcode search types to be Code39 and Code128.
Barcode1DReaderType barcodeType = Barcode1DReaderType.Barcode1DReaderCode39 | Barcode1DReaderType.Barcode1DReaderCode128;
// Start the barcode scanning process. The ExpectedCount parameter is 0, all the barcodes should be retrieved.
gdpictureImaging.Barcode1DReaderDoScan(imageID, Barcode1DReaderScanMode.BestQuality, barcodeType, false, 0);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
{
int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// retrieve Febraban digital line, if detected
file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i, true));
}
}
// Release used resources.
gdpictureImaging.Barcode1DReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the Barcode1DReaderDoScan method, in its raw format.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned
value.
The barcode data.
Use the GetStat() method to check if this method has completed successfully.
This method is used in the "Barcode Recognition" Demo.
Returns the value of a barcode detected by the Barcode1DReaderDoScan method, in its raw format, encoded in a base64 string.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned
value.
The barcode data encoded in base64.
Use the GetStat() method to check if this method has completed successfully.
This method is used in the "Barcode Recognition" Demo.
Returns the angle of a barcode detected by the Barcode1DReaderDoScan method.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned.
value.
The barcode angle in degrees. The angle is measured clockwise relative to the horizontal axis of the image.
This method is used in the "Barcode Recognition" Demo.
Returns if a barcode detected by the Barcode1DReaderDoScan method has a checksum.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned
value.
True if the barcode has a checksum else False.
This method is used in the "Barcode Recognition" Demo.
Returns the X position (in pixels) of the top-left corner of a barcode detected by the Barcode1DReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
The barcode X position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Returns the Y position (in pixels) of the top-left corner of a barcode detected by the Barcode1DReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
The barcode Y position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Returns the X position (in pixels) of the top-right corner of a barcode detected by the Barcode1DReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
The barcode X position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Returns the Y position (in pixels) of the top-right corner of a barcode detected by the Barcode1DReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
The barcode Y position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the Barcode1DReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Returns the Y position (in pixels) of the bottom-right corner of a barcode detected by the Barcode1DReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Returns the X position (in pixels) of the bottom-left corner of a barcode detected by the Barcode1DReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
The barcode X position of the bottom-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Returns the Y position (in pixels) of the bottom-left corner of a barcode detected by the Barcode1DReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and Barcode1DReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Releases from memory all information about latest 1D barcode detection.
This method is used in the "Barcode Recognition" Demo.
Finding all 1D barcodes in a given image and saving their information to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Specify 1D barcode search types to be Code39 and Code128.
Barcode1DReaderType barcodeType = Barcode1DReaderType.Barcode1DReaderCode39 | Barcode1DReaderType.Barcode1DReaderCode128;
// Start the barcode scanning process. The ExpectedCount parameter is 0, all the barcodes should be retrieved.
gdpictureImaging.Barcode1DReaderDoScan(imageID, Barcode1DReaderScanMode.BestQuality, barcodeType, false, 0);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("barcodes.txt"))
{
int barcodesFound = gdpictureImaging.Barcode1DReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
file.WriteLine(gdpictureImaging.Barcode1DReaderGetBarcodeValue(i));
}
}
// Release used resources.
gdpictureImaging.Barcode1DReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a Patch Code recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
A unique image identifier of the GdPicture image representing the image in use.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of Patch Code detected by the PatchCodeReaderDoScan method.
The number of Patch Code detected.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the type of a Patch Code detected by the PatchCodeReaderDoScan method.
Patch Code index. Must be between 1 and PatchCodeReaderGetCodeCount returned
value.
A member of the PatchCodeType enumeration.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-left corner of a Patch Code detected by the
PatchCodeReaderDoScan method.
Patch Code index. Must be between 1 and PatchCodeReaderGetCodeCount returned
value.
The Patch Code X position of the top-left corner.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-left corner of a Patch Code detected by the
PatchCodeReaderDoScan method.
Patch Code index. Must be between 1 and PatchCodeReaderGetCodeCount returned
value.
The Patch Code Y position of the top-left corner.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-right corner of a Patch Code detected by the
PatchCodeReaderDoScan method.
Patch Code index. Must be between 1 and PatchCodeReaderGetCodeCount returned
value.
The Patch Code X position of the top-right corner.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-right corner of a Patch Code detected by the
PatchCodeReaderDoScan method.
Patch Code index. Must be between 1 and PatchCodeReaderGetCodeCount returned
value.
The Patch Code Y position of the top-right corner.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a Patch Code detected by the
PatchCodeReaderDoScan method.
Patch Code index. Must be between 1 and PatchCodeReaderGetCodeCount returned
value.
The Patch Code X position of the bottom-right corner.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-right corner of a Patch Code detected by the
PatchCodeReaderDoScan method.
Patch Code index. Must be between 1 and PatchCodeReaderGetCodeCount returned
value.
The Patch Code Y position of the bottom-right corner.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-left corner of a Patch Code detected by the
PatchCodeReaderDoScan method.
Patch Code index. Must be between 1 and PatchCodeReaderGetCodeCount returned
value.
The Patch Code X position of the bottom-left corner.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-left corner of a Patch Code detected by the
PatchCodeReaderDoScan method.
Patch Code index. Must be between 1 and PatchCodeReaderGetCodeCount returned
value.
The Patch Code Y position of the bottom-left corner.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Releases from memory all information about latest Patch Code Patch Code detection.
This method is used in the "Barcode Recognition" Demo.
Finding patch codes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the patch codes scanning process and write complete information into a text file.
gdpictureImaging.PatchCodeReaderDoScan(imageID);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("patch codes.txt"))
{
int patch codesFound = gdpictureImaging.PatchCodeReaderGetCodeCount();
for (int i = 1; i <= patch codesFound; i++)
{
// Patch codes type, possible values are 1, 2, 4, 8, 16 or 32.
PatchCodeType type = gdpictureImaging.PatchCodeReaderGetCodeType(i);
file.WriteLine("Patch code type = " + type.ToString());
// The patch code position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.PatchCodeReaderGetCodeX1(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX2(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.PatchCodeReaderGetCodeX3(i) + ", " + gdpictureImaging.PatchCodeReaderGetCodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.PatchCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Releases from memory all information about latest Aztec barcode detection.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
A unique image identifier of the GdPicture image representing the image in use.
This method uses the best quality mode for scanning and will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true, to stop the recognition process after the first barcode is found.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the Aztec barcode scanning process using the best quality mode and find all Aztec barcodes.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID);
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter according to your preference.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeAztecReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
This method will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true, to stop the recognition process after the first barcode is found.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and look for all Aztec barcodes.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode);
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
This method requires the Barcode Reading & Writing component to run.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeAztecReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0 so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
This method requires the Barcode Reading & Writing component to run.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeAztecReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
If this is set to true and ExpectedCount > 0, the recognition process stops after first ExpectedCount barcodes were found.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process looking for exactly one single barcode and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, 1, true);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of barcodes detected by the BarcodeAztecReaderDoScan method.
The number of barcodes detected.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodeAztecReaderDoScan method.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode data.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value, as RAW Bytes, of a barcode detected by the BarcodeAztecReaderDoScan method.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode data.
Use the GetStat() method to determine if this method has been successful.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodeAztecReaderDoScan method, in its raw format, encoded in a base64 string.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode data encoded in base64.
Use the GetStat() method to determine if this method has been successful.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the confidence of a barcode detected by the BarcodeAztecReaderReaderDoScan method.
Barcode index. Must be between 1 and BarcodeAztecReaderReaderGetBarcodeCount
returned value.
The barcode confidence. In the range [(less trust) 0 - 100 (full trust)]
This method is used in the "Barcode Recognition" Demo.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-left corner of a barcode detected by the BarcodeAztecReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
Use the GetStat() method to determine if this method has been successful.
The barcode X position of the top-left corner; relative to the ROI, if any is defined.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-right corner of a barcode detected by the BarcodeAztecReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode X position of the top-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeAztecReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the' BarcodeAztecReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-left corner of a barcode detected by the BarcodeAztecReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode Y position of the top-left corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-right corner of a barcode detected by the BarcodeAztecReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode Y position of the top-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeAztecReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-left corner of a barcode detected by the BarcodeAztecReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeAztecReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-left corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding Aztec barcodes in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Aztec barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeAztecReaderScanMode mode = BarcodeAztecReaderScanMode.BestSpeed;
// Start the Aztec barcode scanning process and write info into a text file.
gdpictureImaging.BarcodeAztecReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("Aztec.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeAztecReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeAztecReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeAztecReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeAztecReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeAztecReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeAztecReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
A unique image identifier of the GdPicture image representing the image in use.
This method uses the best quality mode for scanning and will try to detect all available barcodes.
You can use the method and set the ExpectedCount to 1 and StopOnExpectedCount to true, to stop the recognition process after the first barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the DataMatrix barcode scanning process using the best quality mode and look for all barcodes.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID);
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeDataMatrixReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
This method will try to detect all available barcodes.
You can use the method and set the ExpectedCount to 1 and StopOnExpectedCount to true, to stop the recognition process after the first barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix barcode scanning process and look for all barcodes.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode);
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeDataMatrixReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeDataMatrixReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
If this is set to true and ExpectedCount > 0, the recognition process stops after first ExpectedCount barcodes were found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process looking for a single barcode and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, 1, true);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of barcode detected by the BarcodeDataMatrixReaderDoScan method.
The number of barcode detected.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount
returned value.
The barcode data.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value, as RAW Bytes, of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount
returned value.
The barcode data.
Use the GetStat() method to check if this method has completed successfully.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodeDataMatrixReaderDoScan method, in its raw format, encoded in a base64 string.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned
value.
The barcode data encoded in base64.
Use the GetStat() method to check if this method has completed successfully.
This method is used in the "Barcode Recognition" Demo.
Returns the confidence of a barcode detected by the BarcodeDataMatrixReaderReaderDoScan method.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderReaderGetBarcodeCount
returned value.
The barcode confidence. In the range [(less trust) 0 - 100 (full trust)]
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of rows of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount
returned value.
The number of rows of the barcode.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the angle of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned.
value.
The barcode angle in degrees. The angle is measured clockwise relative to the horizontal axis of the image.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of columns of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount
returned value.
The number of columns of the barcode.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-left corner of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned value.
The barcode X position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-left corner of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned value.
The barcode Y position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-right corner of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned value.
The barcode X position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-right corner of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned value.
The barcode Y position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-left corner of a barcode detected by the BarcodeDataMatrixReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeDataMatrixReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Releases from memory all information about latest DataMatrix barcode detection.
This method is used in the "Barcode Recognition" Demo.
Finding DataMatrix barcodes in an image and writes complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the DataMatrix barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeDataMatrixReaderScanMode mode = BarcodeDataMatrixReaderScanMode.BestSpeed;
// Start the DataMatrix scanning process and write info into a text file.
gdpictureImaging.BarcodeDataMatrixReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("DataMatrix.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeSkewAngle(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeColumns(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeDataMatrixReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeDataMatrixReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
A unique image identifier of the GdPicture image representing the image in use.
This method uses the best quality mode for scanning and will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true to stop the recognition process after the first barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the PDF417 barcode scanning process using the best quality looking for all PDF417 barcodes.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID);
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
This method allows you to set the scanning mode parameter according to your preference.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodePDF417ReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
This method will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true to stop the recognition process after the first barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and look for all PDF417 barcodes.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode);
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodePDF417ReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodePDF417ReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
If this is true and ExpectedCount > 0, the recognition process stops after first ExpectedCount barcodes were found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process looking for a single barcode and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, 1, true);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of barcode detected by the BarcodePDF417ReaderDoScan method.
The number of barcode detected.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the confidence of a barcode detected by the BarcodePDF417ReaderDoScan method.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount
returned value.
The barcode confidence. In the range [(less trust) 0 - 100 (full trust)]
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the angle of a barcode detected by the BarcodePDF417ReaderDoScan method.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned.
value.
The barcode angle in degrees. The angle is measured clockwise relative to the horizontal axis of the image.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value, as string, of a barcode detected by the BarcodePDF417ReaderDoScan method.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount
returned value.
The barcode data.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value, as RAW Bytes, of a barcode detected by the BarcodePDF417ReaderDoScan method.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount
returned value.
The barcode data.
Use the GetStat() method to check if this method has completed successfully.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodePDF417ReaderDoScan method, in its raw format, encoded in a base64 string.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned
value.
The barcode data encoded in base64.
Use the GetStat() method to check if this method has completed successfully.
This method is used in the "Barcode Recognition" Demo.
Returns the number of rows of a barcode detected by the BarcodePDF417ReaderDoScan method.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount
returned value.
The number of rows of the barcode.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of columns of a barcode detected by the BarcodePDF417ReaderDoScan method.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount
returned value.
The number of columns of the barcode.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-left corner of a barcode detected by the BarcodePDF417ReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned value.
The barcode X position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-left corner of a barcode detected by the BarcodePDF417ReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned value.
The barcode Y position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-right corner of a barcode detected by the BarcodePDF417ReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned value.
The barcode X position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-right corner of a barcode detected by the BarcodePDF417ReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned value.
The barcode Y position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixel) of the bottom-left corner of a barcode detected by the BarcodePDF417ReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned value.
The barcode X position of the bottom-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-left corner of a barcode detected by the BarcodePDF417ReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the BarcodePDF417ReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-right corner of a barcode detected by the BarcodePDF417ReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodePDF417ReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Releases from memory all information about latest PDF417 barcode detection.
This method is used in the "Barcode Recognition" Demo.
Finding PDF417 barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the PDF417 barcodes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodePDF417ReaderScanMode mode = BarcodePDF417ReaderScanMode.BestSpeed;
// Start the PDF417 barcode scanning process and write info into a text file.
gdpictureImaging.BarcodePDF417ReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("PDF417.txt"))
{
int barcodesFound = gdpictureImaging.BarcodePDF417ReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeValueRAW(i));
// The number of rows of the barcode.
file.WriteLine("Rows = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeRows(i));
// The number of columns of the barcode.
file.WriteLine("Columns = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeColumns(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeConfidence(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodePDF417ReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodePDF417ReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodePDF417ReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodePDF417ReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
A unique image identifier of the GdPicture image representing the image in use.
This method uses the best quality mode for scanning and will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true, to stop the recognition process after one barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the QrCode barcode scanning process using the best quality mode and stop the process after the first QrCode barcode is found.
gdpictureImaging.BarcodeQRReaderDoScan(imageID);
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
This method allows you to set the scanning mode parameter according to your preference.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeAztecReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
This method will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true, to stop the recognition process after one barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode barcode scanning process using and stop the process after the first QrCode barcode is found.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode));
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeAztecReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the maximum number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeAztecReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
If this is true and ExpectedCount > 0, the recognition process stops after first ExpectedCount barcodes were found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of barcode detected by the BarcodeQRReaderDoScan method.
The number of barcode detected.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodeQRReaderDoScan method.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount
returned value.
The barcode data.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value, as RAW Bytes, of a barcode detected by the BarcodeQRReaderDoScan method.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount
returned value.
The barcode data.
Use the GetStat() method to check if this method has completed successfully.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodeQRReaderDoScan method, in its raw format, encoded in a base64 string.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned
value.
The barcode data encoded in base64.
Use the GetStat() method to check if this method has completed successfully.
This method is used in the "Barcode Recognition" Demo.
Returns the confidence of a barcode detected by the BarcodeQRReaderDoScan method.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount
returned value.
The barcode confidence. In the range [(less trust) 0 - 100 (full trust)]
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the angle of a barcode detected by the BarcodeQRReaderDoScan method.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned
value.
The barcode angle in degrees. The angle is measured clockwise relative to the horizontal axis of the image.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the version of a barcode detected by the BarcodeQRReaderDoScan method.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount
returned value.
The version of the barcode.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-left corner of a barcode detected by the BarcodeQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned value.
The barcode X position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-left corner of a barcode detected by the BarcodeQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned value.
The barcode Y position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-right corner of a barcode detected by the BarcodeQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned value.
The barcode X position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-right corner of a barcode detected by the BarcodeQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned value.
The barcode Y position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-left corner of a barcode detected by the BarcodeQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-left corner of a barcode detected by the BarcodeQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned value.
The barcode X position of the bottom-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeQRReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Releases from memory all information about latest QR barcode detection.
This method is used in the "Barcode Recognition" Demo.
Finding QrCodes in an image and writeing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the QrCode scanning process and write complete info into a text file.
gdpictureImaging.BarcodeQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("QrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValue(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeQRReaderGetBarcodeConfidence(i));
// The version of a Qr Code, in range 0-40. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeQRReaderGetVersion(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeQRReaderGetBarcodeSkewAngle(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeQRReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
A unique image identifier of the GdPicture image representing the image in use.
This method uses the best quality mode for scanning and will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and bool StopOnExpectedCount to true, to stop the recognition process after the first barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Start the Micro Qr Code barcode scanning process using the best quality mode and stop the process after the first Micro Qr Code barcode is found.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID);
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
This method allows you to set the scanning mode parameter according to your preference.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeQRReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
This method will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and bool StopOnExpectedCount to true, to stop the recognition process after the first barcode was found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code barcode scanning process and stop the process after the first Micro Qr Code barcode is found.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode);
// Write all available info into a text file.
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeQRReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the maximum number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeQRReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the maximum number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
If this is true and ExpectedCount > 0, the recognition process stops after first ExpectedCount barcodes were found.
For more details, please refer to our Barcode Recognition Sample included
in the installation folder that demonstrates the usage of this method.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of barcode detected by the BarcodeMicroQRReaderDoScan method.
The number of barcode detected.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodeMicroQRReaderDoScan method.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount
returned value.
The barcode data.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the confidence of a barcode detected by the BarcodeMicroQRReaderDoScan method.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount
returned value.
The barcode confidence. In the range [(less trust) 0 - 100 (full trust)]
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the angle of a barcode detected by the BarcodeMicroQRReaderDoScan method.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount returned
value.
The barcode angle in degrees. The angle is measured clockwise relative to the horizontal axis of the image.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the version of a barcode detected by the BarcodeMicroQRReaderDoScan method.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount
returned value.
The version of the barcode.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-left corner of a barcode detected by the BarcodeMicroQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount returned value.
The barcode X position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-left corner of a barcode detected by the BarcodeMicroQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount returned value.
The barcode Y position of the top-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-right corner of a barcode detected by the BarcodeMicroQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount returned value.
The barcode X position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-right corner of a barcode detected by the BarcodeMicroQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount returned value.
The barcode Y position of the top-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeMicroQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-left corner of a barcode detected by the BarcodeMicroQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-left corner of a barcode detected by the BarcodeMicroQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount returned value.
The barcode X position of the bottom-left corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeMicroQRReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMicroQRReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-right corner; relative to the ROI, if any is defined.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Releases from memory all information about latest Micro QR barcode detection.
This method is used in the "Barcode Recognition" Demo.
Finding Micro Qr Code barcodes in an image and writing complete barcodes info into a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the Micro QR Codes in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeQRReaderScanMode mode = BarcodeQRReaderScanMode.BestSpeed;
// Start the Micro Qr Code scanning process and write info into a text file.
gdpictureImaging.BarcodeMicroQRReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MicroQrCodes.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMicroQRReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeValue(i));
// The skew angle of the barcode, in degrees.
file.WriteLine("Skew angle = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeSkewAngle(i));
// Confidence in result, in percentage (values from 0 to 100).
file.WriteLine("Confidence = " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeConfidence(i));
// The version of a Micro Qr Code, in range 1-4. The higher the version, the larger the barcode is.
file.WriteLine("Version = " + gdpictureImaging.BarcodeMicroQRReaderGetVersion(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMicroQRReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMicroQRReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Releases from memory all information about latest MaxiCode detection.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
A unique image identifier of the GdPicture image representing the image in use.
This method uses the best quality mode for scanning and will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true, to stop the recognition process after the first barcode is found.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter according to your preference.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeMaxiCodeReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
This method will try to detect all available barcodes.
You can use the method and set the ExpectedCount parameter to 1 and StopOnExpectedCount to true, to stop the recognition process after the first barcode is found.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
This method requires the Barcode Reading & Writing component to run.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeMaxiCodeReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Starts a barcode recognition process on a specified GdPicture image or on an area of a specified GdPicture image defined by the method.
This method allows you to set the scanning mode parameter as well as to define the required number of barcodes the engine should detect.
This method requires the Barcode Reading & Writing component to run.
Starts a barcode recognition process on a GdPicture image or on an area of a GdPicture image using different parameters according to what you have specified.
A unique image identifier of the GdPicture image representing the image in use.
A member of the BarcodeMaxiCodeReaderScanMode enumeration. The scan mode (speed or quality) used for scanning process.
Specifies the number of barcodes expected to be detected. Use 0 to find all available barcodes within an image.
If this is set to true and ExpectedCount > 0, the recognition process stops after first ExpectedCount barcodes were found.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of barcodes detected by the BarcodeMaxiCodeReaderDoScan method.
The number of barcodes detected.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodeMaxiCodeReaderDoScan method.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode data.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value, as RAW Bytes, of a barcode detected by the BarcodeMaxiCodeReaderDoScan method.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode data.
Use the GetStat() method to determine if this method has been successful.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the value of a barcode detected by the BarcodeMaxiCodeReaderDoScan method, in its raw format, encoded in a base64 string.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode data encoded in base64.
Use the GetStat() method to determine if this method has been successful.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the confidence of a barcode detected by the BarcodeMaxiCodeReaderReaderDoScan method.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderReaderGetBarcodeCount
returned value.
The barcode confidence. In the range [(less trust) 0 - 100 (full trust)]
This method is used in the "Barcode Recognition" Demo.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-left corner of a barcode detected by the BarcodeMaxiCodeReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
Use the GetStat() method to determine if this method has been successful.
The barcode X position of the top-left corner; relative to the ROI, if any is defined.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the top-right corner of a barcode detected by the BarcodeMaxiCodeReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode X position of the top-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeMaxiCodeReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the X position (in pixels) of the bottom-right corner of a barcode detected by the' BarcodeMaxiCodeReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode X position of the bottom-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-left corner of a barcode detected by the BarcodeMaxiCodeReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode Y position of the top-left corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the top-right corner of a barcode detected by the BarcodeAztecReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode Y position of the top-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-right corner of a barcode detected by the BarcodeMaxiCodeReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-right corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the Y position (in pixels) of the bottom-left corner of a barcode detected by the BarcodeMaxiCodeReaderDoScan method.
If ROI has been set, this coordinate is relative to the used ROI.
Barcode index. Must be between 1 and BarcodeMaxiCodeReaderGetBarcodeCount returned value.
The barcode Y position of the bottom-left corner; relative to the ROI, if any is defined.
Use the GetStat() method to determine if this method has been successful.
Finding MaxiCode in an image and writing complete barcodes info in a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Set to 0, so all the MaxiCode in the image should be found.
int expectedBarcodes = 0;
// Perform scanning at best speed, ignoring very damaged barcodes.
BarcodeMaxiCodeReaderScanMode mode = BarcodeMaxiCodeReaderScanMode.BestSpeed;
// Start the MaxiCode scanning process and write info into a text file.
gdpictureImaging.BarcodeMaxiCodeReaderDoScan(imageID, mode, expectedBarcodes);
using (System.IO.StreamWriter file = new System.IO.StreamWriter("MaxiCode.txt"))
{
int barcodesFound = gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeCount();
for (int i = 1; i <= barcodesFound; i++)
{
// Decoded information.
file.WriteLine("Decoded info = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValue(i));
// The raw bytes decoded. It was post-processed to find the correct decoded info based on detected Encoding.
file.WriteLine("Raw bytes = " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeValueRAW(i));
// The barcode position, given by the coordinates of the corners.
file.WriteLine("Position = Top-Left=["
+ gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX1(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY1(i)
+ "] Top-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX2(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY2(i)
+ "] Bottom-Right=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX3(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY3(i)
+ "] Bottom-Left=[" + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeX4(i) + ", " + gdpictureImaging.BarcodeMaxiCodeReaderGetBarcodeY4(i) + "]");
}
}
// Release used resources.
gdpictureImaging.BarcodeMaxiCodeReaderClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Stores into a byte array the Alpha channel values of a GdPicture image or a portion of it.
GdPicture image identifier.
Output parameter. The Alpha channel data.
The left source pixel of the area.
The top source pixel of the area.
The width of the area in pixel.
The height of the area in pixel.
A member of the GdPictureStatus enumeration.
Sets the Alpha channel of a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
The Alpha channel data.
The left source pixel of the area.
The top source pixel of the area.
The width of the area in pixel.
The height of the area in pixel.
A member of the GdPictureStatus enumeration.
Sets a color as transparent in a GdPicture image or in an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
Color to set as transparent. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Sets a color as transparent in a GdPicture image or in area of a GdPicture image defined by SetROI()
method.
This method takes a percentage threshold parameter regarding the color to set as transparent.
Ie: A threshold value of 90 means that all the color value which are within 90% of the color value
parameter will be considered.
GdPicture image identifier.
Color to set as transparent. A suitable color value can be obtained by using the ARGB() method.
Percentage threshold between 0 and 100.
A member of the GdPictureStatus enumeration.
Adds transparency to a GdPicture image or into an area of a GdPicture image defined by SetROI()
method.
This method requires the Image Documents component to run.
GdPicture image identifier.
Value between -255 and 255. 255 means full opacity and -255 means
full transparency.
A member of the GdPictureStatus enumeration.
Creates a new Document Identifier Template from an image file.
The path of the image from which the new template will be created. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
The created template ID if success else, -1 if fail. check the GetStat() method to get the reason
on this result.
Creating two templates and renaming a file using the name of the template which has the best similar content.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateA.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateA");
// Create a template "B".
templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateB.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateB");
// Identify the template which has the best similar content and change the file name accordingly.
templateID = gdpictureImaging.ADRGetCloserTemplateForFile("image.tif");
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
File.Move("image.tif", templateName + "_image.tif");
// Deletes all document identifier templates.
int templateCount = gdpictureImaging.ADRGetTemplateCount();
for (int i = 1; i <= templateCount; i++)
{
templateID = gdpictureImaging.ADRGetTemplateID(1);
gdpictureImaging.ADRDeleteTemplate(templateID);
}
}
Creates a new empty Document Identifier Template. Then, you can add images in this template
using the ADRAddGdPictureImageToTemplate() method.
The created template ID if success else, -1 if fail. check the GetStat() method to get the reason
on this result.
Creates a new Document Identifier Template from a GdPicture image.
GdPicture image identifier. The image from which the new template will be
created.
The created template ID if success else, -1 if fail. check the GetStat() method to get the reason
on this result.
Creating two templates and display the name of the template which has the best similar content to an image file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"templateA.jpg");
int firstTemplateID = gdpictureImaging.ADRCreateTemplateFromGdPictureImage(imageID);
gdpictureImaging.ADRSetTemplateTag(firstTemplateID, "TemplateA");
gdpictureImaging.ReleaseGdPictureImage(imageID);
// Create a template "B".
imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"templateB.jpg");
int secondTemplateID = gdpictureImaging.ADRCreateTemplateFromGdPictureImage(imageID);
gdpictureImaging.ADRSetTemplateTag(secondTemplateID, "TemplateB");
gdpictureImaging.ReleaseGdPictureImage(imageID);
// Identify the template which has the best similar content.
imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"image.jpg");
int templateID = gdpictureImaging.ADRGetCloserTemplateForGdPictureImage(imageID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
MessageBox.Show(templateName, "ADRGetCloserTemplateForGdPictureImage", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Deletes all document identifier templates.
gdpictureImaging.ADRDeleteTemplate(firstTemplateID);
gdpictureImaging.ADRDeleteTemplate(secondTemplateID);
}
Adds an image to a Document Identifier Template from a GdPicture image.
The existing template ID to add the new image.
The image to add to the existing template.
A member of the GdPictureStatus enumeration.
Deletes a Document Identifier Template.
The existing template ID to delete.
True if deleted, else False (unknown template).
Creating two templates and renaming a file using the name of the template which has the best similar content.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateA.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateA");
// Create a template "B".
templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateB.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateB");
// Identify the template which has the best similar content and change the file name accordingly.
templateID = gdpictureImaging.ADRGetCloserTemplateForFile("image.tif");
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
File.Move("image.tif", templateName + "_image.tif");
// Deletes all document identifier templates.
int templateCount = gdpictureImaging.ADRGetTemplateCount();
for (int i = 1; i <= templateCount; i++)
{
templateID = gdpictureImaging.ADRGetTemplateID(1);
gdpictureImaging.ADRDeleteTemplate(templateID);
}
}
Sets a TAG to an existing template.
Tip: this can be the name of the Template Identifier.
An existing template ID.
The tag value. Must be < 256 characters length.
True if success, else False (unknown template).
Creating two templates and renaming a file using the name of the template which has the best similar content.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateA.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateA");
// Create a template "B".
templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateB.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateB");
// Identify the template which has the best similar content and change the file name accordingly.
templateID = gdpictureImaging.ADRGetCloserTemplateForFile("image.tif");
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
File.Move("image.tif", templateName + "_image.tif");
// Deletes all document identifier templates.
int templateCount = gdpictureImaging.ADRGetTemplateCount();
for (int i = 1; i <= templateCount; i++)
{
templateID = gdpictureImaging.ADRGetTemplateID(1);
gdpictureImaging.ADRDeleteTemplate(templateID);
}
}
Loads a complete Template Configuration From a file previously saved with the ADRSaveTemplateConfig()
method.
The path of the template configuration file.
True if success, else False (invalid file content).
Resets the current Template Configuration, if existing (deletes all template identifiers), and
start a new one.
Saves the current Template Configuration within a file in order to load it later using the ADRLoadTemplateConfig()
method.
The path of the template configuration file to create.
True if success, else False (can't create the file or empty template configuration).
Gets a TAG to an existing template.
An existing template ID.
The template TAG value.
Creating two templates and renaming a file using the name of the template which has the best similar content.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateA.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateA");
// Create a template "B".
templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateB.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateB");
// Identify the template which has the best similar content and change the file name accordingly.
templateID = gdpictureImaging.ADRGetCloserTemplateForFile("image.tif");
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
File.Move("image.tif", templateName + "_image.tif");
// Deletes all document identifier templates.
int templateCount = gdpictureImaging.ADRGetTemplateCount();
for (int i = 1; i <= templateCount; i++)
{
templateID = gdpictureImaging.ADRGetTemplateID(1);
gdpictureImaging.ADRDeleteTemplate(templateID);
}
}
Returns the number of images used in a Document Identifier Template.
An existing template ID.
The number of image on which the Document Identifier Template is based.
Returns the current number of Document Identifier Templates.
The number of document identifier templates.
Creating two templates and renaming a file using the name of the template which has the best similar content.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateA.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateA");
// Create a template "B".
templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateB.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateB");
// Identify the template which has the best similar content and change the file name accordingly.
templateID = gdpictureImaging.ADRGetCloserTemplateForFile("image.tif");
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
File.Move("image.tif", templateName + "_image.tif");
// Deletes all document identifier templates.
int templateCount = gdpictureImaging.ADRGetTemplateCount();
for (int i = 1; i <= templateCount; i++)
{
templateID = gdpictureImaging.ADRGetTemplateID(1);
gdpictureImaging.ADRDeleteTemplate(templateID);
}
}
Returns a Document Identifier Template ID from his index.
Template index. Value between 1 and ADRGetTemplateCount().
The Template ID. If TemplateNo is invalid, returns -1.
Creating two templates and renaming a file using the name of the template which has the best similar content.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateA.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateA");
// Create a template "B".
templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateB.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateB");
// Identify the template which has the best similar content and change the file name accordingly.
templateID = gdpictureImaging.ADRGetCloserTemplateForFile("image.tif");
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
File.Move("image.tif", templateName + "_image.tif");
// Deletes all document identifier templates.
int templateCount = gdpictureImaging.ADRGetTemplateCount();
for (int i = 1; i <= templateCount; i++)
{
templateID = gdpictureImaging.ADRGetTemplateID(1);
gdpictureImaging.ADRDeleteTemplate(templateID);
}
}
Performs a Documents Recognition Operation from a GdPicture image and returns the Document
Identifier Template ID which has the best similar content.
This method requires the ADR & OMR component to run.
The GdPicture image.
The Template ID which has the best similar content to the specified image.
Creating two templates and display the name of the template which has the best similar content to an image file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"templateA.jpg");
int firstTemplateID = gdpictureImaging.ADRCreateTemplateFromGdPictureImage(imageID);
gdpictureImaging.ADRSetTemplateTag(firstTemplateID, "TemplateA");
gdpictureImaging.ReleaseGdPictureImage(imageID);
// Create a template "B".
imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"templateB.jpg");
int secondTemplateID = gdpictureImaging.ADRCreateTemplateFromGdPictureImage(imageID);
gdpictureImaging.ADRSetTemplateTag(secondTemplateID, "TemplateB");
gdpictureImaging.ReleaseGdPictureImage(imageID);
// Identify the template which has the best similar content.
imageID = gdpictureImaging.CreateGdPictureImageFromFile(@"image.jpg");
int templateID = gdpictureImaging.ADRGetCloserTemplateForGdPictureImage(imageID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
MessageBox.Show(templateName, "ADRGetCloserTemplateForGdPictureImage", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Deletes all document identifier templates.
gdpictureImaging.ADRDeleteTemplate(firstTemplateID);
gdpictureImaging.ADRDeleteTemplate(secondTemplateID);
}
Performs a Documents Recognition Operation from an image file and returns the Document Identifier
Template ID which has the best similar content.
The path of the image to identify. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
The Template ID which has the best similar content to the specified image.
Creating two templates and renaming a file using the name of the template which has the best similar content.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a template "A".
int templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateA.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateA");
// Create a template "B".
templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateB.tif");
gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateB");
// Identify the template which has the best similar content and change the file name accordingly.
templateID = gdpictureImaging.ADRGetCloserTemplateForFile("image.tif");
string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
File.Move("image.tif", templateName + "_image.tif");
// Deletes all document identifier templates.
int templateCount = gdpictureImaging.ADRGetTemplateCount();
for (int i = 1; i <= templateCount; i++)
{
templateID = gdpictureImaging.ADRGetTemplateID(1);
gdpictureImaging.ADRDeleteTemplate(templateID);
}
}
Returns the Confidence from a specific template obtained during the last Documents Recognition
Operation.
The template ID.
Confidence from specified template. Value between 0 and 100 (identical document).
Returns the Confidence of the closest template obtained during the last Documents Recognition
Operation.
Last Confidence. Value between 0 and 100 (identical document).
Adjust in one shot, the Brightness, Contrast, Saturation & Gamma in a
GdPicture image or in an area of a GdPicture image defined by SetROI() method.
This method is faster than successive calls to any of SetBrightness, SetContrast, SetSaturation
& SetGammaCorrection methods.
GdPicture image identifier.
Brightness adjustment between -100 and 100.
Contrast adjustment between -100 and 100.
Saturation adjustment between -100 and 100.
Gamma adjustment between -100 and 100.
A member of the GdPictureStatus enumeration.
Adjusting the Brightness, Contrast, Saturation and Gamma in an image and saving as a png.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
gdpictureImaging.SetBCSG(imageID, 20, 20, -20, -20);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adjust the Brightness in a GdPicture image or in an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
Brightness adjustment between -100 and 100.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Change image brightness using random value and saves result into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Change image brightness using random value. Allowed values are from -100 to +100.
Random random = new Random();
int brightness = random.Next(-100, 100);
gdpictureImaging.SetBrightness(imageID, brightness);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adjust the Contrast in a GdPicture image or in the area defined by SetROI() method.
GdPicture image identifier.
Contrast adjustment between -100 and 100.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Change image contrast using random value and saves result into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Change image contrast using random value. Allowed values are from -100 to +100.
Random random = new Random();
int contrast = random.Next(-100, 100);
gdpictureImaging.SetContrast(imageID, contrast);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs Gamma Correction in a GdPicture image or in an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
Gamma adjustment between -100 and 100.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing Gamma Correction on an image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Set the gamma intensity [-100;100].
int gamma = 70;
// Apply the gamma value to an image.
gdpictureImaging.SetGammaCorrection(imageID, gamma);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adjust the Saturation in a GdPicture image or in an area of a GdPicture image defined by SetROI() method.
GdPicture image identifier.
Saturation adjustment between -100 and 100.
This filter is not inteneded to alter gray leveled bitmaps, and they will stay the same.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Adjusting the saturation on your image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Set the saturation intensity.
int saturation = 100;
// Apply the saturation to your image.
gdpictureImaging.SetSaturation(imageID, saturation);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Dropout a color from the image.
GdPicture image identifier.
A member of the ColorDropoutFilter enumeration defining the color to remove and the
way to remove it.
A member of the GdPictureStatus enumeration.
Removing form from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Dropout the red pixels from the scan of a red form (pixels are set to white).
gdpictureImaging.FxColorDropout(imageID, ColorDropoutFilter.RedForm);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Copies the defined region of the specified GdPicture image represented by its unique image identifier into the clipboard.
A unique image identifier of the GdPicture image representing the image in use.
The horizontal (X) coordinate of the top left position of the required region, in pixels.
The vertical (Y) coordinate of the top left position of the required region, in pixels.
The width of the required region, in pixels.
The height of the required region, in pixels.
Just to inform you, that this method uses the Clipboard class of the .NET Framework.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Creating a new image from a specified area of an existing image using clipboard.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("");
// Copy the specified region of an image to clipboard.
gdpictureImaging.CopyRegionToClipboard(imageID1, 50, 50, 100, 250);
// Create a new image from clipboard data.
int imageID2 = gdpictureImaging.CreateGdPictureImageFromClipboard();
// Process newly created image.
gdpictureImaging.FxSepia(imageID2);
gdpictureImaging.SaveAsPNG(imageID2, "image.png");
// Release used resources.
gdpictureImaging.DeleteClipboardData();
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Copies the specified GdPicture image represented by its unique image identifier into the clipboard.
A unique image identifier of the GdPicture image representing the image in use.
Just to inform you, that this method uses the Clipboard class of the .NET Framework.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Creating a new image from an existing image using clipboard and processing the newly created image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("");
// Copy the specified region of an image to clipboard.
gdpictureImaging.CopyToClipboard(imageID1);
// Create a new image from clipboard data.
int imageID2 = gdpictureImaging.CreateGdPictureImageFromClipboard();
// Process newly created image.
gdpictureImaging.FxSepia(imageID2);
gdpictureImaging.SaveAsPNG(imageID2, "image.png");
// Release used resources.
gdpictureImaging.DeleteClipboardData();
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Clears the clipboard data after they have been used.
Just to inform you, that this method uses the Clipboard class of the .NET Framework.
Creating a new image from a specified area of an existing image using clipboard.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("");
// Copy the specified region of an image to clipboard.
gdpictureImaging.CopyRegionToClipboard(imageID1, 50, 50, 100, 250);
// Create a new image from clipboard data.
int imageID2 = gdpictureImaging.CreateGdPictureImageFromClipboard();
// Process newly created image.
gdpictureImaging.FxSepia(imageID2);
gdpictureImaging.SaveAsPNG(imageID2, "image.png");
// Release used resources.
gdpictureImaging.DeleteClipboardData();
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Increase or decrease the color components of a GdPicture image or of an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
Value to add to the red component [-255 ; 255].
Value to add to the green component [-255 ; 255].
Value to add to the blue component [-255 ; 255].
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Adjusting the RGB values of the image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg", true);
// Choose the intensity of red, blue and green values between [-255 ; 255].
int redAdjust = 50;
int blueAdjust = 0;
int greenAdjust = 100;
// Adjust the RGB values on your image.
gdpictureImaging.AdjustRGB(imageID, redAdjust, greenAdjust, blueAdjust);
gdpictureImaging.SaveAsJPEG(imageID, "input.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Replaces one color by another on a GdPicture image or into an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
Color to replace. A suitable color value can be obtained by using the ARGB() method.
Color of replacement. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Replaces one color by another on a GdPicture image or into an area of a GdPicture image defined by
SetROI() method.
This method takes a percentage threshold parameter regarding the color to replace.
Ie: A threshold value of 90 means that all the color values which are within 90% of the color value
to replace will be considered.
GdPicture image identifier.
A suitable color value can be obtained by using the ARGBI() method.
Color to replace.
A suitable color value can be obtained by using the ARGBI() method.
Color of replacement.
Percentage threshold between 0 and 100.
A member of the GdPictureStatus enumeration.
Replaces one color by another on a GdPicture image or into an area of a GdPicture image defined by
SetROI() method.
This method takes a percentage threshold parameter regarding the color to replace.
Ie: A threshold value of 90 means that all the color values which are within 90% of the color value
to replace will be considered.
GdPicture image identifier.
Color to replace. A suitable color value can be obtained by using the ARGB() method.
Color of replacement. A suitable color value can be obtained by using the ARGB() method.
Percentage threshold between 0 and 100.
A member of the GdPictureStatus enumeration.
Keeps only the red color component of a GdPicture image or of an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Filtering a jpeg image so only the red component is kept.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Keep only the blue color component.
gdpictureImaging.KeepRedComponent(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Keeps only the green color component of a GdPicture image or of an area of a GdPicture image defined
by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Filtering a jpeg image so only the green component is kept.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Keep only the blue color component.
gdpictureImaging.KeepGreenComponent(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Keeps only the blue color component of a GdPicture image or of an area of a GdPicture image defined
by SetROI() method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Filtering a jpeg image so only the blue component is kept.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Keep only the blue color component.
gdpictureImaging.KeepBlueComponent(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removes the red color component of a GdPicture image or of an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Removing the red component from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Remove the blue color component.
gdpictureImaging.RemoveRedComponent(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removes the green color component of a GdPicture image or of an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Removing the green component from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Remove the blue color component.
gdpictureImaging.RemoveGreenComponent(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removes the blue color component of a GdPicture image or of an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Removing the blue component from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Remove the blue color component.
gdpictureImaging.RemoveBlueComponent(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Scales the blue color component of a GdPicture image or of an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
Scale factor.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Rescaling the blue component in an image and saving as a png.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
gdpictureImaging.ScaleBlueComponent(imageID, 2);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Scales the green color component of a GdPicture image or of an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
Scale factor.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Rescaling the green component in an image and saving as a png.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
gdpictureImaging.ScaleGreenComponent(imageID, 0.5f);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Scales the red color component of a GdPicture image or of an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
Scale factor.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Rescaling the red component in an image and saving as a png.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
gdpictureImaging.ScaleRedComponent(imageID, 2);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Swaps the color components (RGB - > BRG) of a GdPicture image or of an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Swaps the color components (RGB - > GBR) of a GdPicture image or of an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Swaps the color components (RGB - > RBG) of a GdPicture image or of an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Swaps the color components (RGB - > BGR) of a GdPicture image or of an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Swaps the color components (RGB - > GRB) of a GdPicture image or of an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Detects a GdPicture image or the area defined by SetROI() method has pixel with non fully opaque alpha channel.
This method requires the Image Documents component to run.
GdPicture image identifier.
True if transparent pixel are detected, else False.
Use the GetStat() method to check if this method has completed successfully.
Determines whether a GdPicture image or the area defined by SetROI() method is Gray or not.
This method uses a linear formula to determine the color intent. To obtain more accurate result the ColorDetection() method should be used instead.
GdPicture image identifier.
True if it is a grayscale image, else False.
Use the GetStat() method to check if this method has completed successfully.
This method uses a linear formula to determine the color intent. To obtain more accurate result the ColorDetection() method should be used instead.
This method requires the Image Documents component to run.
Determines whether a GdPicture image or the area defined by SetROI() method is composed of black and white pixels only.
This method uses a linear formula to determine the color intent. To obtain more accurate result the ColorDetection() method should be used instead.
GdPicture image identifier.
True if it is a bitonal image, else False.
Use the GetStat() method to check if this method has completed successfully.
This method uses a linear formula to determine the color intent. To obtain more accurate result the ColorDetection() method should be used instead.
Saving an image to tiff ccitt IV or jpeg depending whether it is bitonal or not.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Save the image to tiff ccitt iv in case it is bitonal otherwise save to jpeg.
if (gdpictureImaging.IsBitonal(imageID))
{
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
}
else
{
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Determines whether a GdPicture image or the area defined by SetROI() method is composed of black and white pixels only.
This method uses a linear formula to determine the color intent. To obtain more accurate result the ColorDetection() method should be used instead.
This method accepts a threshold parameter which speaks to the confidence of the detection.
Low Threshold values will require high confidence for the image to be determined as bitonal, and high
values will require low confidence for the image to be determined as bitonal.
GdPicture image identifier.
Threshold between 0 (max confidence) and 765 (min confidence). A value near or
higher than 50 is highly suggested.
Use the GetStat() method to check if this method has completed successfully.
This method uses a linear formula to determine the color intent. To obtain more accurate result the ColorDetection() method should be used instead.
This method requires the Image Documents component to run.
True if it is a bitonal image, else False.
Finding out if an image is bitonal.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Save the image to tiff ccitt iv in case it is bitonal otherwise save to jpeg.
if (gdpictureImaging.IsBitonal(imageID, 0))
{
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
}
else
{
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
if ((gdpictureImaging.GetBitDepth(imageID) == 1) && gdpictureImaging.IsBitonal(imageID, 0))
{
gdpictureImaging.RemoveStapleMark(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
}
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs color detection on an image. Detecting the color scheme can help to dramatically reduce the size of electronically stored documents.
This method requires the MRC - Hyper Compression component to run.
GdPicture image identifier.
Set True to automatically convert the image in its best suited / optimized bits-per-pixel encoding, otherwise False.
This parameter is not used anymore. You can specify any value.
Set True to enable characters repairing during bitonal conversion, if any. This feature is suggested for scanned gray papers acquired in color.
A member of the GdPictureOutputIntent enumeration.
Saving an image to tiff ccitt iv or jpeg depending on the colors used.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp", true);
// Compute the color intent and save to tiff ccitt iv when suitable.
// Save to jpeg when the image is not just black and white.
GdPictureOutputIntent intent = gdpictureImaging.ColorDetection(imageID, true /* AutoConvert*/, true, true /* AutoRepairCharacters */);
switch (intent)
{
case GdPictureOutputIntent.IntentBlackWhite:
case GdPictureOutputIntent.IntentWhite:
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
break;
case GdPictureOutputIntent.IntentGrayscale:
case GdPictureOutputIntent.IntentColor:
case GdPictureOutputIntent.IntentPalletized:
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
break;
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Counts the number of pixel that have a specific color on a GdPicture image or into an area of a
GdPicture image defined by SetROI() method.
This method requires the Image Documents component to run.
GdPicture image identifier.
Color to count. A suitable color value can be obtained by using the ARGB() method.
The number of pixel that match the color.
Use the GetStat() method to check if this method has completed successfully.
Counts the number of unique colors in a GdPicture image or into an area of a GdPicture image defined by SetROI() method.
GdPicture image identifier.
Use the GetStat() method to check if this method has completed successfully.
This method requires the Image Documents component to run.
The number of unique colors.
Showing the number of unique colors on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Count and display the number of colors.
int colorCount = gdpictureImaging.CountUniqueColors(imageID);
MessageBox.Show("Number of unique colors is " + colorCount, "Colors count", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the average color for a GdPicture image or for an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
The average color.
Use the GetStat() method to check if this method has completed successfully.
Specifies if color correction is used for images embedding an ICC profile. False by default.
Enables ICM results in automatic pixel transformation while opening image including an ICC profile.
This parameter only affects image subsequently opened from this same GdPictureImaging object.
Use True to enable color correction, otherwise False.
Applying ICM correction when saving CMYK based image as a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
string filePath = "image.jpg";
if (gdpictureImaging.IsCMYKFile(filePath))
{
// Enable color correction.
gdpictureImaging.EnableICM(true);
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(filePath);
gdpictureImaging.SaveAsTIFF(imageID, "output.tiff", true, TiffCompression.TiffCompressionJPEG, 90);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
}
Returns a new GdPicture image based on the Cyan channel of the CMYK color space of a GdPicture
image.
GdPicture image identifier.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
According to Wikipedia, CMYK (short for cyan, magenta, yellow, and key) is a subtractive color model
used in color printing.
This color model is based on mixing pigments of the following colors in order to make other colors:
* C = Cyan.
* M = Magenta.
* Y = Yellow.
* K = Key (Black).
CMYK is the standard color model used in offset printing for full-color documents. CMYK, or
four-color printing, generates a good final printout with excellent contrast.
Returns a new GdPicture image based on the Magenta channel of the CMYK color space of a GdPicture
image.
GdPicture image identifier.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
According to Wikipedia, CMYK (short for cyan, magenta, yellow, and key) is a subtractive color model
used in color printing.
This color model is based on mixing pigments of the following colors in order to make other colors:
* C = Cyan.
* M = Magenta.
* Y = Yellow.
* K = Key (Black).
CMYK is the standard color model used in offset printing for full-color documents. CMYK, or
four-color printing, generates a good final printout with excellent contrast.
Returns a new GdPicture image based on the Yellow channel of the CMYK color space of a GdPicture
image.
GdPicture image identifier.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
According to Wikipedia, CMYK (short for cyan, magenta, yellow, and key) is a subtractive color model
used in color printing.
This color model is based on mixing pigments of the following colors in order to make other colors:
* C = Cyan.
* M = Magenta.
* Y = Yellow.
* K = Key (Black).
CMYK is the standard color model used in offset printing for full-color documents. CMYK, or
four-color printing, generates a good final printout with excellent contrast.
Returns a new GdPicture image based on the Key (Black) channel of the CMYK color space of a
GdPicture image.
GdPicture image identifier.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
According to Wikipedia, CMYK (short for cyan, magenta, yellow, and key) is a subtractive color model
used in color printing.
This color model is based on mixing pigments of the following colors in order to make other colors:
* C = Cyan.
* M = Magenta.
* Y = Yellow.
* K = Key (Black).
CMYK is the standard color model used in offset printing for full-color documents. CMYK, or
four-color printing, generates a good final printout with excellent contrast.
Applies a specific RGB color profile to a GdPicture image without embedding the color profile
information. Therefore, only image pixels will be modified according to the profile information. If
you need to embed an ICC profile to an image file the ICCAddFromFile() method must be
used.
This method requires the Image Documents component to run.
GdPicture image identifier.
The path of the ICC profile file to apply.
A member of the GdPictureStatus enumeration.
Exports the ICC profile of a GdPicture image to a file.
This method requires the Image Documents component to run.
GdPicture image identifier.
The path of the ICC profile file to create.
A member of the GdPictureStatus enumeration.
Exports the ICC profile of a GdPicture image to an array of bytes.
GdPicture image identifier.
A byte array containing the attached profile, if any.
Use the GetStat() method to determine if the method succeeded.This method requires the Image Documents component to run.
This method requires the Image Documents component to run.
Deletes the ICC profile embedded within a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Attaches an ICC profile from a file to a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
The path of the ICC profile file.
A member of the GdPictureStatus enumeration.
Attaches an ICC profile from an array of bytes to a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
The ICC profile strored within an array of bytes.
A member of the GdPictureStatus enumeration.
Asks if a GdPicture image gets an embedded ICC profile.
This method requires the Image Documents component to run.
GdPicture image identifier.
True if a GdPicture image embeddes ICC profile, else False.
Removes the ICC profile embedded into an image file. This method permits to conserve the input cmyk color model, if any.
The path of the image.
A member of the GdPictureStatus enumeration.
Supported image formats are tiff, jpeg, j2k, jp2, webp and png.This method requires the Image Documents component to run.
Adds/replaces an ICC profile of an existing image file. Supported formats are TIFF, JPEG and PNG images.
This method requires the Image Documents component to run.
The path of the TIFF, JPEG or PNG image.
The path of the ICM color profil to add to the image.
A member of the GdPictureStatus enumeration.
Applies a color-remap table to a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Array which specifies the color remap table. Each entry is a
Imaging.ColorMap oGdPictureImaging.
A member of the GdPictureStatus enumeration.
Replacing shades of red by shades of blue within a an image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Create the table.
System.Drawing.Imaging.ColorMap[] RemapTable = new System.Drawing.Imaging.ColorMap[256];
for (int index = 0; index < 256; index++)
{
System.Drawing.Imaging.ColorMap remap = new System.Drawing.Imaging.ColorMap();
remap.NewColor = Color.FromArgb(0, 0, index);
remap.OldColor = Color.FromArgb(index, 0, 0);
RemapTable[index] = remap;
}
// Apply the table.
gdpictureImaging.SetColorRemap(imageID, RemapTable);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Sets the color key (transparency range) for a specified category on a GdPicture image.
This method sets the high and low color-key values so that a range of colors can be made
transparent.
Any color that has each of its three components (red, green, blue) between the corresponding
components of the high and low color keys is made transparent.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the low color-key value. A suitable color value can be obtained by using the ARGB() method.
Specifies the high color-key value. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Sets a color of a palette as transparent.
If the specified color is not present into the palette this will be added if the number of entries
is lower than 256.
GdPicture image identifier.
Color to set as transparent. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Converting a bmp to a png and setting white as transparent color.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp", false);
// Convert to an 8-bit indexed color image using a standard color palette, set white as transparent and save to png.
gdpictureImaging.ConvertTo8Bpp216(imageID);
gdpictureImaging.PaletteSetTransparentColor(imageID, Color.White);
gdpictureImaging.SaveAsPNG(imageID, "image.png", 6, false);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Gets the transparency color of an indexed GdPicture image.
GdPicture image identifier.
The transparent color of the palette.
Determines whether a GdPicture image has a color defined as transparent.
GdPicture image identifier.
True is a GdPicture image has a color defined as transparent else false.
Gets the type of color palette used by a GdPicture image.
GdPicture image identifier.
Type of palette. A member of the PaletteType enumeration.
Returns the number of colors contained into the color palette of a GdPicture image.
GdPicture image identifier.
Number of Imaging.Colors.
Determining the palette entries count of the selected image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.IsPixelFormatIndexed(imageID))
{
int entriesCount = gdpictureImaging.PaletteGetColorsCount(imageID);
Console.WriteLine("Image contains palete with {0} color entries.", entriesCount.ToString());
}
else Console.WriteLine("Image do not contain indexed colors!");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.IsPixelFormatIndexed(imageID))
{
int entriesCount = gdpictureImaging.PaletteGetColorsCount(imageID);
if (entriesCount > 255)
{
System.Drawing.Color entryColor = gdpictureImaging.PaletteGetEntry(imageID, 130);
Console.WriteLine("Color value of palette entry [130] is: {0}", entryColor.ToString());
}
else Console.WriteLine("Image do not contain palette with 256 colors!");
}
else Console.WriteLine("Image do not contain indexed colors!");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the color of a specific entry of the palette of a GdPicture image.
Index of the color palette. Must be a value between 0 and
PaletteGetColorsCount() - 1 returned value.
GdPicture image identifier.
Color of the selected entry.
Getting information about the specific palette entry of the selected image and showing the result on the screen.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.IsPixelFormatIndexed(imageID))
{
int entriesCount = gdpictureImaging.PaletteGetColorsCount(imageID);
if (entriesCount > 255)
{
System.Drawing.Color entryColor = gdpictureImaging.PaletteGetEntry(imageID, 130);
Console.WriteLine("Color value of palette entry [130] is: {0}", entryColor.ToString());
}
else Console.WriteLine("Image do not contain palette with 256 colors!");
}
else Console.WriteLine("Image do not contain indexed colors!");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the color of a specific entry of the palette of a GdPicture image.
GdPicture image identifier.
Index of the color palette to swap with the second. Must be a value between 0
and PaletteGetColorsCount() - 1 returned value.
Index of the color palette to swap with the first. Must be a value between 0
and PaletteGetColorsCount() - 1 returned value.
A member of the GdPictureStatus enumeration.
Opening a B&W indexed image, swapping palette entries and saving the result into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.PaletteGetColorsCount(imageID) == 2)
{
// Swapping palette entries in B&W image means that the image will be inverted.
gdpictureImaging.PaletteSwapEntries(imageID, 0, 1);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
}
else Console.WriteLine("The loaded image is not of B&W type!");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Sets a new color palette to a GdPicture image.
GdPicture image identifier.
Output parameter. Array of Color Objects. Color entries of the
palette.
A member of the GdPictureStatus enumeration.
Gets into a 1D array the complete color palette of a GdPicture image.
GdPicture image identifier.
Output parameter. Array of Color Objects. Color array which will contain
the complete color palette.
Output parameter. Contains the number of colors contained in the
ColorEntries() array.
A member of the GdPictureStatus enumeration.
Storing the color palette into the array and showing information about entries count.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.IsPixelFormatIndexed(imageID))
{
System.Drawing.Color[] palette = null;
int entriesCount = 0;
gdpictureImaging.PaletteGet(imageID, ref palette, ref entriesCount);
Console.WriteLine("Image contains palete with {0} color entries.", entriesCount.ToString());
}
else Console.WriteLine("Image do not contain indexed colors!");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 1-bit (black and white) bitmap using a variant of the WAN local thresholding method.
This method requires the Image Documents component to run.
GdPicture image identifier.
Value between [0 and 254]. Specifies the aggressiveness of the method. Suggested value is 51. Higher is the value, whiter the resulting bitmap will be.
Converts a GdPicture image to a 1-bit (black and white) bitmap using a variant of the Otsu adaptive thresholding method. This method is particularly efficient on documents with contrasted foreground and background.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converting the image to black and white using a variant of the Otsu adaptive thresholding methods.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
//Convert to black and white.
gdpictureImaging.ConvertTo1BppAT(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 1-bit (black and white) bitmap using a variant of the Otsu adaptive thresholding method. This method is particularly efficient on documents with contrasted foreground and background.
This method requires the Image Documents component to run.
GdPicture image identifier.
Thresholding for determining the foreground. Must be a value between 0 and 100. Suggested value is 50. Higher is the Thresold value darker should be the resulting image.
A member of the GdPictureStatus enumeration.
Converting the image to black and white using a variant of the Otsu adaptive thresholding methods.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
//Convert to black and white.
gdpictureImaging.ConvertTo1BppAT(imageID, 45);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 1-bit (black and white) bitmap using a modified Bradley adaptive thresholding method.
This method requires the Image Documents component to run.
GdPicture image identifier.
Value between [0 and 254]. Specifies the aggressiveness of the method. Suggested value is 38. Higher is the value, whiter the resulting bitmap will be.
A member of the GdPictureStatus enumeration.
Converting the image to black and white using a modified Bradley adaptive thresholding methods.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Specify the aggressiveness of the method. The higher value, the whiter the result.
byte threshold = 120;
// Convert to black and white.
gdpictureImaging.ConvertTo1BppBradley(imageID, threshold);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 1-bit (black and white) bitmap using the Sauvola local adaptive thresholding method. This method is particularly efficient on documents with poor contrast.
This method requires the Image Documents component to run.
GdPicture image identifier.
Factor of thresholding reduction. Must be a balue in tha range ]0 ; 1. Suggested value is 0.35. Higher is the factor value lighter should be the resulting image.
A member of the GdPictureStatus enumeration.
Converts selected image to a 1-bit BW indexed color image, and saves result into a TIF file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.ConvertTo1BppSauvola(imageID, 0.35f);
gdpictureImaging.SaveAsTIFF(imageID, "output.tif", TiffCompression.TiffCompressionAUTO);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 1-bit (black and white) bitmap using the Sauvola local adaptive thresholding method and contrast normalization. This method is particularly efficient on documents with poor contrast.
This method requires the Image Documents component to run.
GdPicture image identifier.
Factor of thresholding reduction. Must be a balue in tha range ]0 ; 1. Suggested value is 0.35. Higher is the factor value lighter should be the resulting image.
This method segments the image in tiles and tries to adjust the contrast in each tiles. If the contrast in a tile is smaller than ContrastMinDif, it uses the minimum and maximum pixel values from neighbor tiles. The value must be in the range [0 - 255] and the suggested one is 50.
The half-width of the kernel used to smooth the minimum and maximum values of each tiles, in the range [0 (no smoothing) - 5]. Suggested value is 2, higer value should help to remove background parasites on poorly contrasted images.
A member of the GdPictureStatus enumeration.
Converts selected image to a 1-bit BW indexed color image, and saves result into a TIF file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.ConvertTo1BppSauvola(imageID, 0.35f, 50, 2);
gdpictureImaging.SaveAsTIFF(imageID, "output.tif", TiffCompression.TiffCompressionAUTO);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 1-bit BW indexed color image.
The color table has 2 entries: 1 Black & 1 White.
GdPicture image identifier.
Is equivalent to ConvertTo1Bpp(ImageID, 160).
A member of the GdPictureStatus enumeration.
Converts selected image to a 1-bit BW indexed color image, and saves result into a TIF file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.ConvertTo1Bpp(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "output.tif", TiffCompression.TiffCompressionAUTO);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 1-bit BW indexed color image specifying a threshold value.
The color table has 2 entries: 1 Black & 1 White.
This method requires the Image Documents component to run.
GdPicture image identifier.
Value between [1 and 255]. Pixels values less than Threshold will be turned black, values equal to or larger till be turned white.
If you do not know what to choose, select 160 which is the suggested value.
The pixel value of colored pixels is computed via the following formula: PixValue = (0.2126F * r + 0.7152F * g + 0.0722F * b)
A member of the GdPictureStatus enumeration.
Converts selected image to a 1-bit BW indexed color image, and saves result into a TIF file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.ConvertTo1Bpp(imageID, 160);
gdpictureImaging.SaveAsTIFF(imageID, "output.tif", TiffCompression.TiffCompressionAUTO);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 1-bit BW indexed color image specifying a threshold value. This method assumes that the input image is already black and white.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converts a GdPicture image to a 4-bit indexed color image using a standard color palette.
The color table has 16 entries.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converts a GdPicture image to a 4-bit indexed color image using custom color palette.
The color table has a maximum of 16 entries.
GdPicture image identifier.
Array of Color Objects. All color entries of the palette.
A member of the GdPictureStatus enumeration.
Quantizes & converts a GdPicture image to a 4-bit indexed color image.
The color table has a maximum of 16 entries.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Color image quantization is a process that reduces the number of distinct colors used in an image,
usually with the intention that the new image should be as visually similar as possible to the
original image.
Converts bitonal images to an enhanced 8-bit gray-scaled indexed color image.
The color table has 256 entries.
GdPicture image identifier.
Soften factor between 1 and 100.
A member of the GdPictureStatus enumeration.
Converts a GdPicture image to an 8-bit gray-scaled indexed color image.
The color table has 256 entries.
GdPicture image identifier.
This method uses a basic grayscale color reduction algorithm, where all three color channels rgb have the weight.
A member of the GdPictureStatus enumeration.
Converts selected image to an 8-bit gray-scaled indexed color image, and saves result into a TIF file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.ConvertTo8BppGrayScale(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "output.tif", TiffCompression.TiffCompressionAUTO);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to an 8-bit gray-scaled indexed color image.
This method uses an advanced grayscale color reduction algorithm.
The color table has 256 entries.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
The algorithm used uses the following formula based on the rgb color channel values 0.2126F * r + 0.7152F * g + 0.0722F * b.
Greyscaling narutal images works better with this method than with ConvertTo8BppGrayScale().
This method requires the Image Documents component to run.
Converts a GdPicture image to an 8-bit indexed color image using a standard color palette.
This method uses an automatic segmentation components algorithm.
The color table has a maximum of 256 entries but only 216 will be used.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converting a bmp to a png and setting white as transparent color.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp", false);
// Convert to an 8-bit indexed color image using a standard color palette, set white as transparent and save to png.
gdpictureImaging.ConvertTo8Bpp216(imageID);
gdpictureImaging.PaletteSetTransparentColor(imageID, Color.White);
gdpictureImaging.SaveAsPNG(imageID, "image.png", 6, false);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Quantizes & converts a GdPicture image to an 8-bit indexed color image. This method uses a
color quantization algorithm.
The color table has a maximum of 256 entries.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Color image quantization is a process that reduces the number of distinct colors used in an image,
usually with the intention that the new image should be as visually similar as possible to the
original image.
Quantizes & converts a GdPicture image to an 8-bit indexed color image with a desired number of
colors. This method uses a color quantization algorithm.
The color table has a maximum of 256 entries.
GdPicture image identifier.
The number of max. distinct colors to use into the new image. [2 - 256]
A member of the GdPictureStatus enumeration.
Color image quantization is a process that reduces the number of distinct colors used in an image,
usually with the intention that the new image should be as visually similar as possible to the
original image.
Converts a GdPicture image to a 16-bit RGB555 color image.
5 bits each are used for the red, green, and blue components. The remaining bit is not used.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converts a GdPicture image to a 16-bit RGB565 color image.
5 bits are used for the red component, 6 bits are used for the green component, and 5 bits are used
for the blue component.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converts a GdPicture image to a 24-bit color image.
8 bits each are used for the red, green, and blue components.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converting an image to a 24-bit RGB color image and saving the result into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
// Convert the image to 24-bit RGB color format. Any transparency will be lost.
gdpictureImaging.ConvertTo24BppRGB(imageID);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 32-bit ARGB color image.
8 bits each are used for the alpha, red, green, and blue components.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converting a selected image to a 32-bit ARGB color image and saving the result into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
// Convert the image.
gdpictureImaging.ConvertTo32BppARGB(imageID);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 32-bit RGB color image.
8 bits each are used for the red, green, and blue components, and the last 8 bits are neglected.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converting a selected image to a 32-bit RGB color image and saving the result into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
// Convert image to 32-bit RGB color format. Any transparency will be lost.
gdpictureImaging.ConvertTo32BppRGB(imageID);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Converts a GdPicture image to a 32-bit PARGB color image.
8 bits each are used for the alpha, red, green, and blue components. The red, green, and blue
components are premultiplied, according to the alpha component.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converts a GdPicture image to a 48-bit RGB color image.
16 bits each are used for the red, green, and blue components.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converts a GdPicture image to a 64-bit ARGB color image.
16 bits each are used for the alpha, red, green, and blue components.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Converts a GdPicture image to a 64-bit PARGB color image.
16 bits each are used for the alpha, red, green, and blue components. The red, green, and blue
components are premultiplied according to the alpha component.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Releases the specified GdPicture image represented by its unique image identifier from memory.
Please note, that the toolkit does not release created images automatically, so releasing images after they have been used is mandatory.
A unique image identifier of the GdPicture image representing the image to release.
It is always a best practice to release images you have created once you have no use for them.
Be aware, that releasing images is mandatory, the toolkit does not release them automatically in any way.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
Performing a negative effect on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
gdpictureImaging.FxNegative(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image and initializes it with a copy of the content of the specified GdPicture image, that is represented by its unique image identifier.
The newly created image is identified by its unique non-zero image identifier and it is independent of the defined source image.
Please note that it is your responsibility to release the image resources once you have no use for them.
A unique image identifier of the GdPicture image representing the source image to clone.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware, that if the source image is a multi-bitmap image, this method will clone only the currently selected bitmap (the current page) and it will create a single frame image.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Cloning an existing GdPicture image to a new one.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create two duplicate gdpicture images from the input file.
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
int imageID2 = gdpictureImaging.CreateClonedGdPictureImage(imageID1);
// Process both of your images (differently).
gdpictureImaging.FxFire(imageID1);
gdpictureImaging.FxNegative(imageID2);
// Save your images in the same multipage tif file.
gdpictureImaging.TiffSaveAsMultiPageFile(imageID1, "images.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffAddToMultiPageFile(imageID1, imageID2);
gdpictureImaging.TiffCloseMultiPageFile(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a tiff with the first page.
int tiffImageID = gdpictureImaging.CreateClonedGdPictureImage(dcmImageID);
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, "image.tif", TiffCompression.TiffCompressionAUTO);
// Add the remaining pages as additional pages to the tif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, dcmImageID, TiffCompression.TiffCompressionAUTO);
}
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Creates a new 32-bit ARGB GdPicture image and initializes it with a copy of the content of the specified GdPicture image,
that is represented by its unique image identifier. The newly created image is identified by its unique non-zero image identifier and it is independent of the defined source image.
Please note that it is your responsibility to release the image resources once you have no use for them.
A unique image identifier of the GdPicture image representing the source image to clone.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware, that if the source image is a multi-bitmap image, this method will clone only the currently selected bitmap (the current page) and it will create a single frame image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creates a new 24-bit RGB GdPicture image and initializes it with a copy of the content of the specified GdPicture image,
that is represented by its unique image identifier. The newly created image is identified by its unique non-zero image identifier and it is independent of the defined source image.
Please note that it is your responsibility to release the image resources once you have no use for them.
A unique image identifier of the GdPicture image representing the source image to clone.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware, that if the source image is a multi-bitmap image, this method will clone only the currently selected bitmap (the current page) and it will create a single frame image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creates a new 32-bit PARGB GdPicture image and initializes it with a copy of the content of the specified GdPicture image,
that is represented by its unique image identifier. The newly created image is identified by its unique non-zero image identifier and it is independent of the defined source image.
Please note that it is your responsibility to release the image resources once you have no use for them.
Be aware that 8 bits are used for each of the alpha, red, green, and blue components. The red, green, and blue components are pre-multiplied, according to the alpha component.
Just to inform you, that this pixel format provides better performances on Windows applications.
A unique image identifier of the GdPicture image representing the source image to clone.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware, that if the source image is a multi-bitmap image, this method will clone only the currently selected bitmap (the current page) and it will create a single frame image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creates a new GdPicture image from the defined area of the specified GdPicture image, that is represented by its unique image identifier.
The newly created image is identified by its unique non-zero image identifier and it is independent of the defined source image.
Please note that it is your responsibility to release the image resources once you have no use for them.
A unique image identifier of the GdPicture image representing the source image, from which the specified area will be cloned.
The horizontal (X) coordinate of the top left position of the required area to clone, in pixels.
The vertical (Y) coordinate of the top left position of the required area to clone, in pixels.
The width of the required area to clone, in pixels.
The height of the required area to clone, in pixels.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware, that if the source image is a multi-bitmap image, this method will clone the defined area only from the currently selected bitmap
(the current page) and it will create a single frame image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Cloning an area of a jpeg image into a new jpeg image using streams.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, "image.jpg");
//Clone an area of the source image into a mew image.
int imageID2 = gdpictureImaging.CreateClonedGdPictureImageArea(imageID1, 50, 50, 100, 250);
//Process the cloned image.
gdpictureImaging.FxPixelize(imageID2);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.png", System.IO.FileMode.CreateNew))
{
//Save a result into a new image file.
gdpictureImaging.SaveAsStream(imageID2, outputStream, GdPicture14.DocumentFormat.DocumentFormatPNG, 6);
}
gdpictureImaging.ReleaseGdPictureImage(imageID2);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
}
}
Creates a new GdPicture image from an image file stored within an area of the memory.
A pointer to the area of the memory which stores the document.
The length in byte of the area.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
Notes for multipage images (TIFF and GIF):
By default, the class loads multipage images (GIF and TIFF) in read & write mode.
To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images.
This method requires the Image Documents component to run.
Creates a new GdPicture image from an image file stored as an array of bytes.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new GdPicture image from an image file stored as an array of bytes.
The image data stored in the array of bytes. This object must be initialized with the proper image data and it must be disposed of by the user as well.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All document formats currently supported by the toolkit are listed here.
This class loads multipage images (GIF and TIFF formats) in read-write mode by default.
If you want to open multipage images in read-only mode, you need to call the method for GIF format
and the method for TIFF format and set the WriteAccess parameter to false before creating an image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creating a GdPicture image from an image file stored as an array of bytes and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
using (Stream stream = File.Open("image.jpg", FileMode.Open))
{
// Load the file to an array of bytes for the sake of demonstration.
// In a production context, the image file should be obviously loaded with CreateGdPictureImageFromFile.
int size = (int)stream.Seek(0, SeekOrigin.End);
byte[] buffer = new byte[size];
stream.Seek(0, SeekOrigin.Begin);
stream.Read(buffer, 0, size);
// Create the GdPicture image and save it as a PNG.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(buffer);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image from an image file stored as an array of bytes. You can specify the image format using this method.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new GdPicture image from an image file stored as an array of bytes.
The image data stored in the array of bytes. This object must be initialized with the proper image data and it must be disposed of by the user as well.
A member of the DocumentFormat enumeration. Specifies an image file format.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All document formats currently supported by the toolkit are listed here.This class loads multipage images (GIF and TIFF formats) in read-write mode by default.
If you want to open multipage images in read-only mode, you need to call the method for GIF format
and the method for TIFF format and set the WriteAccess parameter to false before creating an image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creating a GdPicture image from an image file stored as an array of bytes and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
using (Stream stream = File.Open("image.jpg", FileMode.Open))
{
// Load the file to an array of bytes for the sake of demonstration.
// In a production context, the image file should be obviously loaded with CreateGdPictureImageFromFile.
int size = (int)stream.Seek(0, SeekOrigin.End);
byte[] buffer = new byte[size];
stream.Seek(0, SeekOrigin.Begin);
stream.Read(buffer, 0, size);
// Create the GdPicture image and save it as a PNG.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(buffer, GdPicture14.DocumentFormat.DocumentFormatJPEG);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new native GdPicture image from the clipboard content. The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that this method uses the Clipboard class of the .NET Framework.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creating a new image from a specified area of an existing image using clipboard.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("");
// Copy the specified region of an image to clipboard.
gdpictureImaging.CopyRegionToClipboard(imageID1, 50, 50, 100, 250);
// Create a new image from clipboard data.
int imageID2 = gdpictureImaging.CreateGdPictureImageFromClipboard();
// Process newly created image.
gdpictureImaging.FxSepia(imageID2);
gdpictureImaging.SaveAsPNG(imageID2, "image.png");
// Release used resources.
gdpictureImaging.DeleteClipboardData();
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Creates a new GdPicture image from an instantiated Device Independent Bitmap (DIB) handle provided as an integer value.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
A pointer to a Microsoft® Windows® Graphics Device Independent Bitmap (DIB) handle, as an integer value.
This pointer must be initialized with the proper image data and it must be disposed of by the user as well.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that created GdPicture image will use its own pixel allocation.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creates a new GdPicture image from an instantiated Device Independent Bitmap (DIB) handle provided as IntrPtr.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new GdPicture image from an instantiated Device Independent Bitmap (DIB) handle.
A pointer to a Microsoft® Windows® Graphics Device Independent Bitmap (DIB) handle, as an IntPtr value.
This pointer must be initialized with the proper image data and it must be disposed of by the user as well.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that created GdPicture image will use its own pixel allocation.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creating a GdPicture image from a dib and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
using (Stream stream = File.Open("image.bmp", FileMode.Open))
{
// Load a dib from a bitmap file the sake of demonstration.
// A dib is a bmp without its header.
const int bmpHeaderSize = 14;
int dibSize = (int)stream.Seek(0, SeekOrigin.End) - bmpHeaderSize;
byte[] buffer = new byte[dibSize];
stream.Seek(bmpHeaderSize, SeekOrigin.Begin);
stream.Read(buffer, 0, dibSize);
// Create a dib with the content of the buffer.
IntPtr dibPointer = MemoryUtils.Malloc(dibSize);
Marshal.Copy(buffer, 0, dibPointer, dibSize);
// Create the GdPicture image and save it as a PNG.
int imageID = gdpictureImaging.CreateGdPictureImageFromDIB(dibPointer);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
MemoryUtils.Free(dibPointer);
}
Specifies how this object should subsequently open RAW image.
A combination of members of the RAWImageLoadingOptions enumeration. Default value is Display.
Creates a new GdPicture image representing the image based on an input image file. The file content is not loaded into memory using this method.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new GdPicture image representing the image based on an input image file according to what you have specified.
The file path of the input image file. Use the empty string to allow the control to prompt users to select a file.
You can subsequently use the method to retrieve the path of the selected file.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All document formats currently supported by the toolkit are listed here.
This class loads multipage images (GIF and TIFF formats) in read-write mode by default.
If you want to open multipage images in read-only mode, you need to call the method for GIF format
and the method for TIFF format and set the WriteAccess parameter to false before creating an image.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image resource with the method after being used.
Creating a GdPicture image from an image file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
gdpictureImaging.FxNegative(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm");
// Create a tiff with the first page.
int tiffImageID = gdpictureImaging.CreateClonedGdPictureImage(dcmImageID);
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, "image.tif", TiffCompression.TiffCompressionAUTO);
// Add the remaining pages as additional pages to the tif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, dcmImageID, TiffCompression.TiffCompressionAUTO);
}
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Creates a new GdPicture image representing the image based on an input image file according to what you have specified. You can also specify if the file content is loaded into memory or not using this method.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new GdPicture image representing the image based on an input image file according to what you have specified.
The file path of the input image file. Use the empty string to allow the control to prompt users to select a file.
You can subsequently use the method to retrieve the path of the selected file.
Specifies if the document content will be loaded into memory (true). Loading the document content directly into memory results
in a better manipulation performance, but it consumes more memory. If you load a file into memory, you can subsequently overwrite or delete the file.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All document formats currently supported by the toolkit are listed here.This class loads multipage images (GIF and TIFF formats) in read-write mode by default.
If you want to open multipage images in read-only mode, you need to call the method for GIF format
and the method for TIFF format and set the WriteAccess parameter to false before creating an image.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image resource with the method after being used.
Creating a GdPicture image from an image file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
gdpictureImaging.FxNegative(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Detect and remove the white margins using the default confidence level.
gdpictureImaging.CropWhiteBorders(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image representing the image based on an input image file.
You can also specify if the file content is loaded into memory or not using this method together with enabling or disabling the direct access setting.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new GdPicture image representing the image based on an input image file according to what you have specified.
The file path of the input image file. Use the empty string to allow the control to prompt users to select a file.
You can subsequently use the method to retrieve the path of the selected file.
Specifies if the document content will be loaded into memory (true). Loading the document content directly into memory results
in a better manipulation performance, but it consumes more memory. If you load a file into memory, you can subsequently overwrite or delete the file.
Setting this parameter to true causes to load only image properties, metadata and an embedded thumbnail.
This parameter is particularly useful when you need to only obtain image information without decoding the image itself.
Be aware that all subsequent calls to the methods requiring pixel access using this image resource will fail.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All document formats currently supported by the toolkit are listed here.
This class loads multipage images (GIF and TIFF formats) in read-write mode by default.
If you want to open multipage images in read-only mode, you need to call the method for GIF format
and the method for TIFF format and set the WriteAccess parameter to false before creating an image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image resource with the method after being used.
Creates a new GdPicture image based on a metafile image file.
The path of the file to open.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Supported formats are EMF, WMF and SVG.
Creates a new GdPicture image based on a metafile image file and scaling it by multiplying the image size by a
specified factor.
The path of the file to open. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Multiplies the image size by a specified factor.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Supported formats are EMF, WMF and SVG.
This method requires the Image Documents component to run.
Creates a new GdPicture image from an instantiated HBitmap object based on Microsoft® Windows® Graphics Device Interface (GDI),
provided as an integer value. The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
A pointer to a HBitmap object based on Microsoft® Windows® Graphics Device Interface (GDI), as an integer value.
This pointer must be initialized with the proper image data and it must be disposed of by the user as well.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that created GdPicture image will use its own pixel allocation.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creates a new GdPicture image from an instantiated HBitmap object based on Microsoft® Windows® Graphics Device Interface (GDI),
provided as an IntPtr value. The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new GdPicture image from an instantiated Graphics Device Interface (GDI) handle.
A pointer to a HBitmap object based on Microsoft® Windows® Graphics Device Interface (GDI), as an IntPtr value.
This pointer must be initialized with the proper image data and it must be disposed of by the user as well.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that created GdPicture image will use its own pixel allocation.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creating a GdPicture image from GDI bitmap and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
using (Bitmap bmpScreenCapture = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height))
using (Graphics graphics = Graphics.FromImage(bmpScreenCapture))
{
graphics.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, bmpScreenCapture.Size, CopyPixelOperation.SourceCopy);
int imageID = gdpictureImaging.CreateGdPictureImageFromHBitmap(bmpScreenCapture.GetHbitmap());
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image from an image data stored in a System.Drawing.Bitmap object.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
A System.Drawing.Bitmap object that contains the image data to load.
This object must be initialized with the proper image data and it must be disposed of by the user as well.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creates a new GdPicture image from four separated GdPicture images (1bpp or 8bpp), where each individual image represents
the Cyan, Magenta, Yellow, and Black channel of a resulting image. Each of these images, as well as the newly created image, is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
A unique image identifier of the GdPicture image representing the Cyan channel of the initial image to recompose.
A unique image identifier of the GdPicture image representing the Magenta channel of the initial image to recompose.
A unique image identifier of the GdPicture image representing the Yellow channel of the initial image to recompose.
A unique image identifier of the GdPicture image representing the Black channel of the initial image to recompose.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that the source images must be only 1-bit per pixel or 8-bit per pixel.
For 1-bpp source images, the resulting image will be 8-bpp, otherwise, a 24-bpp resulting image will be created.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creates a new GdPicture image from an instantiated Windows handle to icon provided as an integer value.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
A Windows handle to an icon, as an integer value.
This pointer must be initialized with the proper image data and it must be disposed of by the user as well.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that created GdPicture image will use its own pixel allocation.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creates a new GdPicture image from an instantiated Windows handle to icon provided as an IntPtr value.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new GdPicture image from an instantiated Windows handle to icon.
A Windows handle to an icon, as an IntPtr value.
This pointer must be initialized with the proper image data and it must be disposed of by the user as well.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that created GdPicture image will use its own pixel allocation.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Creating a GdPicture image from an icon handle and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Icon icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetEntryAssembly().Location);
// Create the GdPicture image and save it as a PNG.
int imageID = gdpictureImaging.CreateGdPictureImageFromHICON(icon.Handle);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image from a window handle HWnd.
A Window Handle, as Integer value. This must be a top-level window or a child of
a top level window.
You can get the Windows Desktop hwnd with the GetDesktopHwndI method.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creating a GdPicture image from a Window handle and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromHwnd(gdpictureImaging.GetDesktopHwndI());
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image from a window handle HWnd.
A Window Handle, as IntPtr value. This must be a top-level window or a child of
a top level window.
You can get the Windows Desktop hwnd with the GetDesktopHwnd method.
This method requires the Image Documents component to run.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creating a GdPicture image from a Window handle and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromHwnd(Process.GetCurrentProcess().MainWindowHandle);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image from raw bitmap in memory.
Specifies the width, in pixels, of the bitmap.
Specifies the height, in pixels, of the bitmap.
Specifies the byte offset between the beginning of one scan line and the
next. This is usually (but not necessarily) the number of bytes in the
pixel format (for example, 2 for 16 bit per pixel) multiplied by the
width of the bitmap. The value passed to this parameter must be a multiple
of four.
Specifies the pixel format of the bitmap. A member of the PixelFormat
enumeration.
Pointer to an array of bytes that contains the pixel data. The caller is
responsible for allocating and freeing the block of memory pointed to by
this parameter.
Warning: Do not remove the raw bitmap from the memory until you delete the created GdPicture image.
This method requires the Image Documents component to run.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creating a GdPicture image from raw bits and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a buffer to store 8x8 pixels and change the color of a diagonal.
byte[] bytes = new byte[64];
int index = 0;
while (index < 64)
{
bytes[index] = 0xff;
index += 9;
}
// Copy the managed buffer to and unmanaged buffer.
IntPtr unmanagedPointer = MemoryUtils.Malloc(bytes.Length);
Marshal.Copy(bytes, 0, unmanagedPointer, bytes.Length);
int imageID = gdpictureImaging.CreateGdPictureImageFromRawBits(8, 8, 8, System.Drawing.Imaging.PixelFormat.Format8bppIndexed, unmanagedPointer);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
MemoryUtils.Free(unmanagedPointer);
}
Creates a new GdPicture image from an image stored into a Stream Object.
System.IO.Stream object storing the image data.
The provided stream must support seeking.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
Notes for multipage images (TIFF and GIF):
By default, the class loads multipage images (GIF and TIFF) in read & write mode.
To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images.
If the image is a multipage file (TIFF, JBIG2, GIFF), the stream should be kept open until the image is released.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creating images using streams.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromStream(inputStream);
//Clone an area of the source image into a mew image.
int imageID2 = gdpictureImaging.CreateClonedGdPictureImageArea(imageID1, 50, 50, 100, 250);
//Process the cloned image.
gdpictureImaging.FxPixelize(imageID2);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.png", System.IO.FileMode.CreateNew))
{
//Save a result into a new image file.
gdpictureImaging.SaveAsStream(imageID2, outputStream, GdPicture14.DocumentFormat.DocumentFormatPNG, 6);
}
gdpictureImaging.ReleaseGdPictureImage(imageID2);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
}
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
string filePath = "image.jpg";
if (gdpictureImaging.IsCMYKFile(filePath))
{
// Enable color correction.
gdpictureImaging.EnableICM(true);
using (System.IO.Stream inputStream = new System.IO.FileStream(filePath, System.IO.FileMode.Open))
{
int imageID = gdpictureImaging.CreateGdPictureImageFromStream(inputStream);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.tiff", System.IO.FileMode.CreateNew))
{
gdpictureImaging.SaveAsTIFF(imageID, outputStream, true, TiffCompression.TiffCompressionJPEG, 90);
}
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
}
}
Creates a new GdPicture image from an image stored into a Stream Object. This method uses a GdPicture DocumentFormat enumerator.
System.IO.Stream object storing the image data.
A member of the DocumentFormat enumeration specifying the input image format.
The provided stream must support seeking.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
Notes for multipage images (TIFF and GIF):
By default, the class loads multipage images (GIF and TIFF) in read & write mode.
To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images.
If the image is a multipage file (TIFF, JBIG2, GIFF), the stream should be kept open until the image is released.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Cloning an area of a jpeg image into a new jpeg image using streams.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, GdPicture14.DocumentFormat.DocumentFormatJPEG);
//Clone an area of the source image into a mew image.
int imageID2 = gdpictureImaging.CreateClonedGdPictureImageArea(imageID1, 50, 50, 100, 250);
//Process the cloned image.
gdpictureImaging.FxPixelize(imageID2);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.png", System.IO.FileMode.CreateNew))
{
//Save a result into a new image file.
gdpictureImaging.SaveAsStream(imageID2, outputStream, GdPicture14.DocumentFormat.DocumentFormatPNG, 6);
}
gdpictureImaging.ReleaseGdPictureImage(imageID2);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
}
}
Creates a new GdPicture image from an image stored into a Stream Object. This method uses a GdPicture DocumentFormat enumerator.
System.IO.Stream object storing the image data.
A member of the DocumentFormat enumeration specifying the input image format.
When True, only image properties, metadata and embedded thumbnail will be loaded.
This parameter is particularly useful to obtain image information's without decoding it. Be careful not to call subsequent methods that need to access pixel data if this parameter is set to True.
The provided stream must support seeking.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
Notes for multipage images (TIFF and GIF):
By default, the class loads multipage images (GIF and TIFF) in read & write mode.
To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images.
If the image is a multipage file (TIFF, JBIG2, GIFF), the stream should be kept open until the image is released.
This method requires the Image Documents component to run.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creates a new GdPicture image from an image stored into a Stream Object. This method uses a GdPicture DocumentFormat enumerator.
System.IO.Stream object storing the image data.
The initial name of the file stored in the Stream object. IE: myfile.tif. The document format will be automatically detected based on this file name.
The provided stream must support seeking.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
Notes for multipage images (TIFF and GIF):
By default, the class loads multipage images (GIF and TIFF) in read & write mode.
To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images.
If the image is a multipage file (TIFF, JBIG2, GIFF), the stream should be kept open until the image is released.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creating images using streams.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, "image.jpg");
//Clone an area of the source image into a mew image.
int imageID2 = gdpictureImaging.CreateClonedGdPictureImageArea(imageID1, 50, 50, 100, 250);
//Process the cloned image.
gdpictureImaging.FxPixelize(imageID2);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.png", System.IO.FileMode.CreateNew))
{
//Save a result into a new image file.
gdpictureImaging.SaveAsStream(imageID2, outputStream, GdPicture14.DocumentFormat.DocumentFormatPNG, 6);
}
gdpictureImaging.ReleaseGdPictureImage(imageID2);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
}
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
string filePath = "image.jpg";
if (gdpictureImaging.IsCMYKFile(filePath))
{
// Enable color correction.
gdpictureImaging.EnableICM(true);
using (System.IO.Stream inputStream = new System.IO.FileStream(filePath, System.IO.FileMode.Open))
{
int imageID = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, filePath);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.tiff", System.IO.FileMode.CreateNew))
{
gdpictureImaging.SaveAsTIFF(imageID, outputStream, true, TiffCompression.TiffCompressionJPEG, 90);
}
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
}
}
Creates a new GdPicture image from an image stored into an IStream Object.
An IStream object storing the image data.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
Notes for multipage images (TIFF and GIF):
By default, the class loads multipage images (GIF and TIFF) in read & write mode.
To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creates a new GdPicture image from an image stored into an IStream Object.
An IStream object storing the image data.
When True, only image properties, metadata and embedded thumbnail will be loaded.
This parameter is particularly useful to obtain image information's without decoding it. Be careful not to call subsequent methods that need to access pixel data if this parameter is set to True.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
Notes for multipage images (TIFF and GIF):
By default, the class loads multipage images (GIF and TIFF) in read & write mode.
To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creates a new GdPicture image from an image stored into an IStream Object.
An IStream object storing the image data.
When True, only image properties, metadata and embedded thumbnail will be loaded.
This parameter is particularly useful to obtain image information's without decoding it. Be careful not to call subsequent methods that need to access pixel data if this parameter is set to True.
A member of the DocumentFormat enumeration specifying the input image format.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
Notes for multipage images (TIFF and GIF):
By default, the class loads multipage images (GIF and TIFF) in read & write mode.
To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images.
This method requires the Image Documents component to run.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creates a new GdPicture image from image data stored within string data (Encoding 1252).
String which contains the image file data.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
Notes for multipage images (TIFF and GIF):
By default, the class loads multipage images (GIF and TIFF) in read & write mode.
To open multipage images in read-only mode call the TiffOpenMultiPageForWrite() method specifying False for tiff images or the GifOpenMultiFrameForWrite() method for gif images.
This method requires the Image Documents component to run.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creating a GdPicture image from an image file stored in a string and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
using (Stream stream = File.Open("image.bmp", FileMode.Open))
{
// Load the file to a buffer for the sake of demonstration.
// In a production context, the image file should be obviously loaded with CreateGdPictureImageFromFile.
int size = (int)stream.Seek(0, SeekOrigin.End);
byte[] buffer = new byte[size];
stream.Seek(0, SeekOrigin.Begin);
stream.Read(buffer, 0, size);
// Encode the buffer to a string
string encodedBuffer = Encoding.GetEncoding(1252).GetString(buffer, 0, size);
// Create the GdPicture image and save it as a PNG.
int imageID = gdpictureImaging.CreateGdPictureImageFromString(encodedBuffer);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image from a file stored on a distant server using FTP protocol according to what you have specified.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
The name of the host server, where the file is located, for example ftp.gdpicture.com.
The file path of the image on the host server, for example /demo/image.jpg.
The user's login required to authenticate on the server.
The user's password required to authenticate on the server.
The FTP port number used. It is usually 21.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All document formats currently supported by the toolkit are listed here.This class loads multipage images (GIF and TIFF formats) in read-write mode by default.
If you want to open multipage images in read-only mode, you need to call the method for GIF format
and the method for TIFF format and set the WriteAccess parameter to false before creating an image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Use the method to diagnose the error if this method has failed with one of the GdPictureStatus.Internet... errors.Be aware that you need to release the image with the method after being used.
Creates a new GdPicture image from an image file stored on a distant server using HTTP protocol according to what you have specified.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
The name of the host server, where the image file is located, for example www.gdpicture.com.
The file path of the image file on the host server, for example /demo/image.jpg.
The HTTP port number used. Usually 80 or 443 to use https transfer mode.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All document formats currently supported by the toolkit are listed here.This class loads multipage images (GIF and TIFF formats) in read-write mode by default.
If you want to open multipage images in read-only mode, you need to call the method for GIF format
and the method for TIFF format and set the WriteAccess parameter to false before creating an image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Use the method to diagnose the error if this method has failed with one of the GdPictureStatus.Internet... errors.Be aware that you need to release the image with the method after being used.
Creating a GdPicture image from an image file stored on a distant server using HTTP protocol and saving to a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromHTTP("https://upload.wikimedia.org", "wikipedia/commons/2/21/Hello_World_Brian_Kernighan_1978.jpg", 443);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image from an image file stored on a distant server using HTTP protocol according to what you have specified.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new GdPicture image from an image file stored on a distant server using HTTP protocol according to what you have specified.
The full URI path with the full image file name, where the file is located, for example http://www.gdpicture.com/demo/image.jpg .
The login required to authenticate on the server. It can be an empty string.
The password required to authenticate on the server. It can be an empty string.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All document formats currently supported by the toolkit are listed here.This class loads multipage images (GIF and TIFF formats) in read-write mode by default.
If you want to open multipage images in read-only mode, you need to call the method for GIF format
and the method for TIFF format and set the WriteAccess parameter to false before creating an image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Use the method to diagnose the error if this method has failed with one of the GdPictureStatus.Internet... errors.Be aware that you need to release the image with the method after being used.
Creates a new empty GdPicture image with specific dimensions, bit depth (bits per pixel), and a background color.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new empty GdPicture image with specific dimensions, the required bit depth (bits per pixel) or pixel format, and a background color.
The width, in pixels, of the newly created image.
The height, in pixels, of the newly created image.
The required bit depth of the newly created image.
A color object that defines the background color of the newly created image. This parameter is ignored for indexed bitmap.
You can obtain a suitable color using the one of the ARGB() overloads.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image resource with the method after being used.
Rendering an image with a circle onto the background image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Color backColor = gdpictureImaging.ARGB(255, 0, 255, 0); // Green color
Color circleColor = gdpictureImaging.ARGB(255, 255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGB(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Creates a new empty GdPicture image with specific dimensions, bit depth (bits per pixel), and a background color.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
The width, in pixels, of the newly created image.
The height, in pixels, of the newly created image.
The required bit depth of the newly created image.
A color value that defines the background color of the newly created image. This parameter is ignored for indexed bitmap.
You can obtain a suitable color using the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image resource with the method after being used.
Rendering an image with a circle onto the background image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int backColor = gdpictureImaging.ARGBI(255, 0, 255, 0); // Green color
int circleColor = gdpictureImaging.ARGBI(255, 255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGBI(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Creates a new empty GdPicture image with specific dimensions, bit depth (bits per pixel), and a background color.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Creates a new empty GdPicture image with specific dimensions, the required bit depth (bits per pixel) or pixel format, and a background color.
The width, in pixels, of the newly created image.
The height, in pixels, of the newly created image.
A member of the PixelFormat enumeration. The required pixel format of the newly created image.
A color object that defines the background color of the newly created image. This parameter is ignored for indexed bitmap.
You can obtain a suitable color using the one of the ARGB() overloads.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image resource with the method after being used.
Creates a new empty GdPicture image with specific dimensions, bit depth (bits per pixel), and a background color.
The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
The width, in pixels, of the newly created image.
The height, in pixels, of the newly created image.
A member of the PixelFormat enumeration. The required pixel format of the newly created image.
A color value that defines the background color of the newly created image. This parameter is ignored for indexed bitmap.
You can obtain a suitable color using the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created.
Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image resource with the method after being used.
Checks if a GdPicture image is a multipage DICOM image.
GdPicture image identifier. The image to check.
True if the image is a multipage DICOM image, else false.
Testing whether a dicom document is multipage or not.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
if (gdpictureImaging.DicomIsMultiPage(imageID))
{
MessageBox.Show("Dicom is multipage.", "DicomIsMultiPage", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Dicom is not multipage.", "DicomIsMultiPage", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of pages currently available in a multipage DICOM image.
GdPicture image identifier. The multipage DICOM image.
Number of pages currently available in the multipage DICOM image. Returns 0 if the image is not a
multipage DICOM image.
Finding out the number of pages in a dicom document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Save each and every image to a jpeg.
int pageCount = gdpictureImaging.DicomGetPageCount(imageID);
for (int pageNo = 1; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(imageID, pageNo);
gdpictureImaging.SaveAsJPEG(imageID, "image" + pageNo.ToString() + ".jpg", 75);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a gif with the first page.
int gifImageID = gdpictureImaging.GifCreateMultiFrameFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional frames to the gif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.GifAppendFrameFromGdPictureImage(gifImageID, dcmImageID);
}
gdpictureImaging.GifSaveMultiFrameToFile(gifImageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(gifImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Selects a page of a multipage DICOM image. The page can now be edited or saved to a different file.
GdPicture image identifier. The multipage DICOM image.
Page number between 1 and page count.
A member of the GdPictureStatus enumeration.
Selecting pages of a dicom document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Save each and every image to a jpeg.
int pageCount = gdpictureImaging.DicomGetPageCount(imageID);
for (int pageNo = 1; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(imageID, pageNo);
gdpictureImaging.SaveAsJPEG(imageID, "image" + pageNo.ToString() + ".jpg", 75);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a gif with the first page.
int gifImageID = gdpictureImaging.GifCreateMultiFrameFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional frames to the gif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.GifAppendFrameFromGdPictureImage(gifImageID, dcmImageID);
}
gdpictureImaging.GifSaveMultiFrameToFile(gifImageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(gifImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Returns the number of available tags in a DICOM image.
GdPicture image identifier. The DICOM image.
0: No tag or error. Use the GetStat() method to determine the reason this method failed.
Non-zero: The number of available tags.
Reading the tags from a dicom document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Write in a report all the tags available within the file.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.DicomGetTagsCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
string tagDescription = gdpictureImaging.DicomGetTagDescription(imageID, tagNo);
string tagValue = gdpictureImaging.DicomGetTagValue(imageID, tagNo);
report.AppendLine(tagDescription.ToString() + " " + tagValue.ToString());
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Tags", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns the value, as string, of a specific tag available in a DICOM image.
GdPicture image identifier. The DICOM image.
The tag index. Must be a value in the range 0 ; DicomGetTagsCount() -1.
The value of the specified tag.
Use the GetStat() method to determine if the method succeeded.
Reading the tags from a dicom document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Write in a report all the tags available within the file.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.DicomGetTagsCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
string tagDescription = gdpictureImaging.DicomGetTagDescription(imageID, tagNo);
string tagValue = gdpictureImaging.DicomGetTagValue(imageID, tagNo);
report.AppendLine(tagDescription.ToString() + " " + tagValue.ToString());
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Tags", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns the description, as string, of a specific tag available in a DICOM image.
GdPicture image identifier. The DICOM image.
The tag index. Must be a value in the range 0 ; DicomGetTagsCount() -1.
The description of the specified tag.
Use the GetStat() method to determine if the method succeeded.
Reading the tags from a dicom document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Write in a report all the tags available within the file.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.DicomGetTagsCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
string tagDescription = gdpictureImaging.DicomGetTagDescription(imageID, tagNo);
string tagValue = gdpictureImaging.DicomGetTagValue(imageID, tagNo);
report.AppendLine(tagDescription.ToString() + " " + tagValue.ToString());
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Tags", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns the group identifier of a specific tag available in a DICOM image.
GdPicture image identifier. The DICOM image.
The tag index. Must be a value in the range 0 ; DicomGetTagsCount() -1.
The group identifier of the specified tag.
Use the GetStat() method to determine if the method succeeded.
Returns the element identifier of a specific tag available in a DICOM image.
GdPicture image identifier. The DICOM image.
The tag index. Must be a value in the range 0 ; DicomGetTagsCount() -1.
The element identifier of the specified tag.
Use the GetStat() method to determine if the method succeeded.
Returns the default window level of a DICOM image.
GdPicture image identifier. The DICOM image.
The default window level.
Use the GetStat() method to determine if the method succeeded.
Returns the last window level applied to a DICOM image.
GdPicture image identifier. The DICOM image.
The window level.
Use the GetStat() method to determine if the method succeeded.
Returns the default window width of a DICOM image.
GdPicture image identifier. The DICOM image.
Use the GetStat() method to determine if the method succeeded.
The default window width.
Saving the first page of a dicom document to jpeg using different window levels.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Read the dicom properties.
float windowWidth = gdpictureImaging.DicomGetDefaultWindowWidth(imageID);
float windowLevel = gdpictureImaging.DicomGetMinWindowLevel(imageID);
float maxWindowLevel = gdpictureImaging.DicomGetMaxWindowLevel(imageID);
// Save different views as jpeg.
float step = (maxWindowLevel - windowLevel) / 10;
while (windowLevel <= maxWindowLevel)
{
gdpictureImaging.DicomSetWindowLevel(imageID, windowWidth, windowLevel);
gdpictureImaging.SaveAsJPEG(imageID, "image" + windowLevel.ToString() + ".jpg", 75);
windowLevel += step;
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the last window width applied to a DICOM image.
GdPicture image identifier. The DICOM image.
The last window width.
Use the GetStat() method to determine if the method succeeded.
Returns the maximum window width of a DICOM image.
GdPicture image identifier. The DICOM image.
Use the GetStat() method to determine if the method succeeded.
The maximum window width.
Saving the first page of a dicom document to jpeg using different window widths.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Read the dicom properties.
float windowWidth = gdpictureImaging.DicomGetDefaultWindowWidth(imageID);
float maxWindowWidth = gdpictureImaging.DicomGetMaxWindowWidth(imageID);
float windowLevel = gdpictureImaging.DicomGetDefaultWindowLevel(imageID);
// Save different views as jpeg.
float step = (maxWindowWidth - windowWidth) / 10;
while (windowWidth <= maxWindowWidth)
{
gdpictureImaging.DicomSetWindowLevel(imageID, windowWidth, windowLevel);
gdpictureImaging.SaveAsJPEG(imageID, "image" + windowWidth.ToString() + ".jpg", 75);
windowWidth += step;
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the maximum window level of a DICOM image.
GdPicture image identifier. The DICOM image.
The maximum window level.
Use the GetStat() method to determine if the method succeeded.
Saving the first page of a dicom document to jpeg using different window levels.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Read the dicom properties.
float windowWidth = gdpictureImaging.DicomGetDefaultWindowWidth(imageID);
float windowLevel = gdpictureImaging.DicomGetMinWindowLevel(imageID);
float maxWindowLevel = gdpictureImaging.DicomGetMaxWindowLevel(imageID);
// Save different views as jpeg.
float step = (maxWindowLevel - windowLevel) / 10;
while (windowLevel <= maxWindowLevel)
{
gdpictureImaging.DicomSetWindowLevel(imageID, windowWidth, windowLevel);
gdpictureImaging.SaveAsJPEG(imageID, "image" + windowLevel.ToString() + ".jpg", 75);
windowLevel += step;
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the minimum window level of a DICOM image.
GdPicture image identifier. The DICOM image.
The minimum window level.
Use the GetStat() method to determine if the method succeeded.
Saving the first page of a dicom document to jpeg using different window levels.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Read the dicom properties.
float windowWidth = gdpictureImaging.DicomGetDefaultWindowWidth(imageID);
float windowLevel = gdpictureImaging.DicomGetMinWindowLevel(imageID);
float maxWindowLevel = gdpictureImaging.DicomGetMaxWindowLevel(imageID);
// Save different views as jpeg.
float step = (maxWindowLevel - windowLevel) / 10;
while (windowLevel <= maxWindowLevel)
{
gdpictureImaging.DicomSetWindowLevel(imageID, windowWidth, windowLevel);
gdpictureImaging.SaveAsJPEG(imageID, "image" + windowLevel.ToString() + ".jpg", 75);
windowLevel += step;
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Changes the current window level of a DICOM image by applying VOI LUT transformation.
GdPicture image identifier. The DICOM image.
The window width. Should be a value in the range 1 ; DicomGetMaxWindowWidth().
The window level. Should be a value in the range DicomGetMinWindowLevel() ; DicomGetMaxWindowLevel().
A member of the GdPictureStatus enumeration.
An example of this method can be seen on the DICOM Viewer demo application.
Saving the first page of a dicom document to jpeg using different window levels.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Read the dicom properties.
float windowWidth = gdpictureImaging.DicomGetDefaultWindowWidth(imageID);
float windowLevel = gdpictureImaging.DicomGetMinWindowLevel(imageID);
float maxWindowLevel = gdpictureImaging.DicomGetMaxWindowLevel(imageID);
// Save different views as jpeg.
float step = (maxWindowLevel - windowLevel) / 10;
while (windowLevel <= maxWindowLevel)
{
gdpictureImaging.DicomSetWindowLevel(imageID, windowWidth, windowLevel);
gdpictureImaging.SaveAsJPEG(imageID, "image" + windowLevel.ToString() + ".jpg", 75);
windowLevel += step;
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a 1D barcode on a GdPicture image.
GdPicture image identifier.
A member of the Barcode1DWriterType enumeration.
The data of the barcode to encode.
Left pixel destination of to top-left corner of bounding box the barcode.
Top pixel destination of to top-left corner of bounding box of the
barcode.
Width of the bounding box of the barcode.
Height of the bounding box of the barcode.
Color of the barcode. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Rendering a 1D barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
int dstLeft = 10;
int dstTop = 10;
int dstWidth = 300; //Barcode width
int dstHeight = 80; //Barcode height
// Select the 1D barcode type.
Barcode1DWriterType barcodeType = Barcode1DWriterType.Barcode1DWriterStandard2of5;
int imageID = gdpictureImaging.CreateNewGdPictureImage(20 + dstWidth, 20 + dstHeight, 32, Color.White);
gdpictureImaging.Barcode1DWrite(imageID, barcodeType, data, dstLeft, dstTop, dstWidth, dstHeight, gdpictureImaging.ARGB(0, 0, 0));
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a 1D barcode on a GdPicture image. This method accepts a parameter to specify the barcode
alignment into the specified bounding box. The default alignment is centered.
GdPicture image identifier.
A member of the Barcode1DWriterType enumeration.
The data of the barcode to encode.
Left pixel destination of to top-left corner of bounding box the barcode.
Top pixel destination of to top-left corner of bounding box of the
barcode.
Width of the bounding box of the barcode.
Height of the bounding box of the barcode.
Color of the barcode. A suitable color value can be obtained by using the ARGB() method.
A member of the BarcodeAlign enumeration.
A member of the GdPictureStatus enumeration.
Rendering a centered 1D barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
int dstLeft = 10;
int dstTop = 10;
int dstWidth = 300; // Barcode width
int dstHeight = 80; // Barcode height
// Select the 1D barcode type.
Barcode1DWriterType barcodeType = Barcode1DWriterType.Barcode1DWriterStandard2of5;
int imageID = gdpictureImaging.CreateNewGdPictureImage(20 + dstWidth, 20 + dstHeight, 32, Color.White);
gdpictureImaging.Barcode1DWrite(imageID, barcodeType, data, dstLeft, dstTop, dstWidth, dstHeight, gdpictureImaging.ARGB(0, 0, 0), BarcodeAlign.BarcodeAlignCenter);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a 1D barcode on a GdPicture image. This method accepts a parameter to specify rotation and
another to specify the barcode alignment with the specified bounding box. The default alignment is
centered.
This method requires the Barcode Reading & Writing component to run.
GdPicture image identifier.
A member of the Barcode1DWriterType enumeration.
The data of the barcode to encode.
Left pixel destination of to top-left corner of bounding box the
barcode.
Top pixel destination of to top-left corner of bounding box of the
barcode.
Width of the bounding box of the barcode.
Height of the bounding box of the barcode.
Color of the barcode. A suitable color value can be obtained by using the ARGBI() method.
A member of the BarcodeAlign enumeration.
The rotation of the barcode in degrees.
A member of the GdPictureStatus enumeration.
Rendering a centered and rotated 1D barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
int dstLeft = 10;
int dstTop = 10;
int dstWidth = 300; // Barcode width
int dstHeight = 80; // Barcode height
// Select the 1D barcode type.
Barcode1DWriterType barcodeType = Barcode1DWriterType.Barcode1DWriterStandard2of5;
int imageID = gdpictureImaging.CreateNewGdPictureImage(20 + dstWidth, 20 + dstHeight, 32, Color.White);
gdpictureImaging.Barcode1DWrite(imageID, barcodeType, data, dstLeft, dstTop, dstWidth, dstHeight, gdpictureImaging.ARGBI(0, 0, 0), BarcodeAlign.BarcodeAlignCenter, 90);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a 1D barcode on a GdPicture image. This method accepts a parameter to specify rotation and
another to specify the barcode alignment with the specified bounding box. The default alignment is
centered.
GdPicture image identifier.
A member of the Barcode1DWriterType enumeration.
The data of the barcode to encode.
Left pixel destination of to top-left corner of bounding box the
barcode.
Top pixel destination of to top-left corner of bounding box of the
barcode.
Width of the bounding box of the barcode.
Height of the bounding box of the barcode.
Color of the barcode. A suitable color value can be obtained by using the ARGB() method.
A member of the BarcodeAlign enumeration.
The rotation of the barcode in degrees.
A member of the GdPictureStatus enumeration.
Rendering a centered and rotated 1D barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
int dstLeft = 10;
int dstTop = 10;
int dstWidth = 300; // Barcode width
int dstHeight = 80; // Barcode height
// Select the 1D barcode type.
Barcode1DWriterType barcodeType = Barcode1DWriterType.Barcode1DWriterStandard2of5;
int imageID = gdpictureImaging.CreateNewGdPictureImage(20 + dstWidth, 20 + dstHeight, 32, Color.White);
gdpictureImaging.Barcode1DWrite(imageID, barcodeType, data, dstLeft, dstTop, dstWidth, dstHeight, gdpictureImaging.ARGB(0, 0, 0), BarcodeAlign.BarcodeAlignCenter, 90);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the size, in pixels, required to render a QrCode on a Bitmap.
The data of the barcode to encode.
A member of the BarcodeQREncodingMode enumeration. The encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
Ref. parameter. The version of the QrCode. In the range 0 - 40. Specifies the overall dimensions of the symbol.Use 0 to let the engine decide and return the minimum version required to encode all data.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode.
QR Code requires a four-module wide margin at all sides of a symbol. Consequently a value superior or equal to 4 is highly suggested.
The size of each module, in pixels. A value superior or equal to 4 is recommended.
You can use the GetStat method to determine if the method succeeded.
The size, in pixels, required to render a QrCode.
Rendering a QrCode to a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String that have to be encoded into a barcode.
string data = "Encoding Qr Code";
BarcodeQREncodingMode encodingMode = BarcodeQREncodingMode.BarcodeQREncodingModeUndefined;
BarcodeQRErrorCorrectionLevel errorCorrectionLevel = BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM;
int version = 0;
int moduleSize = 7;
int quietZone = 4;
int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
// Compute size (in pixels), required to render a Qr Code.
int size = gdpictureImaging.BarcodeQRGetSize(data, encodingMode, errorCorrectionLevel, out version, quietZone, moduleSize);
int imageID = gdpictureImaging.CreateNewGdPictureImage(size, size, 32, Color.White);
gdpictureImaging.BarcodeQRWrite(imageID, data, encodingMode, errorCorrectionLevel, version, quietZone, moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "QrCode.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a QrCode barcode on a GdPicture image.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeQREncodingMode enumeration. The encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
The version of the QrCode. In the range 0 - 40. Specifies the overall dimensions of the symbol. Use 0 to let the engine decide the minimum version required to encode all data.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode.
QR Code requires a four-module wide margin at all sides of a symbol. Consequently a value superior or equal to 4 is highly suggested.
The size of each module, in pixels. A value superior or equal to 4 is recommended.
The left position, in pixels, of the QrCode.
The top position, in pixels, of the QrCode.
The QrCode angle.
Color of the symbols. A suitable color value can be obtained by using the ARGBI() method.
Color of the background. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Rendering a QrCode to a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String that have to be encoded into a barcode.
string data = "Encoding Qr Code";
BarcodeQREncodingMode encodingMode = BarcodeQREncodingMode.BarcodeQREncodingModeUndefined;
BarcodeQRErrorCorrectionLevel errorCorrectionLevel = BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM;
int version = 0;
int moduleSize = 7;
int quietZone = 4;
int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
// Compute size (in pixels), required to render a Qr Code.
int size = gdpictureImaging.BarcodeQRGetSize(data, encodingMode, errorCorrectionLevel, out version, quietZone, moduleSize);
int imageID = gdpictureImaging.CreateNewGdPictureImage(size, size, 32, Color.White);
gdpictureImaging.BarcodeQRWrite(imageID, data, encodingMode, errorCorrectionLevel, version, quietZone, moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "QrCode.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a QrCode barcode on a GdPicture image.
This method requires the Barcode Reading & Writing component to run.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeQREncodingMode enumeration. The encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
The version of the QrCode. In the range 0 - 40. Specifies the overall dimensions of the symbol. Use 0 to let the engine decide the minimum version required to encode all data.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode.
QR Code requires a four-module wide margin at all sides of a symbol. Consequently a value superior or equal to 4 is highly suggested.
The size of each module, in pixels. A value superior or equal to 4 is recommended.
The left position, in pixels, of the QrCode.
The top position, in pixels, of the QrCode.
The QrCode angle.
Color of the symbols. A suitable color value can be obtained by using the ARGB() method.
Color of the background. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Rendering a QrCode to a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String that have to be encoded into a barcode.
string data = "Encoding Qr Code";
BarcodeQREncodingMode encodingMode = BarcodeQREncodingMode.BarcodeQREncodingModeUndefined;
BarcodeQRErrorCorrectionLevel errorCorrectionLevel = BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM;
int version = 0;
int moduleSize = 7;
int quietZone = 4;
Color fillColor = gdpictureImaging.ARGB(255, 0, 0, 0);
Color backColor = gdpictureImaging.ARGB(0, 255, 255, 255);
// Compute size (in pixels), required to render a Qr Code.
int size = gdpictureImaging.BarcodeQRGetSize(data, encodingMode, errorCorrectionLevel, out version, quietZone, moduleSize);
int imageID = gdpictureImaging.CreateNewGdPictureImage(size, size, 32, Color.White);
gdpictureImaging.BarcodeQRWrite(imageID, data, encodingMode, errorCorrectionLevel, version, quietZone, moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "QrCode.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the size, in pixels, required to render a Micro QrCode on a Bitmap.
The data of the barcode to encode.
A member of the BarcodeQREncodingMode enumeration. The encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
Ref. parameter. The version of the QrCode. In the range 0 - 4. Specifies the overall dimensions of the symbol.Use 0 to let the engine decide and return the minimum version required to encode all data.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode.
QR Code requires a four-module wide margin at all sides of a symbol. Consequently a value superior or equal to 4 is highly suggested.
The size of each module, in pixels. A value superior or equal to 4 is recommended.
You can use the GetStat method to determine if the method succeeded.
The size, in pixels, required to render a Micro QrCode.
Draws a Micro QrCode barcode on a GdPicture image.
This method requires the Barcode Reading & Writing component to run.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeQREncodingMode enumeration. The encoding mode.
A member of the BarcodeMicroQRErrorCorrectionLevel enumeration. The error correction level.
The version of the QrCode. In the range 0 - 4. Specifies the overall dimensions of the symbol. Use 0 to let the engine decide the minimum version required to encode all data.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode.
QR Code requires a four-module wide margin at all sides of a symbol. Consequently a value superior or equal to 4 is highly suggested.
The size of each module, in pixels. A value superior or equal to 4 is recommended.
The left position, in pixels, of the QrCode.
The top position, in pixels, of the QrCode.
The QrCode angle.
Color of the symbols. A suitable color value can be obtained by using the ARGBI() method.
Color of the background. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Draws a Micro QrCode barcode on a GdPicture image.
This method requires the Barcode Reading & Writing component to run.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeMicroQRErrorCorrectionLevel enumeration. The encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
The version of the QrCode. In the range 0 - 4. Specifies the overall dimensions of the symbol. Use 0 to let the engine decide the minimum version required to encode all data.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode.
QR Code requires a four-module wide margin at all sides of a symbol. Consequently a value superior or equal to 4 is highly suggested.
The size of each module, in pixels. A value superior or equal to 4 is recommended.
The left position, in pixels, of the QrCode.
The top position, in pixels, of the QrCode.
The QrCode angle.
Color of the symbols. A suitable color value can be obtained by using the ARGB() method.
Color of the background. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Returns the size, in pixels, required to render a PDF417 barcode on a Bitmap.
The data of the barcode to encode.
A member of the BarcodePDF417EncodingMode enumeration. The encoding mode.
A member of the BarcodePDF417ErrorCorrectionLevel enumeration. The error correction level.
Specifies the number of rows constituting the barcode. Use 0 for automatic computation (recommended) or a value in the range [3 - 90].
Specifies the number of columns constituting the barcode. Use 0 for automatic computation (recommended) or a value in the range [3 - 30].
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode. A value superior or equal to 4 is highly suggested.
The width of each module, in pixels. A value superior or equal to 4 is recommended.
The height of each row, in pixels. A value superior or equal to 10 is recommended.
Output parameter. The width, in pixels, required to render the PDF417 barcode.
Output parameter. The height, in pixels, required to render the PDF417 barcode.
A member of the GdPictureStatus enumeration.
Rendering a PDF417 barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String that have to be encoded into a barcode.
string data = "PDF417 Barcode";
BarcodePDF417EncodingMode encodingMode = BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined;
// Level 0 to 8 are allowed, the number of error correction codewords is 2^(n+1).
BarcodePDF417ErrorCorrectionLevel errorCorrectionLevel = BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto;
int moduleSize = 5;
int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
int rows = 0, columns = 0; // Let the encoder choose the best ratio.
int quietZone = 3; // 3 modules wide
// Compute size (in pixels), required to render a PDF417 barcode.
gdpictureImaging.BarcodePDF417GetSize(data, encodingMode, ref errorCorrectionLevel, ref rows, ref columns, quietZone, moduleSize, 17 * moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(width, height, 32, Color.White);
gdpictureImaging.BarcodePDF417Write(imageID, data, encodingMode, errorCorrectionLevel, rows, columns, quietZone, moduleSize, 17 * moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "PDF417.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a PDF417 barcode on a GdPicture image.
This method requires the Barcode Reading & Writing component to run.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodePDF417EncodingMode enumeration. The encoding mode.
A member of the BarcodePDF417ErrorCorrectionLevel enumeration. The error correction level.
Specifies the number of rows constituting the barcode. Use 0 for automatic computation (recommended) or a value in the range [3 - 90].
Specifies the number of columns constituting the barcode. Use 0 for automatic computation (recommended) or a value in the range [3 - 30].
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode. A value superior or equal to 4 is highly suggested.
The width of each module, in pixels. A value superior or equal to 4 is recommended.
The height of each row, in pixels. A value superior or equal to 10 is recommended.
The left position, in pixels, of the PDF417 barcode.
The top position, in pixels, of the PDF417 barcode.
The PDF417 barcode angle.
Color of the symbols. A suitable color value can be obtained by using the ARGBI() method.
Color of the background. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Rendering a PDF417 barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String that have to be encoded into a barcode.
string data = "PDF417 Barcode";
BarcodePDF417EncodingMode encodingMode = BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined;
// Level 0 to 8 are allowed, the number of error correction codewords is 2^(n+1).
BarcodePDF417ErrorCorrectionLevel errorCorrectionLevel = BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto;
int moduleSize = 5;
int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
int rows = 0, columns = 0; // Let the encoder choose the best ratio.
int quietZone = 3; // 3 modules wide
// Compute size (in pixels), required to render a PDF417 barcode.
gdpictureImaging.BarcodePDF417GetSize(data, encodingMode, ref errorCorrectionLevel, ref rows, ref columns, quietZone, moduleSize, 17 * moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(width, height, 32, Color.White);
gdpictureImaging.BarcodePDF417Write(imageID, data, encodingMode, errorCorrectionLevel, rows, columns, quietZone, moduleSize, 17 * moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "PDF417.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a PDF417 barcode on a GdPicture image.
This method requires the Barcode Reading & Writing component to run.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodePDF417EncodingMode enumeration. The encoding mode.
A member of the BarcodePDF417ErrorCorrectionLevel enumeration. The error correction level.
Specifies the number of rows constituting the barcode. Use 0 for automatic computation (recommended) or a value in the range [3 - 90].
Specifies the number of columns constituting the barcode. Use 0 for automatic computation (recommended) or a value in the range [3 - 30].
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode. A value superior or equal to 4 is highly suggested.
The width of each module, in pixels. A value superior or equal to 4 is recommended.
The height of each row, in pixels. A value superior or equal to 10 is recommended.
The left position, in pixels, of the PDF417 barcode.
The top position, in pixels, of the PDF417 barcode.
The PDF417 barcode angle.
Color of the symbols. A suitable color value can be obtained by using the ARGB() method.
Color of the background. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Rendering a PDF417 barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String that have to be encoded into a barcode.
string data = "PDF417 Barcode";
BarcodePDF417EncodingMode encodingMode = BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined;
// Level 0 to 8 are allowed, the number of error correction codewords is 2^(n+1).
BarcodePDF417ErrorCorrectionLevel errorCorrectionLevel = BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto;
int moduleSize = 5;
Color fillColor = gdpictureImaging.ARGB(255, 0, 0, 0);
Color backColor = gdpictureImaging.ARGB(0, 255, 255, 255);
int rows = 0, columns = 0; // Let the encoder choose the best ratio.
int quietZone = 3; // 3 modules wide
// Compute size (in pixels), required to render a PDF417 barcode.
gdpictureImaging.BarcodePDF417GetSize(data, encodingMode, ref errorCorrectionLevel, ref rows, ref columns, quietZone, moduleSize, 17 * moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(width, height, 32, Color.White);
gdpictureImaging.BarcodePDF417Write(imageID, data, encodingMode, errorCorrectionLevel, rows, columns, quietZone, moduleSize, 17 * moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "PDF417.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the size, in pixels, required to render a DataMatrix barcode on a Bitmap.
The data of the barcode to encode.
A member of the BarcodeDataMatrixEncodingMode enumeration. The encoding mode.
A member of the BarcodeDataMatrixVersion enumeration. The version of the DataMatrix barcode. Use BarcodeDataMatrixVersionAuto to let the engine decide the minimum version required to encode all data.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode. A value superior or equal to 4 is highly suggested.
The size of each module, in pixels. A value superior or equal to 4 is recommended.
Output parameter. The width, in pixels, required to render the DataMatrix barcode.
Output parameter. The height, in pixels, required to render the DataMatrix barcode.
A member of the GdPictureStatus enumeration.
Rendering a DataMatrix barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
BarcodeDataMatrixEncodingMode encodingMode = BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeUndefined;
BarcodeDataMatrixVersion dmVersion = BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto;
int moduleSize = 8;
int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
// Compute size (in pixels), required to render the DataMatrix barcode.
gdpictureImaging.BarcodeDataMatrixGetSize(data, encodingMode, ref dmVersion, 4, moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(width, height, 32, Color.White);
gdpictureImaging.BarcodeDataMatrixWrite(imageID, data, encodingMode, ref dmVersion, 4, moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a DataMatrix barcode on a GdPicture image.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeDataMatrixEncodingMode enumeration. The encoding mode.
A member of the BarcodeDataMatrixVersion enumeration. The version of the DataMatrix barcode. Use BarcodeDataMatrixVersionAuto to let the engine decide the minimum version required to encode all data.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode. A value superior or equal to 4 is highly suggested.
The size of each module, in pixels. A value superior or equal to 4 is recommended.
The left position, in pixels, of the DataMatrix barcode.
The top position, in pixels, of the DataMatrix barcode.
The DataMatrix barcode angle.
Color of the symbols. A suitable color value can be obtained by using the ARGBI() method.
Color of the background. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Rendering a DataMatrix barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
BarcodeDataMatrixEncodingMode encodingMode = BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeUndefined;
BarcodeDataMatrixVersion dmVersion = BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto;
int moduleSize = 8;
int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
// Compute size (in pixels), required to render the DataMatrix barcode.
gdpictureImaging.BarcodeDataMatrixGetSize(data, encodingMode, ref dmVersion, 4, moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(width, height, 32, Color.White);
gdpictureImaging.BarcodeDataMatrixWrite(imageID, data, encodingMode, ref dmVersion, 4, moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a DataMatrix barcode on a GdPicture image.
This method requires the Barcode Reading & Writing component to run.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeDataMatrixEncodingMode enumeration. The encoding mode.
A member of the BarcodeDataMatrixVersion enumeration. The version of the DataMatrix barcode. Use BarcodeDataMatrixVersionAuto to let the engine decide the minimum version required to encode all data.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode. A value superior or equal to 4 is highly suggested.
The size of each module, in pixels. A value superior or equal to 4 is recommended.
The left position, in pixels, of the DataMatrix barcode.
The top position, in pixels, of the DataMatrix barcode.
The QrCode angle.
Color of the symbols.
Color of the background.
A member of the GdPictureStatus enumeration.
Rendering a DataMatrix barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
BarcodeDataMatrixEncodingMode encodingMode = BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeUndefined;
BarcodeDataMatrixVersion dmVersion = BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto;
int moduleSize = 8;
Color fillColor = gdpictureImaging.ARGB(255, 0, 0, 0);
Color backColor = gdpictureImaging.ARGB(0, 255, 255, 255);
// Compute size (in pixels), required to render the DataMatrix barcode.
gdpictureImaging.BarcodeDataMatrixGetSize(data, encodingMode, ref dmVersion, 4, moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(width, height, 32, Color.White);
gdpictureImaging.BarcodeDataMatrixWrite(imageID, data, encodingMode, ref dmVersion, 4, moduleSize, 0, 0, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Gets for the minimum width required to draw a specific barcode on a GdPicture image using one of the Barcode1DWrite
methods.
A member of the Barcode1DWriterType enumeration.
The data of the barcode to encode.
The minimum width required to draw the barcode. If 0, you can use the GetStat method to get the
reason the method failed.
Returns the size, in pixels, required to render an Aztec barcode on a Bitmap.
The data of the barcode to encode.
A member of the BarcodeAztecCodeVersion enumeration. The version of the Aztec barcode.
Use BarcodeAztecCodeVersionAuto to let the engine decide the minimum version required to encode all data.
The percentage of error correction codewords. It could be a value from 5 to 95. A value of 23 is recommended.
The size, in pixels, of the quiet zone around the barcode. It could be 0, because Aztec barcodes does no require a mandatory quiet zone.
The size of each module, in pixels.
Output parameter. The width, in pixels, required to render the whole Aztec barcode.
Output parameter. The height, in pixels, required to render the whole Aztec barcode.
Use the GetStat() method to determine if this method has been successful.
A member of the GdPictureStatus enumeration.
Rendering an Aztec barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
BarcodeAztecCodeVersion version = BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto;
int moduleSize = 8;
Color fillColor = gdpictureImaging.ARGB(255, 0, 0, 0);
Color backColor = gdpictureImaging.ARGB(0, 255, 255, 255);
int dstLeft = 10;
int dstTop = 10;
// Compute size (in pixels), required to render an Aztec barcode.
gdpictureImaging.BarcodeAztecGetSize(data, ref version, 23, 0, moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(20 + width, 20 + height, 32, Color.White);
gdpictureImaging.BarcodeAztecWrite(imageID, data, ref version, 23, 0, moduleSize, dstLeft, dstTop, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws an Aztec barcode on a GdPicture image.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeAztecCodeVersion enumeration. The version of the Aztec barcode.
Use BarcodeAztecCodeVersionAuto to let the engine decide the minimum version required to encode all data.
The percentage of error correction codewords. It could be a value from 5 to 95. A value of 23 is recommended.
The size, in pixels, of the quiet zone around the barcode. It could be 0, because Aztec barcodes does no require a mandatory quiet zone.
The size of each module, in pixels.
The left position, in pixels, of the Aztec barcode.
The top position, in pixels, of the Aztec barcode.
The Aztec barcode angle.
Color of the symbols. A suitable color value can be obtained by using the ARGBI() method.
Color of the background. A suitable color value can be obtained by using the ARGBI() method.
Use the GetStat() method to determine if this method has been successful.
A member of the GdPictureStatus enumeration.
Rendering an Aztec barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
BarcodeAztecCodeVersion version = BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto;
int moduleSize = 8;
int fillColor = gdpictureImaging.ARGBI(255, 0, 0, 0);
int backColor = gdpictureImaging.ARGBI(0, 255, 255, 255);
int dstLeft = 10;
int dstTop = 10;
// Compute size (in pixels), required to render an Aztec barcode.
gdpictureImaging.BarcodeAztecGetSize(data, ref version, 23, 0, moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(20 + width, 20 + height, 32, Color.White);
gdpictureImaging.BarcodeAztecWrite(imageID, data, ref version, 23, 0, moduleSize, dstLeft, dstTop, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws an Aztec barcode on a GdPicture image.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeAztecCodeVersion enumeration. The version of the Aztec barcode.
Use BarcodeAztecCodeVersionAuto to let the engine decide the minimum version required to encode all data.
The percentage of error correction codewords. It could be a value from 5 to 95. A value of 23 is recommended.
The size, in pixels, of the quiet zone around the barcode. It could be 0, because Aztec barcodes does no require a mandatory quiet zone.
The size of each module, in pixels.
The left position, in pixels, of the Aztec barcode.
The top position, in pixels, of the Aztec barcode.
The Aztec barcode angle.
Color of the symbols.
Color of the background.
A member of the GdPictureStatus enumeration.
Use the GetStat() method to determine if this method has been successful.This method requires the Barcode Reading & Writing component to run.
Rendering an Aztec barcode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
BarcodeAztecCodeVersion version = BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto;
int moduleSize = 8;
Color fillColor = gdpictureImaging.ARGB(255, 0, 0, 0);
Color backColor = gdpictureImaging.ARGB(0, 255, 255, 255);
int dstLeft = 10;
int dstTop = 10;
// Compute size (in pixels), required to render an Aztec barcode.
gdpictureImaging.BarcodeAztecGetSize(data, ref version, 23, 0, moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(20 + width, 20 + height, 32, Color.White);
gdpictureImaging.BarcodeAztecWrite(imageID, data, ref version, 23, 0, moduleSize, dstLeft, dstTop, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the size, in pixels, required to render a MaxiCode on a Bitmap.
The number of modules considered as quiet zone around the barcode.
The distance, in pixels, between two modules on the same horizontal line.
Output parameter. The width, in pixels, required to render the whole MaxiCode.
Output parameter. The height, in pixels, required to render the whole MaxiCode.
Use the GetStat() method to determine if this method has been successful.
A member of the GdPictureStatus enumeration.
Rendering a MaxiCode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string data = "123456";
Color fillColor = gdpictureImaging.ARGB(255, 0, 0, 0);
Color backColor = gdpictureImaging.ARGB(0, 255, 255, 255);
int dstLeft = 10;
int dstTop = 10;
// Compute size (in pixels), required to render a MaxiCode.
gdpictureImaging.BarcodeMaxiCodeGetSize(1, moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(width, height, 32, Color.White);
gdpictureImaging.BarcodeMaxiCodeWrite(imageID, data, ref version, 23, 0, moduleSize, dstLeft, dstTop, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a MaxiCode on a GdPicture image.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeMaxiCodeEncodingMode enumeration. The mode used to encode the MaxiCode.
The number of modules considered as quiet zone around the barcode.
The size of each module, in pixels.
The left position, in pixels, of the MaxiCode.
The top position, in pixels, of the MaxiCode.
The MaxiCode angle.
Color of the symbols. A suitable color value can be obtained by using the ARGBI() method.
Color of the background. A suitable color value can be obtained by using the ARGBI() method.
Use the GetStat() method to determine if this method has been successful.
A member of the GdPictureStatus enumeration.
Rendering a MaxiCode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string gs = ((char)0x1D).ToString();
string data = "123456" + gs + "040" + gs + "001" + gs + "Additional Data";
Color fillColor = gdpictureImaging.ARGB(255, 0, 0, 0);
Color backColor = gdpictureImaging.ARGB(0, 255, 255, 255);
int dstLeft = 10;
int dstTop = 10;
int moduleSize = 15;
// Compute size (in pixels), required to render a MaxiCode.
gdpictureImaging.BarcodeMaxiCodeGetSize(1, moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(dstLeft + width, dstTop + height, 32, Color.White);
gdpictureImaging.BarcodeMaxiCodeWrite(imageID, data, BarcodeMaxiCodeEncodingMode.Mode2, 1, moduleSize, dstLeft, dstTop, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a MaxiCode on a GdPicture image.
GdPicture image identifier.
The data of the barcode to encode.
A member of the BarcodeMaxiCodeEncodingMode enumeration. The mode used to encode the MaxiCode.
The number of modules considered as quiet zone around the barcode.
The size of each module, in pixels.
The left position, in pixels, of the MaxiCode.
The top position, in pixels, of the MaxiCode.
The MaxiCode angle.
Color of the symbols.
Color of the background.
A member of the GdPictureStatus enumeration.
Use the GetStat() method to determine if this method has been successful.This method requires the Barcode Reading & Writing component to run.
Rendering a MaxiCode into a new image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// String with numbers, which have to be encoded into a barcode.
string gs = ((char)0x1D).ToString();
string data = "123456" + gs + "040" + gs + "001" + gs + "Additional Data";
Color fillColor = gdpictureImaging.ARGB(255, 0, 0, 0);
Color backColor = gdpictureImaging.ARGB(0, 255, 255, 255);
int dstLeft = 10;
int dstTop = 10;
int moduleSize = 15;
// Compute size (in pixels), required to render a MaxiCode.
gdpictureImaging.BarcodeMaxiCodeGetSize(1, moduleSize, out int width, out int height);
int imageID = gdpictureImaging.CreateNewGdPictureImage(dstLeft + width, dstTop + height, 32, Color.White);
gdpictureImaging.BarcodeMaxiCodeWrite(imageID, data, BarcodeMaxiCodeEncodingMode.Mode2, 1, moduleSize, dstLeft, dstTop, 0, fillColor, backColor);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a GdPicture image into another GdPicture image applying a transparency effect.
GdPicture image identifier. Specifies the image to be drawn from.
GdPicture image identifier. specifies the image to draw on.
Transparency to apply to the drawn image [0 ; 255]. 0 means full
opacity and 255 full transparency.
Specifies the x-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the y-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the width, in pixels, of the destination rectangle at which
to draw the image.
Specifies the height, in pixels, of the destination rectangle at which
to draw the image.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Rendering a blue image over a red image using defined transparency and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
System.Drawing.Drawing2D.InterpolationMode iMode = System.Drawing.Drawing2D.InterpolationMode.Default;
int width = 180;
int height = 180;
int transparency = 100;
// Create images.
int backImage = gdpictureImaging.CreateNewGdPictureImage(340, 340, 24, 0);
int redImage = gdpictureImaging.CreateNewGdPictureImage(width, height, 24, gdpictureImaging.ARGBI(255, 255, 0, 0));
int blueImage = gdpictureImaging.CreateNewGdPictureImage(width, height, 24, gdpictureImaging.ARGBI(255, 0, 0, 255));
// Render a red image without transparency.
gdpictureImaging.DrawGdPictureImageTransparency(redImage, backImage, 0, 25, 25, width, height, iMode);
// Render a blue image with defined transparency.
gdpictureImaging.DrawGdPictureImageTransparency(blueImage, backImage, transparency, 135, 135, width, height, iMode);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources
gdpictureImaging.ReleaseGdPictureImage(redImage);
gdpictureImaging.ReleaseGdPictureImage(blueImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Draws a GdPicture image into another GdPicture image setting a specific color of the image to draw as
transparent.
GdPicture image identifier. Specifies the image to be drawn from.
GdPicture image identifier. specifies the image to draw to.
The color to set as transparent. A suitable color value can be obtained by using the ARGB() method.
Specifies the x-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the y-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the width, in pixels, of the destination rectangle at which
to draw the image.
Specifies the height, in pixels, of the destination rectangle at which
to draw the image.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Rendering an image with the circle into the background image, with a blue color set as transparent. The result is saved into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create background image
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, Color.Green);
// Create image with blue background, and draw red circle in it
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, Color.Blue);
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, Color.Red, false);
// Draw image with circle into the background image. Blue color will be omited.
gdpictureImaging.DrawGdPictureImageTransparencyColor(circleImage, backImage, Color.Blue, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Draws a GdPicture image into another GdPicture image setting a specific color of the image to draw as
transparent. This method takes a percentage threshold parameter regarding the color to set as
transparent.
Ie: A threshold value of 90 means that all the color values which are within 90% of the color value
parameter will be set as transparent.
GdPicture image identifier. Specifies the image to be drawn from.
GdPicture image identifier. specifies the image to draw to.
The color to set as transparent. A suitable color value can be obtained by using the ARGB() method.
Percentage threshold between 0 and 100.
Specifies the x-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the y-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the width, in pixels, of the destination rectangle at which
to draw the image.
Specifies the height, in pixels, of the destination rectangle at which
to draw the image.
A member of the Drawing2D.InterpolationMode enumeration.
A member of the GdPictureStatus enumeration.
Rendering an image with the circle into the background image, with a blue color set as transparent. The result is saved into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create background image
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, Color.Green);
// Create image with blue background, and draw red circle in it
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, Color.Blue);
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, Color.Red, false);
// Draw image with circle into the background image. Blue color will be omited.
gdpictureImaging.DrawGdPictureImageTransparencyColor(circleImage, backImage, Color.Blue, 90f, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Draws a clipped GdPicture image from several points of co-ordinates into another GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier. Specifies the image to be drawn from.
GdPicture image identifier. specifies the image to draw to.
Array of System.Drawing.Point that specifies the coordinates.
A member of the GdPictureStatus enumeration.
Draws a GdPicture image into another GdPicture image.
GdPicture image identifier. Specifies the image to be drawn from.
GdPicture image identifier. specifies the image to draw to.
Specifies the x-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the y-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the width, in pixels, of the destination rectangle at which
to draw the image.
Specifies the height, in pixels, of the destination rectangle at which
to draw the image.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Rendering an image with a circle onto the background image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Color backColor = gdpictureImaging.ARGB(255, 0, 255, 0); // Green color
Color circleColor = gdpictureImaging.ARGB(255, 255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGB(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Draws a portion of a GdPicture image into another GdPicture image.
GdPicture image identifier. Specifies the image to be drawn from.
GdPicture image identifier. specifies the image to draw to.
Specifies the x-coordinate, in pixel, of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the y-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the width, in pixels, of the destination rectangle at which
to draw the image.
Specifies the height, in pixels, of the destination rectangle at which
to draw the image.
Left pixel source of the image to draw.
Top pixel source of the image to draw.
Width portion in pixels of the image to draw.
Height portion in pixels of the image to draw.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Rendering a portion of an image with a circle onto the background image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
System.Drawing.Drawing2D.InterpolationMode iMode = System.Drawing.Drawing2D.InterpolationMode.Default;
int backColor = gdpictureImaging.ARGBI(255, 0, 255, 0); // Green color
int circleColor = gdpictureImaging.ARGBI(255, 255, 0, 0); // Red color
int dstLeft = 0;
int dstTop = 0;
int dstWidth = 200;
int dstHeight = 200;
int srcLeft = 0;
int srcTop = 0;
int srcWidth = 40;
int srcHeight = 40;
// Create background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(200, 200, 32, backColor);
// Create image with circle.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGBI(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 80, circleColor, true);
// Draw portion of image with circle into the background image.
gdpictureImaging.DrawGdPictureImageRect(circleImage, backImage, dstLeft, dstTop, dstWidth, dstHeight, srcLeft, srcTop, srcWidth, srcHeight, iMode);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Draws a GdPicture image into another GdPicture image using an operator of combination.
GdPicture image identifier. Specifies the image to be drawn from.
GdPicture image identifier. specifies the image to draw tp.
Specifies the x-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the y-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the width, in pixels, of the destination rectangle at which
to draw the image.
Specifies the height, in pixels, of the destination rectangle at which
to draw the image.
A member of the Operators enumeration.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Draws a portion of a GdPicture image into another GdPicture image using an operator of combination.
GdPicture image identifier. Specifies the image to be drawn from.
GdPicture image identifier. specifies the image to draw to.
Specifies the x-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the y-coordinate in pixels of the upper-left corner of
the destination rectangle at which to draw the image.
Specifies the width, in pixels, of the destination rectangle at which
to draw the image.
Specifies the height, in pixels, of the destination rectangle at which
to draw the image.
Specifies the x-coordinate in pixels of the upper-left corner
of the portion of the source image to be drawn.
Specifies the y-coordinate in pixels of the upper-left corner
of the portion of the source image to be drawn.
Specifies the width, in pixels, of the portion of the source image to
be drawn.
Specifies the height, in pixels, of the portion of the source image to
be drawn.
A member of the Operators enumeration.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Draws a skewed GdPicture image from 3 points of co-ordinates into another GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier. Specifies the image to be drawn from.
GdPicture image identifier. specifies the image to draw to.
Left pixel destination of the first point.
Top pixel destination of the first point.
Left pixel destination of the second point.
Top pixel destination of the second point.
Left pixel destination of the third point.
Left pixel destination of the third point.
A member of the Drawing2D.InterPolationMode enumeration.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws an arc on a GdPicture image. The arc is part of an ellipse.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the bounding
rectangle for the ellipse that contains the arc.
Specifies the y-coordinate of the upper-left corner of the bounding
rectangle for the ellipse that contains the arc.
Specifies the width of the ellipse that contains the arc.
Specifies the height of the ellipse that contains the arc.
Specifies the angle between the x-axis and the starting point of the arc.
Specifies the angle between the starting and ending points of the arc.
The width, in pixel, of the pen used to draw the arc.
Color of the arc. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a red arc on top of a black ellipse on a pgn image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the black elipse.
gdpictureImaging.DrawEllipse(imageID, 50, 50, 100, 50, gdpictureImaging.ARGB(255, 0, 0, 0), 1, true);
// Draw the red arc using the same ellipse parameters and chosen angles.
gdpictureImaging.DrawArc(imageID, 50, 50, 100, 50, 200, 160, 2, gdpictureImaging.ARGB(255, 255, 0, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws an arc on a GdPicture image. The arc is part of an ellipse. This method takes a color integer as the PenColor parameter.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the bounding
rectangle for the ellipse that contains the arc.
Specifies the y-coordinate of the upper-left corner of the bounding
rectangle for the ellipse that contains the arc.
Specifies the width of the ellipse that contains the arc.
Specifies the height of the ellipse that contains the arc.
Specifies the angle between the x-axis and the starting point of the arc.
Specifies the angle between the starting and ending points of the arc.
The width, in pixel, of the pen used to draw the arc.
Color of the arc. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a red arc on top of a black ellipse on a pgn image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the black elipse.
gdpictureImaging.DrawEllipse(imageID, 50, 50, 100, 50, gdpictureImaging.ARGBI(255, 0, 0, 0), 1, true);
// Draw the red arc using the same ellipse parameters and chosen angles.
gdpictureImaging.DrawArc(imageID, 50, 50, 100, 50, 200, 160, 2, gdpictureImaging.ARGBI(255, 255, 0, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a bezier spline on a GdPicture image.
GdPicture image identifier.
Specifies the x-coordinate of the starting point of the Bezier spline.
Specifies the y-coordinate of the starting point of the Bezier spline.
Specifies the x-coordinate of the first control point of the Bezier spline.
Specifies the y-coordinate of the first control point of the Bezier spline.
Specifies the x-coordinate of the second control point of the Bezier
spline.
Specifies the y-coordinate of the second control point of the Bezier
spline.
Specifies the x-coordinate of the ending point of the Bezier spline.
Specifies the y-coordinate of the ending point of the Bezier spline.
The width, in pixel, of the pen used to draw the arc.
Color of the Bezier. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a red circle approximation using four Bezier curves on a png image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw a circle approximation.
gdpictureImaging.DrawBezier(imageID, 100, 50, 127, 50, 150, 73, 150, 100, 1, gdpictureImaging.ARGB(255, 255, 0, 0), true);
gdpictureImaging.DrawBezier(imageID, 150, 100, 150, 127, 127, 150, 100, 150, 1, gdpictureImaging.ARGB(255, 255, 0, 0), true);
gdpictureImaging.DrawBezier(imageID, 100, 150, 73, 150, 50, 127, 50, 100, 1, gdpictureImaging.ARGB(255, 255, 0, 0), true);
gdpictureImaging.DrawBezier(imageID, 50, 100, 50, 73, 73, 50, 100, 50, 1, gdpictureImaging.ARGB(255, 255, 0, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a bezier spline on a GdPicture image. The drawing color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the starting point of the Bezier spline.
Specifies the y-coordinate of the starting point of the Bezier spline.
Specifies the x-coordinate of the first control point of the Bezier spline.
Specifies the y-coordinate of the first control point of the Bezier spline.
Specifies the x-coordinate of the second control point of the Bezier
spline.
Specifies the y-coordinate of the second control point of the Bezier
spline.
Specifies the x-coordinate of the ending point of the Bezier spline.
Specifies the y-coordinate of the ending point of the Bezier spline.
The width, in pixel, of the pen used to draw the arc.
Color of the Bezier spline. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a red circle approximation using four Bezier curves on a png image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw a circle approximation.
gdpictureImaging.DrawBezier(imageID, 100, 50, 127, 50, 150, 73, 150, 100, 1, gdpictureImaging.ARGBI(255, 255, 0, 0), true);
gdpictureImaging.DrawBezier(imageID, 150, 100, 150, 127, 127, 150, 100, 150, 1, gdpictureImaging.ARGBI(255, 255, 0, 0), true);
gdpictureImaging.DrawBezier(imageID, 100, 150, 73, 150, 50, 127, 50, 100, 1, gdpictureImaging.ARGBI(255, 255, 0, 0), true);
gdpictureImaging.DrawBezier(imageID, 50, 100, 50, 73, 73, 50, 100, 50, 1, gdpictureImaging.ARGBI(255, 255, 0, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a circle on a GdPicture image.
GdPicture image identifier.
Specifies the x-coordinate of the center of the circle.
Specifies the y-coordinate of the center of the circle.
Diameter of the circle in pixel.
Color of the circle. A suitable color value can be obtained by using the ARGB() method.
The width, in pixel, of the pen used to draw the circle.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a red circle on a png image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
gdpictureImaging.DrawCircle(imageID, 100, 100, 100, gdpictureImaging.ARGB(255, 255, 0, 0), 1, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a circle on a GdPicture image. The drawing color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the center of the circle.
Specifies the y-coordinate of the center of the circle.
Diameter of the circle in pixel.
The circle color. A suitable color value can be obtained by using the ARGBI() method.
The width, in pixel, of the pen used to draw the circle.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a red circle on a png image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
gdpictureImaging.DrawCircle(imageID, 100, 100, 100, gdpictureImaging.ARGBI(255, 255, 0, 0), 1, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a curve on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Array of System.Drawing.Point that specifies the coordinates that the
cardinal spline passes through.
The width, in pixel, of the pen used to draw the curve.
Color of the curve. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a red curve on a png image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
System.Drawing.Point[] points = new System.Drawing.Point[4];
points[0].X = 100;
points[0].Y = 50;
points[1].X = 150;
points[1].Y = 100;
points[2].X = 100;
points[2].Y = 150;
points[3].X = 50;
points[3].Y = 100;
gdpictureImaging.DrawCurve(imageID, points, 1, gdpictureImaging.ARGB(255, 255, 0, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled closed curve on a GdPicture image.
GdPicture image identifier.
Array of System.Drawing.Point that specifies the coordinates that the
cardinal spline passes through.
Color of the filled curve. A suitable color value can be obtained by using the ARGB() method.
Nonnegative real number that specifies how tightly the spline bends as it
passes through the points. A value of 0 specifies that the spline is a
sequence of straight lines. As the value increases, the curve becomes
fuller. The default value is 0.5f.
Specifies how to fill a closed area that is within another closed area and
that is created when the curve or path passes over itself. A member of the
Drawing2D.FillMode enumeration.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
If the first and last coordinates in the points array are not identical, a line is drawn between them
to close the polygon.This method requires the Image Documents component to run.
Draws a closed curve on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Array of System.Drawing.Point that specifies the coordinates that the
cardinal spline passes through.
The width, in pixel, of the pen used to draw the curve.
Color of the curve. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a red closed curve on a png image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
System.Drawing.Point[] points = new System.Drawing.Point[4];
points[0].X = 100;
points[0].Y = 50;
points[1].X = 150;
points[1].Y = 100;
points[2].X = 100;
points[2].Y = 150;
points[3].X = 50;
points[3].Y = 100;
gdpictureImaging.DrawClosedCurve(imageID, points, 1, gdpictureImaging.ARGB(255, 255, 0, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a polygon on a GdPicture image.
GdPicture image identifier.
Array of System.Drawing.Point that specifies the vertices of the polygon.
The width in pixels of the pen used to draw the polygon.
Color of the polygon. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
If the first and last coordinates in the points array are not identical, a line is drawn between them
to close the polygon.
This method requires the Image Documents component to run.
Draws an ellipse on a GdPicture image.
A member of the GdPictureStatus enumeration.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the width of the rectangle that bounds the ellipse.
Specifies the height of the rectangle that bounds the ellipse.
Color of the ellipse. A suitable color value can be obtained by using the ARGB() method.
The width, in pixel, of the pen used to draw the ellipse.
Set to True to apply the Antialiasing algorithm else False.
Drawing a red arc on top of a black ellipse on a pgn image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the black elipse.
gdpictureImaging.DrawEllipse(imageID, 50, 50, 100, 50, gdpictureImaging.ARGB(255, 0, 0, 0), 1, true);
// Draw the red arc using the same ellipse parameters and chosen angles.
gdpictureImaging.DrawArc(imageID, 50, 50, 100, 50, 200, 160, 2, gdpictureImaging.ARGB(255, 255, 0, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws an ellipse on a GdPicture image. The drawing color is specified with an integer value.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the width of the rectangle that bounds the ellipse.
Specifies the height of the rectangle that bounds the ellipse.
The ellipse color. A suitable color value can be obtained by using the ARGBI() method.
The width, in pixel, of the pen used to draw the ellipse.
Set to True to apply the Antialiasing algorithm else False.
Drawing a red arc on top of a black ellipse on a pgn image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the black elipse.
gdpictureImaging.DrawEllipse(imageID, 50, 50, 100, 50, gdpictureImaging.ARGBI(255, 0, 0, 0), 1, true);
// Draw the red arc using the same ellipse parameters and chosen angles.
gdpictureImaging.DrawArc(imageID, 50, 50, 100, 50, 200, 160, 2, gdpictureImaging.ARGBI(255, 255, 0, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a rotated ellipse on a GdPicture image.
GdPicture image identifier.
Angle of rotation in degrees.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the width of the rectangle that bounds the ellipse.
Specifies the height of the rectangle that bounds the ellipse.
Width, in pixel, of the pen used to draw the rectangle.
Color of the ellipse. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a rotated ellipse on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int left = 50, top = 100, width = 250, height = 150;
float angle = 30.0f;
int penWidth = 10;
Color penColor = gdpictureImaging.ARGB(255, 0, 0, 255);
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGB(0, 0, 0, 0));
// Draw the rotated ellipse. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the ellipse boundary.
gdpictureImaging.DrawRotatedEllipse(imageID, angle, left, top, width, height, penWidth, penColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a rotated ellipse on a GdPicture image. It takes a color integer as a PenColor parameter.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the width of the rectangle that bounds the ellipse.
Specifies the height of the rectangle that bounds the ellipse.
Width, in pixel, of the pen used to draw the rectangle.
The ellipse color. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a rotated ellipse on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int left = 50, top = 100, width = 250, height = 150;
float angle = 30.0f;
int penWidth = 10;
Color penColor = gdpictureImaging.ARGBI(255, 0, 0, 255);
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGBI(0, 0, 0, 0));
// Draw the rotated ellipse. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the ellipse boundary.
gdpictureImaging.DrawRotatedEllipse(imageID, angle, left, top, width, height, penWidth, penColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a rotated and filled ellipse on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the width of the rectangle that bounds the ellipse.
Specifies the height of the rectangle that bounds the ellipse.
Color of the rectangle. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Filling a rotated ellipse on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int left = 50, top = 100, width = 250, height = 150;
float angle = 30.0f;
Color fillColor = Color.Green;
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, Color.White);
// Fill the rotated ellipse. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the ellipse boundary.
gdpictureImaging.DrawRotatedFilledEllipse(imageID, angle, left, top, width, height, fillColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled circle on a GdPicture image.
GdPicture image identifier.
Specifies the x-coordinate of the center of the circle.
Specifies the y-coordinate of the center of the circle.
Diameter of the circle in pixel.
Color of the circle. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a filled circle.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Color backColor = gdpictureImaging.ARGB(255, 0, 255, 0); // Green color
Color circleColor = gdpictureImaging.ARGB(255, 255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGB(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int centerX = 200, centerY = 250, diameter = 100;
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, Color.White);
// Fill the circle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the circle boundary.
gdpictureImaging.DrawFilledCircle(imageID, centerX, centerY, diameter, Color.Green, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled circle on a GdPicture image. The filling color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the center of the circle.
Specifies the y-coordinate of the center of the circle.
Diameter of the circle in pixel.
Color of the filled circle. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a filled circle.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int backColor = gdpictureImaging.ARGBI(255, 0, 255, 0); // Green color
int circleColor = gdpictureImaging.ARGBI(255, 255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGBI(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int centerX = 200, centerY = 250, diameter = 100;
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGBI(0, 0, 0, 0));
// Fill the circle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the circle boundary.
gdpictureImaging.DrawFilledCircle(imageID, centerX, centerY, diameter, gdpictureImaging.ARGBI(255, 0, 255, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled circle on a GdPicture image using a texture from a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
GdPicture image identifier. Source image used for the texture.
Specifies the x-coordinate of the center of the circle.
Specifies the y-coordinate of the center of the circle.
Diameter of the circle in pixel.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a filled circle on a GdPicture image using a texture from a file.
GdPicture image identifier.
The texture source file path. Can be an empty string. If empty, prompts the
user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Specifies the x-coordinate of the center of the circle.
Specifies the y-coordinate of the center of the circle.
Diameter of the circle in pixel.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a filled polygon on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Array of System.Drawing.Point that specifies the vertices of the polygon.
Color of the filled polygon. A suitable color value can be obtained by using the ARGB() method.
Specifies how to fill a closed area that is within another closed area and
that is created when the polygon or path passes over itself.A member of the
Drawing2D.FillMode enumeration.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
If the first and last coordinates in the points array are not identical, a line is drawn between them
to close the polygon.
Draws a filled polygon on a GdPicture image using a texture from a file.
GdPicture image identifier.
The texture source file path. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Array of System.Drawing.Point that specifies the vertices of the
polygon.
Specifies how to fill a closed area that is within another closed area
and that is created when the polygon or path passes over itself.A
member of the Drawing2D.FillMode enumeration.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
If the first and last coordinates in the points array are not identical, a line is drawn between them
to close the polygon.
\
Draws a filled polygon on a GdPicture image using a texture from a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
GdPicture image identifier. Source image used for the texture.
Array of System.Drawing.Point that specifies the vertices of the polygon.
Specifies how to fill a closed area that is within another closed area
and that is created when the polygon or path passes over itself.A member
of the Drawing2D.FillMode enumeration.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
If the first and last coordinates in the points array are not identical, a line is drawn between them
to close the polygon.
Draws a filled ellipse on a GdPicture image.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the width of the rectangle that bounds the ellipse.
Specifies the height of the rectangle that bounds the ellipse.
Color of the filled ellipse.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Filling a blue ellipse with a center at 200, 200 with the horizontal radius 150 pixels and the vertical radius 100 pixels.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int centerX = 200, centerY = 200, horizontalRadius = 150, verticalRadius = 100;
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGB(0, 0, 0, 0));
// Fill the ellipse. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the ellipse boundary.
gdpictureImaging.DrawFilledEllipse(imageID, centerX, centerY, horizontalRadius, verticalRadius, gdpictureImaging.ARGB(255, 0, 0, 255), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled ellipse on a GdPicture image. The filling color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the ellipse.
Specifies the width of the rectangle that bounds the ellipse.
Specifies the height of the rectangle that bounds the ellipse.
Color of the filled ellipse. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Filling a blue ellipse with a center at 200, 200 with the horizontal radius 150 pixels and the vertical radius 100 pixels.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int centerX = 200, centerY = 200, horizontalRadius = 150, verticalRadius = 100;
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGBI(0, 0, 0, 0));
// Fill the ellipse. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the ellipse boundary.
gdpictureImaging.DrawFilledEllipse(imageID, centerX, centerY, horizontalRadius, verticalRadius, gdpictureImaging.ARGBI(255, 0, 0, 255), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled rectangle on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Color of the filled rectangle. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Filling a 150x100 pixels red rectangle with a top left corner at 200,100.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int top = 100, left = 200, width = 150, height = 100;
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, Color.White);
// Fill the rectangle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the rectangle boundary.
gdpictureImaging.DrawFilledRectangle(imageID, left, top, width, height, Color.Red, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled rectangle on a GdPicture image. The filling color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Color of the filled rectangle. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Filling a 150x100 pixels red rectangle with a top left corner at 200,100.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int top = 100, left = 200, width = 150, height = 100;
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGBI(0, 0, 0, 0));
// Fill the rectangle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the rectangle boundary.
gdpictureImaging.DrawFilledRectangle(imageID, left, top, width, height, gdpictureImaging.ARGBI(255, 255, 0, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled rectangle on a GdPicture image using an operator of combination.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Color of the filled rectangle. A suitable color value can be obtained by using the ARGB() method.
A member of the Operators enumeration.
A member of the GdPictureStatus enumeration.
Draws a linear gradient curve on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Array of System.Drawing.Point that specifies the coordinates that the
cardinal spline passes through.
The width, in pixel, of the pen used to draw the curve.
Starting of the curve, as Color object. A suitable color value can be obtained by using the ARGB() method.
Ending color of the gradient curve, as Color object. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a linear gradient curve on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Point[] points = new Point[] {
new Point(200,100),
new Point(350,150),
new Point(300,250),
new Point(150,200),
};
int penWidth = 10;
Color startColor = Color.Blue, endColor = Color.Yellow;
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, Color.White);
// Draw gradient curve. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the curve boundary.
gdpictureImaging.DrawGradientCurve(imageID, points, penWidth, startColor, endColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a linear gradient line on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the starting point of the line.
Specifies the y-coordinate of the starting point of the line.
Specifies the x-coordinate of the ending point of the line.
Specifies the y-coordinate of the ending point of the line.
The width, in pixel, of the pen used to draw the line.
Starting color of the gradient line, as Color object. A suitable color value can be obtained by using the ARGB() method.
Ending color of the gradient line, as Color object. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a linear gradient line on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int startLeft = 10, startTop = 20, endLeft = 200, endTop = 150;
int penWidth = 15;
Color startColor = gdpictureImaging.ARGB(255, 0, 0, 255), endColor = gdpictureImaging.ARGB(255, 255, 255, 0);
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGB(0, 0, 0, 0));
// Draw gradient line. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the line boundary.
gdpictureImaging.DrawGradientLine(imageID, startLeft, startTop, endLeft, endTop, penWidth, startColor, endColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a linear gradient line on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the starting point of the line.
Specifies the y-coordinate of the starting point of the line.
Specifies the x-coordinate of the ending point of the line.
Specifies the y-coordinate of the ending point of the line.
The width, in pixel, of the pen used to draw the line.
Starting color of the gradient line, as integer value. A suitable color value can be obtained by using the ARGBI() method.
Ending color of the gradient line, as integer value. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a linear gradient line on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int startLeft = 10, startTop = 20, endLeft = 200, endTop = 150;
int penWidth = 15;
Color startColor = gdpictureImaging.ARGBI(255, 0, 0, 255), endColor = gdpictureImaging.ARGBI(255, 255, 255, 0);
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGBI(0, 0, 0, 0));
// Draw gradient line. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the line boundary.
gdpictureImaging.DrawGradientLine(imageID, startLeft, startTop, endLeft, endTop, penWidth, startColor, endColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a grid on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the starting point of the grid.
Specifies the y-coordinate of the starting point of the grid.
Width of the grid in pixel.
Height of the grid in pixel.
Space, in pixel, between each columns.
Space, in pixel, between each rows.
With of the pen (in pixel) used to draw the grid.
Color of the grid. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Draws a line on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the starting point of the line.
Specifies the y-coordinate of the starting point of the line.
Specifies the x-coordinate of the ending point of the line.
Specifies the y-coordinate of the ending point of the line.
The width, in pixel, of the pen used to draw the line.
Color of the line. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a line on a GdPicture image. The drawing color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the starting point of the line.
Specifies the y-coordinate of the starting point of the line.
Specifies the x-coordinate of the ending point of the line.
Specifies the y-coordinate of the ending point of the line.
The width, in pixel, of the pen used to draw the line.
Color of the line. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a line with an arrow at the end of it.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the starting point of the line.
Specifies the y-coordinate of the starting point of the line.
Specifies the x-coordinate of the ending point of the line.
Specifies the y-coordinate of the ending point of the line.
The width, in pixel, of the pen used to draw the line.
Color of the line. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a rounded rectangle on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Size of the radius in pixel.
The width, in pixel, of the pen used to draw the rectangle.
Color of the rectangle. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a rotated rectangle on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Width, in pixel, of the pen used to draw the rectangle.
Color of the rectangle. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a rotated rectangle on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int left = 50, top = 100, width = 250, height = 150;
float angle = 30.0f;
int penWidth = 20;
Color penColor = gdpictureImaging.ARGB(255, 0, 0, 255);
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGB(0, 0, 0, 0));
// Draw the rotated rectangle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the rectangle boundary.
gdpictureImaging.DrawRotatedRectangle(imageID, angle, left, top, width, height, penWidth, penColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a rotated rectangle on a GdPicture image. The drawing color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Width, in pixel, of the pen used to draw the rectangle.
Color of the rectangle. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing a rotated rectangle on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int left = 50, top = 100, width = 250, height = 150;
float angle = 30.0f;
int penWidth = 20;
Color penColor = gdpictureImaging.ARGBI(255, 0, 0, 255);
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGBI(0, 0, 0, 0));
// Draw the rotated rectangle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the rectangle boundary.
gdpictureImaging.DrawRotatedRectangle(imageID, angle, left, top, width, height, penWidth, penColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled and rounded rectangle on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Radius value between 0 and 90.
Color of the filled circle. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Filling a 250x200 pixels orange rounded rectangle with a top left corner at 100,200.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int top = 200, left = 100, width = 250, height = 200, cornerRadius = 20;
int imageID = gdpictureImaging.CreateNewGdPictureImage(600, 600, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGB(0, 0, 0, 0));
// Fill the rounded rectangle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the rectangle boundary.
gdpictureImaging.DrawFilledRoundedRectangle(imageID, left, top, width, height, cornerRadius, gdpictureImaging.ARGB(255, 255, 165, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a filled and rounded rectangle on a GdPicture image. The filling color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Radius value between 0 and 90.
Color of the filled circle. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Filling a 250x200 pixels orange rounded rectangle with a top left corner at 100,200.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int top = 200, left = 100, width = 250, height = 200, cornerRadius = 20;
int imageID = gdpictureImaging.CreateNewGdPictureImage(600, 600, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGBI(0, 0, 0, 0));
// Fill the rounded rectangle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the rectangle boundary.
gdpictureImaging.DrawFilledRoundedRectangle(imageID, left, top, width, height, cornerRadius, gdpictureImaging.ARGBI(255, 255, 165, 0), true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a rectangle on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
The width, in pixel, of the pen used to draw the rectangle.
Color of the rectangle. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a rectangle on a GdPicture image. The drawing color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
The width, in pixel, of the pen used to draw the rectangle.
Color of the rectangle. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a pie on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse in which to draw the pie.
The y-coordinate of the upper-left corner of the rectangle that bounds
the ellipse in which to draw the pie.
Specifies the width of the rectangle that bounds the ellipse in which to
draw the pie.
Specifies the height of the rectangle that bounds the ellipse in which to
draw the pie.
Specifies the angle, in degrees, between the x-axis and the starting point
of the arc that defines the pie. A positive value specifies clockwise
rotation.
The angle, in degrees, between the starting and ending points of the arc
that defines the pie. A positive value specifies clockwise rotation.
The width, in pixel, of the pen used to draw the rectangle.
Color of the pie. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a pie on a GdPicture image. The drawing color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse in which to draw the pie.
The y-coordinate of the upper-left corner of the rectangle that bounds
the ellipse in which to draw the pie.
Specifies the width of the rectangle that bounds the ellipse in which to
draw the pie.
Specifies the height of the rectangle that bounds the ellipse in which to
draw the pie.
Specifies the angle, in degrees, between the x-axis and the starting point
of the arc that defines the pie. A positive value specifies clockwise
rotation.
The angle, in degrees, between the starting and ending points of the arc
that defines the pie. A positive value specifies clockwise rotation.
The width, in pixel, of the pen used to draw the rectangle.
Color of the pie. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a filled pie on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse in which to draw the pie.
The y-coordinate of the upper-left corner of the rectangle that bounds
the ellipse in which to draw the pie.
Specifies the width of the rectangle that bounds the ellipse in which to
draw the pie.
Specifies the height of the rectangle that bounds the ellipse in which to
draw the pie.
Specifies the angle, in degrees, between the x-axis and the starting point
of the arc that defines the pie. A positive value specifies clockwise
rotation.
The angle, in degrees, between the starting and ending points of the arc
that defines the pie. A positive value specifies clockwise rotation.
Color of the filled pie. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a filled pie on a GdPicture image. The filling color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the ellipse in which to draw the pie.
The y-coordinate of the upper-left corner of the rectangle that bounds
the ellipse in which to draw the pie.
Specifies the width of the rectangle that bounds the ellipse in which to
draw the pie.
Specifies the height of the rectangle that bounds the ellipse in which to
draw the pie.
Specifies the angle, in degrees, between the x-axis and the starting point
of the arc that defines the pie. A positive value specifies clockwise
rotation.
The angle, in degrees, between the starting and ending points of the arc
that defines the pie. A positive value specifies clockwise rotation.
Color of the filled pie. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Draws a rotated and filled rectangle on a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Color of the filled rectangle. A suitable color value can be obtained by using the ARGB() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Filling a rotated rectangle on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int left = 50, top = 100, width = 250, height = 150;
float angle = 30.0f;
int fillColor = gdpictureImaging.ARGB(255, 255, 192, 203); // Pink color.
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGB(0, 0, 0, 0));
// Fill the rotated rectangle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the rectangle boundary.
gdpictureImaging.DrawRotatedFilledRectangle(imageID, angle, left, top, width, height, fillColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a rotated and filled rectangle on a GdPicture image. The filling color is specified with an integer value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
Specifies the x-coordinate of the upper-left corner of the rectangle.
Specifies the y-coordinate of the upper-left corner of the rectangle.
Specifies the width of the rectangle.
Specifies the height of the rectangle.
Color of the filled rectangle. A suitable color value can be obtained by using the ARGBI() method.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Filling a rotated rectangle on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int left = 50, top = 100, width = 250, height = 150;
float angle = 30.0f;
int fillColor = gdpictureImaging.ARGBI(255, 255, 192, 203); // Pink color.
int imageID = gdpictureImaging.CreateNewGdPictureImage(400, 400, System.Drawing.Imaging.PixelFormat.Format24bppRgb, gdpictureImaging.ARGBI(0, 0, 0, 0));
// Fill the rotated rectangle. The AntiAlias parameter is set to true to apply antialiasing algorithm, i.e. to improve the appearance of the rectangle boundary.
gdpictureImaging.DrawRotatedFilledRectangle(imageID, angle, left, top, width, height, fillColor, true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a textured line on a GdPicture image using a texture from a file.
GdPicture image identifier.
The texture source file path. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Specifies the x-coordinate of the starting point of the line.
Specifies the y-coordinate of the starting point of the line.
Specifies the x-coordinate of the ending point of the line.
Specifies the y-coordinate of the ending point of the line.
The width, in pixel, of the pen used to draw the line.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.This method requires the Image Documents component to run.
Draws a textured line on a GdPicture image using a texture from a GdPicture image.
GdPicture image identifier.
GdPicture image identifier. Source image used for the texture.
Specifies the x-coordinate of the starting point of the line.
Specifies the y-coordinate of the starting point of the line.
Specifies the x-coordinate of the ending point of the line.
Specifies the y-coordinate of the ending point of the line.
The width, in pixel, of the pen used to draw the line.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.This method requires the Image Documents component to run.
Sets the font size unit used in the Drawing text methods.
A member of the UnitMode enumeration.
Retrieves the font size unit used in the Drawing text methods.
A member of the UnitMode enumeration.
Retrieves the number of fonts available.
The number of fonts available.
Getting the number of available fonts and finding out the name of the first one if any exists.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int fontCount = gdpictureImaging.FontGetCount();
if (fontCount > 0)
{
string fontName = gdpictureImaging.FontGetName(1);
MessageBox.Show("The number of available fonts: " + fontCount.ToString() +
"\nThe name of the first font: " + fontName, "Fonts", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
MessageBox.Show("No fonts are available", "Fonts", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Retrieves the name of an available font.
Value between 1 and FontGetCount().
A font name.
Getting the number of available fonts and finding out the name of the first one if any exists.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int fontCount = gdpictureImaging.FontGetCount();
if (fontCount > 0)
{
string fontName = gdpictureImaging.FontGetName(1);
MessageBox.Show("The number of available fonts: " + fontCount.ToString() +
"\nThe name of the first font: " + fontName, "Fonts", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
MessageBox.Show("No fonts are available", "Fonts", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns if a specific font is symbolic.
Value between 1 and FontGetCount().
True if the font is symbolic, false otherwise.
Returns if a specific font can render a specific text.
Value between 1 and FontGetCount().
The text to render.
True if the font is will be able to render the specified text.
Determines whether the specified style is available for this font family.
The font family name. ("Arial" or "Helvetica"...).
A member of the FontStyle enumeration.
True if the font style is available else False.
Draws a rotated text on a GdPicture image.
GdPicture image identifier.
Angle of rotation in degrees.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle
that bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle
that bounds the.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
Color of the text. A suitable color value can be obtained by using the ARGB() method.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
To draw watermark text use an ARGB value with alpha component < 255.This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Drawing red text "GdPicture.Net" with 45 degree rotation on a png image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the text in the top left corner of the image with 45 degree rotation
gdpictureImaging.DrawRotatedText(imageID, 45, "GdPicture.Net", 15, 5, 24, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGB(255, 255, 0, 0), "Arial", true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a rotated text on a GdPicture image. The drawing color is specified with an integer value.
GdPicture image identifier.
Angle of rotation in degrees.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle that bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle that bounds the.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
Color of the text. A suitable color value can be obtained by using the ARGBI() method.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
To draw watermark text use an ARGB value with alpha component < 255.This method requires the Image Documents component to run.
This method requires the Image Documents component to run.
Drawing red text "GdPicture.Net" with 45 degree rotation on a png image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the text in the top left corner of the image with 45 degree rotation
gdpictureImaging.DrawRotatedText(imageID, 45, "GdPicture.Net", 15, 5, 24, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGBI(255, 255, 0, 0), "Arial", true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a rotated text with background color on a GdPicture image.
GdPicture image identifier.
Angle of rotation in degrees.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
Color of the text. A suitable color value can be obtained by using the ARGB() method.
Color of the background. A suitable color value can be obtained by using the ARGB() method.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
To draw watermark text use an ARGB value with alpha component < 255.This method requires the Image Documents component to run.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Drawing white text "GdPicture.Net" with a red background and 45 degree rotation on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw the text in the top left corner of the image with 45 degree rotation.
gdpictureImaging.DrawRotatedTextBackColor(imageID, 45, "GdPicture.Net", 30, 5, 24, GdPicture14.FontStyle.FontStyleRegular, System.Drawing.Color.White, System.Drawing.Color.Red, "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a text on a GdPicture image.
GdPicture image identifier.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
Color of the text. A suitable color value can be obtained by using the ARGB() method.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
To draw watermark text use an ARGB value with alpha component < 255.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Drawing the red text "GdPicture.Net" on a png image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawText(imageID, "GdPicture.Net", 5, 5, 24, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGB(255, 255, 0, 0), "Arial", true);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a text on a GdPicture image. The drawing color is specified with an integer value.
GdPicture image identifier.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
Color of the text. A suitable color value can be obtained by using the ARGBI() method.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
To draw watermark text use an ARGB value with alpha component < 255.This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Drawing the red text "GdPicture.Net" on a png image and saving the image using maximum compression.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawText(imageID, "GdPicture.Net", 5, 5, 24, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGBI(255, 255, 0, 0), "Arial", true);
// Save the output png using maximum compression.
gdpictureImaging.SaveAsPNG(imageID, "output.png", 9, false);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Calculate the height of the specified text, based on the specified font, font size and font style.
The result is measured in units specified by the FontSetUnit() method.
This method requires the Image Documents component to run.
GdPicture image identifier.
Text to draw.
The name of the font. IE: "Arial".
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
The height of the text measured in units specified by the FontSetUnit() method.
Drawing the red text and the black text border based on the text width and height on jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
string text = "GdPicture.PDF";
// Set font unit to Pixel
gdpictureImaging.FontSetUnit(UnitMode.UnitPixel);
float width = gdpictureImaging.GetTextWidth(imageID, text, "Arial", 24, GdPicture14.FontStyle.FontStyleRegular);
float height = gdpictureImaging.GetTextHeight(imageID, text, "Arial", 24, GdPicture14.FontStyle.FontStyleRegular);
// Draw the text.
gdpictureImaging.DrawText(imageID, text, 10, 10, 24, GdPicture14.FontStyle.FontStyleRegular, Color.Red, "Arial", true);
// Draw the border rectangle.
gdpictureImaging.DrawRectangle(imageID, 10, 10, (int)width, (int)height, 1, Color.Black, true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Calculate the width of the specified text, based on the specified font, font size and font style. The
result is measured in units specified by the FontSetUnit() method.
This method requires the Image Documents component to run.
GdPicture image identifier.
Text to draw.
The name of the font. IE: "Arial".
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
The width of the text measured in units specified by the FontSetUnit() method.
Drawing the red text and the black text border based on the text width and height on jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
string text = "GdPicture.PDF";
// Set font unit to Pixel
gdpictureImaging.FontSetUnit(UnitMode.UnitPixel);
float width = gdpictureImaging.GetTextWidth(imageID, text, "Arial", 24, GdPicture14.FontStyle.FontStyleRegular);
float height = gdpictureImaging.GetTextHeight(imageID, text, "Arial", 24, GdPicture14.FontStyle.FontStyleRegular);
// Draw the text.
gdpictureImaging.DrawText(imageID, text, 10, 10, 24, GdPicture14.FontStyle.FontStyleRegular, Color.Red, "Arial", true);
// Draw the border rectangle.
gdpictureImaging.DrawRectangle(imageID, 10, 10, (int)width, (int)height, 1, Color.Black, true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a text with background color on a GdPicture image.
GdPicture image identifier.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
Color of the text. A suitable color value can be obtained by using the ARGB() method.
Color of the background. A suitable color value can be obtained by using the ARGB() method.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
To draw watermark text use an ARGB value with alpha component < 255.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Drawing white text "GdPicture.Net" with a red background on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawTextBackColor(imageID, "GdPicture.Net", 5, 5, 24, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGB(255, 255, 255, 255), gdpictureImaging.ARGB(255, 255, 0, 0), "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a text with background color on a GdPicture image. The drawing color is specified with an integer value.
GdPicture image identifier.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
Color of the text. A suitable color value can be obtained by using the ARGBI() method.
Color of the background. A suitable color value can be obtained by using the ARGBI() method.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
To draw watermark text use an ARGB value with alpha component < 255.This method requires the Image Documents component to run.
Drawing white text "GdPicture.Net" with a red background on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawTextBackColor(imageID, "GdPicture.Net", 5, 5, 24, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGBI(255, 255, 255, 255), gdpictureImaging.ARGBI(255, 255, 0, 0), "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws an aligned text into a bounding box on a GdPicture image.
GdPicture image identifier.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the text box.
Specifies the y-coordinate of the upper-left corner of the text box.
Specifies the width, in pixels, of the text box.
Specifies the height, in pixels, of the text box.
The font size in units specified by the FontSetUnit() method.
A member of the TextAlign enumeration.
A member of the FontStyle enumeration.
Color of the text. A suitable color value can be obtained by using the ARGB() method.
The name of the font. IE: "Arial".
Set this parameter to True to draw the textbox that bounds the text.
Set to True to apply the Antialiasing algorithm else False.
To draw watermark text use an ARGB value with alpha component < 255.
A member of the GdPictureStatus enumeration.
Drawing some text on images.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw text in the top left corner of the image.
gdpictureImaging.DrawTextBox(imageID, "This is left aligned text by GdPicture.Net", 5, 5, 250, 150, 24, TextAlignment.TextAlignmentNear, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGB(255, 255, 0, 0), "Arial", true, true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
GdPicture14.FontStyle fontStyle = GdPicture14.FontStyle.FontStyleItalic;
string text = "Long sample text";
Color redColor = gdpictureImaging.ARGB(255, 255, 0, 0);
int fontSize = 12;
// Create background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, gdpictureImaging.ARGB(255, 255, 255, 255));
// Draw sample text into the background image.
gdpictureImaging.DrawTextBox(backImage, text, 20, 20, 100, 40, fontSize, TextAlignment.TextAlignmentNear, fontStyle, redColor, "Times", true, true);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Draws an aligned text into a bounding box on a GdPicture image. The drawing color is specified with an integer value.
GdPicture image identifier.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the text box.
Specifies the y-coordinate of the upper-left corner of the text box.
Specifies the width, in pixels, of the text box.
Specifies the height, in pixels, of the text box.
The font size in units specified by the FontSetUnit() method.
A member of the TextAlign enumeration.
A member of the FontStyle enumeration.
Color of the text. A suitable color value can be obtained by using the ARGBI() method.
The name of the font. IE: "Arial".
Set this parameter to True to draw the textbox that bounds the text.
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
To draw watermark text use an ARGB value with alpha component < 255.
This method requires the Image Documents component to run.
Drawing some text on images.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw text in the top left corner of the image.
gdpictureImaging.DrawTextBox(imageID, "This is left aligned text by GdPicture.Net", 5, 5, 250, 150, 24, TextAlignment.TextAlignmentNear, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGBI(255, 255, 0, 0), "Arial", true, true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
GdPicture14.FontStyle fontStyle = GdPicture14.FontStyle.FontStyleItalic;
string text = "Long sample text";
int redColor = gdpictureImaging.ARGBI(255, 255, 0, 0);
int fontSize = 12;
// Create background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, gdpictureImaging.ARGBI(255, 255, 255, 255));
// Draw sample text into the background image.
gdpictureImaging.DrawTextBox(backImage, text, 20, 20, 100, 40, fontSize, TextAlignment.TextAlignmentNear, fontStyle, redColor, "Times", true, true);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Measures the specified string when drawn with the specified Font and the specified alignment.
This method requires the Image Documents component to run.
GdPicture image identifier.
Text to draw.
Specifies/Receives the x-coordinate of the upper-left corner of the text box.
Specifies/Receives the y-coordinate of the upper-left corner of the text box.
Specifies/Receives the width, in pixels, of the text box.
Specifies/Receives the height, in pixels, of the text box.
The font size in units specified by the FontSetUnit() method.
A member of the TextAlign enumeration.
A member of the FontStyle enumeration.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
Receives the number of characters that actually fit into the layout rectangle.
Receives the number of lines that fit into the layout rectangle.
Draws a text on a GdPicture image using a linear gradient Imaging.Colors.
GdPicture image identifier.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the.
Starting color of the gradient. A suitable color value can be obtained by using the ARGB() method.
Ending color of the gradient. A suitable color value can be obtained by using the ARGB() method.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
To draw watermark text use an ARGB value with alpha component < 255.
A member of the GdPictureStatus enumeration.
Drawing text using linear gradient fill with red start color and black end color on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawTextGradient(imageID, "GdPicture.Net", 5, 5, gdpictureImaging.ARGB(255, 255, 0, 0), gdpictureImaging.ARGB(255, 0, 0, 0), 48, GdPicture14.FontStyle.FontStyleRegular, "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a text on a GdPicture image using a linear gradient Imaging.Colors. The drawing colors are specified with integer values.
GdPicture image identifier.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle that
bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle that
bounds the.
Starting color of the gradient. A suitable color value can be obtained by using the ARGBI() method.
Ending color of the gradient. A suitable color value can be obtained by using the ARGBI() method.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
To draw watermark text use an ARGB value with alpha component < 255.
This method requires the Image Documents component to run.
Drawing text using linear gradient fill with red start color and black end color on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawTextGradient(imageID, "GdPicture.Net", 5, 5, gdpictureImaging.ARGBI(255, 255, 0, 0), gdpictureImaging.ARGBI(255, 0, 0, 0), 48, GdPicture14.FontStyle.FontStyleRegular, "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a textured text on a GdPicture image using a texture from a file.
GdPicture image identifier.
The texture source file path. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle
that bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle
that bounds the.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Drawing text using image texture fill from file on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawTextTextureFromFile(imageID, "texture.bmp", "GdPicture.Net", 5, 5, 24, GdPicture14.FontStyle.FontStyleRegular, "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Draws a textured text on a GdPicture image using a texture from a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
GdPicture image identifier. Source image used for the texture.
Text to draw.
Specifies the x-coordinate of the upper-left corner of the rectangle
that bounds the.
Specifies the y-coordinate of the upper-left corner of the rectangle
that bounds the.
The font size in units specified by the FontSetUnit() method.
A member of the FontStyle enumeration.
The name of the font. IE: "Arial".
Set to True to apply the Antialiasing algorithm else False.
A member of the GdPictureStatus enumeration.
Drawing text using image texture fill from GdPicture image on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
int imageTextureID = gdpictureImaging.CreateGdPictureImageFromFile("texture.bmp");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawTextTextureFromGdPictureImage(imageID, imageTextureID, "GdPicture.Net", 5, 5, 24, GdPicture14.FontStyle.FontStyleRegular, "Arial", true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Fills an area of unified color in a GdPicture image with a specific color.
GdPicture image identifier.
Specifies the x-coordinate, in pixel, of the point where filling is to
start.
Specifies the y-coordinate, in pixel, of the point where filling is to
start.
The filling color. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
This method or an overload of it is used in the "Image Processing" VB.NET Demo.
Filling an area of unified color in a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Fills an area of unified color.
gdpictureImaging.FloodFill(imageID, 5, 5, gdpictureImaging.ARGBI(255, 255, 0, 0));
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Fills an area of unified color in a GdPicture image with a specific color.
GdPicture image identifier.
Specifies the x-coordinate, in pixel, of the point where filling is to
start.
Specifies the y-coordinate, in pixel, of the point where filling is to
start.
Color to use for the filling operation. A suitable color value can be obtained by using the ARGB() method.
This method or an overload of it is used in the "Image Processing" VB.NET Demo.
A member of the GdPictureStatus enumeration.
Filling an area of unified color in a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Fills an area of unified color.
gdpictureImaging.FloodFill(imageID, 5, 5, Color.Red);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs a twirl effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
Twirl Factor between 0 and 100.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs a swirl effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
Swirl Factor between 1 and 100.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs a rounded mirror effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Applying the mirror rounded effect to an image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the mirror rounded effect to an image.
gdpictureImaging.FxMirrorRounded(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs horizontal wave effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
Width of the wave in pixels.
Height of the wave in pixels.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs vertical wave effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
Width of the wave in pixels.
Height of the wave in pixels.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs blur effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a blur effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the blur effect to your image.
gdpictureImaging.FxBlur(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs a Subtract Background (RollingBall) algorithm. It mainly is used for Medical Images like
images of cells. The two parameters in the algorithm give you control over the size of the
subtraction and the color of it. For more information please revise Stanley Sternberg's, “Biomedical
Image Processingâ€, IEEE Computer, January 1983.
GdPicture image identifier.
Size of ball rolled under the image. Controlled the amount of
subtraction. Value >= 50.
Whether a background is lighter or not than the foreground. Value >=
true.
A member of the GdPictureStatus enumeration.
Subtracting background from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Subtracting a background (RollingBall).
gdpictureImaging.FxSubtractBackground(imageID, 10, false);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs scan line effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs sepia effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a sepia effect on a grayscale or colored image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("color_image.jpg", true);
// Applying the sepia effect to an image.
gdpictureImaging.FxSepia(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "color_image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs "colorization" effect on a GdPicture image or on an area of a GdPicture image
defined by SetROI().
GdPicture image identifier.
Hue [0 - 100].
Saturation [0 - 100].
Luminosity [0 - 100].
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a "colorization" effect on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Performing "colorization" effect.
gdpictureImaging.FxColorize(imageID, 180, 50, 100);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs Dilate effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs a contrast histogram stretch filter on a GdPicture image or on an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Applying the contrast stretch effect to a colored image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("color_image.jpg", true);
// Stretch the contrast levels of an image.
gdpictureImaging.FxStretchContrast(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "color_image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs an automatic contrast enhancement on a GdPicture image or on an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Performs a negative effect (color inversion) on a GdPicture image or on an area of a GdPicture image
defined by SetROI() method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a negative effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
gdpictureImaging.FxNegative(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create two duplicate gdpicture images from the input file.
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
int imageID2 = gdpictureImaging.CreateClonedGdPictureImage(imageID1);
// Process both of your images (differently).
gdpictureImaging.FxFire(imageID1);
gdpictureImaging.FxNegative(imageID2);
// Save your images in the same multipage tif file.
gdpictureImaging.TiffSaveAsMultiPageFile(imageID1, "images.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffAddToMultiPageFile(imageID1, imageID2);
gdpictureImaging.TiffCloseMultiPageFile(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Performs a convolution filter on a GdPicture image or on an area of a GdPicture image defined by SetROI() method.
This method requires the Image Documents component to run.
GdPicture image identifier.
The 2D array specifying the convolution kernel. It must be squared, odd and in the [3, 99] range (see example).
Specifies if the alpha channel must be processed.
A member of the GdPictureStatus enumeration.
Performs a fire effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a fire effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the fire effect to your image.
gdpictureImaging.FxFire(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create two duplicate gdpicture images from the input file.
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
int imageID2 = gdpictureImaging.CreateClonedGdPictureImage(imageID1);
// Process both of your images (differently).
gdpictureImaging.FxFire(imageID1);
gdpictureImaging.FxNegative(imageID2);
// Save your images in the same multipage tif file.
gdpictureImaging.TiffSaveAsMultiPageFile(imageID1, "images.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffAddToMultiPageFile(imageID1, imageID2);
gdpictureImaging.TiffCloseMultiPageFile(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Performs a halo effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
The left destination of the halo.
The top destination of the halo.
The halo radius.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Adding a halo effect to your image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Set the location and the size for the effect.
int left = 1000;
int top = 500;
int radius = 500;
// Apply the halo effect to your image.
gdpictureImaging.FxHalo(imageID, left, top, radius);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs red eyes correction filter on a GdPicture image or on an area of a GdPicture image defined
by SetROI() method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing red eyes correction filter on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Perform red eyes correction filter.
gdpictureImaging.FxRedEyesCorrection(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs a soften filter on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
Factor between 1 and 100.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs a 3x3 despeckle filter (also known as median filter) on a GdPicture image or on an area of a
GdPicture image defined by SetROI() method. It works as a noise removal filter, for Salt-And-Pepper
like-noise, or varied dots around a document.
It can remove black noise pixels from white backgrounds and visa versa. It also can remove random noise from multicolored backgrounds.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Applying a despeckle filter an a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
gdpictureImaging.FxDespeckle(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "processed_image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs a 3x3 despeckle filter on a GdPicture image or on an area of a GdPicture image defined by SetROI() method.
It works as a noise removal filter, for Salt-And-Pepper like-noise, or varied dots around a document.
It can remove black noise pixels from white backgrounds and visa versa.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
Option to make sure text in small documents was not affected. Only set to True if image DPI is less than 200. Otherwise, set to False.
A member of the GdPictureStatus enumeration.
This method is used in the C# "Document Clean Up" Demo.
This method requires the Image Documents component to run.
Offers advanced despeckle features on a GdPicture image or on an area of a GdPicture image defined by SetROI() method.
It works as a noise removal filter, for Salt-And-Pepper like-noise, or varied dots around a document.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
A member of the DespeckleType enumeration. The despeckle mode.
The strength for the cleanup. The higher is the value, the more pixels are changed.
A member of the GdPictureStatus enumeration.
The advanced bitonal despeckle offers several flavors of cleanup algorithms: remove small speckles, remove isolated dots, remove
tiny white holes, etc.
The strength parameter adjusts the internal parameters of the selected type of despeckle. The higher is the value, the more impact
the filter has on the image. The typical usage is a slider in the user interface from 0 to 100. When the slider is on position 0, the image
is not changed. When the slider is on position 100, a lot of pixels are removed from the image.This method requires the Image Documents component to run.
Performs an extreme despeckle filter on a GdPicture image or on an area of a GdPicture image defined by SetROI() method.
This method requires the Image Documents component to run.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
Option to try to detect the dots of i and j letters in the text and not remove it as part of noise. If set to true, will slow down the filter a little.
A member of the GdPictureStatus enumeration.
Performs a skeletonize (thinning) algorithm on a bitonal GdPicture image or part of it by using SetROI().
This method reduces edges sizes, it can reduce edges to 1 pixel in thickness.
GdPicture image identifier.
Number of passes the algorithm should run. The higher the passes, the thinner the originally thick edges will be. If -1 is used, the
algorithm will run until all edges are 1 pixel thick. Range from 1 - 10. If you do not know what to use, a value of 4 is suggested.
A member of the GdPictureStatus enumeration.
This method supports only 1 bpp indexed (Format1bppIndexed) images.
It is suggested that for noisy images a call to FxBitonalDepeckle() or FxBitonalDespeckleMore() is made before the use of this method to yield better results
and so that noise is not thinned out.
This method requires the Image Documents component to run.
Performs an outline effect on a bitonal GdPicture image or on an area of a GdPicture image defined by
SetROI() method. The effect trims regions that are at least 3 pixels thick into their outer edges.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method supports only 1 bpp indexed (Format1bppIndexed) images.
It is suggested that for noisy images a call to FxBitonalDepeckle() or FxBitonalDespeckleMore() is made before the use of this method to yield better results
and so that noise is not outlined.
This method is used in the "Image Processing" Demo.
This method requires the Image Documents component to run.
Performs a 5x5 despeckle filter on a GdPicture image or on an area of a GdPicture image defined by SetROI() method.
It works as a noise removal filter, for Salt-And-Pepper like-noise, or varied dots around a document.
It can remove black noise pixels from white backgrounds and visa versa.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
Option to make sure text in small documents was not affected. Only set to True if image DPI is less than 200. Otherwise, set to False.
A member of the GdPictureStatus enumeration.
This method is used in the "Document Clean Up" C# Demo.
This method requires the Image Documents component to run.
Performs a median filter of any size of kernel (amount of pixels included in operation) on a
GdPicture image or on an area of a GdPicture image defined by SetROI() method.
This method clears the image of Salt and Pepper noise, which is random dot like noise of white and black color.
GdPicture image identifier.
Level corresponding to number of pixels to include in the median operation,
where Level = n, corresponds to (n*2+1)^2 pixels to be included. For
Example, KernelSize = 1 includes 9 pixels in the median operation,
KernelSize = 2 includes 25 pixels in the median operation. Range from 1 to 60.
If value supplied is out of range the method will return GdPictureStatus.InvalidParameter.
This method is used in the "Image Processing" and the "Document Clean Up" C# Demo.
A member of the GdPictureStatus enumeration.
Performing a median filter on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Range from 1 to 60. The higher the value, the harsher it applies the filter.
int kernel_size = 2;
// Performing a median filter.
gdpictureImaging.FxMedian(imageID, kernel_size);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs a Gaussian (blur via Gaussian deviation formula)filter of any size of kernel (amount of
pixels included in operation) on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
The size of the square kernel to use. Should be a odd value. For example, a size of 3 will involve 3 * 3 pixels in each pass. The larger the value
the more blur you get. The range is larger or equal than 3, and less than the Image's Smaller Dimension (Width, Height) divided by 2.
Suggested value is 3 for a [96-120] DPI image and 5 for a [200-250] dpi bitmap.
If the value supplied is our of range the method will return GdPictureStatus.InvalidParameter.
This method is used in the "Image Processing" and the "Document Clean Up" C# Demo.
A member of the GdPictureStatus enumeration.
Applies a gaussian filter to a region of interest set on an image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image_1080x720.jpg", true);
// Set the blur intensity of the gaussian filter.
int kernel = 20;
// Set the region of interest.
gdpictureImaging.SetROI(300, 200, 500, 150);
// Apply the gaussian filter to the ROI.
gdpictureImaging.FxGaussian(imageID, kernel);
// Delete the region of interest.
gdpictureImaging.ResetROI();
gdpictureImaging.SaveAsJPEG(imageID, "image_1080x720.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs a Edge Detection via the Sobel Operator on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Performs a Edge Detection via the Prewitt Operator on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Performs an Unsharp Mask effect which is a Sharpen effect via subtracting a Gaussian mask of the
image, on a GdPicture image or on an area of a GdPicture image defined by SetROI() method.
GdPicture image identifier.
Radius of Edges to become after the effect is applies. It controls how wide
they get after the filter is applied. Radius and Amount interact, reducing
one, allows more of the other. Minimum Value of Radius should be 3 or more
to allow for enough pixels surrounding the edge to be investigated. If value
passed less than 3 is passed it will be ammended automatically to 3. Proper
value is 5. Value >= 3.
Amount of Contrast to be added to areas of edges where filter will be
applies. It controls how much darker and how much brighter the edges become.
Proper value is 0.5, Value between 0.0-5.0.
It controls the amount of edges to be sharpened. Smaller values sharpen
more, higher values exclude the subtle edges from being sharpened. Proper
value is 40. Value between 0-255.
A member of the GdPictureStatus enumeration.
This method is used in the "Document Clean Up" C# Demo.
Performs a Maximum filter (Dilate Filter)of any size of kernel (amount of pixels included in
operation) on a GdPicture image or on an area of a GdPicture image defined by SetROI() method. It
selects the Maximum value or the neighboring pixels to each pixel and gives it that value.
Basically, in binary images, it makes objects in the become smaller, and in colored images it makes the image brighter because the darker objects shrink.
GdPicture image identifier.
How much smaller should objects become in each direction of the four directions, left, right, top, and bottom.
This value should be larger than 1 and smaller than Image's Smaller Dimension (Width or Height) divided by 2.
If a value entered is out of range, the method return value will be GdPictureStatus.InvalidParameter.
A member of the GdPictureStatus enumeration.
Performing a maximum filter on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Performing a maximum filter.
gdpictureImaging.FxMax(imageID, 5);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs a Minimum filter (Erode Filter)of any size of kernel (amount of pixels included in
operation) on a GdPicture image or on an area of a GdPicture image defined by SetROI() method. It
selects the Minimum value or the neighboring pixels to each pixel and gives it that value.
Basically, in binary images, it makes objects in the image grow larger, and in colored images it makes the image darker because the darker objects grow.
GdPicture image identifier.
How large should objects grow in each direction of the four directions, left, right, top, and bottom
This value should be larger than 1 and smaller than Image's Smaller Dimension (Width or Height) divided by 2.
If a value entered is out of range, the method return value will be GdPictureStatus.InvalidParameter.
A member of the GdPictureStatus enumeration.
Performing a minimum filter on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Performing a minimum filter.
gdpictureImaging.FxMin(imageID, 5);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs a 5x5 despeckle filter (also known as median filter) on a GdPicture image or into an area of
a GdPicture image defined by SetROI() method. It works as a noise removal filter, for
Salt-And-Pepper like-noise, or varied dots around a document.
It can remove black noise pixels from white backgrounds and visa versa. It also can remove random noise from multicolored backgrounds.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Barcode Recognition" Demo.
Performs emboss effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing an emboss effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the emboss effect to your image.
gdpictureImaging.FxEmboss(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs emboss effect specifying a background color on a GdPicture image or on an area of a
GdPicture image defined by SetROI() method.
GdPicture image identifier.
Background color. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performing an emboss effect on a GdPicture image with a specified background color.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the emboss effect to your image using the specified background color.
gdpictureImaging.FxEmboss(imageID, Color.Bisque);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs emboss more effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method. Same as Emboss effect but to more of a degree.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs emboss more effect specifying a background color on a GdPicture image or on an area of a
GdPicture image defined by SetROI() method. Same as emboss effect but to more of a degree.
GdPicture image identifier.
Color of the background. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Performs engrave effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing an engrave effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the engrave effect to your image.
gdpictureImaging.FxEngrave(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs engrave effect specifying a background color on a GdPicture image or on an area of a
GdPicture image defined by SetROI() method.
GdPicture image identifier.
Background color. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Performing an engrave effect on a GdPicture image with a specified background color.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the engrave effect to your image using the specified background color.
gdpictureImaging.FxEngrave(imageID, Color.Bisque);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs engrave more effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method. Same as Engrave effect but to more of a degree.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs engrave more effect specifying a background color on a GdPicture image or on an area of a
GdPicture image defined by SetROI() method. Same as the Engrave effect but to more of a degree.
GdPicture image identifier.
Background color. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Performs edge enhance effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs connected contour effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a connected contour effect on your image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Applying the connected contour effect to your image.
gdpictureImaging.FxConnectedContour(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs noise effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a noise effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Add the noise to your image.
gdpictureImaging.FxAddNoise(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs contour effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a contour effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Applying the contour effect to your image.
gdpictureImaging.FxContour(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs relief effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a relief effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the relief effect to your image.
gdpictureImaging.FxRelief(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs erode effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs sharpen effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a sharpen effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the sharpen effect to your image.
gdpictureImaging.FxSharpen(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs sharpen more effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method. Same effect as Sharpen but to a larger degree.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs diffuse effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a Diffuse effect on the region of interest on the GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Set the region of interest. Apply the Diffuse effect to your ROI. Delete the region of interest.
gdpictureImaging.SetROI(200, 500, 400, 200);
gdpictureImaging.FxDiffuse(imageID);
gdpictureImaging.ResetROI();
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs DiffuseMore effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method. It is the same as a Diffuse effect but to more of a degree.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a DiffuseMore effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the DiffuseMore effect to your image.
gdpictureImaging.FxDiffuseMore(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs smooth effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs aqua effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing an aqua effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Apply the aqua effect to your image.
gdpictureImaging.FxAqua(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Sets the Red, Green or Blue background color as transparent in a GdPicture image or in area of a
GdPicture image defined by SetROI() method. This method is particularly accurate to remove the
Green, Blue or Red background of a photo.
GdPicture image identifier.
A member of the ColorKey enumeration defining the color to remove (can be
Red, Blue or Green).
Variation between 0 and 512. 0 means no possible variation of the color
key. Suggest value is 240, higher can result with non removed background
space.
Specifies the minimum value of the component. Must be a value between 0 and
255. Default value is 25 for dark background, 50 for standard background
and 80 for background with high luminosity.
A member of the GdPictureStatus enumeration.
Performs "pixelize" effect on a GdPicture image or on an area of a GdPicture image defined
by SetROI() method. This filter makes the image appear as pixelated.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Cloning an area of a jpeg image into a new jpeg image, then performing the "pixelize" effect on the cloned image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, GdPicture14.DocumentFormat.DocumentFormatJPEG);
//Clone an area of the source image into a mew image.
int imageID2 = gdpictureImaging.CreateClonedGdPictureImageArea(imageID1, 50, 50, 100, 250);
//Process the cloned image.
gdpictureImaging.FxPixelize(imageID2);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.png", System.IO.FileMode.CreateNew))
{
//Save a result into a new image file.
gdpictureImaging.SaveAsStream(imageID2, outputStream, GdPicture14.DocumentFormat.DocumentFormatPNG, 6);
}
gdpictureImaging.ReleaseGdPictureImage(imageID2);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
}
}
Performs grayscale effect on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Performing a grayscale effect on a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Convert an image to grayscale.
gdpictureImaging.FxGrayscale(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs black & white effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
GdPicture image identifier.
A member of the BitonalReduction enumeration.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Performs black & white effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method.
This method takes a parameter to defines the palette color weight.
GdPicture image identifier.
A member of the BitonalReduction enumeration.
The color palette weight. Range [1 - 255]. If the value selected is outside the range, minimum or maximum will be automatically selected.
Suggested value is 15. Only available for Burke, Stucki & FloydSteinberg Native.Filters.
A member of the GdPictureStatus enumeration.
Performs black & white effect on a GdPicture image or on an area of a GdPicture image defined by
SetROI() method using a specific threshold value. Values above or equal to the threshold value will
be set white, and values lower than the threshold value will be set as black.
GdPicture image identifier.
Value between [1 and 254] The default value is 128 which means '50%'.pixel
lighter than 50% => become white, darker => become black.
A member of the GdPictureStatus enumeration.
Exports a specified GdPicture image to a HBitmap object based on Microsoft® Windows® Graphics Device Interface (GDI), as an IntPtr value.
Please note that it is your responsibility to release the returned HBitmap object once you have no use for it.
A unique image identifier of the GdPicture image representing the image to export.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that you need to release the resulting HBitmap object with the method after being used.
This method requires the Image Documents component to run.
A pointer to a newly created HBitmap object based on Microsoft® Windows® Graphics Device Interface (GDI), as an IntPtr value,
containing the specified GdPictureImage data. The method can be subsequently used to determine if this method has been successful.
Exports a specified GdPicture image to a HBitmap object based on Microsoft® Windows® Graphics Device Interface (GDI), as an integer value.
Please note that it is your responsibility to release the returned HBitmap object once you have no use for it.
A unique image identifier of the GdPicture image representing the image to export.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that you need to release the resulting HBitmap object with the method after being used.
A pointer to a newly created HBitmap object based on Microsoft® Windows® Graphics Device Interface (GDI), as an integer value,
containing the specified GdPictureImage data. The method can be subsequently used to determine if this method has been successful.
Exports a specified GdPicture image to a HICON object, known as Windows handle to icon, as an IntPtr value.
Please note that it is your responsibility to release the returned HBitmap object once you have no use for it.
A unique image identifier of the GdPicture image representing the image to export.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that you need to release the resulting HICON object with the method after being used.
This method requires the Image Documents component to run.
A pointer to a newly created HICON object, known as Windows handle to icon, as an IntPtr value,
containing the specified GdPictureImage data. The method can be subsequently used to determine if this method has been successful.
Releases a specified HBitmap object from the memory.
A pointer to a HBitmap object you need to release, as an IntPtr value.
Be aware that this method does not reset the previously set error status.
Releases a specified HBitmap object from the memory.
A pointer to a HBitmap object you need to release, as an integer value.
Be aware that this method does not reset the previously set error status.
Releases a specified HICON object from the memory.
A pointer to a HICON object you need to release, as an IntPtr value.
Be aware that this method does not reset the previously set error status.
Gets the Graphics object associated with a GdPicture image.
A unique image identifier of the GdPicture image representing the source image for further usage.
Use the GetStat() method to see if this method Succeeded.
A Graphics object cannot be created from an image that has an indexed pixel format.
This method requires the Image Documents component to run.
A Graphics Object associated with this GdPicture image.
Exports a specified GdPicture image to a DIB object, known as Device Independent Bitmap (DIB), as an IntPtr value.
Please note that it is your responsibility to release the returned DIB object once you have no use for it.
A unique image identifier of the GdPicture image representing the image to export.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that you need to release the resulting DIB object with the method after being used.
This method requires the Image Documents component to run.
A pointer to a newly created DIB object, known as Device Independent Bitmap (DIB), as an IntPtr value,
containing the specified GdPictureImage data. The method can be subsequently used to determine if this method has been successful.
Exports a specified GdPicture image to a DIB object, known as Device Independent Bitmap (DIB), as an integer value.
Please note that it is your responsibility to release the returned DIB object once you have no use for it.
A unique image identifier of the GdPicture image representing the image to export.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that you need to release the resulting DIB object with the method after being used.
This method requires the Image Documents component to run.
A pointer to a newly created DIB object, known as Device Independent Bitmap (DIB), as an integer value,
containing the specified GdPictureImage data. The method can be subsequently used to determine if this method has been successful.
Releases a specified DIB object from the memory.
A pointer to a DIB object you need to release, as an integer value.
Be aware that this method does not reset the previously set error status.
Releases a specified DIB object from the memory.
A pointer to a DIB object you need to release, as an IntPtr value.
Be aware that this method does not reset the previously set error status.
Returns a gdiplus image handle from a GdPicture image.
A unique image identifier of the GdPicture image representing the image to export.
The exported gdiplus image handle.
The exported gdiplus image will have the same pixel source as the GdPicture image passed as a
parameter. Therefore, if you remove the specified GdPicture image from memory you will remove at same time the
exported gdiplus image data.
Use the GetStat() method to check if this method succeeded.
Returns a Bitmap object from a GdPicture image.
A unique image identifier of the GdPicture image representing the image to export.
The exported Bitmap object will have the same pixel source as a GdPicture image.
Therefore, if you remove the GdPicture image from memory you will remove at same time the exported
Bitmap data.
Use the GetStat() method to check if this method succeeded.
This method requires the Image Documents component to run.
A Bitmap object. The exported Bitmap image.
Getting a Bitmap object from a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Get a System.Drawing.Bitmap object and save it to a file.
using (Bitmap bitmap = gdpictureImaging.GetBitmapFromGdPictureImage(imageID))
{
bitmap.Save("image.png");
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates an Anchor Template from a GdPicture image.
Anchoring mechanism (or template recognition) can help to align area to be processed by filters, OMR,
OCR or barcode recognition. For example, if several documents are scanned of the same form, and the
scanning orientation or quality is not guaranteed, the GdPicture Anchoring System can be used to
specify the orientation of each document and the translation made to each document from the one where
the user selected their Areas (surrounding rectangles).
Note: To maximize detection speed and accuracy, the Anchor region must contain less than 50% white pixel and should minimize white margins.
GdPicture image identifier.
The left position, in pixel, (0-based), of the rectangle surrounding the
template.
The top position, in pixel, (0-based), of the rectangle surrounding the
template.
The width, in pixel, of the rectangle surrounding the template.
The height, in pixel, of the rectangle surrounding the template.
An Anchor Template Identifier to be used with the FindAnchor and the DeleteAnchorTemplate method.
This method is used in the "OMR" Demo.
A result of 0 means that the method failed. Use the GetStat() method to determine if this method failed.
Be aware that FindAnchor() method ignores DPI. Templates and candidates need to have the same characteristics to achieve consistent results.
That means you need to rescale images in question according to the DPI if required.
This method requires the ADR & OMR component to run.
Creating an anchor template from the template image and finding the anchor element on the target image. The result is saved into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open image files.
int anchorImage = gdpictureImaging.CreateGdPictureImageFromFile("templateImage.tif");
int targetImage = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
// Create the anchor template. Let supose, that the key element is present on coordinates 100,100 and it has size 50 x 50 pixels.
IntPtr template = gdpictureImaging.CreateAnchorTemplate(anchorImage, 100, 100, 50, 50);
// Change the resolution of the target image to have the same dimensions (in pixels), as the template image.
int anchorImgWidth = gdpictureImaging.GetWidth(anchorImage);
int anchorImgHeight = gdpictureImaging.GetHeight(anchorImage);
gdpictureImaging.Resize(targetImage, anchorImgWidth, anchorImgHeight, System.Drawing.Drawing2D.InterpolationMode.Default);
int left = 0;
int top = 0;
int width = 0;
int height = 0;
double accuracy = 0;
gdpictureImaging.FindAnchor(targetImage, template, OMRMode.FavorSpeed, 0, 0, anchorImgWidth, anchorImgHeight, ref left, ref top, ref width, ref height, ref accuracy);
// If the anchor is successfully recognized, we will mark it on the target image.
if (accuracy > 75)
{
gdpictureImaging.DrawRectangle(targetImage, left, top, width, height, 2, gdpictureImaging.ARGBI(255, 255, 0, 0), false);
}
gdpictureImaging.SaveAsPNG(targetImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(anchorImage);
gdpictureImaging.ReleaseGdPictureImage(targetImage);
}
Releases from the memory an Anchor Template previously created by the CreateAnchorTemplate
method.
The Anchor template identifier.
Tries to determine the position of a specific template on a region of interest of a GdPicture image.
The sample application "OMR - Anchor" demonstrates clearly the usage of the Anchor Mechanism.
GdPicture image identifier.
An Anchor Template Identifier returned by the CreateAnchorTemplate
method.
A member of the OMRMode enumeration. FavorSpeed is suggested since
there is almost no accuracy difference between FavorSpeed and
FavorQuality.
The left position, in pixel, (0-based), of the area to search the
anchor template.
The top position, in pixel, (0-based), of the area to search the
anchor template.
The width, in pixel, of the area to search the anchor template.
The height, in pixel, of the area to search the anchor template.
Output parameter. Returns the left position, in pixel, (0-based), of
the detected anchor template.
Output parameter. Returns the top position, in pixel, (0-based), of
the detected anchor template.
Output parameter. Returns the width, in pixel, of the detected
anchor template.
Output parameter. Returns the height, in pixel, of the detected
anchor template.
Output parameter. Accuracy in percentage [0 - 100].
Be aware that this method ignores DPI. Templates and candidates need to have the same characteristics to achieve consistent results.
That means you need to rescale images in question according to the DPI if required.This method is used in the "OMR" Demo.
A member of the GdPictureStatus enumeration.
Creating an anchor template from the template image and finding the anchor element on the target image. The result is saved into a PNG file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open image files.
int anchorImage = gdpictureImaging.CreateGdPictureImageFromFile("templateImage.tif");
int targetImage = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
// Create the anchor template. Let supose, that the key element is present on coordinates 100,100 and it has size 50 x 50 pixels.
IntPtr template = gdpictureImaging.CreateAnchorTemplate(anchorImage, 100, 100, 50, 50);
// Change the resolution of the target image to have the same dimensions (in pixels), as the template image.
int anchorImgWidth = gdpictureImaging.GetWidth(anchorImage);
int anchorImgHeight = gdpictureImaging.GetHeight(anchorImage);
gdpictureImaging.Resize(targetImage, anchorImgWidth, anchorImgHeight, System.Drawing.Drawing2D.InterpolationMode.Default);
int left = 0;
int top = 0;
int width = 0;
int height = 0;
double accuracy = 0;
gdpictureImaging.FindAnchor(targetImage, template, OMRMode.FavorSpeed, 0, 0, anchorImgWidth, anchorImgHeight, ref left, ref top, ref width, ref height, ref accuracy);
// If the anchor is successfully recognized, we will mark it on the target image.
if (accuracy > 75)
{
gdpictureImaging.DrawRectangle(targetImage, left, top, width, height, 2, gdpictureImaging.ARGBI(255, 255, 0, 0), false);
}
gdpictureImaging.SaveAsPNG(targetImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(anchorImage);
gdpictureImaging.ReleaseGdPictureImage(targetImage);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not. This method is
mainly used for Square and Perfectly Circular Fields. An OMR field can be a checkbox, a fill-in-area
checkbox, areas on a multiple choice examination form, or any area where highlighting is required to
indicate a certain choice.
GdPicture image identifier.
Array of Rectangle. This parameter is used as a reference to the location
of the OMR Fields. Where each Rectangle in the Areas, corresponds to a
rectangle surrounding a single OMR field. For example, if 10 Rectangles
exist in Areas, there will be 10 OMR Fields to be investigated whether they
were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
If many documents are scanned of the same form, and the scanning position (due to translation) or quality is not
guaranteed, the GdPicture Anchoring System can be used to specify the translation made to each document
from the one where the user selected their Areas(surrounding rectangles). Then you can manually change the
rectangle arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
// Specifying rectangles for OMR.
const int markCount = 3;
Rectangle[] areas = new Rectangle[markCount];
// Each mark uses a quadruplet for its location (left, top, width, height).
areas[0] = new Rectangle(850, 1580, 30, 30); // First area left, top, width, height.
areas[1] = new Rectangle(850, 1620, 30, 30); // Second area left, top, width, height.
areas[2] = new Rectangle(850, 1660, 30, 30); // Third area left, top, width, height.
int[] filled = gdpictureImaging.OMRDetectMarks(imageID, areas, markCount);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[index].X.ToString());
result.AppendLine("Top:" + areas[index].Y.ToString());
result.AppendLine("Width:" + areas[index].Width.ToString());
result.AppendLine("Height:" + areas[index].Height.ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not. This method is
mainly used for Square and Perfectly Circular Fields. An OMR field can be a checkbox, a fill-in-area
checkbox, areas on a multiple choice examination form, or any area where highlighting is required to
indicate a certain choice.
GdPicture image identifier.
Array of Rectangle. This parameter is used as a reference to the location
of the OMR Fields. Where each Rectangle in the Areas, corresponds to a
rectangle surrounding a single OMR field. For example, if 10 Rectangles
exist in Areas, there will be 10 OMR Fields to be investigated whether they
were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
Whether the OMR field contains a character inside it or not.
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
If many documents are scanned of the same form, and the scanning position (due to translation) or quality is not
guaranteed, the GdPicture Anchoring System can be used to specify the translation made to each document
from the one where the user selected their Areas(surrounding rectangles). Then you can manually change the
rectangle arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
// Specifying rectangles for OMR.
const int markCount = 3;
Rectangle[] areas = new Rectangle[markCount];
// Each mark uses a quadruplet for its location (left, top, width, height).
areas[0] = new Rectangle(850, 1580, 30, 30); // First area left, top, width, height.
areas[1] = new Rectangle(850, 1620, 30, 30); // Second area left, top, width, height.
areas[2] = new Rectangle(850, 1660, 30, 30); // Third area left, top, width, height.
int[] filled = gdpictureImaging.OMRDetectMarks(imageID, areas, markCount, false);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[index].X.ToString());
result.AppendLine("Top:" + areas[index].Y.ToString());
result.AppendLine("Width:" + areas[index].Width.ToString());
result.AppendLine("Height:" + areas[index].Height.ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not, with Sensitivity
Control and Confidence Level returned. This method is mainly used for Square and Perfectly Circular
Fields. An OMR field can be a checkbox, a fill-in-area checkbox, areas on a multiple choice
examination form, or any area where highlighting is required to indicate a certain choice.
GdPicture image identifier.
Array of Rectangle. This parameter is used as a reference to the location
of the OMR Fields. Where each Rectangle in the Areas, corresponds to a
rectangle surrounding a single OMR field. For example, if 10 Rectangles
exist in Areas, there will be 10 OMR Fields to be investigated whether
they were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
How sensitive the method is to degree of filling of the OMR field in
respect to the size of the field itself. Higher values will result in more
tolerant results where semi filling of the field would yield positive
results. Lower values will result in less tolerant results where maximum
filling of the field only would yield positive results Sensitivity greatly
affects the confidence value returned. Range from 0.0 to 1.0. If different
values are entered, they will automatically be limited to this range.
Default Value is 0.5.
Reference to a 1-Dimensional array of Integers. Must be initialized and
sent to method. After the method is called, the array elements would
correspond to the confidence of the result returned by the method. For
Examples, if Confidence[0] = 40, then the first OMR field result returned
is 40% accurate. It is important to mark that Confidence is greatly
affected by "Sensitivity". Confidence value is a mixture of how much the
sensitivity standard was accomplished, how much was it exceeded or unmet.
It also details the respect of the filling to the size of the border and
the regularity of the border.
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
"Sensitivity" affects the "Confidence" returned. Low Sensitivity would return high results of
Confidence for empty fields, but low Confidence results for semi filled fields. High Sensitivity
would return low results of Confidence for empty fields, but High Confidence results for semi filled
fields. It is important to note that "Confidence" is the degree of confidence that sensitivity rules
are met, and not the actual filling or not filling of the field. If sensitivity values do not
correspond properly to the filling, the confidence would spell to the sensitivity value more than the
actual filling or not filling of the field.
If many documents are scanned of the same form, and the scanning orientation or quality is not guaranteed, the GdPicture Anchoring System can be used to
specify the orientation of each document and the translation made to each document from the one where
the user selected their Areas (surrounding rectangles). Then you can manually change the rectangle
arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
This method requires the ADR & OMR component to run.
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
// Specifying rectangles for OMR.
const int markCount = 3;
Rectangle[] areas = new Rectangle[markCount];
// Each mark uses a quadruplet for its location (left, top, width, height).
areas[0] = new Rectangle(850, 1580, 30, 30); // First area left, top, width, height.
areas[1] = new Rectangle(850, 1620, 30, 30); // Second area left, top, width, height.
areas[2] = new Rectangle(850, 1660, 30, 30); // Third area left, top, width, height.
int[] confidences = new int[markCount];
int[] filled = gdpictureImaging.OMRDetectMarks(imageID, areas, markCount, 0.5, confidences);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[index].X.ToString());
result.AppendLine("Top:" + areas[index].Y.ToString());
result.AppendLine("Width:" + areas[index].Width.ToString());
result.AppendLine("Height:" + areas[index].Height.ToString());
result.AppendLine("Confidence:" + confidences[index].ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not, with Sensitivity
Control and Confidence Level returned. This method is mainly used for Square and Perfectly Circular
Fields. An OMR field can be a checkbox, a fill-in-area checkbox, areas on a multiple choice
examination form, or any area where highlighting is required to indicate a certain choice.
GdPicture image identifier.
Array of Rectangle. This parameter is used as a reference to the location
of the OMR Fields. Where each Rectangle in the Areas, corresponds to a
rectangle surrounding a single OMR field. For example, if 10 Rectangles
exist in Areas, there will be 10 OMR Fields to be investigated whether
they were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
How sensitive the method is to degree of filling of the OMR field in
respect to the size of the field itself. Higher values will result in more
tolerant results where semi filling of the field would yield positive
results. Lower values will result in less tolerant results where maximum
filling of the field only would yield positive results Sensitivity greatly
affects the confidence value returned. Range from 0.0 to 1.0. If different
values are entered, they will automatically be limited to this range.
Default Value is 0.5.
Reference to a 1-Dimensional array of Integers. Must be initialized and
sent to method. After the method is called, the array elements would
correspond to the confidence of the result returned by the method. For
Examples, if Confidence[0] = 40, then the first OMR field result returned
is 40% accurate. It is important to mark that Confidence is greatly
affected by "Sensitivity". Confidence value is a mixture of how much the
sensitivity standard was accomplished, how much was it exceeded or unmet.
It also details the respect of the filling to the size of the border and
the regularity of the border.
Whether the OMR field contains a character inside it or not.
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
"Sensitivity" affects the "Confidence" returned. Low Sensitivity would return high results of
Confidence for empty fields, but low Confidence results for semi filled fields. High Sensitivity
would return low results of Confidence for empty fields, but High Confidence results for semi filled
fields. It is important to note that "Confidence" is the degree of confidence that sensitivity rules
are met, and not the actual filling or not filling of the field. If sensitivity values do not
correspond properly to the filling, the confidence would spell to the sensitivity value more than the
actual filling or not filling of the field.
If many documents are scanned of the same form, and the
scanning orientation or quality is not guaranteed, the GdPicture Anchoring System can be used to
specify the orientation of each document and the translation made to each document from the one where
the user selected their Areas (surrounding rectangles). Then you can manually change the rectangle
arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
This method requires the ADR & OMR component to run.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
// Specifying rectangles for OMR.
const int markCount = 3;
Rectangle[] areas = new Rectangle[markCount];
// Each mark uses a quadruplet for its location (left, top, width, height).
areas[0] = new Rectangle(850, 1580, 30, 30); // First area left, top, width, height.
areas[1] = new Rectangle(850, 1620, 30, 30); // Second area left, top, width, height.
areas[2] = new Rectangle(850, 1660, 30, 30); // Third area left, top, width, height.
int[] confidences = new int[markCount];
int[] filled = gdpictureImaging.OMRDetectMarks(imageID, areas, markCount, 0.5, confidences, false);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[index].X.ToString());
result.AppendLine("Top:" + areas[index].Y.ToString());
result.AppendLine("Width:" + areas[index].Width.ToString());
result.AppendLine("Height:" + areas[index].Height.ToString());
result.AppendLine("Confidence:" + confidences[index].ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not. This method is
mainly used for Oval shaped Fields. An OMR field can be a checkbox, a fill-in-area checkbox, areas on
a multiple choice examination form, or any area where highlighting is required to indicate a certain
choice.
GdPicture image identifier.
Array of Rectangle. This parameter is used as a reference to the location
of the OMR Fields. Where each Rectangle in the Areas, corresponds to a
rectangle surrounding a single OMR field. For example, if 10 Rectangles
exist in Areas, there will be 10 OMR Fields to be investigated whether they
were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
If many documents are scanned of the same form, and the scanning position (due to translation) or quality is not
guaranteed, the GdPicture Anchoring System can be used to specify the translation made to each document
from the one where the user selected their Areas(surrounding rectangles). Then you can manually change the
rectangle arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
// Specifying rectangles for OMR.
const int markCount = 3;
Rectangle[] areas = new Rectangle[markCount];
// Each mark uses a quadruplet for its location (left, top, width, height).
areas[0] = new Rectangle(850, 1580, 30, 30); // First area left, top, width, height.
areas[1] = new Rectangle(850, 1620, 30, 30); // Second area left, top, width, height.
areas[2] = new Rectangle(850, 1660, 30, 30); // Third area left, top, width, height.
int[] filled = gdpictureImaging.OMRDetectOvalMarks(imageID, areas, markCount);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[index].X.ToString());
result.AppendLine("Top:" + areas[index].Y.ToString());
result.AppendLine("Width:" + areas[index].Width.ToString());
result.AppendLine("Height:" + areas[index].Height.ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not. This method is
mainly used for Oval shaped Fields. An OMR field can be a checkbox, a fill-in-area checkbox, areas on
a multiple choice examination form, or any area where highlighting is required to indicate a certain
choice.
GdPicture image identifier.
Array of Rectangle. This parameter is used as a reference to the location
of the OMR Fields. Where each Rectangle in the Areas, corresponds to a
rectangle surrounding a single OMR field. For example, if 10 Rectangles
exist in Areas, there will be 10 OMR Fields to be investigated whether they
were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
Whether the OMR field contains a character inside it or not.
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
If many documents are scanned of the same form, and the scanning position (due to translation) or quality is not
guaranteed, the GdPicture Anchoring System can be used to specify the translation made to each document
from the one where the user selected their Areas(surrounding rectangles). Then you can manually change the
rectangle arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
// Specifying rectangles for OMR.
const int markCount = 3;
Rectangle[] areas = new Rectangle[markCount];
// Each mark uses a quadruplet for its location (left, top, width, height).
areas[0] = new Rectangle(850, 1580, 30, 30); // First area left, top, width, height.
areas[1] = new Rectangle(850, 1620, 30, 30); // Second area left, top, width, height.
areas[2] = new Rectangle(850, 1660, 30, 30); // Third area left, top, width, height.
int[] filled = gdpictureImaging.OMRDetectOvalMarks(imageID, areas, markCount, false);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[index].X.ToString());
result.AppendLine("Top:" + areas[index].Y.ToString());
result.AppendLine("Width:" + areas[index].Width.ToString());
result.AppendLine("Height:" + areas[index].Height.ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not, with Sensitivity
Control and Confidence Level returned. This method is mainly used for Oval shaped Fields. An OMR
field can be a checkbox, a fill-in-area checkbox, areas on a multiple choice examination form, or any
area where highlighting is required to indicate a certain choice.
GdPicture image identifier.
Array of Rectangle. This parameter is used as a reference to the location
of the OMR Fields. Where each Rectangle in the Areas, corresponds to a
rectangle surrounding a single OMR field. For example, if 10 Rectangles
exist in Areas, there will be 10 OMR Fields to be investigated whether
they were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
How sensitive the method is to degree of filling of the OMR field in
respect to the size of the field itself. Higher values will result in more
tolerant results where semi filling of the field would yield positive
results. Lower values will result in less tolerant results where maximum
filling of the field only would yield positive results Sensitivity greatly
affects the confidence value returned. Range from 0.0 to 1.0. If different
values are entered, they will automatically be limited to this range.
Default Value is 0.5.
Reference to a 1-Dimensional array of Integers. Must be initialized and
sent to method. After the method is called, the array elements would
correspond to the confidence of the result returned by the method. For
Examples, if Confidence[0] = 40, then the first OMR field result returned
is 40% accurate. It is important to mark that Confidence is greatly
affected by "Sensitivity". Confidence value is a mixture of how much the
sensitivity standard was accomplished, how much was it exceeded or unmet.
It also details the respect of the filling to the size of the border and
the regularity of the border.
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
"Sensitivity" affects the "Confidence" returned. Low Sensitivity would return high results of
Confidence for empty fields, but low Confidence results for semi filled fields. High Sensitivity
would return low results of Confidence for empty fields, but High Confidence results for semi filled
fields. It is important to note that "Confidence" is the degree of confidence that sensitivity rules
are met, and not the actual filling or not filling of the field. If sensitivity values do not
correspond properly to the filling, the confidence would spell to the sensitivity value more than the
actual filling or not filling of the field.
If many documents are scanned of the same form, and the scanning orientation or quality is not guaranteed, the GdPicture Anchoring System can be used to
specify the orientation of each document and the translation made to each document from the one where
the user selected their Areas (surrounding rectangles). Then you can manually change the rectangle
arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
// Specifying rectangles for OMR.
const int markCount = 3;
Rectangle[] areas = new Rectangle[markCount];
// Each mark uses a quadruplet for its location (left, top, width, height).
areas[0] = new Rectangle(850, 1580, 30, 30); // First area left, top, width, height.
areas[1] = new Rectangle(850, 1620, 30, 30); // Second area left, top, width, height.
areas[2] = new Rectangle(850, 1660, 30, 30); // Third area left, top, width, height.
int[] confidences = new int[markCount];
int[] filled = gdpictureImaging.OMRDetectOvalMarks(imageID, areas, markCount, 0.5, confidences);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[index].X.ToString());
result.AppendLine("Top:" + areas[index].Y.ToString());
result.AppendLine("Width:" + areas[index].Width.ToString());
result.AppendLine("Height:" + areas[index].Height.ToString());
result.AppendLine("Confidence:" + confidences[index].ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not, with Sensitivity
Control and Confidence Level returned. This method is mainly used for Oval shaped Fields. An OMR
field can be a checkbox, a fill-in-area checkbox, areas on a multiple choice examination form, or any
area where highlighting is required to indicate a certain choice.
GdPicture image identifier.
Array of Rectangle. This parameter is used as a reference to the location
of the OMR Fields. Where each Rectangle in the Areas, corresponds to a
rectangle surrounding a single OMR field. For example, if 10 Rectangles
exist in Areas, there will be 10 OMR Fields to be investigated whether
they were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
How sensitive the method is to degree of filling of the OMR field in
respect to the size of the field itself. Higher values will result in more
tolerant results where semi filling of the field would yield positive
results. Lower values will result in less tolerant results where maximum
filling of the field only would yield positive results Sensitivity greatly
affects the confidence value returned. Range from 0.0 to 1.0. If different
values are entered, they will automatically be limited to this range.
Default Value is 0.5.
Reference to a 1-Dimensional array of Integers. Must be initialized and
sent to method. After the method is called, the array elements would
correspond to the confidence of the result returned by the method. For
Examples, if Confidence[0] = 40, then the first OMR field result returned
is 40% accurate. It is important to mark that Confidence is greatly
affected by "Sensitivity". Confidence value is a mixture of how much the
sensitivity standard was accomplished, how much was it exceeded or unmet.
It also details the respect of the filling to the size of the border and
the regularity of the border.
Whether the OMR field contains a character inside it or not.
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
"Sensitivity" affects the "Confidence" returned. Low Sensitivity would return high results of
Confidence for empty fields, but low Confidence results for semi filled fields. High Sensitivity
would return low results of Confidence for empty fields, but High Confidence results for semi filled
fields. It is important to note that "Confidence" is the degree of confidence that sensitivity rules
are met, and not the actual filling or not filling of the field. If sensitivity values do not
correspond properly to the filling, the confidence would spell to the sensitivity value more than the
actual filling or not filling of the field.
If many documents are scanned of the same form, and the scanning orientation or quality is not guaranteed, the GdPicture Anchoring System can be used to
specify the orientation of each document and the translation made to each document from the one where
the user selected their Areas (surrounding rectangles). Then you can manually change the rectangle
arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
This method requires the ADR & OMR component to run.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
// Specifying rectangles for OMR.
const int markCount = 3;
Rectangle[] areas = new Rectangle[markCount];
// Each mark uses a quadruplet for its location (left, top, width, height).
areas[0] = new Rectangle(850, 1580, 30, 30); // First area left, top, width, height.
areas[1] = new Rectangle(850, 1620, 30, 30); // Second area left, top, width, height.
areas[2] = new Rectangle(850, 1660, 30, 30); // Third area left, top, width, height.
int[] confidences = new int[markCount];
int[] filled = gdpictureImaging.OMRDetectOvalMarks(imageID, areas, markCount, 0.5, confidences, false);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[index].X.ToString());
result.AppendLine("Top:" + areas[index].Y.ToString());
result.AppendLine("Width:" + areas[index].Width.ToString());
result.AppendLine("Height:" + areas[index].Height.ToString());
result.AppendLine("Confidence:" + confidences[index].ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not, with Sensitivity
Control and Confidence Level returned. This method is mainly used for Square and Perfectly Circular
Fields. An OMR field can be a checkbox, a fill-in-area checkbox, areas on a multiple choice
examination form, or any area where highlighting is required to indicate a certain choice.
This overload is for COM Interop purpose and takes an array of Integer for the Areas parameter.
GdPicture image identifier.
Array of Integer. This parameter is used as a reference to the location
of the OMR Fields. Where each quadruplet (left, top, width, height) corresponds to a
rectangle surrounding a single OMR field. For example, if 40 entries
exist in Areas, there will be 10 OMR Fields to be investigated whether
they were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
How sensitive the method is to degree of filling of the OMR field in
respect to the size of the field itself. Higher values will result in more
tolerant results where semi filling of the field would yield positive
results. Lower values will result in less tolerant results where maximum
filling of the field only would yield positive results Sensitivity greatly
affects the confidence value returned. Range from 0.0 to 1.0. If different
values are entered, they will automatically be limited to this range.
Default Value is 0.5.
Reference to a 1-Dimensional array of Integers. Must be initialized and
sent to method. After the method is called, the array elements would
correspond to the confidence of the result returned by the method. For
Examples, if Confidence[0] = 40, then the first OMR field result returned
is 40% accurate. It is important to mark that Confidence is greatly
affected by "Sensitivity". Confidence value is a mixture of how much the
sensitivity standard was accomplished, how much was it exceeded or unmet.
It also details the respect of the filling to the size of the border and
the regularity of the border.
Whether the OMR field contains a character inside it or not.
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
"Sensitivity" affects the "Confidence" returned. Low Sensitivity would return high results of
Confidence for empty fields, but low Confidence results for semi filled fields. High Sensitivity
would return low results of Confidence for empty fields, but High Confidence results for semi filled
fields. It is important to note that "Confidence" is the degree of confidence that sensitivity rules
are met, and not the actual filling or not filling of the field. If sensitivity values do not
correspond properly to the filling, the confidence would spell to the sensitivity value more than the
actual filling or not filling of the field.
If many documents are scanned of the same form, and the
scanning orientation or quality is not guaranteed, the GdPicture Anchoring System can be used to
specify the orientation of each document and the translation made to each document from the one where
the user selected their Areas (surrounding rectangles). Then you can manually change the rectangle
arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
const int markCount = 3;
// Each mark uses a quadruplet for its location (left, top, width, height).
int[] areas = new int[markCount * 4]
{
// First area left, top, width, height.
850, 1580, 30, 30,
// Second area left, top, width, height.
850, 1620, 30, 30,
// Third area left, top, width, height.
850, 1660, 30, 30
};
int[] confidences = new int[markCount];
int[] filled = gdpictureImaging.OMRDetectMarks(imageID, ref areas, markCount, 0.5, ref confidences, false);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[4 * index].ToString());
result.AppendLine("Top:" + areas[4 * index + 1].ToString());
result.AppendLine("Width:" + areas[4 * index + 2].ToString());
result.AppendLine("Height:" + areas[4 * index + 3].ToString());
result.AppendLine("Confidence:" + confidences[index].ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns whether a selected OMR (Optical Mark Recognition) field/s is filled or not, with Sensitivity
Control and Confidence Level returned. This method is mainly used for Oval shaped Fields. An OMR
field can be a checkbox, a fill-in-area checkbox, areas on a multiple choice examination form, or any
area where highlighting is required to indicate a certain choice.
This overload is for COM Interop purpose and takes an array of Integer for the Areas parameter.
GdPicture image identifier.
Array of Integer. This parameter is used as a reference to the location
of the OMR Fields. Where each quadruplet (left, top, width, height) corresponds to a
rectangle surrounding a single OMR field. For example, if 40 entries
exist in Areas, there will be 10 OMR Fields to be investigated whether
they were checked (filled) or not.
Number of Rectangles sent to the method. Basically, the length of
Areas().
How sensitive the method is to degree of filling of the OMR field in
respect to the size of the field itself. Higher values will result in more
tolerant results where semi filling of the field would yield positive
results. Lower values will result in less tolerant results where maximum
filling of the field only would yield positive results Sensitivity greatly
affects the confidence value returned. Range from 0.0 to 1.0. If different
values are entered, they will automatically be limited to this range.
Default Value is 0.5.
Reference to a 1-Dimensional array of Integers. Must be initialized and
sent to method. After the method is called, the array elements would
correspond to the confidence of the result returned by the method. For
Examples, if Confidence[0] = 40, then the first OMR field result returned
is 40% accurate. It is important to mark that Confidence is greatly
affected by "Sensitivity". Confidence value is a mixture of how much the
sensitivity standard was accomplished, how much was it exceeded or unmet.
It also details the respect of the filling to the size of the border and
the regularity of the border.
Whether the OMR field contains a character inside it or not.
The method returns an Array of integers.
If the value of an element is 0, then the field was not filled. If the value of an element is 1, then
the field was filled.
The Elements of the returned array will correspond to the Elements of the Rectangles Array Areas().
Where if the first element of the returned array[0] is 0, then the OMR field surrounded by the
rectangle in the element of Areas[0] was not filled. Similarly, if the first element of the returned
array[5] is 1, then the OMR field surrounded by the rectangle in the element of Areas[5] was filled.
All Rectangles sent to the method via array Areas can be of any size or location, as long as they:
1. Surround the OMR Field completely.
2. Do not intersect with borders of OMR field.
3. Do not intersect with other objects in the document.
Closer, more accurate selection of those rectangles will yield faster and more accurate results.
"Sensitivity" affects the "Confidence" returned. Low Sensitivity would return high results of
Confidence for empty fields, but low Confidence results for semi filled fields. High Sensitivity
would return low results of Confidence for empty fields, but High Confidence results for semi filled
fields. It is important to note that "Confidence" is the degree of confidence that sensitivity rules
are met, and not the actual filling or not filling of the field. If sensitivity values do not
correspond properly to the filling, the confidence would spell to the sensitivity value more than the
actual filling or not filling of the field.
If many documents are scanned of the same form, and the
scanning orientation or quality is not guaranteed, the GdPicture Anchoring System can be used to
specify the orientation of each document and the translation made to each document from the one where
the user selected their Areas (surrounding rectangles). Then you can manually change the rectangle
arrays to each document via the data provided.
To obtain best and most accurate results, images have to be of good quality, at least 200 dpi is recommended.
This method is used in the "OMR" Demo.
This method requires the ADR & OMR component to run.
Testing whether a selected OMR (Optical Mark Recognition) field/s is filled or not within a tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
const int markCount = 3;
// Each mark uses a quadruplet for its location (left, top, width, height).
int[] areas = new int[markCount * 4]
{
// First area left, top, width, height.
850, 1580, 30, 30,
// Second area left, top, width, height.
850, 1620, 30, 30,
// Third area left, top, width, height.
850, 1660, 30, 30
};
int[] confidences = new int[markCount];
int[] filled = gdpictureImaging.OMRDetectOvalMarks(imageID, ref areas, markCount, 0.5, ref confidences, false);
StringBuilder result = new StringBuilder();
for (int index = 0; index < markCount; index++)
{
result.AppendLine("Index:" + index.ToString());
result.AppendLine("Left:" + areas[4 * index].ToString());
result.AppendLine("Top:" + areas[4 * index + 1].ToString());
result.AppendLine("Width:" + areas[4 * index + 2].ToString());
result.AppendLine("Height:" + areas[4 * index + 3].ToString());
result.AppendLine("Confidence:" + confidences[index].ToString());
result.AppendLine("Filled:" + filled[index].ToString());
result.AppendLine();
}
MessageBox.Show(result.ToString(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the width of a GdPicture image in pixels.
GdPicture image identifier.
Width in pixel.
Utilizing the width of an image when processing it.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Remove 5% all around the image.
int height = gdpictureImaging.GetHeight(imageID);
int width = gdpictureImaging.GetWidth(imageID);
gdpictureImaging.Crop(imageID, width * 5 / 100, height * 5 / 100, width * 90 / 100, height * 90 / 100);
gdpictureImaging.SaveAsPNG(imageID, "crop.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Get the red channel histogram and the image dimensions.
int [] histo = new int[256];
gdpictureImaging.HistogramGetRed(imageID, ref histo);
int count = gdpictureImaging.GetWidth(imageID) * gdpictureImaging.GetHeight(imageID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
// Create an image representing the histogram.
// The image has the same width as the histogram and its height is 1000.
int histogramID = gdpictureImaging.CreateNewGdPictureImage(256, 1000, 24, Color.White);
for ( int i = 0; i < 256; i ++ )
{
int value = histo[i] * 1000 / count;
for (int j = 0; j < value; j++)
{
gdpictureImaging.PixelSetColor(histogramID, i, j, Color.Red);
}
}
gdpictureImaging.SaveAsPNG(histogramID, "histo.png");
gdpictureImaging.ReleaseGdPictureImage(histogramID);
}
Returns the heightof a GdPicture image in pixels.
GdPicture image identifier.
Height in pixels.
Utilizing the height of an image when processing it.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Remove 5% all around the image.
int height = gdpictureImaging.GetHeight(imageID);
int width = gdpictureImaging.GetWidth(imageID);
gdpictureImaging.Crop(imageID, width * 5 / 100, height * 5 / 100, width * 90 / 100, height * 90 / 100);
gdpictureImaging.SaveAsPNG(imageID, "crop.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Get the red channel histogram and the image dimensions.
int[] histo = new int[256];
gdpictureImaging.HistogramGetRed(imageID, ref histo);
int count = gdpictureImaging.GetWidth(imageID) * gdpictureImaging.GetHeight(imageID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
// Create an image representing the histogram.
// The image has the same width as the histogram and its height is 1000.
int histogramID = gdpictureImaging.CreateNewGdPictureImage(256, 1000, 24, Color.White);
for (int i = 0; i < 256; i++)
{
int value = histo[i] * 1000 / count;
for (int j = 0; j < value; j++)
{
gdpictureImaging.PixelSetColor(histogramID, i, j, Color.Red);
}
}
gdpictureImaging.SaveAsPNG(histogramID, "histo.png");
gdpictureImaging.ReleaseGdPictureImage(histogramID);
}
Returns the height of a GdPicture image in inches .
GdPicture image identifier.
Height in inches.
Returns the width of a GdPicture image in inches.
GdPicture image identifier.
Width in inches.
Returns the format of a GdPicture image.
GdPicture image identifier.
A member of the DocumentFormat enumeration.
Returns the pixel format of a GdPicture image.
GdPicture image identifier.
A member of the PixelFormat enumeration.
Returns the color space of a GdPicture image.
GdPicture image identifier.
A member of the ImageColorSpace enumeration.
Returns the bit depth (Bits per Pixel) of a GdPicture image.
GdPicture image identifier.
Can be:
1. For 1 bit per pixel image.
4. For 4 bits per pixel image.
8. For 8 bits per pixel image.
16. For 16 bits per pixel image.
24. For 24 bits per pixel image.
32. For 32 bits per pixel image.
48. For 48 bits per pixel image.
64. For 64 bits per pixel image.
Removing staple marks on 1bpp b&w image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
if ((gdpictureImaging.GetBitDepth(imageID) == 1) && gdpictureImaging.IsBitonal(imageID, 0))
{
gdpictureImaging.RemoveStapleMark(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
}
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the compression scheme of a GdPicture image (TIFF format only).
GdPicture image identifier.
A member of the TiffCompression enumeration
Deskewing a tiff image by analyzing angles in the range [-12; +12] degrees.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("skewed.tif");
gdpictureImaging.AutoDeskew(imageID, 15, gdpictureImaging.ARGB(255, 255, 255, 255), 12, true);
// Let's encode the new tiff with the same mode used by the input image.
TiffCompression tiffCompression = gdpictureImaging.GetTiffCompression(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "deskewed.tif", tiffCompression);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Asks if the pixel format of a GdPicture image is indexed.
GdPicture image identifier.
True if the pixel format is indexed else False.
Processing images with the indexed pixel format.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.IsPixelFormatIndexed(imageID))
{
System.Drawing.Color[] palette = null;
int entriesCount = 0;
gdpictureImaging.PaletteGet(imageID, ref palette, ref entriesCount);
Console.WriteLine("Image contains palete with {0} color entries.", entriesCount.ToString());
}
else Console.WriteLine("Image do not contain indexed colors!");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open image file. Empty string allows the control to prompt for a selecting file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.IsPixelFormatIndexed(imageID))
{
int entriesCount = gdpictureImaging.PaletteGetColorsCount(imageID);
if (entriesCount>255)
{
System.Drawing.Color entryColor = gdpictureImaging.PaletteGetEntry(imageID,130);
Console.WriteLine("Color value of palette entry [130] is: {0}", entryColor.ToString());
}
else Console.WriteLine("Image do not contain palette with 256 colors!");
}
else Console.WriteLine("Image do not contain indexed colors!");
// Release used resources
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns if the pixel format of a GdPicture image has an alpha component.
GdPicture image identifier.
True if the pixel format is indexed else False.
Gets the horizontal resolution of a GdPicture image.
GdPicture image identifier.
Horizontal resolution in Dot Per Inch (DPI).
This method is used in the "Image Processing" Demo.
Gets the vertical resolution of a GdPicture image.
GdPicture image identifier.
Vertical resolution in Dot Per Inch (DPI).
This method is used in the "Image Processing" Demo.
Changes the horizontal resolution of a GdPicture image.
GdPicture image identifier.
The new horizontal resolution in Dot Per Inch (DPI).
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Changes the vertical resolution of a GdPicture image.
GdPicture image identifier.
The new vertical resolution in Dot Per Inch (DPI).
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Computes the red channel histogram of a GdPicture image.
GdPicture image identifier.
Output parameter. Array of 256 entries containing the red channel
histogram data.
A member of the GdPictureStatus enumeration.
Getting the red channel histogram of a jpeg image and creating an image representing this histogram.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Get the red channel histogram and the image dimensions.
int[] histo = new int[256];
gdpictureImaging.HistogramGetRed(imageID, ref histo);
int count = gdpictureImaging.GetWidth(imageID) * gdpictureImaging.GetHeight(imageID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
// Create an image representing the histogram.
// The image has the same width as the histogram and its height is 1000.
int histogramID = gdpictureImaging.CreateNewGdPictureImage(256, 1000, 24, Color.White);
for (int i = 0; i < 256; i++)
{
int value = histo[i] * 1000 / count;
for (int j = 0; j < value; j++)
{
gdpictureImaging.PixelSetColor(histogramID, i, j, Color.Red);
}
}
gdpictureImaging.SaveAsPNG(histogramID, "histo.png");
gdpictureImaging.ReleaseGdPictureImage(histogramID);
}
Computes the green channel histogram of a GdPicture image.
GdPicture image identifier.
Output parameter. Array of 256 entries containing the green channel
histogram data.
A member of the GdPictureStatus enumeration.
Computes the blue channel histogram of a GdPicture image.
GdPicture image identifier.
Output parameter. Array of 256 entries containing the blue channel
histogram data.
A member of the GdPictureStatus enumeration.
Computes the alpha channel histogram of a GdPicture image.
GdPicture image identifier.
Output parameter. Array of 256 entries containing the alpha channel
histogram data.
A member of the GdPictureStatus enumeration.
Computes in one call, alpha, red, green and blue channel histograms of a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Output parameter. Array of 256 entries containing the alpha channel histogram
data.
Output parameter. Array of 256 entries containing the red channel histogram
data.
Output parameter. Array of 256 entries containing the green channel histogram
data.
Output parameter. Array of 256 entries containing the blue channel histogram
data.
A member of the GdPictureStatus enumeration.
Computes the colors histogram of a 8bpp indexed GdPicture image.
GdPicture image identifier.
Output parameter. Array of 256 entries containing the histogram data.
A member of the GdPictureStatus enumeration.
This method works only with 8bpp image.
This method requires the Image Documents component to run.
Removes 1 pixel-sized isolated black dots in 8 directions: E, NE, SE, S, SW, W, NW, N in a
GdPicture image or in an area of a GdPicture image defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
This method requires the Image Documents component to run.
Removing isolated dots from a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Removes 1 pixel-sized isolated black dots in 8 directions: E, NE, SE, S, SW, W, NW, N.
gdpictureImaging.FxBitonalRemoveIsolatedDots8(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removes 1 pixel-sized isolated black dots 4 directions: N, S, W, E in a GdPicture image or in an
area of a GdPicture image defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method requires the Image Documents component to run.
Removing isolated dots from a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Removes 1 pixel-sized isolated black dots 4 directions: N, S, W, E.
gdpictureImaging.FxBitonalRemoveIsolatedDots4(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removes 4 pixels-sized isolated black dots in the 8 directions: E, NE, SE, S, SW, W, NW, N in a
GdPicture image or in an area of a GdPicture image defined by SetROI() method.
GdPicture image identifier.
This method is used in the "Image Processing" Demo.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Removing isolated dots from a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Remove 4 pixels-sized isolated black dots in the 8 directions: E, NE, SE, S, SW, W, NW, N.
gdpictureImaging.FxBitonalRemoveIsolatedDots2x2(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Fills the 1 pixel size holes in the vertical direction in a GdPicture image or in an area of a
GdPicture image defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Barcode Recognition" Demo.
This method requires the Image Documents component to run.
Filling holes within a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Fills the 1 pixel size holes in the vertical direction.
gdpictureImaging.FxBitonalFillHolesV(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Fills the 1 pixel size holes in the vertical and horizontal directions in a GdPicture image or in an
area of a GdPicture image defined by SetROI() method. This methods is equivalent of 2 successive
call of FxBitonalFillHolesV() and FxBitonalFillHolesH()
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Filling holes within a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Fills the 1 pixel size holes in the horizontal and vertical directions.
gdpictureImaging.FxBitonalFillHolesHV(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Fills the 1 pixel size holes in the horizontal direction in a GdPicture image or in an area of a
GdPicture image defined by SetROI() method.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Barcode Recognition" Demo.
This method requires the Image Documents component to run.
Filling holes within a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Fills the 1 pixel size holes in the horizontal direction.
gdpictureImaging.FxBitonalFillHolesH(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Dilates black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter helps to dilate black pixels in 2 directions: W, E. The actions of this filter are
less prominent than FxDilate4.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Dilating a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Dilates black pixels in 2 directions: W, E.
gdpictureImaging.FxBitonalDilateH(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Dilates black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter helps to dilate black pixels in 2 directions: N, S. The actions of this filter are
less prominent than FxDilate4.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Dilating a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Dilates black pixels in 2 directions: N, S.
gdpictureImaging.FxBitonalDilateV(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Dilates black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter helps to dilate black pixels in 4 directions: N, S, W, E. The actions of this filter
are less prominent than FxDilate8.
It can be used used to improve very fine and degraded characters.
GdPicture image identifier.
This method is used in the "Image Processing" and "Barcode Recognition"Demo.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Dilating a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Dilates black pixels in 4 directions: N, S, W, E.
gdpictureImaging.FxBitonalDilate4(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Dilates black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter helps to dilate black pixels in 8 directions: E, NE, SE, S, SW, W, NW, N. The actions
of this filter are more prominent than FxDilate4.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Dilating a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Dilates black pixels in 8 directions: E, NE, SE, S, SW, W, NW, N.
gdpictureImaging.FxBitonalDilate8(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Erodes black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter retains the black pixels surrounded in two cardinal directions: W, E.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Eroding a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Erodes black pixels in two cardinal directions: W, E.
gdpictureImaging.FxBitonalErodeH(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Erodes black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter retains the black pixels surrounded in the two cardinal directions: N, S. The actions of this filter are
less prominent than FxBitonalErode4.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Eroding a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Erodes black pixels in two cardinal directions: N, S.
gdpictureImaging.FxBitonalErodeV(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Erodes black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter retains the black pixels surrounded in the four cardinal directions: N, S, W, E.
Very useful when the characters are bold and very close to each other.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" and "Barcode Recognition"Demo.
Erodes black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter retains the black pixels surrounded in the 8 directions: E, NE, SE, S, SW, W, NW, N.
The actions of this filter are more prominent than FxBitonalErode4.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Performs a morphological open operation a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
An open morphological operation is an erosion operation followed a dilation operation.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Performs a morphological close operation a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
An open morphological operation is a dilation operation followed an erosion operation.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Erodes black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter retains the black pixels surrounded in the 8 directions: E, NE, SE, S, SW, W, NW, N with an amount if pixels in each direction is specified by the user.
Very useful when the characters are bold and very close to each other.
GdPicture image identifier.
This parameter is not used yet.
A member of the GdPictureStatus enumeration.
Dilates black pixels in a GdPicture image or in an area of a GdPicture image defined by SetROI()
method.
This filter helps dilates black pixels surrounded in the 8 directions: E, NE, SE, S, SW, W, NW, N with an amount if pixels specified by the user.
This method requires the Image Documents component to run.
GdPicture image identifier.
This parameter is not used yet.
A member of the GdPictureStatus enumeration.
Applies transformation to a JPEG image without loss of information.
When a JPEG image is compressed, some of the information in the image is lost.
If you open a JPEG file, modify the image, and save it to another JPEG file, the quality will
decrease.
This method allows to opening / modifying / saving JPEG images, without loss of information.
This method requires the Image Documents component to run.
The path of the image to transform.
The path of the transformed image.
The JPEG transformation to apply. A member of the JPEGTransformation enumeration.
A member of the GdPictureStatus enumeration.
The image's width and height have to be divisible by 16, otherwise, and Invalid Parameter will be returned.
Performs a lossless crop on a JPEG image.
The source JPEG image.
The destination JPEG image.
The left position, in pixel, of the area to crop.
The top position, in pixel, of the area to crop.
The width, in pixel, of the area to crop.
The height, in pixel, of the area to crop.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Cropping a jpeg image without loss of information.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Cropping a jpeg image without loss of information.
gdpictureImaging.JPEGLosslessCrop("image.jpg", "cropped.jpg", 0, 0, 100, 100);
}
Returns the XML Packet tag (code 700 (hex 0x02BC)) of a GdPicture image as string.
GdPicture image identifier.
The XML tag content.
Reading the xml packet tag of a jpeg and save it to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Read the xml packet tag.
string xml = gdpictureImaging.TagGetXMLPacket(imageID);
File.WriteAllText("image.xml", xml);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Writes the XML Packet tag (code 700 (hex 0x02BC)) of a GdPicture image as string.
GdPicture image identifier.
The XML packet tag value as string.
A member of the GdPictureStatus enumeration.
Writes the XML Packet tag (code 700 (hex 0x02BC)) of a GdPicture image as byte.
GdPicture image identifier.
The XML packet tag value as byte array.
A member of the GdPictureStatus enumeration.
Asks to the component to preserve or not the tags when a GdPicture image is edited.
True to preserve tags else False.
Returns the number of tags attached to a GdPicture image.
GdPicture image identifier.
The number of tags attached to a GdPicture image.
Dealing with the tags of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Write in a report all the tags available within the file.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tagID = gdpictureImaging.TagGetID(imageID, tagNo);
string tagName = gdpictureImaging.TagGetName(imageID, tagNo);
string tagValue = gdpictureImaging.TagGetValueString(imageID, tagNo);
report.AppendLine(tagID.ToString() + " " + tagName.ToString() + " " + tagValue.ToString());
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Tags", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Walk the list of tags to gather the gps coordinates.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tag = gdpictureImaging.TagGetID(imageID, tagNo);
switch (tag)
{
case Tags.TagGpsLatitudeRef:
report.Append("LatitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLongitudeRef:
report.Append("LongitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLatitude:
case Tags.TagGpsLongitude:
StringBuilder coordinate = new StringBuilder();
if (gdpictureImaging.TagGetType(imageID, tagNo) == TagType.TagTypeRational)
{
// Read the rationals for the coordinate, usually 3 floatting values, 8 bytes per value.
int dataLength = gdpictureImaging.TagGetLength(imageID, tagNo);
byte[] data = new byte[dataLength];
gdpictureImaging.TagGetValueBytes(imageID, tagNo, ref data);
int rationalsCount = dataLength / 8;
int readIndex = 0;
for (int rationalIndex = 0; rationalIndex < rationalsCount; rationalIndex++)
{
uint numerator = System.BitConverter.ToUInt32(data, readIndex);
uint denominator = System.BitConverter.ToUInt32(data, readIndex + 4);
double value = (double)numerator / (double)denominator;
coordinate.Append(value.ToString());
coordinate.Append(" ");
readIndex += 8;
}
}
else
{
coordinate.Append(gdpictureImaging.TagGetValueString(imageID, tagNo));
}
report.Append(tag.ToString() + ": ");
report.AppendLine(coordinate.ToString());
break;
default:
break;
}
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Coordinates", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns the kind of rotation, if any, defined by the exif orientation tag.
GdPicture image identifier.
A member of the GdPictureRotateFlipType enumeration.
Use the GetStat() method to determine if this method succeeded.
GdPictureRotateFlipType.GdPictureRotateNoneFlipNone is returned in case of no orientation tag found on the specified GdPicture image.
Returns the number of IPTC tag attached to a GdPicture image.
GdPicture image identifier.
Number of IPTC tag.
Deletes a tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of tags attached to a
GdPicture image.
A member of the GdPictureStatus enumeration.
Deletes all tags attached to a GdPicture image.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Returns a tag ID attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of tags attached to a
GdPicture image.
A member of the Tags enumeration.
Dealing with the tags of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Write in a report all the tags available within the file.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tagID = gdpictureImaging.TagGetID(imageID, tagNo);
string tagName = gdpictureImaging.TagGetName(imageID, tagNo);
string tagValue = gdpictureImaging.TagGetValueString(imageID, tagNo);
report.AppendLine(tagID.ToString() + " " + tagName.ToString() + " " + tagValue.ToString());
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Tags", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Walk the list of tags to gather the gps coordinates.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tag = gdpictureImaging.TagGetID(imageID, tagNo);
switch (tag)
{
case Tags.TagGpsLatitudeRef:
report.Append("LatitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLongitudeRef:
report.Append("LongitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLatitude:
case Tags.TagGpsLongitude:
StringBuilder coordinate = new StringBuilder();
if (gdpictureImaging.TagGetType(imageID, tagNo) == TagType.TagTypeRational)
{
// Read the rationals for the coordinate, usually 3 floatting values, 8 bytes per value.
int dataLength = gdpictureImaging.TagGetLength(imageID, tagNo);
byte[] data = new byte[dataLength];
gdpictureImaging.TagGetValueBytes(imageID, tagNo, ref data);
int rationalsCount = dataLength / 8;
int readIndex = 0;
for (int rationalIndex = 0; rationalIndex < rationalsCount; rationalIndex++)
{
uint numerator = System.BitConverter.ToUInt32(data, readIndex);
uint denominator = System.BitConverter.ToUInt32(data, readIndex + 4);
double value = (double)numerator / (double)denominator;
coordinate.Append(value.ToString());
coordinate.Append(" ");
readIndex += 8;
}
}
else
{
coordinate.Append(gdpictureImaging.TagGetValueString(imageID, tagNo));
}
report.Append(tag.ToString() + ": ");
report.AppendLine(coordinate.ToString());
break;
default:
break;
}
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Coordinates", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns an IPTC tag ID attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of IPTC TAGs attached to a
GdPicture image.
The IPTC tag ID. A member of the IPTCTags enumeration.
Returns the length in bytes of an IPTC tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of IPTC TAGs attached to a
GdPicture image.
The length of the tag.
Returns the length in bytes of a tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of tags attached to a
GdPicture image.
The length of the tag.
Reading gps coordinates from the tags of a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Walk the list of tags to gather the gps coordinates.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tag = gdpictureImaging.TagGetID(imageID, tagNo);
switch (tag)
{
case Tags.TagGpsLatitudeRef:
report.Append("LatitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLongitudeRef:
report.Append("LongitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLatitude:
case Tags.TagGpsLongitude:
StringBuilder coordinate = new StringBuilder();
if (gdpictureImaging.TagGetType(imageID, tagNo) == TagType.TagTypeRational)
{
// Read the rationals for the coordinate, usually 3 floatting values, 8 bytes per value.
int dataLength = gdpictureImaging.TagGetLength(imageID, tagNo);
byte[] data = new byte[dataLength];
gdpictureImaging.TagGetValueBytes(imageID, tagNo, ref data);
int rationalsCount = dataLength / 8;
int readIndex = 0;
for (int rationalIndex = 0; rationalIndex < rationalsCount; rationalIndex++)
{
uint numerator = System.BitConverter.ToUInt32(data, readIndex);
uint denominator = System.BitConverter.ToUInt32(data, readIndex + 4);
double value = (double)numerator / (double)denominator;
coordinate.Append(value.ToString());
coordinate.Append(" ");
readIndex += 8;
}
}
else
{
coordinate.Append(gdpictureImaging.TagGetValueString(imageID, tagNo));
}
report.Append(tag.ToString() + ": ");
report.AppendLine(coordinate.ToString());
break;
default:
break;
}
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Coordinates", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns as string a tag name attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of tags attached to a
GdPicture image.
The name of the tag.
Reading the tags from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Write in a report all the tags available within the file.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tagID = gdpictureImaging.TagGetID(imageID, tagNo);
string tagName = gdpictureImaging.TagGetName(imageID, tagNo);
string tagValue = gdpictureImaging.TagGetValueString(imageID, tagNo);
report.AppendLine(tagID.ToString() + " " + tagName.ToString() + " " + tagValue.ToString());
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Tags", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns the type of a tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of tags attached to a
GdPicture image.
A member of the TagType enumeration.
Reading gps coordinates from the tags of a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Walk the list of tags to gather the gps coordinates.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tag = gdpictureImaging.TagGetID(imageID, tagNo);
switch (tag)
{
case Tags.TagGpsLatitudeRef:
report.Append("LatitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLongitudeRef:
report.Append("LongitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLatitude:
case Tags.TagGpsLongitude:
StringBuilder coordinate = new StringBuilder();
if (gdpictureImaging.TagGetType(imageID, tagNo) == TagType.TagTypeRational)
{
// Read the rationals for the coordinate, usually 3 floatting values, 8 bytes per value.
int dataLength = gdpictureImaging.TagGetLength(imageID, tagNo);
byte[] data = new byte[dataLength];
gdpictureImaging.TagGetValueBytes(imageID, tagNo, ref data);
int rationalsCount = dataLength / 8;
int readIndex = 0;
for (int rationalIndex = 0; rationalIndex < rationalsCount; rationalIndex++)
{
uint numerator = System.BitConverter.ToUInt32(data, readIndex);
uint denominator = System.BitConverter.ToUInt32(data, readIndex + 4);
double value = (double)numerator / (double)denominator;
coordinate.Append(value.ToString());
coordinate.Append(" ");
readIndex += 8;
}
}
else
{
coordinate.Append(gdpictureImaging.TagGetValueString(imageID, tagNo));
}
report.Append(tag.ToString() + ": ");
report.AppendLine(coordinate.ToString());
break;
default:
break;
}
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Coordinates", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns the type of an IPTC tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of IPTC TAGs attached to a
GdPicture image.
A member of the TagType enumeration.
Returns as string, the value of a tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of tags attached to a
GdPicture image.
The value of the tag.
Dealing with the tags of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Write in a report all the tags available within the file.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tagID = gdpictureImaging.TagGetID(imageID, tagNo);
string tagName = gdpictureImaging.TagGetName(imageID, tagNo);
string tagValue = gdpictureImaging.TagGetValueString(imageID, tagNo);
report.AppendLine(tagID.ToString() + " " + tagName.ToString() + " " + tagValue.ToString());
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Tags", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Walk the list of tags to gather the gps coordinates.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tag = gdpictureImaging.TagGetID(imageID, tagNo);
switch (tag)
{
case Tags.TagGpsLatitudeRef:
report.Append("LatitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLongitudeRef:
report.Append("LongitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLatitude:
case Tags.TagGpsLongitude:
StringBuilder coordinate = new StringBuilder();
if (gdpictureImaging.TagGetType(imageID, tagNo) == TagType.TagTypeRational)
{
// Read the rationals for the coordinate, usually 3 floatting values, 8 bytes per value.
int dataLength = gdpictureImaging.TagGetLength(imageID, tagNo);
byte[] data = new byte[dataLength];
gdpictureImaging.TagGetValueBytes(imageID, tagNo, ref data);
int rationalsCount = dataLength / 8;
int readIndex = 0;
for (int rationalIndex = 0; rationalIndex < rationalsCount; rationalIndex++)
{
uint numerator = System.BitConverter.ToUInt32(data, readIndex);
uint denominator = System.BitConverter.ToUInt32(data, readIndex + 4);
double value = (double)numerator / (double)denominator;
coordinate.Append(value.ToString());
coordinate.Append(" ");
readIndex += 8;
}
}
else
{
coordinate.Append(gdpictureImaging.TagGetValueString(imageID, tagNo));
}
report.Append(tag.ToString() + ": ");
report.AppendLine(coordinate.ToString());
break;
default:
break;
}
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Coordinates", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns as string, the value of a tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of tags attached to a
GdPicture image.
A boolean specifying if undefined tag types should be handled as ASCII tags.
The value of the tag.
Dealing with the tags of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Write in a report all the tags available within the file.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tagID = gdpictureImaging.TagGetID(imageID, tagNo);
string tagName = gdpictureImaging.TagGetName(imageID, tagNo);
string tagValue = gdpictureImaging.TagGetValueString(imageID, tagNo);
report.AppendLine(tagID.ToString() + " " + tagName.ToString() + " " + tagValue.ToString());
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Tags", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Walk the list of tags to gather the gps coordinates.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tag = gdpictureImaging.TagGetID(imageID, tagNo);
switch (tag)
{
case Tags.TagGpsLatitudeRef:
report.Append("LatitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLongitudeRef:
report.Append("LongitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLatitude:
case Tags.TagGpsLongitude:
StringBuilder coordinate = new StringBuilder();
if (gdpictureImaging.TagGetType(imageID, tagNo) == TagType.TagTypeRational)
{
// Read the rationals for the coordinate, usually 3 floatting values, 8 bytes per value.
int dataLength = gdpictureImaging.TagGetLength(imageID, tagNo);
byte[] data = new byte[dataLength];
gdpictureImaging.TagGetValueBytes(imageID, tagNo, ref data);
int rationalsCount = dataLength / 8;
int readIndex = 0;
for (int rationalIndex = 0; rationalIndex < rationalsCount; rationalIndex++)
{
uint numerator = System.BitConverter.ToUInt32(data, readIndex);
uint denominator = System.BitConverter.ToUInt32(data, readIndex + 4);
double value = (double)numerator / (double)denominator;
coordinate.Append(value.ToString());
coordinate.Append(" ");
readIndex += 8;
}
}
else
{
coordinate.Append(gdpictureImaging.TagGetValueString(imageID, tagNo));
}
report.Append(tag.ToString() + ": ");
report.AppendLine(coordinate.ToString());
break;
default:
break;
}
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Coordinates", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns as string, the value of an IPTC tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of IPTC TAGs attached to a
GdPicture image.
The value of the tag.
IPTC tags reading is supported in TIFF and JPEG formats.
Writes an IPTC tag from data stored within formatted string.
GdPicture image identifier.
A member of the IPTCTags enumeration.
A member of the GdPictureStatus enumeration.
IPTC tags writing is supported in TIFF and JPEG formats.
This method requires the Image Documents component to run.
Deletes all IPTC tags attached to a GdPicture image.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Deletes an IPTC tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of IPTC tags attached to a
GdPicture image.
A member of the GdPictureStatus enumeration.
Returns as bytes, the value of a tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of tags attached to a
GdPicture image.
Output parameter. Array where the tag value data will be stored.
The length of the Data array.
Reading gps coordinates from the tags of a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Walk the list of tags to gather the gps coordinates.
StringBuilder report = new StringBuilder();
int tagCount = gdpictureImaging.TagCount(imageID);
for (int tagNo = 1; tagNo <= tagCount; tagNo++)
{
Tags tag = gdpictureImaging.TagGetID(imageID, tagNo);
switch (tag)
{
case Tags.TagGpsLatitudeRef:
report.Append("LatitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLongitudeRef:
report.Append("LongitudeRef: ");
report.AppendLine(gdpictureImaging.TagGetValueString(imageID, tagNo));
break;
case Tags.TagGpsLatitude:
case Tags.TagGpsLongitude:
StringBuilder coordinate = new StringBuilder();
if (gdpictureImaging.TagGetType(imageID, tagNo) == TagType.TagTypeRational)
{
// Read the rationals for the coordinate, usually 3 floatting values, 8 bytes per value.
int dataLength = gdpictureImaging.TagGetLength(imageID, tagNo);
byte[] data = new byte[dataLength];
gdpictureImaging.TagGetValueBytes(imageID, tagNo, ref data);
int rationalsCount = dataLength / 8;
int readIndex = 0;
for (int rationalIndex = 0; rationalIndex < rationalsCount; rationalIndex++)
{
uint numerator = System.BitConverter.ToUInt32(data, readIndex);
uint denominator = System.BitConverter.ToUInt32(data, readIndex + 4);
double value = (double)numerator / (double)denominator;
coordinate.Append(value.ToString());
coordinate.Append(" ");
readIndex += 8;
}
}
else
{
coordinate.Append(gdpictureImaging.TagGetValueString(imageID, tagNo));
}
report.Append(tag.ToString() + ": ");
report.AppendLine(coordinate.ToString());
break;
default:
break;
}
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(report.ToString(), "Coordinates", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns as bytes, the value of an IPTC tag attached to a GdPicture image.
GdPicture image identifier.
Must be a value between 1 and the number of IPTC TAGs attached to a
GdPicture image.
Output parameter. Array where the tag value data will be stored.
The length of the Data array.
Writes a tag from data stored within an array of bytes.
GdPicture image identifier.
A member of the Tags enumeration.
Type of the tag to write. A member of the TagType enumeration.Please ensure that you provide a correct type of the tag.
For further assistance, please refer to the CIPA DC-008-2016: Exchangeable image file format for digital still cameras: Exif Version 2.31.
Array where the tag value data is stored.
A member of the GdPictureStatus enumeration.
Writes a tag from data stored within formatted string.
GdPicture image identifier.
A member of the Tags enumeration.
Type of the tag to write. A member of the TagType enumeration which can be: TagType.TagTypeASCII, TagType.TagTypeByte, TagType.TagTypeLong, TagType.TagTypeShort, TagType.TagTypeSLong, TagType.TagTypeRational or TagType.TagTypeSRational.
Please ensure that you provide a correct type of the tag.
For further assistance, please refer to the CIPA DC-008-2016: Exchangeable image file format for digital still cameras: Exif Version 2.31.
The formatted tag value. Please follow the formats below for individual tag types:
- BYTE tags will have this mask: "#,#,...,#".[#] : A component as unsigned 8-bit integer with a value between 0 and 255.[,] : A component delimiter.
- SHORT tags will have this mask: "#,#,...,#".[#] : A component as unsigned 16-bit integer with a value between 0 and 65535.[,] : A component delimiter.
- Integer tags will have this mask: "#,#,...,#".[#] : A component as unsigned 32-bit integer with a value between 0 and 4294967295.[,] : A component delimiter.
- SInteger tags will have this mask: "#,#,...,#".[#] : A component as signed 32-bit integer with a value between -2147483648 and 2147483647.[,] : A component delimiter.
- RATIONAL tags will have this mask: "#/#,#/#,...,#/#".[#/#] : A component will consist of two unsigned 32-bit integers denoting the enumerator and denominator.
Each integer will have a value between 0 and 4294967295.[,] : A component delimiter.
- SRATIONAL tags will have this mask: "#/#,#/#,...,#/#".[#/#] : A component will consist of two signed 32-bit integers denoting the' enumerator and denominator.
Each integer will have a value between -2147483648 and 2147483647.[,] : A component delimiter.
A member of the GdPictureStatus enumeration.
Starts a MICR recognition process on a GdPicture image or on an area of a GdPicture image defined by SetROI() method.
GdPicture image identifier.
A member of the MICRFont enumeration.
The MICR context. A member of the MICRContext enumeration.
This parameter can be used to specify your own white list of chars.
Can be any members of "0123456789/<#>^ABCDEFGHIJKLMNOPQRSTUVWXYZ" for CMC7 symbols detection or "0123456789ABCD" for E-13B.
Use empty string to recognize all characters.
The number of expected symbols to detect. Use 0 if this number is undefined.
This method is used in the "MICR" Demo.
Use the GetStat() method to determine if this method succeeded.
This method requires the MICR component to run.
The string representation of the detected symbols.
Reading an MICR line within a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
string whiteList = "0123456789/<#>^ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Read the CMC7 line contained in the image.
string text = gdpictureImaging.MICRDoMICR(imageID, MICRFont.MICRFontCMC7, MICRContext.MICRContextLineFinding, whiteList, whiteList.Length);
gdpictureImaging.MICRClear();
gdpictureImaging.ReleaseGdPictureImage(imageID);
MessageBox.Show(text, "MICR", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns the number of symbols recognized during the last MICR process done by the
MICRDoMICR() method.
The number of recognized symbols.
This method is used in the "MICR" Demo.
Use the GetStat() method to determine if this method succeeded.
Returns the detection confidence, in percentage, of one of the symbols recognized during the
last MICR process done by the MICRDoMICR() method.
The symbol index between 1 and the number of recognized symbols returned
by the MICRGetSymbolsCount() method.
The recognized candidate (1 or 2). 1 for the symbol with the best accuracy or 2 for the one with the next-lower level.
The confidence, in the range 0-100.
This method is used in the "MICR" Demo.
Use the GetStat() method to determine if this method succeeded.
Returns the character representation of one of the symbols recognized during the
last MICR process done by the MICRDoMICR() method.
The symbol index between 1 and the number of recognized symbols returned
by the MICRGetSymbolsCount() method.
The recognized candidate (1 or 2). 1 for the symbol with the best accuracy or 2 for the one with the next-lower level.
This method is used in the "MICR" Demo.
Use the GetStat() method to determine if this method succeeded.
The symbol representation. Can be a member of "0123456789/<#>^ABCDEFGHIJKLMNOPQRSTUVWXYZ" for CMC7 symbols or "0123456789ABCD" for E-13B.
Returns the left position, in pixel, of one of the symbols recognized during the
last MICR process done by the MICRDoMICR() method.
The symbol index between 1 and the number of recognized symbols returned
by the MICRGetSymbolsCount() method.
The left position in pixel.
This method is used in the "MICR" Demo.
Use the GetStat() method to determine if this method succeeded.
Returns the top position, in pixel, of one of the symbols recognized during the
last MICR process done by the MICRDoMICR() method.
The symbol index between 1 and the number of recognized symbols returned
by the MICRGetSymbolsCount() method.
The top position in pixel.
This method is used in the "MICR" Demo.
Use the GetStat() method to determine if this method succeeded.
Returns the right position, in pixel, of one of the symbols recognized during the
last MICR process done by the MICRDoMICR() method.
The symbol index between 1 and the number of recognized symbols returned
by the MICRGetSymbolsCount() method.
The right position in pixel.
This method is used in the "MICR" Demo.
Use the GetStat() method to determine if this method succeeded.
Returns the bottom position, in pixel, of one of the symbols recognized during the
last MICR process done by the MICRDoMICR() method.
The symbol index between 1 and the number of recognized symbols returned
by the MICRGetSymbolsCount() method.
The bottom position in pixel.
This method is used in the "MICR" Demo.
Use the GetStat() method to determine if this method succeeded.
Returns the line position of one of the symbols recognized during the last MICR
process done by the MICRDoMICR() method.
The symbol index between 1 and the number of recognized symbols returned
by the MICRGetSymbolsCount() method.
The line on which the symbol has been detected.
This method is used in the "MICR" Demo.
Releases from memory all information about the last MICR process done by the MICRDoMICR() method.
This method is used in the "MICR" Demo.
Returns the number of the selected page.
GdPicture image identifier.
The number of the selected page.
Use the GetStat() method to determine if this method succeeded.
Selects a page in a GdPicture image.
GdPicture image identifier.
The page number in the range [1 - GetPageCount()].
A member of the GdPictureStatus enumeration.
Selects a page in a GdPicture image.
GdPicture image identifier.
The page number in the range [1 - GetPageCount()].
When True, only image properties, metadata and embedded thumbnail will be loaded.
This parameter is particularly useful to obtain image information's without decoding it. Be careful not to call subsequent methods that need to access pixel data if this parameter is set to True
A member of the GdPictureStatus enumeration.
Returns the page count in a GdPicture image.
GdPicture image identifier.
The page count in a GdPicture image.
Use the GetStat() method to determine if this method succeeded.
Sets the transparency color for a Gif GdPicture image.
If the specified GdPicture image is an editable multiframe gif image,
you should use this method for each frame of the image.
GdPicture image identifier.
Color to set as transparent. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Creates a new editable multiframe Gif image based on an
image file.
The path of the file to open. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
0: The image could not created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created editable multiframe gif image.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
This method requires the Image Documents component to run.
Creating a multiframe Gif image based on image files.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a new editable multiframe Gif image based on an image file and append frames from files.
int imageID = gdpictureImaging.GifCreateMultiFrameFromFile("frame1.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame2.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame3.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame4.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame5.bmp");
// Set the number of times the animation should be played, 0 = infinite.
gdpictureImaging.GifSetLoopCount(imageID, 0);
// Set the "frame time" for each and every frame to 1s and the frame disposal to leave the image in place to beentirely or partially overdrawn by the next image.
int frameCount = gdpictureImaging.GifGetFrameCount(imageID);
for (int frameNo = 1; frameNo <= frameCount; frameNo++)
{
gdpictureImaging.GifSetFrameTime(imageID, frameNo, 100);
gdpictureImaging.GifSetFrameDisposal(imageID, frameNo, 1);
}
gdpictureImaging.GifSaveMultiFrameToFile(imageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new editable multiframe gif image based from
a GdPicture image.
GdPicture image identifier. The image from which the new multiframe gif image
will be created.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
This method requires the Image Documents component to run.
0: The image could not created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The created editable multiframe gif image.
Saving the pages of a dicom document to an animated gif.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a gif with the first page.
int gifImageID = gdpictureImaging.GifCreateMultiFrameFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional frames to the gif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.GifAppendFrameFromGdPictureImage(gifImageID, dcmImageID);
}
gdpictureImaging.GifSaveMultiFrameToFile(gifImageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(gifImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Returns the "Loop Count" of a multiframe gif image.
A Loop Count is the number of times an animation of the multiframe gif shall be played.
This method requires the Image Documents component to run.
GdPicture image identifier. The multiframe gif image. (Can be an editable
multiframe gif or a read-only gif image.)
The number of times the animation shall be played. 0 = infinite.
This method works with both editable multiframe gif images and ones opened as read-only.
Sets the "Loop Count" of a multiframe gif image.
A Loop Count is the number of times an animation of the multiframe gif should be played.
GdPicture image identifier. The multiframe gif image. (Can be an editable
multiframe gif or a read-only gif image.).
The number of times the animation should be played. Between 0 and 65536. 0 =
infinite.
A member of the GdPictureStatus enumeration.
This method works with both editable multiframe gif images and ones opened as read-only.
This method requires the Image Documents component to run.
Creating a multiframe Gif image based on image files.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a new editable multiframe Gif image based on an image file and append frames from files.
int imageID = gdpictureImaging.GifCreateMultiFrameFromFile("frame1.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame2.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame3.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame4.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame5.bmp");
// Set the number of times the animation should be played, 0 = infinite.
gdpictureImaging.GifSetLoopCount(imageID, 0);
// Set the "frame time" for each and every frame to 1s and the frame disposal to leave the image in place to beentirely or partially overdrawn by the next image.
int frameCount = gdpictureImaging.GifGetFrameCount(imageID);
for (int frameNo = 1; frameNo <= frameCount; frameNo++)
{
gdpictureImaging.GifSetFrameTime(imageID, frameNo, 100);
gdpictureImaging.GifSetFrameDisposal(imageID, frameNo, 1);
}
gdpictureImaging.GifSaveMultiFrameToFile(imageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Selects a frame of a multiframe gif image. The frame can now be edited or saved to a different file.
GdPicture image identifier. The multiframe gif image. (Can be an editable
multiframe gif or a read-only gif image.).
Frame no between 1 and frame count.
A member of the GdPictureStatus enumeration.
This method works with both editable multiframe gif images and ones opened as read-only
Returns the "frame time" of a frame of a multiframe gif image.
Frame time is the amount of time in ms to display the frame for (GIF specific - the value stored in
the file is centiseconds (1/100th of a second)).
GdPicture image identifier. The multiframe gif image.
Frame no between 1 and frame count.
The frame time of the selected frame of the multiframe gif image.
This method works with both editable multiframe gif images and ones opened as read-only.
This method requires the Image Documents component to run.
Creating a multiframe Gif image based on image files.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a new editable multiframe Gif image based on an image file and append frames from files.
int imageID = gdpictureImaging.GifCreateMultiFrameFromFile("frame1.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame2.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame3.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame4.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame5.bmp");
// Set the number of times the animation should be played, 0 = infinite.
gdpictureImaging.GifSetLoopCount(imageID, 0);
// Set the "frame time" for each and every frame to 1s and the frame disposal to leave the image in place to beentirely or partially overdrawn by the next image.
int frameCount = gdpictureImaging.GifGetFrameCount(imageID);
for (int frameNo = 1; frameNo <= frameCount; frameNo++)
{
gdpictureImaging.GifSetFrameTime(imageID, frameNo, 100);
gdpictureImaging.GifSetFrameDisposal(imageID, frameNo, 1);
}
gdpictureImaging.GifSaveMultiFrameToFile(imageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Sets the "frame time" of a frame of a multiframe gif image.
Frame time is the amount of time in ms to display the frame for (GIF specific - the value stored in
the file is centiseconds (1/100th of a second)).
A member of the GdPictureStatus enumeration.
GdPicture image identifier. The multiframe gif image.
Frame no between 1 and frame count.
Frame time is the amount of time in ms to display the frame for (GIF
specific - the value stored in the file is centiseconds (1/100th of a
second)).
This method works with both editable multiframe gif images and ones opened as read-only.
This method requires the Image Documents component to run.
Sets the "Frame disposal method" of a frame of an editable multiframe gif image.
This method should be called before saving using the GifSaveMultiFrameToFile() method.
This defines what to do with the logical canvas area after displaying this image.
GdPicture image identifier. The multiframe gif image.
Frame no between 1 and frame count.
Can be:1: Leave. Will leave the image in place to be
entirely or partially overdrawn by the next image.2:
Background. Will blank out the area used by the frame with the
background color.3: Previous. Will return the logical
canvas to the previous state before the image was drawn.
A member of the GdPictureStatus enumeration.
This method works only with editable multiframe gif images.
Creating a multiframe Gif image based on image files.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a new editable multiframe Gif image based on an image file and append frames from files.
int imageID = gdpictureImaging.GifCreateMultiFrameFromFile("frame1.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame2.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame3.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame4.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame5.bmp");
// Set the number of times the animation should be played, 0 = infinite.
gdpictureImaging.GifSetLoopCount(imageID, 0);
// Set the "frame time" for each and every frame to 1s and the frame disposal to leave the image in place to beentirely or partially overdrawn by the next image.
int frameCount = gdpictureImaging.GifGetFrameCount(imageID);
for (int frameNo = 1; frameNo <= frameCount; frameNo++)
{
gdpictureImaging.GifSetFrameTime(imageID, frameNo, 100);
gdpictureImaging.GifSetFrameDisposal(imageID, frameNo, 1);
}
gdpictureImaging.GifSaveMultiFrameToFile(imageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the number of frames in a multiframe gif image.
GdPicture image identifier. The multiframe gif image.
This method works with both editable multiframe gif images and ones opened as read-only.
Number of frames in the multiframe gif image.
Returns 0 if the image is not a multiframe gif image.
Creating a multiframe Gif image based on image files.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a new editable multiframe Gif image based on an image file and append frames from files.
int imageID = gdpictureImaging.GifCreateMultiFrameFromFile("frame1.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame2.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame3.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame4.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame5.bmp");
// Set the number of times the animation should be played, 0 = infinite.
gdpictureImaging.GifSetLoopCount(imageID, 0);
// Set the "frame time" for each and every frame to 1s and the frame disposal to leave the image in place to beentirely or partially overdrawn by the next image.
int frameCount = gdpictureImaging.GifGetFrameCount(imageID);
for (int frameNo = 1; frameNo <= frameCount; frameNo++)
{
gdpictureImaging.GifSetFrameTime(imageID, frameNo, 100);
gdpictureImaging.GifSetFrameDisposal(imageID, frameNo, 1);
}
gdpictureImaging.GifSaveMultiFrameToFile(imageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Gets the current frame (or selected frame) in a multiframe gif image.
GdPicture image identifier. The multiframe gif image.
Returns the current frame of the multiframe gif image.
Returns 0 if the image is not valid or has no selected frame.
This method works with both editable multiframe gif images and ones opened as read-only.
Checks whether an image is a multiframe gif image or not.
GdPicture image identifier. The image to check.
True if the image is a multiframe gif image, else false.
This method works with both editable multiframe gif images and ones opened as read-only.
Determines whether an image is an editable multiframe gif image or not.
GdPicture image identifier. The image to check.
True if the image is an editable multiframe gif image, else false.
Deletes the frame of an editable multiframe gif image at a selected position.
GdPicture image identifier. The editable multiframe gif image in which a frame
will be deleted.
The position of the frame to delete. Must be a value from 1 to the current
number of frames available in the multiframe gif image.
A member of the GdPictureStatus enumeration.
This method can only be used with an editable multiframe gif image.
To check if an image is an editable multiframe gif image you can use the GifIsEditableMultiFrame() method.
To save modifications brought to the multiframe gif image you need to use the GifSaveMultiFrameToFile() method.
This method requires the Image Documents component to run.
This method controls the way of multiframe gif image loading.
By default, the class loads multiframe gif images in read-write mode through the following methods:
CreateGdPictureImageFromByteArray
CreateGdPictureImageFromFile
CreateGdPictureImageFromStream
CreateGdPictureImageFromString
CreateGdPictureImageFromFTP
CreateGdPictureImageFromHTTP
If you want to open multiframe gif images as read-only,
you should this method using False for the WriteAccess parameter.
True to load the multiframe gif images for reading and writing,
else False to open them as read-only.
Saves an editable multiframe gif image to a file.
GdPicture image identifier. The editable multiframe gif image to save as
file.
The path to save the image.
This method can only be used with an editable multiframe gif image.
To check if an image is an editable multiframe gif image you can use the GifIsEditableMultiFrame()
method.
This method must only be used to save an editable multiframe gif image.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Creating a multiframe Gif image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a new editable multiframe Gif image based on an image file and append frames from files.
int imageID = gdpictureImaging.GifCreateMultiFrameFromFile("frame1.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame2.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame3.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame4.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame5.bmp");
// Set the number of times the animation should be played, 0 = infinite.
gdpictureImaging.GifSetLoopCount(imageID, 0);
// Set the "frame time" for each and every frame to 1s and the frame disposal to leave the image in place to beentirely or partially overdrawn by the next image.
int frameCount = gdpictureImaging.GifGetFrameCount(imageID);
for (int frameNo = 1; frameNo <= frameCount; frameNo++)
{
gdpictureImaging.GifSetFrameTime(imageID, frameNo, 100);
gdpictureImaging.GifSetFrameDisposal(imageID, frameNo, 1);
}
gdpictureImaging.GifSaveMultiFrameToFile(imageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a gif with the first page.
int gifImageID = gdpictureImaging.GifCreateMultiFrameFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional frames to the gif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.GifAppendFrameFromGdPictureImage(gifImageID, dcmImageID);
}
gdpictureImaging.GifSaveMultiFrameToFile(gifImageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(gifImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Appends a new frame from file to the end of an editable multiframe gif image.
GdPicture image identifier. The editable multiframe gif image in which the
frame will be added.
The path of the image to append within the editable multiframe gif image.
A member of the GdPictureStatus enumeration.
-This method can only be used with an editable multiframe gif image.
To check if an image is an editable multiframe gif image you can use the GifIsEditableMultiFrame()
method.
To save modifications brought to the multiframe gif image you need to use the
GifSaveMultiFrameToFile() method.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
This method requires the Image Documents component to run.
Creating a multiframe Gif image based on image files.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a new editable multiframe Gif image based on an image file and append frames from files.
int imageID = gdpictureImaging.GifCreateMultiFrameFromFile("frame1.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame2.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame3.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame4.bmp");
gdpictureImaging.GifAppendFrameFromFile(imageID, "frame5.bmp");
// Set the number of times the animation should be played, 0 = infinite.
gdpictureImaging.GifSetLoopCount(imageID, 0);
// Set the "frame time" for each and every frame to 1s and the frame disposal to leave the image in place to beentirely or partially overdrawn by the next image.
int frameCount = gdpictureImaging.GifGetFrameCount(imageID);
for (int frameNo = 1; frameNo <= frameCount; frameNo++)
{
gdpictureImaging.GifSetFrameTime(imageID, frameNo, 100);
gdpictureImaging.GifSetFrameDisposal(imageID, frameNo, 1);
}
gdpictureImaging.GifSaveMultiFrameToFile(imageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Appends a new frame from a GdPicture image to the end of an editable multiframe gif image.
GdPicture image identifier. The editable multiframe gif image in which
the frame will be added.
GdPicture image identifier. The image to append within the editable
multiframe gif image.
A member of the GdPictureStatus enumeration.
This method can only be used with an editable multiframe gif image.
To check if an image is an editable multiframe gif image you can use the GifIsEditableMultiFrame()
method.
To save modifications brought to the multiframe gif image you need to use the
GifSaveMultiFrameToFile() method.
This method requires the Image Documents component to run.
Saving the pages of a dicom document to an animated gif.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a gif with the first page.
int gifImageID = gdpictureImaging.GifCreateMultiFrameFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional frames to the gif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.GifAppendFrameFromGdPictureImage(gifImageID, dcmImageID);
}
gdpictureImaging.GifSaveMultiFrameToFile(gifImageID, "image.gif");
gdpictureImaging.ReleaseGdPictureImage(gifImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Inserts a new frame from file at the selected position an editable multiframe gif image.
The Frame position has to be a number smaller or equal than the current number of frames available in the
multiframe gif image.
GdPicture image identifier. The editable multiframe gif image in which the
frame will be inserted.
The position to add the new frame. Must be a value from 1 to the current
number of frames available in the multiframe gif image.
The path of the image to append within the editable multiframe gif image.
A member of the GdPictureStatus enumeration.
This method can only be used with an editable multiframe gif image.
To check if an image is an editable multiframe gif image you can use the GifIsEditableMultiFrame()
method.
To save modifications brought to the multiframe gif image you need to use the
GifSaveMultiFrameToFile() method.
Supported formats are listed here: http://www.gdpicture.com/solutions/supported-formats/.
This method requires the Image Documents component to run.
Inserts a new frame from a GdPicture image at the given position in an editable multiframe gif image.
The frameposition has to be a number smaller or equal than the current number of frames available in the
multiframe gif image.
GdPicture image identifier. The editable multiframe gif image in which
the frame will be inserted.
The position to add the new frame. Must be a value from 1 to the current
number of frames available in the multiframe gif image.
GdPicture image identifier. The image to append within the editable
multiframe gif image.
A member of the GdPictureStatus enumeration.
This method can only be used with an editable multiframe gif image.
To check if an image is an editable multiframe gif image you can use the GifIsEditableMultiFrame()
method.
To save modifications brought to the multiframe gif image you need to use the
GifSaveMultiFrameToFile() method.
This method requires the Image Documents component to run.
Swaps two frames in an editable multiframe gif image.
GdPicture image identifier. The editable multiframe gif image in which frames
will be swapped.
The position of the first frame to swap with the second. Must be a value from
1 to the current number of frames available in the multiframe gif image.
The position of the second frame to swap with the first one. Must be a value
from 1 to the current number of frames available in the multiframe gif image.
A member of the GdPictureStatus enumeration.
This method can only be used with an editable multiframe gif image.
To check if an image is an editable multiframe gif image you can use the GifIsEditableMultiFrame()
method.
To save modifications brought to the multiframe gif image you need to use the
GifSaveMultiFrameToFile() method.
This method requires the Image Documents component to run.
Stores a GdPicture image as first page of a new multipage JBIG2 file.
You will be able to append new page to the created file using the JBIG2AddToMultiPageFile() method.
This method requires the Image Documents component to run.
GdPicture image identifier. The GdPicture image to store as the first page
of the multipage JBIG2 file.Do not release this image
before ending the multipage JBIG2 file with the JBIG2CloseMultiPageFile()
method. (see example).
The path of the multipage tiff file to create.
A member of the GdPictureStatus enumeration.
Adds a page to a multipage JBIG2 file created with the JBIG2SaveAsMultiPageFile() method.
GdPicture image identifier. The GdPicture image used with the
JBIG2SaveAsMultiPageFile() method. This must be the first image ot the
file.
GdPicture image identifier. The image to append within multipage JBIG2
file. You will be able to release this image after calling this
method.
Use the JBIG2CloseMultiPageFile() method when you don't want to append new page to the multipage
JBIG2 file.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Terminates and closes a multipage JBIG2 file created with the JBIG2SaveAsMultiPageFile() method.
GdPicture image identifier. The GdPicture image stored as the first page of
the multipage JBIG2 file. You will be able to release this image after calling
this method.
A member of the GdPictureStatus enumeration.
Checks if a GdPicture image is a multipage JBIG2 image
GdPicture image identifier. The image to check.
True if the image is a multipage JBIG2 image, else false.
Selects a page of a multipage JBIG2 image. The page can now be edited or saved to a different file.
This method requires the Image Documents component to run.
GdPicture image identifier. The multipage JBIG2 image.
Page number between 1 and page count.
A member of the GdPictureStatus enumeration.
Returns the number of pages currently available in a multipage JBIG2 image.
GdPicture image identifier. The multipage JBIG2 image.
Number of pages currently available in the multipage JBIG2 image. Returns 0 if the image is not a
multipage JBIG2 image.
Returns the number of pages in the specified multipage TIFF image represented by its unique image identifier.
This method only handles multipage TIFF images, both editable or opened as read-only.
A unique image identifier of the GdPicture image representing the multipage TIFF image.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that this method only supports multipage TIFF images, both editable or opened as read-only.
If the specified image is not a multipage image, this method will fail.
The number of pages in the specified multipage TIFF image.
The method can be subsequently used to determine if this method has been successful.
Deleting pages of a multipage tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
gdpictureImaging.TiffDeletePage(imageID, pageCount);
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
int pageNo = 1;
while (pageNo <= pageCount)
{
gdpictureImaging.TiffSelectPage(imageID, pageNo);
if (gdpictureImaging.IsBlank(imageID))
{
gdpictureImaging.TiffDeletePage(imageID, pageNo);
pageCount--;
}
else
{
pageNo++;
}
}
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the page number of the currently selected page within the specified multipage TIFF image represented by its unique image identifier.
This method only handles multipage TIFF images, both editable or opened as read-only.
A unique image identifier of the GdPicture image representing the multipage TIFF image.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that this method only supports multipage TIFF images, both editable or opened as read-only.
If the specified image is not a multipage image, this method will fail.
The page number of the currently selected page in the specified multipage TIFF image.
It is a value from 1 to or 0 if no page is selected.
The method can be subsequently used to determine if this method has been successful.
Selects a required page in the specified multipage TIFF image represented by its unique image identifier.
The defined page is selected for further use, which means, that the page can be edited or saved to a different file.
This method only handles multipage TIFF images, both editable or opened as read-only.
A unique image identifier of the GdPicture image representing the multipage TIFF image.
The page number of a page you want to select. It must be a value from 1 to .
Be aware that this method only supports multipage TIFF images, both editable or opened as read-only.
If the specified image is not a multipage image, this method will fail.
Just to inform you, that you can check out the currently selected page using the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Removing the blank pages from a tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
int pageNo = 1;
while (pageNo <= pageCount)
{
gdpictureImaging.TiffSelectPage(imageID, pageNo);
if (gdpictureImaging.IsBlank(imageID))
{
gdpictureImaging.TiffDeletePage(imageID, pageNo);
pageCount--;
}
else
{
pageNo++;
}
}
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
This method allows you to directly extract a specified page from a multipage TIFF image, that is represented by its unique image identifier.
The required page is easily extracted to a TIFF image file without the need to decode and re-encode the bitmap.
This method only handles multipage TIFF images, both editable or opened as read-only.
Be aware that when working with the multipage TIFF format using GdPicture images, the resulting image files created from individual pages
are compressed in memory using the TIFF CCITT 4 compression when they are bitonal, otherwise they are compressed using the TIFF LZW compression.
A unique image identifier of the GdPicture image representing the multipage TIFF image.
The page number of a page you want to extract. It must be a value from 1 to .
The file path where the TIFF image of the extracted page will be saved. If the specified file already exists, it will be overwritten.
An optional parameter specifying the expected compression mode.
Be aware that this method only supports multipage TIFF images, both editable or opened as read-only. If the specified image is not a multipage image, this method will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
This method allows you to directly extract a specified page from a multipage TIFF image, that is represented by its unique image identifier.
The required page is easily extracted to a TIFF image file without the need to decode and re-encode the bitmap.
This method only handles multipage TIFF images, both editable or opened as read-only.
Be aware that when working with the multipage TIFF format using GdPicture images, the resulting image files created from individual pages
are compressed in memory using the TIFF CCITT 4 compression when they are bitonal, otherwise they are compressed using the TIFF LZW compression.
An optional parameter specifying the expected compression mode.
This method allows you to directly extract a specified page from a multipage TIFF image, that is represented by its unique image identifier,
to a file or to a stream without the need to decode and re-encode the bitmap.
A unique image identifier of the GdPicture image representing the multipage TIFF image.
The page number of a page you want to extract. It must be a value from 1 to .
A Stream object where the TIFF image of the extracted page will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Be aware that this method only supports multipage TIFF images, both editable or opened as read-only. If the specified image is not a multipage image, this method will fail.
Please note that the output stream should be open for writing and should be closed/disposed of by the user as well.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Checks whether the specified image, represented by its unique image identifier, is a multipage TIFF image, either a read-only or an editable one.
A unique image identifier of the GdPicture image representing a required TIFF image.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the specified image is a multipage TIFF image, otherwise false.
The method can be subsequently used to determine if this method has been successful.
Allows you to control the way of creating and loading multipage TIFF image files.
This class loads multipage TIFF images in read-write mode using the CreateGdPictureImageFrom... methods by default.
Setting the WriteAccess parameter to false before loading a file allows you to create multipage TIFF images as read-only.
Set this parameter to true if you want to load files for reading and writing, otherwise set it to false to load them as read-only.
Please ensure you are using this method before loading the file, otherwise it will not take into account.
Creates a new GdPicture image representing the editable multipage TIFF image based on an input file.
The newly created image is identified by its unique non-zero image identifier.
Please note that you can specify the read-only or read-write mode using the method before loading the file.
Creates a new GdPicture image representing the editable multipage TIFF image based on the parameters you have specified.
The file path of the source file. Use the empty string to allow the control to prompt users to select a file.
You can subsequently use the method to retrieve the path of the selected file.
All document formats currently supported by the toolkit are listed here.
A unique image identifier of the GdPicture image representing the newly created editable multipage TIFF image.
The returned value is non-zero if the image is successfully created. Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Handling with a multipage tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage1.tif");
gdpictureImaging.TiffSwapPages(imageID, 1, 2);
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage2.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage1.tif");
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
gdpictureImaging.TiffDeletePage(imageID, pageCount);
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage2.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image representing the editable multipage TIFF image based on an input file.
The newly created image is identified by its unique non-zero image identifier.
Please note that you can specify the read-only or read-write mode using the method before loading the file.
Creates a new GdPicture image representing the editable multipage TIFF image based on the parameters you have specified.
The file path of the source file. Use the empty string to allow the control to prompt users to select a file.
Specifies if the file content will be loaded into memory (true). Loading the file content directly into memory results in
a better manipulation performance, but it consumes more memory. If you load a file into memory, you can subsequently overwrite or delete the file.
Suggested value is false, which means that the file is opened in read access mode.You can subsequently use the method to retrieve the path of the selected file.
All document formats currently supported by the toolkit are listed here.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the newly created editable multipage TIFF image.
The returned value is non-zero if the image is successfully created. Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Handling with a multipage tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
gdpictureImaging.TiffSwapPages(imageID, 1, 2);
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
gdpictureImaging.TiffDeletePage(imageID, pageCount);
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a new GdPicture image representing the editable multipage TIFF image based on a previously created GdPicture image.
The newly created image is identified by its unique non-zero image identifier.
Please note that you can specify the read-only or read-write mode using the method before loading the file.
This method requires the Image Documents component to run.
The unique image identifier of the GdPicture image representing the source image.
A unique image identifier of the GdPicture image representing the newly created editable multipage TIFF image.
The returned value is non-zero if the image is successfully created. Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image with the method after being used.
Saving the pages of a dicom document to a multipage tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a tiff with the first page.
int tiffImageID = gdpictureImaging.TiffCreateMultiPageFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional pages to the tif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.TiffAppendPageFromGdPictureImage(tiffImageID, dcmImageID);
}
gdpictureImaging.TiffSaveMultiPageToFile(tiffImageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Checks whether the specified image, represented by its unique image identifier, is an editable multipage TIFF image, that means it has not been opened as read-only.
A unique image identifier of the GdPicture image representing the multipage TIFF image.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the specified image is an editable multipage TIFF image, means not read-only; otherwise false.
The method can be subsequently used to determine if this method has been successful.
Appends a new page from the specified file to the end of an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image, in which the new page will be added.
The file path of the image file, which will be appended to the specified editable multipage TIFF image.
Supported input document formats are listed here.
Be aware that this method only handles editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Appends a new page from the specified GdPicture image to the end of an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image, in which the new page will be added.
A unique image identifier of the GdPicture image representing the image, which will be appended to the specified editable multipage TIFF image.
Be aware that this method only handles editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Saving the pages of a dicom document to a multipage tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a tiff with the first page.
int tiffImageID = gdpictureImaging.TiffCreateMultiPageFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional pages to the tif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.TiffAppendPageFromGdPictureImage(tiffImageID, dcmImageID);
}
gdpictureImaging.TiffSaveMultiPageToFile(tiffImageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Appends a new page from the specified GdPicture image to the end of an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image, in which the new page will be added.
A unique image identifier of the GdPicture image representing the image, which will be appended to the specified editable multipage TIFF image.
Specifies if the added page must be subsequently selected.
Be aware that this method only handles editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Saving the pages of a dicom document to a multipage tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a tiff with the first page.
int tiffImageID = gdpictureImaging.TiffCreateMultiPageFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional pages to the tif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.TiffAppendPageFromGdPictureImage(tiffImageID, dcmImageID);
}
gdpictureImaging.TiffSaveMultiPageToFile(tiffImageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Inserts a new page from the specified file at a given position of an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image, in which the new page will be inserted.
The required position of the page to insert, that means the page number for the newly inserted page.
It must be a value from 1 to .
The file path of the image file, which will be inserted at the given page position of an editable multipage TIFF image.
Supported input document formats are listed here.
Be aware that this method only handles editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Inserts a new page from the specified file at a given position of an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image, in which the new page will be inserted.
The required position of the page to insert, that means the page number for the newly inserted page.
It must be a value from 1 to .
The file path of the image file, which will be inserted at the given page position of an editable multipage TIFF image.
Supported input document formats are listed here.
Specifies if the added page must be subsequently selected.
Be aware that this method only handles editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Inserts a new page from the specified GdPicture image at a given position of an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image, in which the new page will be inserted.
The required position of the page to insert, that means the page number for the newly inserted page.
It must be a value from 1 to .
A unique image identifier of the GdPicture image representing the image, which will be inserted at the given page position of the specified editable multipage TIFF image.
Be aware that this method only handles editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Inserts a new page from the specified GdPicture image at a given position of an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image, in which the new page will be inserted.
The required position of the page to insert, that means the page number for the newly inserted page.
It must be a value from 1 to .
A unique image identifier of the GdPicture image representing the image, which will be inserted at the given page position of the specified editable multipage TIFF image.
Specifies if the added page must be subsequently selected.
Be aware that this method only handles editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Swaps two pages specified by their page numbers in an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image.
The page number of the one page you want to swap. It must be a value from 1 to .
The page number of the other page you want to swap. It must be a value from 1 to .
Be aware that this method only handles an editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Swapping two pages in a multipage tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
gdpictureImaging.TiffSwapPages(imageID, 1, 2);
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Moves a specified page to a destination page in an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image.
The page number of a required page you want to move. It must be a value from 1 to .
The page number of a destination page. It must be a value from 1 to .
Be aware that this method only handles an editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Deletes a page specified by its page number in an editable multipage TIFF image, that is represented by its unique image identifier.
This method only handles editable multipage TIFF images; otherwise it will fail.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image.
The page number of a page you want to delete. It must be a value from 1 to .
Be aware that this method only handles an editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, for saving the provided modifications you need to use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Deleting the last page of a multipage tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
gdpictureImaging.TiffDeletePage(imageID, pageCount);
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a GdPicture image representing the editable multipage TIFF image to a multipage TIFF file acording to what you have specified.
This method only handles editable multipage TIFF images; otherwise it will fail.
Saves a GdPicture image representing the editable multipage TIFF image to a multipage TIFF file acording to what you have specified.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image to be saved.
The file path where the specified image will be saved. Be aware, that if the destination file path is the same as the source file path,
the method will fail unless the image has not been loaded in memory.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Please note that if you apply the JPEG compression, the quality factor used by default is 90.
You can use the overloaded method to set your preferred value for the JpegQuality parameter.
Be aware that this method only handles editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, if the destination file is the same as the source file, the method will fail,
unless the image has not been loaded in memory applying the LoadInMemory parameter in the overloaded method.Just to inform you, that if you are applying CCITT3 or CCITT4 compression scheme, the image you want to save can only have 1bpp pages included, otherwise the LZW compression scheme is used.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Saving pages to a multipage tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
gdpictureImaging.TiffSwapPages(imageID, 1, 2);
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a tiff with the first page.
int tiffImageID = gdpictureImaging.TiffCreateMultiPageFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional pages to the tif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.TiffAppendPageFromGdPictureImage(tiffImageID, dcmImageID);
}
gdpictureImaging.TiffSaveMultiPageToFile(tiffImageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Saves a GdPicture image representing the editable multipage TIFF image to a multipage TIFF file acording to what you have specified.
You can also define a JPEG quality parameter when the JPEG compression is required using this method.
This method only handles editable multipage TIFF images; otherwise it will fail.
Saves a GdPicture image representing the editable multipage TIFF image to a multipage TIFF file acording to what you have specified.
A unique image identifier of the GdPicture image representing the editable multipage TIFF image to be saved.
The file path where the specified image will be saved. Be aware, that if the destination file path is the same as the source file path,
the method will fail unless the image has not been loaded in memory.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression.
This parameter is ignored when the required compression scheme is different than JPEG.
Be aware that this method only handles editable multipage TIFF images.
You can use the method to check if a required image is an editable multipage TIFF image.
Likewise, if the destination file is the same as the source file, the method will fail,
unless the image has not been loaded in memory applying the LoadInMemory parameter in the overloaded method.Just to inform you, that if you are applying CCITT3 or CCITT4 compression scheme, the image you want to save can only have 1bpp pages included, otherwise the LZW compression scheme is used.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Saving pages to a multipage tiff.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
gdpictureImaging.TiffSwapPages(imageID, 1, 2);
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionJPEG, 90);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int dcmImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.dcm", false);
// Create a tiff with the first page.
int tiffImageID = gdpictureImaging.TiffCreateMultiPageFromGdPictureImage(dcmImageID);
// Add the remaining pages as additional pages to the tif.
int pageCount = gdpictureImaging.DicomGetPageCount(dcmImageID);
for (int pageNo = 2; pageNo <= pageCount; pageNo++)
{
gdpictureImaging.DicomSelectPage(dcmImageID, pageNo);
gdpictureImaging.TiffAppendPageFromGdPictureImage(tiffImageID, dcmImageID);
}
gdpictureImaging.TiffSaveMultiPageToFile(tiffImageID, "image.tif", TiffCompression.TiffCompressionJPEG, 90);
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(tiffImageID);
gdpictureImaging.ReleaseGdPictureImage(dcmImageID);
}
Appends an image resource, represented by its unique GdPicture image identifier, to a new or existing single or multipage TIFF file according to what you have specified.
The image is added as a new page after the last page of the specified destination TIFF file. If you want to add more pages from your source file to the destination TIFF file,
please use this method for each single page.
Appends an image resource to a new or existing single or multipage TIFF file according to what you have specified.
A unique image identifier of the GdPicture image representing the single image, that you want to append as a new page at the end of the destination TIFF file.
The file path of the destination TIFF file, where the specified image will be appended. If this file does not exist, it will be created.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Please note that if you apply the JPEG compression, the quality factor used by default is 90.
You can use the overloaded method to set your preferred value for the JpegQuality parameter.
Just to remind you, that the toolkit creates the destination file according to the file path you have specified if this file does not exist yet.
Be aware that if you are applying CCITT3 or CCITT4 compression scheme, the image you want to append can only be 1bpp, otherwise the LZW compression scheme is used.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Appending a jpeg image at the last page of an existing multipage tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
gdpictureImaging.AppendToTiff(imageID, "multipage.tif", TiffCompression.TiffCompressionJPEG);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Appends an image resource, represented by its unique GdPicture image identifier, to a new or existing single or multipage TIFF file according to what you have specified.
This method allows you to set a JpegQuality parameter if you will apply a JPEG compression scheme.
The image is added as a new page after the last page of the specified destination TIFF file. If you want to add more pages from your source file to the destination TIFF file,
please use this method for each single page.
Appends an image resource to a new or existing single or multipage TIFF file according to what you have specified.
A unique image identifier of the GdPicture image representing the single image, that you want to append as a new page at the end of the destination TIFF file.
The file path of the destination TIFF file, where the specified image will be appended. If this file does not exist, it will be created.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Specifies the JPEG compression quality, between 1 (worst quality) and 100 (better quality).
This parameter is ignored when the specified TIFF compression scheme is different than JPEG.
Just to remind you, that the toolkit creates the destination file according to the file path you have specified if this file does not exist yet.
Be aware that if you are applying CCITT3 or CCITT4 compression scheme, the image you want to append can only be 1bpp, otherwise the LZW compression scheme is used.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Appending a jpeg image at the last page of an existing multipage tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
gdpictureImaging.AppendToTiff(imageID, "multipage.tif", TiffCompression.TiffCompressionJPEG, 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Appends an image resource, represented by its unique GdPicture image identifier, to a single page or a multipage TIFF file, located in a Stream object,
according to what you have specified. This method allows you to set a JpegQuality parameter if you will apply a JPEG compression scheme.
The image is added as a new page after the last page of the specified destination TIFF file. If you want to add more pages from your source file to the destination TIFF file,
please use this method for each single page.
Appends an image resource to a new or existing single or multipage TIFF file according to what you have specified.
A unique image identifier of the GdPicture image representing the single image, that you want to append as a new page at the end of the destination TIFF file.
A Stream object containing the destination TIFF file. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Specifies the JPEG compression quality, between 1 (worst quality) and 100 (better quality).
This parameter is ignored when the specified TIFF compression scheme is different than JPEG.
Please note that the output stream should be open for writing and should be closed/disposed of by the user as well.
Be aware that if you are applying CCITT3 or CCITT4 compression scheme, the image you want to append can only be 1bpp, otherwise the LZW compression scheme is used.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Merges two image files according to their file paths. The result is saved as a multipage TIFF image file to a file path you have specified.
The file path of the first image file to merge.
The file path of the second image file to merge.
The file path of the destination TIFF image file.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Supported input document formats are listed here.
Be aware that if you are applying CCITT3 or CCITT4 compression scheme, the source images can only be 1bpp, otherwise the LZW compression scheme is used.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Merges several image files according to their file paths stored in the input parameter.
The result is saved as a multipage TIFF image file to a file path you have specified.
An array of strings defining the file paths of all image files you want to merge.
The file path of the destination TIFF image file.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Supported input document formats are listed here.
Be aware that if you are applying CCITT3 or CCITT4 compression scheme, the source images can only be 1bpp, otherwise the LZW compression scheme is used.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Merges several image files according to their file paths stored in the input parameter.
The result is saved as a multipage TIFF image file to a file path you have specified.
A string containing the file paths of all image files you want to merge, for example "file1.tif,file2.tif".
Please use only comma as a file path separator in the given string.
The file path of the destination TIFF image file.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Supported input document formats are listed here.
Be aware that if you are applying CCITT3 or CCITT4 compression scheme, the source images can only be 1bpp, otherwise the LZW compression scheme is used.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Stores a specified GdPicture image, that is represented by its unique image identifier, as the first page of a new multipage TIFF image file to a given file path.
You can subsequently add a new page to this image file using one of the TiffAddToMultiPageFile() methods, for example the method.
This sequential writing is the faster way to create multipage TIFF image files by adding individual pages based on one page files.
Stores a specified GdPicture image as the first page of a new multipage TIFF image file, which will be used for subsequent sequential multipage TIFF writing.
This is the faster approach when creating multipage TIFF image files.
A unique image identifier of the GdPicture image representing the first page of the resulting multipage TIFF image file.
Do not release this image resource before closing the resulting multipage TIFF image file using the method.
Please follow the attached example on how to properly use the method.
The file path where the resulting multipage TIFF image file will be saved.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Please note that if you apply the JPEG compression, the quality factor used by default is 90.
You can use the overloaded method to set your preferred value for the JpegQuality parameter.
Please note that you need to close the resulting file using the method when you finish adding pages.
Be aware that for accessing the data of the newly created image file you have to save, close and release the image resource,
and then you need to reload it again, for example, using the .
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Generating a multipage tiff from different image files.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
/*Adding first page from a jpeg file*/
int tiffImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// After calling TiffSaveAsMultiPageFile, tiffID will specify the multipage tiff identifier.
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, "multipage.tif", TiffCompression.TiffCompressionJPEG);
/*Adding second page from a png file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png");
// Enabling horizontal differencing predictor mode for lzw compression.
gdpictureImaging.TagSetValueString(imageID, Tags.TagPredictor, TagType.TagTypeShort, "2");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionLZW);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Adding third page from a single page tiff-ccitt4 file*/
imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Closing the produced multipage file*/
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create two duplicate gdpicture images from the input file.
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
int imageID2 = gdpictureImaging.CreateClonedGdPictureImage(imageID1);
// Process both of your images (differently).
gdpictureImaging.FxFire(imageID1);
gdpictureImaging.FxNegative(imageID2);
// Save your images in the same multipage tif file.
gdpictureImaging.TiffSaveAsMultiPageFile(imageID1, "images.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffAddToMultiPageFile(imageID1, imageID2);
gdpictureImaging.TiffCloseMultiPageFile(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Stores a specified GdPicture image, that is represented by its unique image identifier, as the first page of a new multipage TIFF image file to a given stream.
You can subsequently add a new page to this image file using one of the TiffAddToMultiPageFile() methods, for example the method.
This sequential writing is the faster way to create multipage TIFF image files by adding individual pages based on one page files.
Stores a specified GdPicture image as the first page of a new multipage TIFF image file, which will be used for subsequent sequential multipage TIFF writing.
This is the faster approach when creating multipage TIFF image files.
A unique image identifier of the GdPicture image representing the first page of the resulting multipage TIFF image file.
Do not release this image resource before closing the resulting multipage TIFF image file using the method.
Please follow the attached example on how to properly use the method.
A Stream object where the newly created multipage TIFF image file will be stored.
This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Please note that if you apply the JPEG compression, the quality factor used by default is 90.
You can use the overloaded method to set your preferred value for the JpegQuality parameter.
Please note that you need to close the resulting file using the method when you finish adding pages.
At the same, the output stream should be open for writing and should be closed/disposed of by the user as well.
Be aware that for accessing the data of the newly created image file you have to save, close and release the image resource,
and then you need to reload it again, for example, using the .
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Generating a multipage tiff using streams, from different image files, using specific compression mode per page.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
{
/*Adding first page from a jpeg file*/
int tiffImageID = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, GdPicture14.DocumentFormat.DocumentFormatJPEG); /* or "image.jpg"*/
using (System.IO.Stream outputStream = new System.IO.FileStream("multipage.tif", System.IO.FileMode.CreateNew))
{
//After calling TiffSaveAsMultiPageFile, tiffID will specify the multipage tiff identifier.
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, outputStream, TiffCompression.TiffCompressionJPEG);
using (System.IO.Stream nextStream = new System.IO.FileStream("image.png", System.IO.FileMode.Open))
{
/*Adding second page from a png file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromStream(nextStream, GdPicture14.DocumentFormat.DocumentFormatPNG); /* or "image.png"*/
//Enabling horizontal differencing predictor mode for lzw compression.
gdpictureImaging.TagSetValueString(imageID, Tags.TagPredictor, TagType.TagTypeShort, "2");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionLZW);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (System.IO.Stream nextStream = new System.IO.FileStream("image.tif", System.IO.FileMode.Open))
{
/*Adding third page from a single page tiff-ccitt4 file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromStream(nextStream, GdPicture14.DocumentFormat.DocumentFormatTIFF); /* or "image.tif"*/
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
/*Closing the produced multipage file*/
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
}
}
}
Stores a specified GdPicture image, that is represented by its unique image identifier, as the first page of a new multipage TIFF image file to a given stream.
You can also define a JPEG quality parameter when the JPEG compression is required using this method.
You can subsequently add a new page to this image file using one of the TiffAddToMultiPageFile() methods, for example the method.
This sequential writing is the faster way to create multipage TIFF image files by adding individual pages based on one page files.
Stores a specified GdPicture image as the first page of a new multipage TIFF image file, which will be used for subsequent sequential multipage TIFF writing.
This is the faster approach when creating multipage TIFF image files.
A unique image identifier of the GdPicture image representing the first page of the resulting multipage TIFF image file.
Do not release this image resource before closing the resulting multipage TIFF image file using the method.
Please follow the attached example on how to properly use the method.
A Stream object where the newly created multipage TIFF image file will be stored.
This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression.
This parameter is ignored when the required compression scheme is different than JPEG.
Please note that you need to close the resulting file using the method when you finish aing pages.
At the same, the output stream should be open for writing and should be closed/disposed of by the user as well.
Be aware that for accessing the data of the newly created image file you have to save, close and release the image resource,
and then you need to reload it again, for example, using the .
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Generating a multipage tiff using streams, from different image files, using specific compression mode per page.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
{
/*Adding first page from a jpeg file*/
int tiffImageID = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, GdPicture14.DocumentFormat.DocumentFormatJPEG); /* or "image.jpg"*/
using (System.IO.Stream outputStream = new System.IO.FileStream("multipage.tif", System.IO.FileMode.CreateNew))
{
//After calling TiffSaveAsMultiPageFile, tiffID will specify the multipage tiff identifier.
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, outputStream, TiffCompression.TiffCompressionJPEG, 75 /*Jpeg quality*/);
using (System.IO.Stream nextStream = new System.IO.FileStream("image.png", System.IO.FileMode.Open))
{
/*Adding second page from a png file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromStream(nextStream, GdPicture14.DocumentFormat.DocumentFormatPNG); /* or "image.png"*/
//Enabling horizontal differencing predictor mode for lzw compression.
gdpictureImaging.TagSetValueString(imageID, Tags.TagPredictor, TagType.TagTypeShort, "2");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionLZW);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (System.IO.Stream nextStream = new System.IO.FileStream("image.tif", System.IO.FileMode.Open))
{
/*Adding third page from a single page tiff-ccitt4 file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromStream(nextStream, GdPicture14.DocumentFormat.DocumentFormatTIFF); /* or "image.tif"*/
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
/*Closing the produced multipage file*/
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
}
}
}
Stores a specified GdPicture image, that is represented by its unique image identifier, as the first page of a new multipage TIFF image file to a given file path.
You can also define a JPEG quality parameter when the JPEG compression is required using this method.
You can subsequently add a new page to this image file using one of the TiffAddToMultiPageFile() methods, for example the method.
This sequential writing is the faster way to create multipage TIFF image files by adding individual pages based on one page files.
Stores a specified GdPicture image as the first page of a new multipage TIFF image file, which will be used for subsequent sequential multipage TIFF writing.
This is the faster approach when creating multipage TIFF image files.
A unique image identifier of the GdPicture image representing the first page of the resulting multipage TIFF image file.
Do not release this image resource before closing the resulting multipage TIFF image file using the method.
Please follow the attached example on how to properly use the method.
The file path where the resulting multipage TIFF image file will be saved.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression.
This parameter is ignored when the required compression scheme is different than JPEG.
Please note that you need to close the resulting file using the method when you finish adding pages.
Be aware that for accessing the data of the newly created image file you have to save, close and release the image resource,
and then you need to reload it again, for example, using the .
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Generating a multipage tiff, from different image files, using specific compression mode per page.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
/*Adding first page from a jpeg file*/
int tiffImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// After calling TiffSaveAsMultiPageFile, tiffID will specify the multipage tiff identifier.
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, "multipage.tif", TiffCompression.TiffCompressionJPEG, 75 /*Jpeg quality*/);
/*Adding second page from a png file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png");
// Enabling horizontal differencing predictor mode for lzw compression.
gdpictureImaging.TagSetValueString(imageID, Tags.TagPredictor, TagType.TagTypeShort, "2");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionLZW);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Adding third page from a single page tiff-ccitt4 file*/
imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Closing the produced multipage file*/
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
}
Adds a required GdPicture image, which represents a single image, to a specified GdPicture image, which represents the multipage TIFF image file
previously initialized by one of the TiffSaveAsMultiPageFile() methods. Both GdPicture images are defined by their unique image identifiers.
This method implements a sequential multipage TIFF writing approach, which is the faster way to create multipage TIFF image files by adding individual pages.
Adds a required GdPicture image, which represents a single image, to a specified GdPicture image, which represents the multipage TIFF image file.
This method implements a sequential multipage TIFF writing approach, which is the faster way to create multipage TIFF image files by adding individual pages.
A unique image identifier of the GdPicture image representing the resulting multipage TIFF image file,
that has been previously initialized using one of the TiffSaveAsMultiPageFile() methods. It is the first image resource of the resulting multipage TIFF image file.
Please follow the attached example on how to properly use the method.
A unique image identifier of the GdPicture image representing the image, which will be added to the resulting multipage TIFF image file.
You can release this image resource using the method after adding it to the resulting file.
Please note that you need to close the resulting file using the method when you finish adding pages.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Generating a multipage tiff from different image files.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
/*Adding first page from a jpeg file*/
int tiffImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// After calling TiffSaveAsMultiPageFile, tiffID will specify the multipage tiff identifier.
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
/*Adding second page from a png file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Adding third page from a single page tiff file*/
imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Closing the produced multipage file*/
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create two duplicate gdpicture images from the input file.
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
int imageID2 = gdpictureImaging.CreateClonedGdPictureImage(imageID1);
// Process both of your images (differently).
gdpictureImaging.FxFire(imageID1);
gdpictureImaging.FxNegative(imageID2);
// Save your images in the same multipage tif file.
gdpictureImaging.TiffSaveAsMultiPageFile(imageID1, "images.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffAddToMultiPageFile(imageID1, imageID2);
gdpictureImaging.TiffCloseMultiPageFile(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Adds a required GdPicture image, which represents a single image, to a specified GdPicture image, which represents the multipage TIFF image file
previously initialized by one of the TiffSaveAsMultiPageFile() methods. Both GdPicture images are defined by their unique image identifiers.
This method implements a sequential multipage TIFF writing approach, which is the faster way to create multipage TIFF image files by adding individual pages.
Adds a required GdPicture image, which represents a single image, to a specified GdPicture image, which represents the multipage TIFF image file.
This method implements a sequential multipage TIFF writing approach, which is the faster way to create multipage TIFF image files by adding individual pages.
A unique image identifier of the GdPicture image representing the resulting multipage TIFF image file,
that has been previously initialized using one of the TiffSaveAsMultiPageFile() methods. It is the first image resource of the resulting multipage TIFF image file.
Please follow the attached example on how to properly use the method.
A unique image identifier of the GdPicture image representing the image, which will be added to the resulting multipage TIFF image file.
You can release this image resource using the method after adding it to the resulting file.
A member of the TiffCompression enumeration. The TIFF compression scheme to be used for compressing the added image.
You can use the overloaded method to benefit from using the JPEG compression and specifying the quality parameter.
Please note that you need to close the resulting file using the method when you finish adding pages.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Generating a multipage tiff, from different image files, using specific compression mode per page.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
/*Adding first page from a jpeg file*/
int tiffImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// After calling TiffSaveAsMultiPageFile, tiffID will specify the multipage tiff identifier.
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, "multipage.tif", TiffCompression.TiffCompressionJPEG, 75 /*Jpeg quality*/);
/*Adding second page from a png file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png");
// Enabling horizontal differencing predictor mode for lzw compression.
gdpictureImaging.TagSetValueString(imageID, Tags.TagPredictor, TagType.TagTypeShort, "2");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionLZW);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Adding third page from a single page tiff-ccitt4 file*/
imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Closing the produced multipage file*/
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
}
Adds a required GdPicture image, which represents a single image, to a specified GdPicture image, which represents the multipage TIFF image file
previously initialized by one of the TiffSaveAsMultiPageFile() methods. Both GdPicture images are defined by their unique image identifiers.
This method implements a sequential multipage TIFF writing approach, which is the faster way to create multipage TIFF image files by adding individual pages.
Adds a required GdPicture image, which represents a single image, to a specified GdPicture image, which represents the multipage TIFF image file.
This method implements a sequential multipage TIFF writing approach, which is the faster way to create multipage TIFF image files by adding individual pages.
A unique image identifier of the GdPicture image representing the resulting multipage TIFF image file,
that has been previously initialized using one of the TiffSaveAsMultiPageFile() methods. It is the first image resource of the resulting multipage TIFF image file.
Please follow the attached example on how to properly use the method.
A unique image identifier of the GdPicture image representing the image, which will be added to the resulting multipage TIFF image file.
You can release this image resource using the method after adding it to the resulting file.
A member of the TiffCompression enumeration. The TIFF compression scheme to be used for compressing the added image.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression.
This parameter is ignored when the required compression scheme is different than JPEG.
Please note that you need to close the resulting file using the method when you finish adding pages.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Generating a multipage tiff, from different image files, using specific compression mode per page.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
/*Adding first page from a jpeg file*/
int tiffImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// After calling TiffSaveAsMultiPageFile, tiffID will specify the multipage tiff identifier.
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, "multipage.tif", TiffCompression.TiffCompressionJPEG, 75 /*Jpeg quality*/);
/*Adding second page from a jpg file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image2.jpg");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionJPEG, 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Adding third page from a single page tiff-ccitt4 file*/
imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Closing the produced multipage file*/
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
}
Terminates and closes a multipage TIFF image file represented by a unique image identifier of the GdPicture image,
that has been previously initialized with one of the TiffSaveAsMultiPageFile() methods.
A unique image identifier of the GdPicture image representing the image stored as the first page of the multipage TIFF image file.
You need to release this image using the method after closing the image file.
Be aware that this method is explicitly intended for use on images previously initialized by one of the TiffSaveAsMultiPageFile() methods.
Please follow the attached example on how to properly use the method.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Generating a multipage tiff from different image files.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
/*Adding first page from a jpeg file*/
int tiffImageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// After calling TiffSaveAsMultiPageFile, tiffID will specify the multipage tiff identifier.
gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, "multipage.tif", TiffCompression.TiffCompressionJPEG, 75 /*Jpeg quality*/);
/*Adding second page from a png file*/
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png");
// Enabling horizontal differencing predictor mode for lzw compression.
gdpictureImaging.TagSetValueString(imageID, Tags.TagPredictor, TagType.TagTypeShort, "2");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionLZW);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Adding third page from a single page tiff-ccitt4 file*/
imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
/*Closing the produced multipage file*/
gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create two duplicate gdpicture images from the input file.
int imageID1 = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
int imageID2 = gdpictureImaging.CreateClonedGdPictureImage(imageID1);
// Process both of your images (differently).
gdpictureImaging.FxFire(imageID1);
gdpictureImaging.FxNegative(imageID2);
// Save your images in the same multipage tif file.
gdpictureImaging.TiffSaveAsMultiPageFile(imageID1, "images.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.TiffAddToMultiPageFile(imageID1, imageID2);
gdpictureImaging.TiffCloseMultiPageFile(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
gdpictureImaging.ReleaseGdPictureImage(imageID2);
}
Stores into an array of bytes the pixel indexes of an area of a paletized 8bpp GdPicture image.
GdPicture image identifier.
Output parameter. Array of pixel indexes. each entry of the array is a
reference to a palette index [0 - 255].
The left source pixel of the area.
The top source pixel of the area.
The width of the area in pixel.
The height of the area in pixel.
A member of the GdPictureStatus enumeration.
This method works only with 8bpp image.
Set pixel indexes from an array of bytes to an area of a paletized 8bpp GdPicture image.
GdPicture image identifier.
Array of pixel indexes. each entry of the array is a reference to a
palette index [0 - 255].
The left destination pixel of the area.
The top destination pixel of the area.
The width of the area in pixel.
The height of the area in pixel.
A member of the GdPictureStatus enumeration.
This method works only with 8bpp image.
Stores into an array of Integer the ARGB pixel values of an area of a GdPicture image.
GdPicture image identifier.
Output parameter. Array of pixel data.
The left source pixel of the area.
The top source pixel of the area.
The width of the area in pixel.
The height of the area in pixel.
A member of the GdPictureStatus enumeration.
Changes the pixel values contained into an area of a GdPicture image from an array which contains
Integer ARBG color values.
GdPicture image identifier.
Array of pixel data.
The left destination pixel of the area.
The top destination pixel of the area.
The width of the destination area in pixel.
The height of the destination area in pixel.
A member of the GdPictureStatus enumeration.
The method automatically converts image pixel format to PixelFormat.Format32bppArgb.
Stores into an array of byte each Blue, Green, Red and Alpha components of the pixel contained into
an area of a GdPicture image.
GdPicture image identifier.
Output parameter. Array of pixel data.
The left source pixel of the area.
The top source pixel of the area.
The width of the area in pixel.
The height of the area in pixel.
A member of the GdPictureStatus enumeration.
A member of the GdPictureStatus enumeration.
Changes the pixel values contained into an area of a GdPicture image from an array which contains
each each Blue, Green, Red and Alpha components of pixel.
GdPicture image identifier.
Array of pixel data.
The left destination pixel of the area.
The top destination pixel of the area.
The width of the destination area in pixel.
The height of the destination area in pixel.
A member of the GdPictureStatus enumeration.
The method automatically converts all images PixelFormat to PixelFormat.Format32bppArgb.
Changes the pixel values contained into an area of a GdPicture image from an array which contains
each each Blue, Green, and Red components of pixel.
GdPicture image identifier.
Array of pixel data.
The left destination pixel of the area.
The top destination pixel of the area.
The width of the destination area in pixel.
The height of the destination area in pixel.
Specifies if input pixel are ordered in R-G-B versus in B-G-R.
A member of the GdPictureStatus enumeration.
The method automatically converts all images PixelFormat to PixelFormat.Format24bppRgb.
Gets the color of a specified pixel in a GdPicture image, as Color object.
GdPicture image identifier.
Value that specifies the x-coordinate (column) of the pixel.
Value that specifies the y-coordinate (row) of the pixel.
The pixel color, as Color object.
Gets the color of a specified pixel in a GdPicture image, as 32-bit integer value.
GdPicture image identifier.
Value that specifies the x-coordinate (column) of the pixel.
Value that specifies the y-coordinate (row) of the pixel.
The pixel color as 32-bit integer value.
Sets the color of a specified pixel in a GdPicture image.
GdPicture image identifier.
Value that specifies the x-coordinate (column) of the pixel.
Value that specifies the y-coordinate (row) of the pixel.
The color to apply, as Color object. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Getting the red channel histogram of a jpeg image and creating an image representing this histogram.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", false);
// Get the red channel histogram and the image dimensions.
int[] histo = new int[256];
gdpictureImaging.HistogramGetRed(imageID, ref histo);
int count = gdpictureImaging.GetWidth(imageID) * gdpictureImaging.GetHeight(imageID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
// Create an image representing the histogram.
// The image has the same width as the histogram and its height is 1000.
int histogramID = gdpictureImaging.CreateNewGdPictureImage(256, 1000, 24, Color.White);
for (int i = 0; i < 256; i++)
{
int value = histo[i] * 1000 / count;
for (int j = 0; j < value; j++)
{
gdpictureImaging.PixelSetColor(histogramID, i, j, Color.Red);
}
}
gdpictureImaging.SaveAsPNG(histogramID, "histo.png");
gdpictureImaging.ReleaseGdPictureImage(histogramID);
}
Sets the color of a specified pixel in a GdPicture image.
GdPicture image identifier.
Value that specifies the x-coordinate (column) of the pixel.
Value that specifies the y-coordinate (row) of the pixel.
The color to apply, as 32-bit integer value. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Returns the width, in bytes, of a single row of pixel data of a GdPicture image.
Also known as pitch or scan width, this width is a multiple, or possibly sub-multiple, of the pixel
dimensions of the image and may be padded out to include a few more bytes.
GdPicture image identifier.
If success, non 0: a GdPicture image stride. If fail, 0: Use the GetStat() method to determine the
reason this method failed.
Force a specific GdPicture image to be arranged top-down in memory.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
A Top-down image has a positive stride.
Force a specific GdPicture image to be arranged bottom-up in memory.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
A bottom-up image has a negative stride, because stride is defined as the number of bytes need to move down a row of pixels.
Returns a pointer to the data-bits of a GdPicture image.
It is up to you to interpret these bytes correctly, according to the results of GetBitDepth() and
GetStride() methods.
GdPicture image identifier.
If success, non 0: A pointer to the data-bits of the bitmap. If fail, 0: Use the GetStat() method
to determine the reason this method failed.
Returns an array of pointers of all GdPicture image scanlines.
GdPicture image identifier.
An array of bitmap scanlines pointer; First entry is the top scanline and latest is the bottom.
Returns the printer color mode setting of the active printer. This property determines whether the output will print in color or in monochrome.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method
and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the PrinterColorMode enumeration. The value of the active printer color mode setting.
Showing basic printer settings on the screen.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Printer settings information:");
Console.WriteLine("Printer color mode: {0}", gdpictureImaging.PrintGetColorMode().ToString());
Console.WriteLine("Paper orientation: {0}", gdpictureImaging.PrintGetOrientation().ToString());
Console.WriteLine("Printing quality: {0}", gdpictureImaging.PrintGetQuality().ToString());
}
Sets up the printer color mode setting of the active printer. This property determines whether the output will print in color or in monochrome.
A member of the PrinterColorMode enumeration. The new value of the active printer color mode setting.
Just to remind you that the active printer is the printer identified by the method or set by the method
and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Setting basic printer properties.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Setting printer color mode to -monochrome/shades of BW-");
gdpictureImaging.PrintSetColorMode(PrinterColorMode.PrinterColorModeGray);
Console.WriteLine("Setting paper orientation to -portrait-");
gdpictureImaging.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
Console.WriteLine("Setting printing quality to -draft-");
gdpictureImaging.PrintSetQuality(PrintQuality.PrintQualityDraft);
}
Returns the printer document name setting of the active printer. You can use it to display during the next print process (for example, in a print
status dialog box or printer queue) while printing the document.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to inform you that the default value specified by the toolkit is "GdPicture Print Process".
Likewise to remind you that the active printer is the printer identified by the method or set by the method
and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The value of the active printer document name setting.
Printing an image with the help of standard Windows Printer Dialog.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.PrintDialog(imageID) == false)
{
MessageBox.Show("Printing failed for " + gdpictureImaging.PrintGetDocumentName() +
"\nError: " + gdpictureImaging.PrintGetStat() +
"\nMessage: " + gdpictureImaging.PrintGetLastError(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Printing succeded for " + gdpictureImaging.PrintGetDocumentName(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Sets up the printer document name setting of the active printer. You can use it to display during the next print process
(for example, in a print status dialog box or printer queue) while printing the document.
The new value of the printer document name setting.
Just to inform you that the default value specified by the toolkit is "GdPicture Print Process".
Likewise to remind you that the active printer is the printer identified by the method or set by the method
and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Enables or disables showing the progress indicator during the print process. The printing progress bar is displayed by default.
Set this parameter to true if you want to show the progress bar during the print process, otherwise set it to false. The default value is true.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Sets up the paper source, means the paper tray, from which the printer gets paper, used by the active printer.
The value matches up to the PaperSource.Kind property of the default paper settings.
The constant that represents the paper source to be used. Please refer to the System.Drawing.Printing.PaperSourceKind enumeration for correct values.
The standard values are listed below (please see the corresponding ordering number):
- Upper
- Lower
- Middle
- Manual
- Enveloper
- ManualFeed
- AutomaticFeed
- TractorFeed
- SmallFormat
- LargeFormat
- LargeCapacity
14. Cassette15. FormSource257. or greater: Custom
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
true if the method has been followed successfully, otherwise false.
Please use the method or the method to determine the specific reason for the method's failure.
Sets up the paper source property of the active printer.
Sets up the paper source, from which the active printer gets paper.
A PaperSource object that defines the new value of the paper source property to be used.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
true if the method has been followed successfully, otherwise false.
Please use the method or the method to determine the specific reason for the method's failure.
Returns the paper source, means the paper tray, from which the printer gets paper, used by the active printer.
The value is determined through the PaperSource.Kind property of the default page settings.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The constant that represents the current paper source. Please refer to the System.Drawing.Printing.PaperSourceKind enumeration for correct values.
The standard values are listed below (please see the corresponding ordering number):
- Upper
- Lower
- Middle
- Manual
- Enveloper
- ManualFeed
- AutomaticFeed
- TractorFeed
- SmallFormat
- LargeFormat
- LargeCapacity
14. Cassette15. FormSource257. or greater: Custom
The method can be subsequently used or the method to determine if this method has been successful.
Determining information about the paper bin used by the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int binType = gdpictureImaging.PrintGetPaperBin();
Console.WriteLine("Paper bin type used by printer: {0}", binType.ToString());
if (binType == 7) Console.WriteLine("This printer is using automatic feeder.");
}
Sets up the required range of pages you want to print during the next print process using the active printer.
The first page from the required range of pages.
The last page from the required range of pages.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Sets up the required selection of pages you want to print during the next print process using the active printer.
The specified pages selection will not take into account if you will print using the PrintDialog... methods.
The custom page range to be set for printing, for example, "1;4;5" to process pages 1, 4 and 5 or "1-5;10" to process pages from 1 to 5 and page 10. Set this
parameter to "*" to process all pages of the current document.
Be aware that the defined pages selection will not take into account if you will use the one of the PrintDialog... methods.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the printer quality setting of the active printer. This setting matches the PrinterResolutionKind property included in the
PrinterSettings.PrinterResolutions parameter of the active printer.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
Likewise to inform you that you can also use the method to retrieve currently defined printer settings
of the active printer with all its relevant properties.
A member of the PrintQuality enumeration. The value of the active printer quality setting.
Showing basic printer settings on the screen.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Printer settings information:");
Console.WriteLine("Printer color mode: {0}", gdpictureImaging.PrintGetColorMode().ToString());
Console.WriteLine("Paper orientation: {0}", gdpictureImaging.PrintGetOrientation().ToString());
Console.WriteLine("Printing quality: {0}", gdpictureImaging.PrintGetQuality().ToString());
}
Sets up the printer quality setting of the active printer. This setting matches the PrinterResolutionKind property included in the
PrinterSettings.PrinterResolutions parameter of the active printer.
If the required Quality parameter is identified within the set of PrinterSettings.PrinterResolutions property items of the active printer, then
the currently defined active printer resolution is filled up with the specified resolution attributes provided by the corresponding printer resolution item.
A member of the PrintQuality enumeration. The new value of the active printer quality setting.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
Likewise to inform you that you can also use the method to specify all relevant printer settings for the active printer
according to your preference and printer possibilities.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Setting basic printer properties.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Setting printer color mode to -monochrome/shades of BW-");
gdpictureImaging.PrintSetColorMode(PrinterColorMode.PrinterColorModeGray);
Console.WriteLine("Setting paper orientation to -portrait-");
gdpictureImaging.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
Console.WriteLine("Setting printing quality to -draft-");
gdpictureImaging.PrintSetQuality(PrintQuality.PrintQualityDraft);
}
Returns the status of the last executed print operation. You can use the method to find out more details.
A member of the GdPictureStatus enumeration. The status of the last executed print operation.
Printing an image with the help of standard Windows Printer Dialog.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.PrintDialog(imageID) == false)
{
MessageBox.Show("Printing failed for " + gdpictureImaging.PrintGetDocumentName() +
"\nError: " + gdpictureImaging.PrintGetStat() +
"\nMessage: " + gdpictureImaging.PrintGetLastError(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Printing succeded for " + gdpictureImaging.PrintGetDocumentName(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the error description of the last executed print operation, that has failed.
The value resets to its default (an empty string) starting each new print job.
The description of the last printing error.
Showing the error description of the last executed print operation, that has failed.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.Print(imageID) != GdPictureStatus.OK)
{
string errorMessage = gdpictureImaging.PrintGetLastError();
Console.WriteLine("Error during printing: {0}", errorMessage);
};
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.PrintDialog(imageID) == false)
{
MessageBox.Show("Printing failed for " + gdpictureImaging.PrintGetDocumentName() +
"\nError: " + gdpictureImaging.PrintGetStat() +
"\nMessage: " + gdpictureImaging.PrintGetLastError(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Printing succeded for " + gdpictureImaging.PrintGetDocumentName(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Sets up the printer copies setting of the active printer, that means the number of copies to be printed.
The number of copies to be printed. The new value of the active printer copies setting.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Setting basic printer properties.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Setting image alignment to -top left corner-");
gdpictureImaging.PrintSetAlignment(PrintAlignment.PrintAlignmentTopLeft);
Console.WriteLine("Setting number of copies to -3-");
gdpictureImaging.PrintSetCopies(3);
Console.WriteLine("Setting duplex mode to -Horizontal-");
gdpictureImaging.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Horizontal);
Console.WriteLine("Enabling document collate");
gdpictureImaging.PrintSetCollate(true);
}
Returns the printer copies setting of the active printer, that means the number of copies to be printed.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The number of copies to be printed. The value of the active printer copies setting.
Showing basic printer settings on the screen.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Printer settings information:");
Console.WriteLine("Image aligment: {0}", gdpictureImaging.PrintGetAlignment().ToString());
Console.WriteLine("Number of copies: {0}", gdpictureImaging.PrintGetCopies().ToString());
Console.WriteLine("Duplex mode: {0}", gdpictureImaging.PrintGetDuplexMode().ToString());
Console.WriteLine("Will be printed document collated?: {0}", gdpictureImaging.PrintGetCollate().ToString());
}
Sets up the printer duplex mode setting of the active printer. This property determines whether a page is printed on both sides
(if the printer supports this feature).
A member of the Duplex enumeration. The new value of the active printer duplex mode setting.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Setting basic printer properties.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Setting image alignment to -top left corner-");
gdpictureImaging.PrintSetAlignment(PrintAlignment.PrintAlignmentTopLeft);
Console.WriteLine("Setting number of copies to -3-");
gdpictureImaging.PrintSetCopies(3);
Console.WriteLine("Setting duplex mode to -Horizontal-");
gdpictureImaging.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Horizontal);
Console.WriteLine("Enabling document collate");
gdpictureImaging.PrintSetCollate(true);
}
Returns the printer duplex mode setting of the active printer. This property determines whether a page is printed on both sides
(if the printer supports this feature).
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the Duplex enumeration. The value of the active printer duplex mode setting.
Showing basic printer settings on the screen.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Printer settings information:");
Console.WriteLine("Image aligment: {0}", gdpictureImaging.PrintGetAlignment().ToString());
Console.WriteLine("Number of copies: {0}", gdpictureImaging.PrintGetCopies().ToString());
Console.WriteLine("Duplex mode: {0}", gdpictureImaging.PrintGetDuplexMode().ToString());
Console.WriteLine("Will be printed document collated?: {0}", gdpictureImaging.PrintGetCollate().ToString());
}
Sets up the printer collate setting of the active printer. This property determines, whether the printed document is collated.
Setting it to true will print a complete copy of the document before the first page of the next copy is printed.
Setting it to false will print each page by the number of copies specified before printing the next page.
The new value of the printer collate setting.
Please note that collating is only performed when the number of copies is greater than 1.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Setting basic printer properties.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Setting image alignment to -top left corner-");
gdpictureImaging.PrintSetAlignment(PrintAlignment.PrintAlignmentTopLeft);
Console.WriteLine("Setting number of copies to -3-");
gdpictureImaging.PrintSetCopies(3);
Console.WriteLine("Setting duplex mode to -Horizontal-");
gdpictureImaging.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Horizontal);
Console.WriteLine("Enabling document collate");
gdpictureImaging.PrintSetCollate(true);
}
Returns the printer collate setting of the active printer. This property determines, whether the printed document is collated.
true will print a complete copy of the document before the first page of the next copy is printed. false will print each page by the number of
copies specified before printing the next page.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Please note that collating is only performed when the number of copies is greater than 1.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The value of the printer collate setting. true if the printed document is collated when printing, otherwise false.
Showing basic printer settings on the screen.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Printer settings information:");
Console.WriteLine("Image aligment: {0}", gdpictureImaging.PrintGetAlignment().ToString());
Console.WriteLine("Number of copies: {0}", gdpictureImaging.PrintGetCopies().ToString());
Console.WriteLine("Duplex mode: {0}", gdpictureImaging.PrintGetDuplexMode().ToString());
Console.WriteLine("Will be printed document collated?: {0}", gdpictureImaging.PrintGetCollate().ToString());
}
Prompts the printer driver to show the printer settings dialog box of the active printer allowing you to specify a parent window handle.
A handle to the parent window of the active printer configuration property sheet.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Sets up the printer orientation setting of the active printer. This property determines the page orientation when printing.
A member of the PrinterOrientation enumeration. The new value of the active printer orientation setting.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Setting basic printer properties.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Setting printer color mode to -monochrome/shades of BW-");
gdpictureImaging.PrintSetColorMode(PrinterColorMode.PrinterColorModeGray);
Console.WriteLine("Setting paper orientation to -portrait-");
gdpictureImaging.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
Console.WriteLine("Setting printing quality to -draft-");
gdpictureImaging.PrintSetQuality(PrintQuality.PrintQualityDraft);
}
Returns the printer orientation setting of the active printer. This property determines the page orientation when printing.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the PrinterOrientation enumeration. The value of the active printer orientation setting.
Showing basic printer settings on the screen.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Printer settings information:");
Console.WriteLine("Printer color mode: {0}", gdpictureImaging.PrintGetColorMode().ToString());
Console.WriteLine("Paper orientation: {0}", gdpictureImaging.PrintGetOrientation().ToString());
Console.WriteLine("Printing quality: {0}", gdpictureImaging.PrintGetQuality().ToString());
}
Returns the name of the printer, that is currently selected as the active printer, means the printer, which is subsequently used when printing.
It is mostly the default printer, if not set otherwise. Hovewer, you can use the method to select
your preferred printer for next print jobs without affecting any other installed printers.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to inform you that the printer, which name is returned by this method, is used to execute all subsequent print jobs
and all subsequently altered printer settings are related to this printer.
Likewise, none of the available printers or their properties are affected using any of the print methods of this class.
The name of the active printer to be used for subsequent printing.
Controling the currently selected printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
string name = gdpictureImaging.PrintGetActivePrinter();
Console.WriteLine("Default printer name: {0}", name);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int printCount = gdpictureImaging.PrintGetPrintersCount();
string message = "The number of printers: " + printCount;
if (printCount > 0)
{
gdpictureImaging.PrintSetActivePrinter(gdpictureImaging.PrintGetPrinterName(1));
message += "\nThe active printer is: " + gdpictureImaging.PrintGetActivePrinter();
}
MessageBox.Show(message, "Active printer", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Sets the printer, identified by its name, as the active printer, in other words makes it the currently selected printer, which is subsequently used when printing.
The specified printer is used to execute all next print jobs using the print methods of this class, if not set otherwise, without affecting any other installed printers.
You can use the method to retrieve the currently selected printer, denoted as the active printer for print methods of this class.
At the same this printer utilizes all by you altered printer settings without affecting the installed printers.
The name of the printer you want to set up as an active printer to be used for subsequent printing.
Just to inform you that the printer selected by this method is used to execute all subsequent print jobs and all subsequently altered printer settings are
related to this printer. Likewise, none of the available printers or their properties are affected using any of the print methods of this class.
true if the method has been followed successfully, otherwise false.
Please use the method or the method to determine the specific reason for the method's failure.
Changing the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int printCount = gdpictureImaging.PrintGetPrintersCount();
string message = "The number of printers: " + printCount;
if (printCount > 0)
{
gdpictureImaging.PrintSetActivePrinter(gdpictureImaging.PrintGetPrinterName(1));
message += "\nThe active printer is: " + gdpictureImaging.PrintGetActivePrinter();
}
MessageBox.Show(message, "Active printer", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Sets up the printer settings of the active printer.
As explained in the or the methods, none of the available printers
or their properties are affected using any of the print methods of this class.
A System.Drawing.Printing.PrinterSettings object. The newly specified printer settings of the active printer.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Specifying that files will print to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
PrinterSettings prnSettings = gdpictureImaging.PrintGetPrinterSettings();
// Set the option to print to a file.
prnSettings.PrintToFile = true;
gdpictureImaging.PrintSetPrinterSettings(prnSettings);
}
Returns the printer settings of the active printer.
As explained in the or the methods, none of the available printers
or their properties are affected using any of the print methods of this class.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A System.Drawing.Printing.PrinterSettings object. The printer settings of the active printer.
Specifying that files will print to a file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
PrinterSettings prnSettings = gdpictureImaging.PrintGetPrinterSettings();
// Set the option to print to a file.
prnSettings.PrintToFile = true;
gdpictureImaging.PrintSetPrinterSettings(prnSettings);
}
Returns the number of all available (installed) printers on the computer.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
The number of available printers.
Changing the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int printCount = gdpictureImaging.PrintGetPrintersCount();
string message = "The number of printers: " + printCount;
if (printCount > 0)
{
gdpictureImaging.PrintSetActivePrinter(gdpictureImaging.PrintGetPrinterName(1));
message += "\nThe active printer is: " + gdpictureImaging.PrintGetActivePrinter();
}
MessageBox.Show(message, "Active printer", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Returns the name of the printer according to the index you have specified.
You can use the method to determine the number of all available printers.
The printer index is simply an integer value from 1 to .
The printer index. It must be a value from 1 to .
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
The name of the specified printer.
Finding out the name of the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int printCount = gdpictureImaging.PrintGetPrintersCount();
string printers = "The number of printers: " + printCount + ".\n";
for (int i = 1; i<=printCount; i++)
{
printers += gdpictureImaging.PrintGetPrinterName(i) + "\n";
}
MessageBox.Show(printers, "Available printers", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int printCount = gdpictureImaging.PrintGetPrintersCount();
string message = "The number of printers: " + printCount;
if (printCount > 0)
{
gdpictureImaging.PrintSetActivePrinter(gdpictureImaging.PrintGetPrinterName(1));
message += "\nThe active printer is: " + gdpictureImaging.PrintGetActivePrinter();
}
MessageBox.Show(message, "Active printer", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings and then to print the specified GdPicture image.
This method uses the actual paper size when printing.
A unique image identifier of the GdPicture image representing the image in use.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
Printing an image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.PrintDialog(imageID);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.PrintDialog(imageID) == false)
{
MessageBox.Show("Printing failed for " + gdpictureImaging.PrintGetDocumentName() +
"\nError: " + gdpictureImaging.PrintGetStat() +
"\nMessage: " + gdpictureImaging.PrintGetLastError(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Printing succeded for " + gdpictureImaging.PrintGetDocumentName(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings and then to print the specified GdPicture image.
This method uses the actual paper size when printing.
Invokes the standard Windows Print dialog box allowing you to print the specified GdPicture image by selecting additional settings.
A unique image identifier of the GdPicture image representing the image in use.
Represents the top-level window that will own the modal dialog box.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
Printing an image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.PrintDialog(imageID, this);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.PrintDialog(imageID, this) == false)
{
MessageBox.Show("Printing failed for " + gdpictureImaging.PrintGetDocumentName() +
"\nError: " + gdpictureImaging.PrintGetStat() +
"\nMessage: " + gdpictureImaging.PrintGetLastError(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Printing succeded for " + gdpictureImaging.PrintGetDocumentName(), "Printing status", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings
and then to print the specified GdPicture image adjusting the picture size to the default paper size.
A unique image identifier of the GdPicture image representing the image in use.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
Printing an image with the help of standard Windows Printer Dialog.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.PrintDialogFit(imageID);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings
and then to print the specified GdPicture image adjusting the picture size to the default paper size.
This method also allows to specify the top-level window that will own the modal dialog box.
Invokes the standard Windows Print dialog box allowing you to print the specified GdPicture image
adjusting the picture size to the default paper size together with selecting additional settings.
A unique image identifier of the GdPicture image representing the image in use.
Represents the top-level window that will own the modal dialog box.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
Printing an image with the help of standard Windows Printer Dialog.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.PrintDialogFit(imageID, this);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings
and then to print the specified GdPicture image with the defined size and the position.
A unique image identifier of the GdPicture image representing the image in use.
Specifies the x-coordinate (in inches) of the upper-left corner of the provided GdPicture image into the paper.
Specifies the y-coordinate (in inches) of the upper-left corner of the provided GdPicture image into the paper.
Specifies the width (in inches) of the provided GdPicture image into the paper.
Specifies the height (in inches) of the provided GdPicture image into the paper.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
Printing a portion of an image with the help of standard Windows Printer Dialog.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
float dstLeft = 2, dstTop = 2;
float width = 10, height = 50;
gdpictureImaging.PrintDialogBySize(imageID, dstLeft, dstTop, width, height);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings
and then to print the specified GdPicture image with the defined size and the position.
This method also allows to specify the top-level window that will own the modal dialog box.
Invokes the standard Windows Print dialog box allowing you to print the specified GdPicture image
with the defined size and the position together with selecting additional settings.
A unique image identifier of the GdPicture image representing the image in use.
Represents the top-level window that will own the modal dialog box.
Specifies the x-coordinate (in inches) of the upper-left corner of the provided GdPicture image into the paper.
Specifies the y-coordinate (in inches) of the upper-left corner of the provided GdPicture image into the paper.
Specifies the width (in inches) of the provided GdPicture image into the paper.
Specifies the height (in inches) of the provided GdPicture image into the paper.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
Printing a portion of an image with the help of standard Windows Printer Dialog.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
float dstLeft = 2, dstTop = 2;
float width = 10, height = 50;
gdpictureImaging.PrintDialogBySize(imageID, this, dstLeft, dstTop, width, height);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Prints a specified GdPicture image to the active printer using the actual paper size.
A unique image identifier of the GdPicture image representing the image in use.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Printing an image using the default printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureImaging.Print(imageID);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Prints a specified GdPicture image to the active printer adjusting the picture size to the default paper size.
A unique image identifier of the GdPicture image representing the image in use.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Printing an image while scaling it to the current paper size using the default printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
// Print an image in the maximum possible size while preserving the aspect ratio.
gdpictureImaging.PrintFit(imageID);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Prints a specified GdPicture image to the active printer with the specific size and the position.
A unique image identifier of the GdPicture image representing the image in use.
Specifies the x-coordinate (in inches) of the upper-left corner of the provided GdPicture image into the paper.
Specifies the y-coordinate (in inches) of the upper-left corner of the provided GdPicture image into the paper.
Specifies the width (in inches) of the provided GdPicture image into the paper.
Specifies the height (in inches) of the provided GdPicture image into the paper.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Printing a portion of an image using the default printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Open an image file. An empty string allows the control to prompt for selecting a file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
float dstLeft = 2, dstTop = 2;
float width = 10, height = 50;
gdpictureImaging.PrintBySize(imageID, dstLeft, dstTop, width, height);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
Sets up the standard paper size, means the type of the paper, to be used by the active printer.
The constant that represents the required standard paper size to be used. Please refer to the System.Drawing.Printing.PaperKind enumeration for correct values.
Some of them are listed below (please see the corresponding ordering number):
- Letter, 8.5 x 11 in.
- Letter Small, 8.5 x 11 in.
- Tabloid, 11 x 17 in.
- Ledger, 17 x 11 in.
- Legal, 8.5 x 14 in.
- Statement, 5 1/2 x 8 1/2 in.
- Executive, 7 1/2 x 10 1/2 in.
- A3, 297 x 420 mm
- A4, 210 x 297 mm
- A4 Small, 210 x 297 mm
- A5, 148 x 210 mm
- B4, 250 x 354 mm
- B5, 182 x 257 mm
- Folio, 8.5 x 13 in.
- Quarto, 215 x 275 mm
- Standard 10 x 14 in.
- Standard 11 x 17 in.
- Note, 8.5 x 11 in.
- Envelope #9, 3 7/8 x 8 7/8 in.
- Envelope #10, 4 1/8 x 9.5 in.
- Envelope #11, 4.5 x 10 3/8 in.
- Envelope #12, 4.5 x 11 in.
- Envelope #14, 5 x 11.5 in.
- C size sheet
- D size sheet
- E size sheet
- Envelope DL, 110 x 220 mm
- Envelope C5, 162 x 229 mm
- Envelope C3, 324 x 458 mm
- Envelope C4, 229 x 324 mm
- Envelope C6, 114 x 162 mm
- Envelope C65, 114 x 229 mm
- Envelope B4, 250 x 353 mm
- Envelope B5, 176 x 250 mm
- Envelope B6, 176 x 125 mm
- Envelope Italy, 110 x 230 mm
- Envelope Monarch, 3 7/8 x 7.5 in.
- Envelope, 3 5/8 x 6.5 in.
- U.S. Standard Fanfold, 14 7/8 x 11 in.
- German Standard Fanfold, 8.5 x 12 in.
- German Legal Fanfold, 8 1/2 x 13 in.
- to 68. Less-common international sizes.
Greater than 118. Custom paper sizes.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Sets the paper size, means the type of the paper, to be used by the active printer.
A PaperSize object that defines the new value of the paper size to be used.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Sets up a custom paper size to be used by the active printer.
The custom paper width to be used, in inches.
The custom paper height to be used, in inches.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the height of the paper to be used by the active printer.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The paper height, in inches.
Determining information about the paper size used by the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Paper size information:");
Console.WriteLine("Paper width: {0} inches", gdpictureImaging.PrintGetPaperWidth().ToString());
Console.WriteLine("Paper height: {0} inches", gdpictureImaging.PrintGetPaperHeight().ToString());
}
Returns the width of the paper to be used by the active printer.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The paper width, in inches.
Determining information about the paper size used by the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Paper size information:");
Console.WriteLine("Paper width: {0} inches", gdpictureImaging.PrintGetPaperWidth().ToString());
Console.WriteLine("Paper height: {0} inches", gdpictureImaging.PrintGetPaperHeight().ToString());
}
Returns the value of an image alignment setting of the active printer. This value determines how the image is aligned when printing.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the PrintAlignment enumeration. The value of the image alignment property.
Showing basic printer settings on the screen.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Printer settings information:");
Console.WriteLine("Image aligment: {0}", gdpictureImaging.PrintGetAlignment().ToString());
Console.WriteLine("Number of copies: {0}", gdpictureImaging.PrintGetCopies().ToString());
Console.WriteLine("Duplex mode: {0}", gdpictureImaging.PrintGetDuplexMode().ToString());
Console.WriteLine("Will be printed document collated?: {0}", gdpictureImaging.PrintGetCollate().ToString());
}
Sets up the value of an image alignment setting of the active printer. This value determines how the image is aligned when printing.
A member of the PrintAlignment enumeration. The new value of the image alignment property.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Setting basic printer properties.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Console.WriteLine("Setting image alignment to -top left corner-");
gdpictureImaging.PrintSetAlignment(PrintAlignment.PrintAlignmentTopLeft);
Console.WriteLine("Setting number of copies to -3-");
gdpictureImaging.PrintSetCopies(3);
Console.WriteLine("Setting duplex mode to -Horizontal-");
gdpictureImaging.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Horizontal);
Console.WriteLine("Enabling document collate");
gdpictureImaging.PrintSetCollate(true);
}
Sets up the auto-rotation property of the active printer, that determines, if the pages are automatically rotated to fit on the output medium when printing.
Defines the auto-rotation property. Set this parameter to true if you want to select the page orientation automatically,
otherwise set it to false.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the current paper size, means the type of the paper, to be used by the active printer.
The value is determined through the PaperSize.Kind property of the default page settings.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The constant that represents the current paper size. Please refer to the System.Drawing.Printing.PaperKind enumeration for correct values. Some of them are
listed below (please see the corresponding ordering number):
- Letter, 8.5 x 11 in.
- Letter Small, 8.5 x 11 in.
- Tabloid, 11 x 17 in.
- Ledger, 17 x 11 in.
- Legal, 8.5 x 14 in.
- Statement, 5 1/2 x 8 1/2 in.
- Executive, 7 1/2 x 10 1/2 in.
- A3, 297 x 420 mm
- A4, 210 x 297 mm
- A4 Small, 210 x 297 mm
- A5, 148 x 210 mm
- B4, 250 x 354 mm
- B5, 182 x 257 mm
- Folio, 8.5 x 13 in.
- Quarto, 215 x 275 mm
- Standard 10 x 14 in.
- Standard 11 x 17 in.
- Note, 8.5 x 11 in.
- Envelope #9, 3 7/8 x 8 7/8 in.
- Envelope #10, 4 1/8 x 9.5 in.
- Envelope #11, 4.5 x 10 3/8 in.
- Envelope #12, 4.5 x 11 in.
- Envelope #14, 5 x 11.5 in.
- C size sheet
- D size sheet
- E size sheet
- Envelope DL, 110 x 220 mm
- Envelope C5, 162 x 229 mm
- Envelope C3, 324 x 458 mm
- Envelope C4, 229 x 324 mm
- Envelope C6, 114 x 162 mm
- Envelope C65, 114 x 229 mm
- Envelope B4, 250 x 353 mm
- Envelope B5, 176 x 250 mm
- Envelope B6, 176 x 125 mm
- Envelope Italy, 110 x 230 mm
- Envelope Monarch, 3 7/8 x 7.5 in.
- Envelope, 3 5/8 x 6.5 in.
- U.S. Standard Fanfold, 14 7/8 x 11 in.
- German Standard Fanfold, 8.5 x 12 in.
- German Legal Fanfold, 8 1/2 x 13 in.
- to 68. Less-common international sizes.
Greater than 118. Custom paper sizes.
Determining information about the paper size of the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int paperSize = gdpictureImaging.PrintGetPaperSize();
Console.WriteLine("Printer size of active printer is: {0}", paperSize.ToString());
if (paperSize == 9) Console.WriteLine("This printer is using standard paper of A4 format.");
}
Returns the physical margins (x and y coordinates), that are part of the default page settings property of the active printer.
Both margins are used as defaults for all pages to be printed.
Output parameter. The physical margin (x-coordinate) at the left of the page, in inches.
Output parameter. The physical margin (y-coordinate) at the top of the page, in inches.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Determining information about physical margins of the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
float leftMargin = 0;
float topMargin = 0;
gdpictureImaging.PrintGetMargins(ref leftMargin, ref topMargin);
Console.WriteLine("Printer attribute information:");
Console.WriteLine("Left margin: {0} inches.", leftMargin.ToString());
Console.WriteLine("Top margin: {0} inches.", topMargin.ToString());
}
Draws a GdPicture image into a HDC (Handle to Device Context).
GdPicture image identifier. Image to draw.
Device Context destination.
Left pixel destination of the HDC.
Top pixel destination of the HDC.
Width, in pixel, of the drawn image.
Height, in pixel, of the drawn image.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Draws a GdPicture image into a graphics object.
GdPicture image identifier. Image to draw.
Graphics destination.
Left pixel destination of the graphics.
Top pixel destination of the graphics.
Width, in pixel, of the drawn image.
Height, in pixel, of the drawn image.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Draws a GdPicture image into a window defined by a Window Handle.
GdPicture image identifier. Image to draw.
Window Handle destination.
Left pixel destination of the window.
Top pixel destination of the window.
Width, in pixel, of the drawn image.
Height, in pixel, of the drawn image.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Draws a portion of a GdPicture image into a HDC (Handle to Device Context).
GdPicture image identifier. Image to draw.
Device Context destination.
Left pixel destination of the HDC.
Top pixel destination of the HDC.
Width, in pixel, of the drawn image.
Height, in pixel, of the drawn image.
Left pixel source of the image to draw.
Top pixel source of the image to draw.
Width portion, in pixel, of the image to draw.
Height portion, in pixel, of the image to draw.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Draws a portion of a GdPicture image into a graphics object.
GdPicture image identifier. Image to draw.
Graphics destination.
Left pixel destination of the graphics.
Top pixel destination of the graphics.
Width, in pixel, of the drawn image.
Height, in pixel, of the drawn image.
Left pixel source of the image to draw.
Top pixel source of the image to draw.
Width portion, in pixel, of the image to draw.
Height portion, in pixel, of the image to draw.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Draws a portion of a GdPicture image into a window defined by a Window Handle.
GdPicture image identifier. Image to draw.
Window Handle destination.
Left pixel destination of the window.
Top pixel destination of the window.
Width, in pixel, of the drawn image.
Height, in pixel, of the drawn image.
Left pixel source of the image to draw.
Top pixel source of the image to draw.
Width portion, in pixel, of the image to draw.
Height portion, in pixel, of the image to draw.
A member of the Drawing2D.InterPolationMode enumeration.
A member of the GdPictureStatus enumeration.
Crops a custom area of a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
Left source pixel.
Top source pixel.
Width in pixel.
Height in pixel.
A member of the GdPictureStatus enumeration.
Cropping from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Remove 5% all around the image.
int height = gdpictureImaging.GetHeight(imageID);
int width = gdpictureImaging.GetWidth(imageID);
gdpictureImaging.Crop(imageID, width * 5 / 100, height * 5 / 100, width * 90 / 100, height * 90 / 100);
gdpictureImaging.SaveAsPNG(imageID, "crop.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Crops the top of a GdPicture image.
GdPicture image identifier.
Height, in pixel, to remove from the top of a GdPicture image.
A member of the GdPictureStatus enumeration.
Cropping 10 lines from the top of the image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Crop 10 lines from the top of the image.
gdpictureImaging.CropTop(imageID, 10);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Crops the bottom of a GdPicture image.
GdPicture image identifier.
Height, in pixel, to remove from the bottom of a GdPicture image.
A member of the GdPictureStatus enumeration.
Cropping 10 lines from the bottom of the image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Crop 10 lines from the bottom of the image.
gdpictureImaging.CropBottom(imageID, 10);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Crops the left of a GdPicture image.
GdPicture image identifier.
Width, in pixel, to remove from the left of a GdPicture image.
A member of the GdPictureStatus enumeration.
Cropping 10 lines from the left of the image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Crop 10 lines from the left of the image.
gdpictureImaging.CropLeft(imageID, 10);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Crops the right of a GdPicture image.
GdPicture image identifier.
Width, in pixel, to remove from the right of a GdPicture image.
A member of the GdPictureStatus enumeration.
Cropping 10 lines from the right of the image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Crop 10 lines from the right of the image.
gdpictureImaging.CropRight(imageID, 10);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Rotates clock-wise or flips a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the RotateFlipType enumeration.
A member of the GdPictureStatus enumeration.
Rotating a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Rotate the image by 90°.
gdpictureImaging.Rotate(imageID, RotateFlipType.Rotate90FlipNone);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Rotates clockwise a GdPicture by a specific angle keeping the originals width and height of the
picture.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
A member of the GdPictureStatus enumeration.
Rotates clockwise a GdPicture by a specific angle and specific back color keeping the originals width
and height of the picture.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
Color of the background. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Rotates clockwise a GdPicture by a specific from the center with a specific angle keeping the originals width and
height of the picture.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
A member of the GdPictureStatus enumeration.
Rotates clockwise a GdPicture by a specific angle from the center with custom back color keeping the
originals width and height of the picture.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
Color of the background. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Rotates clockwise a GdPicture by a specific angle.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
A member of the GdPictureStatus enumeration.
Rotating a jpeg image by 75°.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Rotate the image by 75°.
gdpictureImaging.RotateAngle(imageID, 75);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Rotates clockwise a GdPicture by a specific angle and a custom back color.
This method requires the Image Documents component to run.
GdPicture image identifier.
Angle of rotation in degrees.
Color of the background. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Rotating a jpeg image by 75° using a light blue background color.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Rotate the image by 75° with a light blue background color.
gdpictureImaging.RotateAngleBackColor(imageID, 75, Color.LightBlue);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Resizes a GdPicture image.
GdPicture image identifier.
New image width in pixel.
New image height in pixel.
A member of the Drawing2D.InterPolationMode enumeration.
This method automatically adjusts the vertical and horizontal image resolution in order to maintain the aspect ratio.
If the intention is to change the aspect ratio, the SetVerticalResolution() and/or SetHorizontalResolution() methods should be used instead.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Resizing a 1920x1080 pixels image to a 1080x720 pixels image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image_1920x1080.jpg", false);
// Set the new dimensions for your image.
int newImageWidth = 1080;
int newImageHeight = 720;
// Resize the image.
gdpictureImaging.Resize(imageID, newImageWidth, newImageHeight, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsJPEG(imageID, "image_1080x720.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a resized GdPicture image from a GdPicture image.
GdPicture image identifier. The image to release.
New image width in pixel.
New image height in pixel.
A member of the Drawing2D.InterPolationMode enumeration.
- 0: Failure. Use the GetStat() method to determine the reason this method failed.
- Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
This method automatically adjusts the vertical and horizontal image resolution in order to maintain the aspect ratio.
If the intention is to change the aspect ratio, the SetVerticalResolution() and/or SetHorizontalResolution() methods should be used instead.
This method requires the Image Documents component to run.
Resizes a GdPicture image with custom height keeping the original aspect ratio for the new width
value.
GdPicture image identifier.
The new height of the image in pixel.
A member of the Drawing2D.InterPolationMode enumeration.
This method automatically adjusts the vertical and horizontal image resolution in order to maintain the aspect ratio.
If the intention is to change the aspect ratio, the SetVerticalResolution() and/or SetHorizontalResolution() methods should be used instead.
A member of the GdPictureStatus enumeration.
Resizing the image making it half the original size.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Resize the image making its height half. The width of the image will be changed in order to maintain the aspect ratio.
int height = gdpictureImaging.GetHeight(imageID);
gdpictureImaging.ResizeHeightRatio(imageID, height / 2, System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Resizes a GdPicture image with custom width keeping the original aspect ratio for the new height
value.
GdPicture image identifier.
The new image width in pixel.
A member of the Drawing2D.InterPolationMode enumeration.
This method automatically adjusts the vertical and horizontal image resolution in order to maintain the aspect ratio.
If the intention is to change the aspect ratio, the SetVerticalResolution() and/or SetHorizontalResolution() methods should be used instead.
A member of the GdPictureStatus enumeration.
Resizing the image making it twice the original size.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Resize the image making its width twice larger. The height of the image will be changed in order to maintain the aspect ratio.
int width = gdpictureImaging.GetWidth(imageID);
gdpictureImaging.ResizeWidthRatio(imageID, width * 2, System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Resizes a GdPicture image image, keeping the same aspect ratio.
GdPicture image identifier.
Scale percentage value. ie: if ScalePercent = 50, the image is reduced to half size.
A member of the Drawing2D.InterPolationMode enumeration.
This method automatically adjusts the vertical and horizontal image resolution in order to maintain the aspect ratio.
If the intention is to change the aspect ratio, the SetVerticalResolution() and/or SetHorizontalResolution() methods should be used instead.
A member of the GdPictureStatus enumeration.
Rescaling an image and saving as a png.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", false);
gdpictureImaging.Scale(imageID, 95.0f, System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds borders around a GdPicture image.
GdPicture image identifier.
The width of the border in pixel.
Color of the borders. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Adding borders around a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels blue borders around the image.
int borderWidth = 10;
Color borderColor = gdpictureImaging.ARGB(255, 0, 0, 255);
gdpictureImaging.AddBorders(imageID, borderWidth, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds borders around a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
The width of the border in pixel.
Color of the borders. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Adding borders around a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels blue borders around the image.
int borderWidth = 10;
int borderColor = gdpictureImaging.ARGBI(255, 0, 0, 255);
gdpictureImaging.AddBorders(imageID, borderWidth, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds border to the top of a GdPicture image.
GdPicture image identifier.
The height of the border in pixel.
Color of the border. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Adding the border to the top of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels blue border to the top of the image.
int borderHeight = 10;
Color borderColor = Color.FromArgb(0, 0, 255);
gdpictureImaging.AddBorderTop(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds border to the top of a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
The height of the border in pixel.
Color of the border. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Adding the border to the top of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels blue border to the top of the image.
int borderHeight = 10;
int borderColor = gdpictureImaging.ARGBI(255, 0, 0, 255);
gdpictureImaging.AddBorderTop(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds border to the bottom of a GdPicture image.
GdPicture image identifier.
The width of the border in pixel.
Color of the border. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Adding the border to the bottom of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels green border at the bottom of the image.
int borderHeight = 10;
Color borderColor = Color.FromArgb(0, 255, 0);
gdpictureImaging.AddBorderBottom(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds border to the bottom of a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
The width of the border in pixel.
Color of the border. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Adding the border to the bottom of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels green border at the bottom of the image.
int borderHeight = 10;
int borderColor = gdpictureImaging.ARGBI(255, 0, 255, 0);
gdpictureImaging.AddBorderBottom(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds border to the left of a GdPicture image.
GdPicture image identifier.
The width of the border in pixel.
Color of the border. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Adding the border to the left of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels green border at the left of the image.
int borderHeight = 10;
Color borderColor = Color.FromArgb(0, 255, 0);
gdpictureImaging.AddBorderLeft(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds border to the left of a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
The width of the border in pixel.
Color of the border. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Adding the border to the left of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels green border at the left of the image.
int borderHeight = 10;
int borderColor = gdpictureImaging.ARGBI(255, 0, 255, 0);
gdpictureImaging.AddBorderLeft(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds border to the right of a GdPicture image.
GdPicture image identifier.
The width of the border in pixel.
Color of the border. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Adding the border to the right of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels blue border to the right of the image.
int borderHeight = 10;
Color borderColor = Color.FromArgb(0, 0, 255);
gdpictureImaging.AddBorderTop(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Adds border to the right of a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
The width of the border in pixel.
Color of the border. A suitable color value can be obtained by using the ARGBI() method.
A member of the GdPictureStatus enumeration.
Adding the border to the right of a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.png", true);
// Add a 10 pixels blue border to the right of the image.
int borderHeight = 10;
int borderColor = gdpictureImaging.ARGBI(255, 0, 0, 255);
gdpictureImaging.AddBorderTop(imageID, borderHeight, borderColor);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a GdPicture image as a windows or OS/2 bitmap image.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as a windows or OS/2 bitmap image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Set true to compress the bitmap pixels with the RLE compression scheme. Only available for 8 bpp bitmap.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as wbmp (Wireless Bitmap) image.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
WBMP format is a format used on WAP (Wireless Application Protocol).
You can load WBMP images into mobile device which supports WAP (ie: cellular phones).
This format supports only 1BPP image.
This method requires the Image Documents component to run.
Saves a GdPicture image as x11 pixmap image.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
This method works only with 8-bit and 24-bit images.
This method requires the Image Documents component to run.
Saves a GdPicture image as a window icon image format specifying a color to set as transparent.
GdPicture image identifier.
A string that contains the name of the file to which to save the image.
This parameter defines the transparent color of the ICON. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as a window icon image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as a window icon image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the IconSize enumeration. The icons size.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as a window icon image format specifying a color to set as transparent.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
This parameter defines the transparent color of the icon. A suitable color value can be obtained by using the ARGB() method.
A member of the IconSize enumeration. The icons size.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as a window icon image format specifying whether it has a transparent color and the color to set as transparent if so.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Whether the icon has a transparent color or not.
This parameter defines the transparent color of the icon. A suitable color value can be obtained by using the ARGB() method. This parameter will be ignored if HasTransparentColor is set to false.
A member of the IconSize enumeration. The icons size.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as Graphics Interchange Format image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as Portable Network Graphics image.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Saving a processed GdPicture image as a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Change image contrast using random value. Allowed values are from -100 to +100.
Random random = new Random();
int contrast = random.Next(-100, 100);
gdpictureImaging.SetContrast(imageID, contrast);
gdpictureImaging.SaveAsPNG(imageID, "output.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Remove 5% all around the image.
int height = gdpictureImaging.GetHeight(imageID);
int width = gdpictureImaging.GetWidth(imageID);
gdpictureImaging.Crop(imageID, width * 5 / 100, height * 5 / 100, width * 90 / 100, height * 90 / 100);
gdpictureImaging.SaveAsPNG(imageID, "crop.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a GdPicture image as Portable Network Graphics image. This overload supports compression level customization.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
The level of compression to use, in the range 0 (no compression) to 9 (max compression). Suggested value is 6, using higer value should result in a smaller file size but also increases encoding time.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Drawing the red text "GdPicture.Net" on a png image and saving the image using maximum compression.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawText(imageID, "GdPicture.Net", 5, 5, 24, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGBI(255, 255, 0, 0), "Arial", true);
// Save the output png using maximum compression.
gdpictureImaging.SaveAsPNG(imageID, "output.png", 6);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a GdPicture image as Portable Network Graphics image. This overload supports interlacing and compression level customization.
This method requires the Image Documents component to run.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
The level of compression to use, in the range 0 (no compression) to 9 (max compression). Suggested value is 6, using higer value should result in a smaller file size but also increases encoding time.
Specifies if the encoder must produce and interlaced version of the image. Interlacing increases file size.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Drawing the red text "GdPicture.Net" on a png image and saving the image using maximum compression.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.png");
// Draw the text in the top left corner of the image.
gdpictureImaging.DrawText(imageID, "GdPicture.Net", 5, 5, 24, GdPicture14.FontStyle.FontStyleRegular, gdpictureImaging.ARGBI(255, 255, 0, 0), "Arial", true);
// Save the output png using maximum compression.
gdpictureImaging.SaveAsPNG(imageID, "output.png", 6, false);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a GdPicture image as JBIG2 image format with lossless compression.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
Saves a required GdPicture image to a given file path as jpeg image.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
Please note that the JPEG compression quality level used by this method is 75 by default.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Saving jpeg images.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
gdpictureImaging.FxNegative(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.jpg");
string text = "GdPicture.PDF";
float width = gdpictureImaging.GetTextWidth(imageID, text, "Arial", 24, GdPicture14.FontStyle.FontStyleRegular);
float height = gdpictureImaging.GetTextHeight(imageID, text, "Arial", 24, GdPicture14.FontStyle.FontStyleRegular);
// Draw the text.
gdpictureImaging.DrawText(imageID, text, 10, 10, 24, GdPicture14.FontStyle.FontStyleRegular, Color.Red, "Arial", true);
// Draw the border rectangle.
gdpictureImaging.DrawRectangle(imageID, 10, 10, (int)width, (int)height, 1, Color.Black, true);
gdpictureImaging.SaveAsJPEG(imageID, "output.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a required GdPicture image to a given file path as jpeg image. You can specify the JPEG compression level using this method.
Saves a required GdPicture image to a given file path as jpeg image according to what you have specified.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression. The default value is 75.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Performing a negative effect on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
gdpictureImaging.FxNegative(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 85);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a required GdPicture image to a given file path as jpeg image. You can specify additional JPEG parameters for saving using this method.
Saves a required GdPicture image to a given file path as jpeg image according to what you have specified.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression. The default value is 75.
Set this parameter to true to save the image as a progressive JPEG, otherwise set it to false.
The default value is false.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Performing a negative effect on a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
gdpictureImaging.FxNegative(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75, true);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a required GdPicture image to a given file path as jpeg image. You can specify additional JPEG parameters for saving using this method.
This method requires the Image Documents component to run.
Saves a required GdPicture image to a given file path as jpeg image according to what you have specified.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression. The default value is 75.
Set this parameter to true to save the image as a progressive JPEG, otherwise set it to false.
The default value is false.
A member of the JPEGSubsamplingMode enumeration. Chroma subsampling mode used for image compression in JPEG images.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Saves a GdPicture image as WebP image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Specifies the compression quality between 1 (smallest file) and 100 (highest quality). Usually 75. Value >= 100 will perform lossless encoding.
Defines quality/speed trade-off between 0 (fast) and 6 (slower-better). Usually 6.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as Truevision TARGA image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
This method works only with 8-bit, 16-bit, 24-bit and 32-bit images.
Use the IsPixelFormatHasAlpha(ImageID) method to check if a GdPicture image has an alpha component.
Saves a GdPicture image as Portable Bitmap image.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
This method works only with 1-bit, 8-bit grayscale and 24-bit images.
Use the IsPixelFormatHasAlpha(ImageID) method to check if a GdPicture image has an alpha component.
This method requires the Image Documents component to run.
Saves a GdPicture image as WMF image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image in high dynamic-range image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A combination of members of the ExrCompression enumeration.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as JPEG-2000 codestream image.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as JPEG-2000 codestream image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Specifies the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as JPEG-2000 File image.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as JPEG-2000 File image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A string that contains the name of the file to which to save the image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
Specifies the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.
A member of the GdPictureStatus enumeration.
Returns, if any, the last HTTP or FTP transfer error description.
The error description.
Retrieving the last transfer error description.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Set the transferring options.
gdpictureImaging.SetFtpPassiveMode(true);
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.UploadFileToFTP(@"D:\images\image.jpg", "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Uploading failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Uploading using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Set the active FTP transfer more.
gdpictureImaging.SetFtpPassiveMode(false);
if (gdpictureImaging.SaveToFTP(imageID, GdPicture14.DocumentFormat.DocumentFormatJPEG, 75, "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Saving failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Saving using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a GdPicture image into a FTP server.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the DocumentFormat enumeration. Currently supported formats are:
DocumentFormatBMP.DocumentFormatJPEG.DocumentFormatPNG.DocumentFormatTIFF.DocumentFormatGIF.DocumentFormatJ2K (JPEG2000 codestream).DocumentFormatJP2 (JPEG2000) DocumentFormatTARGA.DocumentFormatEXR.DocumentFormatWBMP.DocumentFormatXPM.DocumentFormatPBM.DocumentFormatWMF.DocumentFormatWEBP.
Compression or encoding quality to use.
For JPEG format: the parameter defines the quality between 1 (lower) and 100 (higher).For WebP format: the parameter defines the quality between 1 (lower) and 100 (higher - lossless encoding).For TIFF format: the parameter defines the compression scheme to be used: 1 for none, 2 for RLE, 3 for CCITT3, 4 for CCITT4, 5 for LZW, 7 for JPEG, 32946 for Deflate and 65536 for automatic compression adjustment. For more options the SaveAsTiff() method taking a Stream object as parameter can be used.For JPEG2000 format: the parameter defines the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.For PNG format: the parameter defines the compression level Between [0(no compression - faster encoding) ... 9(max compression - slower encoding)]. Default value is 6.For other formats use 0.
The host server ie: ftp.com.
The image file path to create into the distant server ie:
/demo/image.jpg.
User Login.
User Password.
The FTP port number used. Usually 21.
A member of the GdPictureStatus enumeration. If HTTP or FTP error status is returned the GetLastTransferError method can be used to diagnose the error.
Saving an image to a file located on a distant server using FTP transfer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Set the active FTP transfer more.
gdpictureImaging.SetFtpPassiveMode(false);
if (gdpictureImaging.SaveToFTP(imageID, GdPicture14.DocumentFormat.DocumentFormatJPEG, 75, "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Saving failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Saving using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a GdPicture image into a HTTP server. This method uses HTTP PUT protocol method.
GdPicture image identifier.
A member of the DocumentFormat enumeration. Currently supported formats are:
DocumentFormatBMP.DocumentFormatJPEG.DocumentFormatPNG.DocumentFormatTIFF.DocumentFormatGIF.DocumentFormatJ2K (JPEG2000 codestream).DocumentFormatJP2 (JPEG2000) DocumentFormatTARGA.DocumentFormatEXR.DocumentFormatWBMP.DocumentFormatXPM.DocumentFormatPBM.DocumentFormatWMF.DocumentFormatWEBP.
Compression or encoding quality to use.
For JPEG format: the parameter defines the quality between 1 (lower) and 100 (higher).For WebP format: the parameter defines the quality between 1 (lower) and 100 (higher - lossless encoding).For TIFF format: the parameter defines the compression scheme to be used: 1 for none, 2 for RLE, 3 for CCITT3, 4 for CCITT4, 5 for LZW, 7 for JPEG, 32946 for Deflate and 65536 for automatic compression adjustment. For more options the SaveAsTiff() method taking a Stream object as parameter can be used.For JPEG2000 format: the parameter defines the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.For PNG format: the parameter defines the compression level Between [0(no compression - faster encoding) ... 9(max compression - slower encoding)]. Default value is 6.For other formats use 0.
Address of destination. IE:
http://www.google.com/uploads/myimage.jpg.
A member of the GdPictureStatus enumeration. If HTTP or FTP error status is returned the GetLastTransferError method can be used to diagnose the error.
Saving an image to a file located on a distant server using HTTP transfer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Set the packet size.
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.SaveToHTTP(imageID, GdPicture14.DocumentFormat.DocumentFormatJPEG, 75, "http://www.google.com/uploads/myimage.jpg") != GdPictureStatus.OK)
{
MessageBox.Show("Saving failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Saving to HTTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a GdPicture image into a HTTP server using authentication. This method uses HTTP PUT protocol method.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the DocumentFormat enumeration. Currently supported formats are:
DocumentFormatBMP.
DocumentFormatJPEG.
DocumentFormatPNG.
DocumentFormatTIFF.
DocumentFormatGIF.
DocumentFormatJ2K (JPEG2000 codestream).
DocumentFormatJP2 (JPEG2000)
DocumentFormatTARGA.
DocumentFormatEXR.
DocumentFormatWBMP.
DocumentFormatXPM.
DocumentFormatPBM.
DocumentFormatWMF.
DocumentFormatWEBP.
Compression or encoding quality to use.
For JPEG format: the parameter defines the quality between 1 (lower) and 100 (higher).
For WebP format: the parameter defines the quality between 1 (lower) and 100 (higher - lossless encoding).
For TIFF format: the parameter defines the compression scheme to be used: 1 for none, 2 for RLE, 3 for CCITT3, 4 for CCITT4, 5 for LZW, 7 for JPEG, 32946 for Deflate and 65536 for automatic compression adjustment. For more options the SaveAsTiff() method taking a Stream object as parameter can be used.
For JPEG2000 format: the parameter defines the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.
For PNG format: the parameter defines the compression level Between [0(no compression - faster encoding) ... 9(max compression - slower encoding)]. Default value is 6.
For other formats use 0.
Address of destination. IE:
http://www.google.com/uploads/myimage.jpg.
User Login.
User Password.
A member of the GdPictureStatus enumeration. If HTTP or FTP error status is returned the GetLastTransferError method can be used to diagnose the error.
Saving an image to a file located on a distant server using HTTP transfer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Set the packet size.
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.SaveToHTTP(imageID, GdPicture14.DocumentFormat.DocumentFormatJPEG, 75, "http://www.google.com/uploads/myimage.jpg", "user", "password") != GdPictureStatus.OK)
{
MessageBox.Show("Saving failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Saving using HTTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a required GdPicture image to a given file path as Tagged Image File Format (tif) acording to what you have specified.
This method only saves the currently selected page of the specified image if it is an editable multipage TIFF image.
Saves a required GdPicture image to a given file path as Tagged Image File Format (tif) acording to what you have specified.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Please note that if you apply the JPEG compression, the quality factor used by default is 90.
You can use the overloaded method to set your preferred value for the JpegQuality parameter.
Be aware that if the specified GdPicture image represents an editable multipage TIFF image, this method only saves the currently selected page.
You should use the method to save an editable multipage TIFF image instead.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Saving a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Remove vertical and horizontal lines using default parameters.
gdpictureImaging.RemoveLines(imageID, LineRemoveOrientation.Horizontal | LineRemoveOrientation.Vertical);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Invert white text with black background.
gdpictureImaging.AutoTextInvert(imageID, 100, 100, 60, 100, true, false, 1);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a required GdPicture image to a given file path as Tagged Image File Format (tif) acording to what you have specified.
You can also define a JPEG quality parameter when the JPEG compression is required using this method.
This method only saves the currently selected page of the specified image if it is an editable multipage TIFF image.
Saves a required GdPicture image to a given file path as Tagged Image File Format (tif) acording to what you have specified.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression.
This parameter is ignored when the required compression scheme is different than JPEG.
Be aware that if the specified GdPicture image represents an editable multipage TIFF image, this method only saves the currently selected page.
You should use the method to save an editable multipage TIFF image instead.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Saving tiff image while applying jpeg compression.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
// Invert white text with black background.
gdpictureImaging.AutoTextInvert(imageID, 100, 100, 60, 100, true, false, 1);
gdpictureImaging.SaveAsTIFF(imageID, "output.tif", TiffCompression.TiffCompressionJPEG, 90);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a required GdPicture image to a given file path as Tagged Image File Format (tif) acording to what you have specified.
You can utilize the CMYK color space if required when saving an image using this method.
This method only saves the currently selected page of the specified image if it is an editable multipage TIFF image.
Saves a required GdPicture image to a given file path as Tagged Image File Format (tif) acording to what you have specified.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
Set this parameter to true, if you want to save the required image as TIFF file in CMYK color space, otherwise set it to false.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
Please note that if you apply the JPEG compression, the quality factor used by default is 90.
You can use the overloaded method to set your preferred value for the JpegQuality parameter.
Be aware that if the specified GdPicture image represents an editable multipage TIFF image, this method only saves the currently selected page.
You should use the method to save an editable multipage TIFF image instead.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Applying ICM correction when saving CMYK based image as a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
string filePath = "image.jpg";
if (gdpictureImaging.IsCMYKFile(filePath))
{
// Enable color correction.
gdpictureImaging.EnableICM(true);
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(filePath);
gdpictureImaging.SaveAsTIFF(imageID, "output.tiff", true, TiffCompression.TiffCompressionAUTO);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
}
Saves a required GdPicture image to a given file path as Tagged Image File Format (tif) acording to what you have specified.
You can also define a JPEG quality parameter when the JPEG compression is required as well as you can utilize the CMYK color space when saving an image using this method.
This method only saves the currently selected page of the specified image if it is an editable multipage TIFF image.
Saves a required GdPicture image to a given file path as Tagged Image File Format (tif) acording to what you have specified.
A unique image identifier of the GdPicture image representing the image to be saved.
The file path where the specified image will be saved. Use the empty string to allow the control to prompt users to select a file.
If the specified file already exists, it will be overwritten.You can subsequently use the method to retrieve the path of the selected file.
Set this parameter to true, if you want to save the required image as TIFF file in CMYK color space, otherwise set it to false.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression.
This parameter is ignored when the required compression scheme is different than JPEG.
Be aware that if the specified GdPicture image represents an editable multipage TIFF image, this method only saves the currently selected page.
You should use the method to save an editable multipage TIFF image instead.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Applying ICM correction when saving CMYK based image as a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
string filePath = "image.jpg";
if (gdpictureImaging.IsCMYKFile(filePath))
{
// Enable color correction.
gdpictureImaging.EnableICM(true);
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(filePath);
gdpictureImaging.SaveAsTIFF(imageID, "output.tiff", true, TiffCompression.TiffCompressionJPEG, 90);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
}
Saves a GdPicture image as Tagged Image File Format.
This methods takes a parameter to save tiff in CMYK color space and another parameter to defines jpeg quality .
GdPicture image identifier.
A stream object to save the image file.
Set True to save tiff in CMYK color space, else False.
A member of the TiffCompression enumeration.
Specifies the compression quality, between 1 (worst quality) and 100 (better quality). This parameter is ignored when the specified compression scheme is different than JPEG.
If the specified GdPicture image is an editable multipage tiff image, this method will save only the selected page.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Applying ICM correction when saving CMYK based image as a tiff image using streams.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
string filePath = "image.jpg";
if (gdpictureImaging.IsCMYKFile(filePath))
{
// Enable color correction.
gdpictureImaging.EnableICM(true);
using (System.IO.Stream inputStream = new System.IO.FileStream(filePath, System.IO.FileMode.Open))
{
int imageID = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, filePath);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.tiff", System.IO.FileMode.CreateNew))
{
gdpictureImaging.SaveAsTIFF(imageID, outputStream, true, TiffCompression.TiffCompressionJPEG, 90);
}
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
}
}
Saves a GdPicture image to a byte array. This methods can generate multipage tiff file if the input GdPicture image is an editable multipage tiff.
This method requires the Image Documents component to run.
GdPicture image identifier.
Output parameter. The image data.
Output parameter. The number of bytes wrote into the Data array.
A member of the DocumentFormat enumeration. Currently supported formats are:
DocumentFormatBMP.
DocumentFormatJPEG.
DocumentFormatPNG.
DocumentFormatTIFF.
DocumentFormatGIF.
DocumentFormatJ2K (JPEG2000 codestream).
DocumentFormatJP2 (JPEG2000)
DocumentFormatTARGA.
DocumentFormatEXR.
DocumentFormatWBMP.
DocumentFormatXPM.
DocumentFormatPBM.
DocumentFormatWMF.
DocumentFormatWEBP.
Compression or encoding quality to use.
For JPEG format: the parameter defines the quality between 1 (lower) and 100 (higher).
For WebP format: the parameter defines the quality between 1 (lower) and 100 (higher - lossless encoding).
For TIFF format: the parameter defines the compression scheme to be used: 1 for none, 2 for RLE, 3 for CCITT3, 4 for CCITT4, 5 for LZW, 7 for JPEG, 32946 for Deflate and 65536 for automatic compression adjustment. For more options the SaveAsTiff() method taking a Stream object as parameter can be used.
For JPEG2000 format: the parameter defines the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.
For PNG format: the parameter defines the compression level Between [0(no compression - faster encoding) ... 9(max compression - slower encoding)]. Default value is 6.
For other formats use 0.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image to a stream. This methods can generate multipage tiff file if the input GdPicture image is an editable multipage tiff.
This method requires the Image Documents component to run.
GdPicture image identifier.
The stream object to save the image.
A member of the DocumentFormat enumeration. Currently supported formats are:
DocumentFormatBMP.
DocumentFormatJPEG.
DocumentFormatPNG.
DocumentFormatTIFF.
DocumentFormatGIF.
DocumentFormatJ2K (JPEG2000 codestream).
DocumentFormatJP2 (JPEG2000)
DocumentFormatTARGA.
DocumentFormatEXR.
DocumentFormatWBMP.
DocumentFormatXPM.
DocumentFormatPBM.
DocumentFormatWMF.
DocumentFormatWEBP.
Compression or encoding quality to use.
For JPEG format: the parameter defines the quality between 1 (lower) and 100 (higher).
For WebP format: the parameter defines the quality between 1 (lower) and 100 (higher - lossless encoding).
For TIFF format: the parameter defines the compression scheme to be used: 1 for none, 2 for RLE, 3 for CCITT3, 4 for CCITT4, 5 for LZW, 7 for JPEG, 32946 for Deflate and 65536 for automatic compression adjustment. For more options the SaveAsTiff() method taking a Stream object as parameter can be used.
For JPEG2000 format: the parameter defines the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.
For PNG format: the parameter defines the compression level Between [0(no compression - faster encoding) ... 9(max compression - slower encoding)]. Default value is 6.
For other formats use 0.
A member of the GdPictureStatus enumeration.
Cloning an area of a jpeg image into a new jpeg image using streams.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
{
int imageID1 = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, "image.jpg");
//Clone an area of the source image into a mew image.
int imageID2 = gdpictureImaging.CreateClonedGdPictureImageArea(imageID1, 50, 50, 100, 250);
//Process the cloned image.
gdpictureImaging.FxPixelize(imageID2);
using (System.IO.Stream outputStream = new System.IO.FileStream("output.png", System.IO.FileMode.CreateNew))
{
//Save a result into a new image file.
gdpictureImaging.SaveAsStream(imageID2, outputStream, GdPicture14.DocumentFormat.DocumentFormatPNG, 6);
}
gdpictureImaging.ReleaseGdPictureImage(imageID2);
gdpictureImaging.ReleaseGdPictureImage(imageID1);
}
}
Saves a GdPicture image to an IStream. This methods can generate multipage tiff file if the input GdPicture image is an editable multipage tiff.
This method requires the Image Documents component to run.
GdPicture image identifier.
The IStream object to save the image.
A member of the DocumentFormat enumeration. Currently supported formats are:
DocumentFormatBMP.
DocumentFormatJPEG.
DocumentFormatPNG.
DocumentFormatTIFF.
DocumentFormatGIF.
DocumentFormatJ2K (JPEG2000 codestream).
DocumentFormatJP2 (JPEG2000)
DocumentFormatTARGA.
DocumentFormatEXR.
DocumentFormatWBMP.
DocumentFormatXPM.
DocumentFormatPBM.
DocumentFormatWMF.
DocumentFormatWEBP.
Compression or encoding quality to use.
For JPEG format: the parameter defines the quality between 1 (lower) and 100 (higher).
For WebP format: the parameter defines the quality between 1 (lower) and 100 (higher - lossless encoding).
For TIFF format: the parameter defines the compression scheme to be used: 1 for none, 2 for RLE, 3 for CCITT3, 4 for CCITT4, 5 for LZW, 7 for JPEG, 32946 for Deflate and 65536 for automatic compression adjustment. For more options the SaveAsTiff() method taking a Stream object as parameter can be used.
For JPEG2000 format: the parameter defines the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.
For PNG format: the parameter defines the compression level Between [0(no compression - faster encoding) ... 9(max compression - slower encoding)]. Default value is 6.
For other formats use 0.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image to a string. This methods can generate multipage tiff file if the input GdPicture image is an editable multipage tiff.
GdPicture image identifier.
A member of the DocumentFormat enumeration. Currently supported formats are:
DocumentFormatBMP.
DocumentFormatJPEG.
DocumentFormatPNG.
DocumentFormatTIFF.
DocumentFormatGIF.
DocumentFormatJ2K (JPEG2000 codestream).
DocumentFormatJP2 (JPEG2000)
DocumentFormatTARGA.
DocumentFormatEXR.
DocumentFormatWBMP.
DocumentFormatXPM.
DocumentFormatPBM.
DocumentFormatWMF.
DocumentFormatWEBP.
Compression or encoding quality to use.
For JPEG format: the parameter defines the quality between 1 (lower) and 100 (higher).
For WebP format: the parameter defines the quality between 1 (lower) and 100 (higher - lossless encoding).
For TIFF format: the parameter defines the compression scheme to be used: 1 for none, 2 for RLE, 3 for CCITT3, 4 for CCITT4, 5 for LZW, 7 for JPEG, 32946 for Deflate and 65536 for automatic compression adjustment. For more options the SaveAsTiff() method taking a Stream object as parameter can be used.
For JPEG2000 format: the parameter defines the compression rate Between [1(MaxQuality - Lossless) ... 512(Poor quality)]. Default value is 16.
For PNG format: the parameter defines the compression level Between [0(no compression - faster encoding) ... 9(max compression - slower encoding)]. Default value is 6.
For other formats use 0.
A string (encoding 1252) containing the saved image.
It is recommended to subsequently encode the returned string into Base64 string to facilitate transfer by using the Encode64String() method (see example).
This method requires the Image Documents component to run.
Creates a multipage PDF from a multipage tiff image.
GdPicture image identifier. The multipage tiff image to save as PDF.
The destination of the pdf to create.
True to generate PDF in PDF/A 1-b format else False.
The title of the PDF.
The PDF Author.
The PDF Subject.
The PDF Keywords.
The name of the application which creates the PDF.
A member of the GdPictureStatus enumeration.
Saving a multipage tiff file to a PDF document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("multipage.tiff");
gdpictureImaging.PdfCreateFromMultipageTIFF(imageID, "output.pdf", true, "PDF from TIFF", "GdPicture.NET 14", "For test", "pdf, tiff", "Orpalis");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a multipage PDF from a multipage tiff image.
This method requires the PDF Processing and Image Conversion components to run.
GdPicture image identifier. The multipage tiff image to save as PDF.
The destination of the pdf to create.
True to generate PDF in PDF/A 1-b format else False.
The title of the PDF.
The PDF Author.
The PDF Subject.
The PDF Keywords.
The name of the application which creates the PDF.
A member of the PdfCompression enumeration. The scheme to use to compress bitonal bitmap within the PDF.
A member of the PdfCompression enumeration. The scheme to use to compress color bitmap within the PDF.
A member of the GdPictureStatus enumeration.
Saving a multipage tiff file to a PDF document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("multipage.tiff");
gdpictureImaging.PdfCreateFromMultipageTIFF(imageID, "output.pdf", true, "PDF from TIFF", "GdPicture.NET 14", "For test", "pdf, tiff", "Orpalis",
PdfCompression.PdfCompressionJPEG, PdfCompression.PdfCompressionJPEG);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a multipage PDF with encryption from a multipage tiff image.
This method requires the PDF Processing and Image Conversion components to run.
GdPicture image identifier. The multipage tiff image to save as PDF.
The destination of the pdf to create.
The title of the PDF.
The PDF Author.
The PDF Subject.
The PDF Keywords.
The name of the application which creates the PDF.
A member of the PdfEncryption enumeration. Note: AES 256 encyption is not yet available.
A value returned by the PdfCreateRights method.
The user password for the PDF. Can be an empty string.
The owner password for the PDF. Can be an empty string.
A member of the GdPictureStatus enumeration.
Saving a multipage tiff file to a PDF document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("multipage.tiff");
// Create pdf rights for saving.
PdfRight pdfRights = gdpictureImaging.PdfCreateRights(true, false, false, true, false, false, false, true);
gdpictureImaging.PdfCreateFromMultipageTIFF(imageID, "output.pdf", "PDF from TIFF", "GdPicture.NET 14", "For test", "pdf, tiff", "Orpalis",
PdfEncryption.PdfEncryption256BitAES, pdfRights, "userpassw", "ownerpassw");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a multipage PDF with encryption from a multipage tiff image.
This method requires the PDF Processing and Image Conversion components to run.
GdPicture image identifier. The multipage tiff image to save as PDF.
The destination of the pdf to create.
The title of the PDF.
The PDF Author.
The PDF Subject.
The PDF Keywords.
The name of the application which creates the PDF.
A member of the PdfEncryption enumeration. Note: AES 256 encyption is not yet available.
A value returned by the PdfCreateRights method.
The user password for the PDF. Can be an empty string.
The owner password for the PDF. Can be an empty string.
A member of the PdfCompression enumeration. The scheme to use to compress bitonal bitmap within the PDF.
A member of the PdfCompression enumeration. The scheme to use to compress color bitmap within the PDF.
A member of the GdPictureStatus enumeration.
Saving a multipage tiff file to a PDF document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("multipage.tiff");
// Create pdf rights for saving.
PdfRight pdfRights = gdpictureImaging.PdfCreateRights(true, false, false, true, false, false, false, true);
gdpictureImaging.PdfCreateFromMultipageTIFF(imageID, "output.pdf", "PDF from TIFF", "GdPicture.NET 14", "For test", "pdf, tiff", "Orpalis",
PdfEncryption.PdfEncryption256BitAES, pdfRights, "userpassw", "ownerpassw",
PdfCompression.PdfCompressionJPEG, PdfCompression.PdfCompressionJPEG);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Saves a GdPicture image as single page pdf.
This method requires the PDF Processing component to run.
GdPicture image identifier.
The complete PDF file path to save a GdPicture image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
True to generate PDF in PDF/A 1-b format else False.
The title of the PDF.
The PDF Author.
The PDF Subject.
The PDF Keywords.
The name of the application which creates the PDF.
A member of the GdPictureStatus enumeration.
Saving the image as a PDF document specifying document properties.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
// Get the file path of the loaded image file.
string filePath = gdpictureImaging.GetLastPath();
string pdfPath = System.IO.Path.ChangeExtension(filePath, ".pdf");
// Get the current version of the GdPicture.NET toolkit.
string version = (gdpictureImaging.GetVersion()).ToString();
version = version.Insert(version.IndexOf('.') + 2, ".");
// Define the document properties when saving, for example, the current version of the GdPicture.NET toolkit.
gdpictureImaging.SaveAsPDF(imageID, pdfPath, false, "Saving image as PDF", "GdPicture ver." + version.ToString(), "For test", "image, pdf", "Orpalis");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
else
MessageBox.Show("An image can't be created.\nError: " + gdpictureImaging.GetStat().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Saves a GdPicture image as single page pdf stream.
This method requires the PDF Processing component to run.
GdPicture image identifier.
The Stream object to save a GdPicture image.
True to generate PDF in PDF/A 1-b format else False.
The title of the PDF.
The PDF Author.
The PDF Subject.
The PDF Keywords.
The name of the application which creates the PDF.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as single page pdf with encryption.
This method requires the PDF Processing component to run.
GdPicture image identifier.
The complete PDF file path to save a GdPicture image. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
The title of the PDF.
The PDF Author.
The PDF Subject.
The PDF Keywords.
The name of the application which creates the PDF.
A member of the PdfEncryption enumeration. Note: AES 256 encyption is
not yet available.
A value returned by the PdfCreateRights method.
The user password for the PDF. Can be an empty string.
The owner password for the PDF. Can be an empty string.
A member of the GdPictureStatus enumeration.
Saving the image as a PDF document specifying document properties and pdf rights.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
// Get the file path of the loaded image file.
string filePath = gdpictureImaging.GetLastPath();
string pdfPath = System.IO.Path.ChangeExtension(filePath, ".pdf");
// Get the current version of the GdPicture.NET toolkit.
string version = (gdpictureImaging.GetVersion()).ToString();
version = version.Insert(version.IndexOf('.') + 2, ".");
// Create pdf rights for saving.
PdfRight pdfRights = gdpictureImaging.PdfCreateRights(true, false, true, true, false, false, false, true);
// Define the document properties when saving, for example, the current version of the GdPicture.NET toolkit and the pdf rights.
gdpictureImaging.SaveAsPDF(imageID, filepath, "Saving image as PDF", "GdPicture ver." + version.ToString(), "For test", "image, pdf", "Orpalis", PdfEncryption.PdfEncryption256BitAES, pdfRights, "userpassw", "ownerpassw");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
else
MessageBox.Show("An image can't be created.\nError: " + gdpictureImaging.GetStat().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Saves a GdPicture image as single page pdf stream with encryption.
GdPicture image identifier.
The Stream object to save a GdPicture image.
The title of the PDF.
The PDF Author.
The PDF Subject.
The PDF Keywords.
The name of the application which creates the PDF.
A member of the PdfEncryption enumeration. Note: AES 256 encyption is
not yet available.
A value returned by the PdfCreateRights method.
The user password for the PDF. Can be an empty string.
The owner password for the PDF. Can be an empty string.
A member of the GdPictureStatus enumeration.
Saves a GdPicture image as single page pdf stream with encryption.
This method requires the PDF Processing component to run.
GdPicture image identifier.
The IStream object to save a GdPicture image.
The title of the PDF.
The PDF Author.
The PDF Subject.
The PDF Keywords.
The name of the application which creates the PDF.
A member of the PdfEncryption enumeration. Note: AES 256 encyption is
not yet available.
A value returned by the PdfCreateRights method.
The user password for the PDF. Can be an empty string.
The owner password for the PDF. Can be an empty string.
A member of the GdPictureStatus enumeration.
Determines whether a GdPicture image (document) is negative.
GdPicture image identifier.
True if it is a Negative image, else False.
Use the GetStat() method to check if this method has completed successfully.
This method requires the Image Documents component to run.
Detects if a GdPicture image or on an area of a GdPicture image defined by SetROI() method is blank.
GdPicture image identifier.
Use the GetStat() method to check if this method has completed successfully.
True if it is a blank image, else False.
Removing the blank pages from a tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
int pageNo = 1;
while (pageNo <= pageCount)
{
gdpictureImaging.TiffSelectPage(imageID, pageNo);
if (gdpictureImaging.IsBlank(imageID))
{
gdpictureImaging.TiffDeletePage(imageID, pageNo);
pageCount--;
}
else
{
pageNo++;
}
}
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects if a GdPicture image or on an area of a GdPicture image defined by SetROI() method is blank.
GdPicture image identifier.
Confidence threshold in the range [0 - 100]. Suggested value is 99.5.
True if it is a blank image, else False.
Use the GetStat() method to check if this method has completed successfully.
Removing the blank pages from a tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
int pageNo = 1;
while (pageNo <= pageCount)
{
gdpictureImaging.TiffSelectPage(imageID, pageNo);
if (gdpictureImaging.IsBlank(imageID, 95))
{
gdpictureImaging.TiffDeletePage(imageID, pageNo);
pageCount--;
}
else
{
pageNo++;
}
}
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects if a GdPicture image or on an area of a GdPicture image defined by SetROI() method is blank, with option to account for margins.
GdPicture image identifier.
Confidence threshold in the range [0 - 100]. Suggested value is 99.5.
Specifies if the algorithm must drop the margins during the calculation (slower). Yields more accurate results for images with margins. Default value is true.
True if it is a blank image, else False.
Use the GetStat() method to check if this method has completed successfully.
Removing the blank pages from a tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
int pageNo = 1;
while (pageNo <= pageCount)
{
gdpictureImaging.TiffSelectPage(imageID, pageNo);
if (gdpictureImaging.IsBlank(imageID, 95, false))
{
gdpictureImaging.TiffDeletePage(imageID, pageNo);
pageCount--;
}
else
{
pageNo++;
}
}
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects if a GdPicture image or on an area of a GdPicture image defined by SetROI() method is blank, with option to account for margins.
GdPicture image identifier.
Confidence threshold in the range [0 - 100]. Suggested value is 99.5.
Specifies if the algorithm must drop the margins during the calculation (slower). Yields more accurate results for images with margins. Default value is true.
Specifies if the algorithm must drop the punch holes during the calculation (slower). Yields more accurate results for images with punch holes. Default value is true.
True if it is a blank image, else False.
Use the GetStat() method to check if this method has completed successfully.
Removing the blank pages from a tiff document.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.TiffCreateMultiPageFromFile("multipage.tif", true);
int pageCount = gdpictureImaging.TiffGetPageCount(imageID);
int pageNo = 1;
while (pageNo <= pageCount)
{
gdpictureImaging.TiffSelectPage(imageID, pageNo);
if (gdpictureImaging.IsBlank(imageID, 95, false, false))
{
gdpictureImaging.TiffDeletePage(imageID, pageNo);
pageCount--;
}
else
{
pageNo++;
}
}
gdpictureImaging.TiffSaveMultiPageToFile(imageID, "multipage.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects if a GdPicture image or on an area of a GdPicture image defined by SetROI() method is blank, with parameters to account for margins and for computed confidence limit.
GdPicture image identifier.
Confidence threshold in the range [0 - 100]. Suggested value is 99.5.
Specifies if the algorithm must drop the margins during the calculation (slower). Yields more accurate results for images with margins. Default value is true.
Returns the confidence limit computed by the algorithm.
True if it is a blank image, else False.
Use the GetStat() method to check if this method has completed successfully.
Detects if a GdPicture image or on an area of a GdPicture image defined by SetROI() method is blank, with parameters to account for margins and for computed confidence limit.
GdPicture image identifier.
Confidence threshold in the range [0 - 100]. Suggested value is 99.5.
Specifies if the algorithm must drop the margins during the calculation (slower). Yields more accurate results for images with margins. Default value is true.
Specifies if the algorithm must drop the punch holes during the calculation (slower). Yields more accurate results for images with punch holes. Default value is true.
Returns the confidence limit computed by the algorithm.
True if it is a blank image, else False.
Use the GetStat() method to check if this method has completed successfully.
This method requires the Image Documents component to run.
Removes empty form information and keeps the entered information only. Highly useful for better and
faster OCR processing, and reducing the image compression size.
GdPicture image identifier. The Filled Form.
GdPicture image identifier. The Empty Template Form Document.Has to be the same Height and Width as ImageID.
Whether or not to try to fix gaps of interaction between form and
data.
A member of the GdPictureStatus enumeration.
The Filled Form Image and the Empty Template image have to be the same height and width, or else an
Invalid Parameter will be returned.
Setting UseGapCorrection to True, will slow the speed of the algorithm, but will result in much more
accurate characters and filled data. Nonetheless, most applications will not need it. If accuracy is
what is sought after, set it to true, but make sure the process is called after the scan process and
not during to avoid any delays. The slowing of the UseGapCorrection option should be overlooked when
considering the tremendous outcomes of FormDropOut mentioned above on the application in general.
This method requires the Image Documents component to run.
Removes blobs and ink blobs with a specified size margin.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
Minimum Width of Blob considered for removal.
Minimum Height of Blob considered for removal.
Maximum Width of Blob considered for removal.
Maximum Height of Blob considered for removal.
Can be any value, not used internally starting V11.
A member of the GdPictureStatus enumeration.
This method is used in the "Document Clean Up" C# Demo.
This method will remove blobs with black pixels being at least 60% of the bounding rectangle of the blob.
Removing blobs from a tiff and saving as a png.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
int minBlobWidth = 50;
int minBlobHeight = 50;
int maxBlobWidth = 1000;
int maxBlobHeight = 1000;
gdpictureImaging.RemoveBlob(imageID, minBlobWidth, minBlobHeight, maxBlobWidth, maxBlobHeight, BlobRemoveMode.FavorQuality);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removes blobs and ink blobs with a specified size margin. It is a very powerful tool for despeckling (removing parasites) from images without affecting the content.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
Minimum Width of Blob considered for removal.
Minimum Height of Blob considered for removal.
Maximum Width of Blob considered for removal.
Maximum Height of Blob considered for removal.
Minimum percentage of black pixels within blob compared to blob bounding rectangle. Range [1-99]
Maximum percentage of black pixels within blob compared to blob bounding rectangle. Range [2-100]
This method is used in the "Document Clean Up" C# Demo.
To use it as a despeckling method you need to:
1. Know the range of the noise size (which is usually smaller than a character size).
2. Set the MinFillPercent and MaxFillPercent to 1 and 100 respectively.
3. Set MinBlobWidth and MinBlobHeight to 1 and 2 respectively.
4. Set MaxBlobWidth and MaxBlobHeight to a value smaller than the size of a character in your image.
The size of the character is highly dependent on the dpi of the image and the content. The higher the dpi, the higher the MaxBlobWidth and MaxBlobHeight should be.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Removing blobs from a tiff and saving as a png.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", false);
int minBlobWidth = 50;
int minBlobHeight = 50;
int maxBlobWidth = 1000;
int maxBlobHeight = 1000;
int minFillPercent = 90;
int maxFillPercent = 100;
gdpictureImaging.RemoveBlob(imageID, minBlobWidth, minBlobHeight, maxBlobWidth, maxBlobHeight, minFillPercent, maxFillPercent);
gdpictureImaging.SaveAsPNG(imageID, "image.png");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removes all punch holes of the image. This method allows you to remove both circle and rectangle punch holes, as well
as the punch holes that looks like a part of the circle (residuals of holes). The image you want to process can be black and white, grayscale and colored as well.
Removes all punch holes situated on the margins of your image.
GdPicture image identifier.
Be aware that only 1, 8 and 24 bit per pixel images are supported.
This method is used in the "Image Processing Sample" and the "Document Clean Up Sample", both are C# demo applications. Please
read the sections "Learning GdPicture.NET" and "Programming" in the GdPicture reference guide for further information on this feature.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Removes punch holes from a bitonal tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("bitonal.tif", false);
gdpictureImaging.RemoveHolePunch(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "processed_image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removes all punch holes situated on the exactly specified margin of the image. This method allows you to remove both circle and rectangle punch holes,
as well as the punch holes that looks like a part of the circle (residuals of holes). You are able to select the specific margin of your image. The image you
want to process can be black and white, grayscale and colored as well.
Removes all punch holes situated on the margins of your image.
GdPicture image identifier.
Be aware that only 1, 8 and 24 bit per pixel images are supported.
A member of the HolePunchMargins enumeration. The required image margin you want to repair.
You can combine margins using the "OR" operator, as it is shown in the example below.
Just to remind you that you can use the binary operator "OR" with HolePunchMargins enumerations to specify more than one margin at the same time.
This method is used in the "Image Processing Sample" and the "Document Clean Up Sample", both are C# demo applications. Please read the sections "Learning
GdPicture.NET" and "Programming" in the GdPicture reference guide for further information on this feature.
A member of the GdPictureStatus enumeration.
If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
This method requires the Image Documents component to run.
Removes punch holes from a bitonal tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("bitonal.tif", false);
gdpictureImaging.RemoveHolePunch(imageID, HolePunchMargins.MarginLeft | HolePunchMargins.MarginRight);
gdpictureImaging.SaveAsTIFF(imageID, "processed_image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removes the staples marks on the image.
This method requires the Image Documents component to run.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
A member of the GdPictureStatus enumeration.
Removing staple marks on 1bpp b&w image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
if ((gdpictureImaging.GetBitDepth(imageID) == 1) && gdpictureImaging.IsBitonal(imageID, 0))
{
gdpictureImaging.RemoveStapleMark(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
}
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Inverts white text with black background to become black text with white background.
This method requires the Image Documents component to run.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
Minimum width of the black background object.
Minimum height of the black background object.
Minimum percent of black pixels within the background object. Can be thought of as how much black space there needs to be
where there is no white text.
Maximum percent of black pixels within the background object. Can be thought of as how much white text there needs to be
in the black object.
Whether or not to despeckle the background after inverting it. Black objects are usually imperfectly scanned in low DPIs, resulting in holes
which would appear as noise once inverted. Setting this to True would clean up this noise, but would also eliminate some characters if they are too small.
Whether or not the object is connected to lines as part of a table for example.
If ConnectedToLines is True, then you would need to specify the max thickness of those lines. A value between 1-5 is suggested.
A member of the GdPictureStatus enumeration.
Inverting white text with black background to become black text with white background within a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Invert white text with black background.
gdpictureImaging.AutoTextInvert(imageID, 100, 100, 60, 100, true, false, 1);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Deletes black borders of a document image by replacing them with white content.
GdPicture image identifier.
Max distance in pixels from edges of image a border is allowed to start. Suggested value is 10.
Whether the borders are skewed or not. Meaning if the borders are not uniform in size,
such that their width changes along the y-axis if they are vertical borders,
or their height changes along the x-axis if they are horizontal borders, or both. Suggested value is false.
This method is used in the "Image Processing" and "Document Clean Up" C# Demo.
It is highly suggested to use AutoDeskew() before calling this method if the image or the borders are skewed,
if that is not an option, setting this parameter to True will try to overcome the borders without overcoming the document content. But as skewed borders could easily
overlap with document content, the method might become overzealous and delete some document content.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Deleting black borders from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Delete black borders from a skewed image by replacing them with white content.
// The max distance in pixels from edges of an image where a border is allowed to start is 10 pixels.
gdpictureImaging.DeleteBlackBorders(imageID, 10, true);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs line removal on a GdPicture image or on an area of a GdPicture image defined by SetROI()
method.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
A member of LineRemoveOrientation enumeration specifying whether to remove horizontal or vertical lines.
You can use the method to remove both vertical and horizontal lines at the same time by using a bitwise OR between LineRemoveOrientation.Horizontal and LineRemoveOrientation.Vertical
This method is used in the "Document Clean Up" Demo.
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Removing lines from a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Remove vertical and horizontal lines using default parameters.
gdpictureImaging.RemoveLines(imageID, LineRemoveOrientation.Horizontal | LineRemoveOrientation.Vertical);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Performs line removal on a GdPicture image or on an area of a GdPicture image defined by SetROI() method.
GdPicture image identifier. Only 1 bit per pixel images with black and white palette are supported.
A member of LineRemoveOrientation enumeration specifying whether to remove horizontal or vertical lines.
Maximum Gap size in the line for it to be considered as a line. If set to 0, no gaps are allowed in the line. If set to -1, gaps calculation is irrelevant to the line equation. Default value is -1.
Maximum thickness of a line allowed at any area of the line. If the line is thicker than this value, the line will not be removed. Range from 1 to 50. Default value is 8.
Minimum Length allowed for the line to be removed. Only lines with a length equal to or bigger than this value will be removed. Range from 1 to Image Width if Horizontal, and from 1 to Image Height if Vertical Line. Default valus is 75.
Maximum Character Interception of the Line. If characters intercepting the line have a size of interception larger than this value, the line will not be removed. Range from 0 to MinLineLength / 2. Default value is 8.
Whether to reconnect characters that are broken upon the lines removal or keep the gaps where the line was. Default value is false.
A member of the GdPictureStatus enumeration.
You can use the method to remove both vertical and horizontal lines at the same time by using a bitwise OR between LineRemoveOrientation.Horizontal and LineRemoveOrientation.Vertical
If you are using the RemoveLines method to increase your OCR result accuracy, set ReConnectBrokenCharacters to True.
If MaxLineGap is set to -1, gaps calculation is irrelevant to the line equation, thus some removed lines will have gaps. If you do not want gaps at all, set it to 0.
This method is used in the "Document Clean Up" Demo. Please check appendix "Learning GdPicture.NET" > "Sample Guide Overview" for more information.
This method requires the Image Documents component to run.
Removing lines from a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Remove vertical and horizontal lines using default parameters.
gdpictureImaging.RemoveLines(imageID, LineRemoveOrientation.Horizontal | LineRemoveOrientation.Vertical, -1, 8, 75, 8, false);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Tries to deskew a GdPicture image to about ± 15 degrees.
Deskewing an image can help a lot to do OCR, OMR, barcode detection or just improve the readability
of an image.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method is used in the "Image Processing" Demo.
Deskewing a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("skewed.tif");
gdpictureImaging.AutoDeskew(imageID);
// Let's encode the new tiff with the same mode used by the input image.
TiffCompression tiffCompression = gdpictureImaging.GetTiffCompression(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "deskewed.tif", tiffCompression);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Tries to deskew a GdPicture image to about ± specified degrees.
Deskewing an image can help a lot to do OCR, OMR, barcode detection or just improve the readability
of an image.
GdPicture image identifier.
Maximum angle of research. IE: set 10 to perform a skew research
about ±10 degrees. A value lower than 15 is suggested. Value used by other overloads is 15.
A member of the GdPictureStatus enumeration.
This method is useful when you suspect some images to be skewed, but you do not want completely rotated
images to be deskewed. It offers control and limitation over the deskew operation.
This method requires the Image Documents component to run.
Deskewing a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("skewed.tif");
gdpictureImaging.AutoDeskew(imageID, 10);
// Let's encode the new tiff with the same mode used by the input image.
TiffCompression tiffCompression = gdpictureImaging.GetTiffCompression(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "deskewed.tif", tiffCompression);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Tries to deskew a GdPicture image to about ± specified degrees. This method enables to specify the
background color to use.
Deskewing an image can help a lot to do OCR, OMR, barcode detection or just improve the readability
of an image.
GdPicture image identifier.
Maximum angle of research. IE: set 10 to perform a skew research
about ±10 degrees. A value lower than 15 is suggested. Value used by other overloads is 15.
Color to use to fill background. A suitable color value can be obtained by using the ARGB() method.
A member of the GdPictureStatus enumeration.
Deskewing often results in "padding" surrounding the image where the dimensions of the image were extended because of the rotation.
This method offers a fill color for this padding, so that if you specify it to be the same as the original background color, the deformities
would not show.
Deskewing a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("skewed.tif");
gdpictureImaging.AutoDeskew(imageID, 15, gdpictureImaging.ARGB(255, 255, 255, 255));
// Let's encode the new tiff with the same mode used by the input image.
TiffCompression tiffCompression = gdpictureImaging.GetTiffCompression(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "deskewed.tif", tiffCompression);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Tries to deskew a GdPicture image to about ± specified degrees. This method enables to specify the
background color to use as a Color Integer Value. It also enables you to put a cut off value where slight skewing of image is allowed.
Deskewing an image can help a lot to do OCR, OMR, barcode detection or just improve the readability
of an image.
GdPicture image identifier.
Maximum angle of research. IE: set 10 to perform a skew research
about ±10 degrees. A value lower than 15 is suggested. Value used by other overloads is 15.
Color to use to fill background. A suitable color value can be obtained by using the ARGBI() method.
Determines the smallest angle of skew to detect. 0.25 is suggested. Higher value results in faster detection and vice-versa. Value used by other overloads is 0.25.
Determines if the engine must be optimistic in the skew detection. For example, set true when you know the image has a skew and false otherwise. Value used by other overloads is False.
A member of the GdPictureStatus enumeration.
When minor skewing of images does not affect the subsequent processes, sometimes it is perferred not to deskew the image,
could be for quality or timesaving. This method offers the input of a cutt off value, where slight skewing is allowed.
Be aware: If the skew angle is larger than the cutt off value, the returned value will be rounded to the nearest multiple of (AngleStep)
This method requires the Image Documents component to run.
Deskewing a tiff image by analyzing angles in the range [-12; +12] degrees.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("skewed.tif");
gdpictureImaging.AutoDeskew(imageID, 15, gdpictureImaging.ARGBI(255, 255, 255, 255), 12, true);
// Let's encode the new tiff with the same mode used by the input image.
TiffCompression tiffCompression = gdpictureImaging.GetTiffCompression(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "deskewed.tif", tiffCompression);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Tries to deskew a GdPicture image.
Deskewing an image can help a lot to do OCR, OMR, barcode detection or just improve the readability
of an image.
GdPicture image identifier.
Determines if the engine must be optimistic in the skew detection. For example, set true when you know the image has a skew and false otherwise. Value used by other overloads is False.
A member of the GdPictureStatus enumeration.
Deskewing a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("skewed.tif");
gdpictureImaging.AutoDeskew(imageID, true);
// Let's encode the new tiff with the same mode used by the input image.
TiffCompression tiffCompression = gdpictureImaging.GetTiffCompression(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "deskewed.tif", tiffCompression);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Tries to deskew a GdPicture image to about ± specified degrees. This method enables to specify the
background color to use as a Color Object. It also enables you to put a cut off value where slight skewing of image is allowed.
Deskewing an image can help a lot to do OCR, OMR, barcode detection or just improve the readability
of an image.
GdPicture image identifier.
Maximum angle of research. IE: set 10 to perform a skew research
about ±10 degrees. A value lower tha 15 is suggested.
Color to use to fill background. A suitable color value can be obtained by using the ARGB() method.
Determines the smallest angle of skew to detect. 0.25 is suggested. Higher value results in faster detection and vice-versa.
Determines if the engine must be optimistic in the skew detection. For example, set true when you know the image has a skew and false otherwise. Default value is false.
When minor skewing of images does not affect the subsequent processes, sometimes it is perferred not to deskew the image,
could be for quality or timesaving. This method offers the input of a cutt off value, where slight skewing is allowed.
Be aware: If the skew angle is larger than the cutt off value, the returned value will be rounded to the nearest multiple of (AngleStep)
This method requires the Image Documents component to run.
A member of the GdPictureStatus enumeration.
Deskewing a tiff image by analyzing angles in the range [-12; +12] degrees.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("skewed.tif");
gdpictureImaging.AutoDeskew(imageID, 15, gdpictureImaging.ARGB(255, 255, 255, 255), 12, true);
// Let's encode the new tiff with the same mode used by the input image.
TiffCompression tiffCompression = gdpictureImaging.GetTiffCompression(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "deskewed.tif", tiffCompression);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Determines the skew angle of an image in degrees.
It has a parameter for max angle of research.
GdPicture image identifier.
Maximum angle of research. IE: set 10 to perform a skew research
about ±10 degrees. A value lower than 15 is suggested.
Image skew in degrees.
Use the GetStat() method to determine if this method has succeeded.
This method requires the Image Documents component to run.
Determines the skew angle of an image in degrees.
GdPicture image identifier.
Image skew in degrees.
Use the GetStat() method to determine if this method has succeeded.
This method requires the Image Documents component to run.
Determines the skew angle of an image in degrees.
It has a parameter to activate/unactivate optimistic mode.
GdPicture image identifier.
Determines if the engine must be optimistic in the skew detection. For example, set true when you know the image has a skew and false otherwise.
If you do not know which to choose, suggested value is false.
Image skew in degrees.
Use the GetStat() method to determine if this method has succeeded.
This method requires the Image Documents component to run.
Determines the skew angle of an image in degrees.
It has a parameter for max angle of research.
It also has a minimum angle cut off value where smaller angles will be tolerated.
GdPicture image identifier.
Maximum angle of research. IE: set 10 to perform a skew research
about ±10 degrees. A value lower than 15 is suggested.
Determines the smallest angle of skew to detect. 0.25 is suggested. Higher value results in faster detection and vice-versa.
Determines if the engine must be optimistic in the skew detection. For example, set true when you know the image has a skew and false otherwise.
If you do not know which to choose, suggested value is false.
Image skew in degrees.
Use the GetStat() method to determine if this method has succeeded.
This method requires the Image Documents component to run.
Detects and removes margins consisting of white color around a GdPicture image.
GdPicture image identifier.
This method or an overload of it is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Removing the white margins from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Detect and remove the white margins using the default confidence level.
gdpictureImaging.CropWhiteBorders(imageID);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects and removes margins consisting of white color around a GdPicture image.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be removed, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
GdPicture image identifier.
Confidence threshold in percentage. Default value is 99.
A member of the GdPictureStatus enumeration.
This method or an overload of it is used in the "Image Processing" Demo.
This method requires the Image Documents component to run.
Removing the white margins from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Detect and remove the white margins using the custom confidence level.
gdpictureImaging.CropWhiteBorders(imageID, 99);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects and removes margins consisting of white color around a GdPicture image.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be removed, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
It also has a SkipLinesCount which is the number of lines surrounding the image to be skipped and not
considered as borders and removed.
GdPicture image identifier.
Confidence threshold in percentage. Default value is 99.
Specifies the number of lines around the image which must be
ignored.
A member of the GdPictureStatus enumeration.
This method or an overload of it is used in the "Image Processing" Demo.
This method requires the Image Documents component to run.
Removing the white margins from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg", true);
// Detect and remove the white margins using the custom parameters.
gdpictureImaging.CropWhiteBorders(imageID, 99, 1);
gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects and removes margins consisting of black color around a GdPicture image.
GdPicture image identifier.
This method or an overload of it is used in the "Image Processing" Demo.
A member of the GdPictureStatus enumeration.
Removing the black margins from a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Detect and remove the black margins using the default confidence level.
gdpictureImaging.CropBlackBorders(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects and removes margins consisting of black color around a GdPicture image.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be removed, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
A member of the GdPictureStatus enumeration.
This method or an overload of it is used in the "Image Processing" Demo.
This method requires the Image Documents component to run.
GdPicture image identifier.
Confidence threshold in percentage 0-100. Default value is 75.
Removing the black margins from a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Detect and remove the black margins using the custom confidence level.
gdpictureImaging.CropBlackBorders(imageID, 99);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects and removes margins consisting of black color around a GdPicture image.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be removed, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
It also has a SkipLinesCount which is the number of lines surrounding the image to be skipped and not
considered as borders and removed.
A member of the GdPictureStatus enumeration.
This method or an overload of it is used in the "Image Processing" Demo.
This method requires the Image Documents component to run.
GdPicture image identifier.
Confidence threshold in percentage 0-100. Default value is 75.
Specifies the number of lines around the image which must be
ignored.
Removing the black margins from a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Detect and remove the black margins using the custom parameters.
gdpictureImaging.CropBlackBorders(imageID, 99, 1);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects and sets to White, margins consisting of black color around a GdPicture image.
This method does not have the same behavior as the CropBlackBorders() method: The black borders
are not removed but are set to blank. Therefore, the image dimensions are kept the same.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
This method or an overload of it is used in the "Image Processing" Demo.
Whitening the black margins on a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Detect and set to white the black margins using the default confidence level.
gdpictureImaging.CropBlackBordersEx(imageID);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects and sets to White, margins consisting of black color around a GdPicture image.
This method does not have the same behavior as the CropBlackBorders() method: The black borders
are not removed but are set to blank. Therefore, the image dimensions are kept the same.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be set as blank, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
GdPicture image identifier.
Confidence threshold in percentage. Default value is 75.
A member of the GdPictureStatus enumeration.
This method only detects rectangular borders, for all types of borders, including ones that are resultant from deskewing, or bad scanning, please use DeleteBlackBorders() instead.
This method requires the Image Documents component to run.
Whitening the black margins on a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Detect and set to white the black margins using the custom confidence level.
gdpictureImaging.CropBlackBordersEx(imageID, 99);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects and sets to White, margins consisting of black color around a GdPicture image.
This method does not have the same behavior as the CropBlackBorders() method: The black borders
are not removed but are set to blank. Therefore, the image dimensions are kept.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be set as blank, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
It also has a SkipLinesCount which is the number of lines surrounding the image to be skipped and not
considered as borders to be set as blanked.
This method only detects rectangular borders, for all types of borders, please use DeleteBlackBorders() instead.
GdPicture image identifier.
Confidence threshold in percentage. Default value is 75.
Specifies the number of lines around the image which must be
ignored.
A member of the GdPictureStatus enumeration.
This method only detects rectangular borders, for all types of borders, including ones that are resultant from deskewing, or bad scanning, please use DeleteBlackBorders() instead.
This method requires the Image Documents component to run.
Whitening the black margins on a black and white tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
// Detect and set to white the black margins using the custom parameters.
gdpictureImaging.CropBlackBordersEx(imageID, 99, 1);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detects and removes margins consisting of constant color around a GdPicture image.
GdPicture image identifier.
A member of the ImagingContext enumeration.
A member of the GdPictureStatus enumeration.
Detects and removes margins consisting of constant color around a GdPicture image.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be removed, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
GdPicture image identifier.
Confidence threshold in percentage. Default value is 99 for documents and
92 for digital photo.
A member of the ImagingContext enumeration.
A member of the GdPictureStatus enumeration.
Detects and removes margins consisting of constant color around a GdPicture image.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be removed, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Confidence threshold in percentage. Default value is 99 for documents
and 92 for digital photo.
A member of the ReferencePoint enumeration. Default value is
ReferencePoint.ReferencePointTopLeft.
A member of the ImagingContext enumeration.
A member of the GdPictureStatus enumeration.
Detects margins consisting of constant color around a GdPicture image.
Returns the coordinate of the cropping selection which can be used by the Crop
method.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be removed, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Confidence threshold in percentage. Default value is 99 for documents
and 92 for digital photo.
A member of the ReferencePoint enumeration. Default value is
ReferencePoint.ReferencePointTopLeft.
Returns the left coordinate, in pixel, of the area without margins.
Returns the top coordinate, in pixel, of the area without margins.
Returns the width, in pixel, of the area without margins.
Returns the height, in pixel, of the area without margins.
A member of the GdPictureStatus enumeration.
Detects margins consisting of constant color around a GdPicture image.
Returns the coordinate of the cropping selection which can be used by the Crop
method.
It has a Confidence Parameter where if the lines and borders detection confidence exceeds this value
they will be removed, and left as they are if the confidence in detecting them is less than the
Confidence Parameter Value.
This method requires the Image Documents component to run.
GdPicture image identifier.
Confidence threshold in percentage. Default value is 99 for documents
and 92 for digital photo.
A member of the ReferencePoint enumeration. Default value is
ReferencePoint.ReferencePointTopLeft.
Returns the left coordinate, in pixel, of the area without margins.
Returns the top coordinate, in pixel, of the area without margins.
Returns the width, in pixel, of the area without margins.
Returns the height, in pixel, of the area without margins.
A member of the GdPictureStatus enumeration.
Specifies the way how the toolkit handles bitmap caching. The initial cache mode is memory caching.
A member of the PageCacheMode enumeration. The cache mode to be used for bitmap caching. The default value is PageCacheMode.Memory.
Please note, that the default value is memory caching.
Creates a value, which determines access permissions to the various operations within the PDF document according to what you have specified.
This value is subsequently used as the Rights parameter when saving the processed image as an encrypted PDF document, for example,
using the method.
Allows the user to print the document. Set this parameter to true if you want to allow printing, otherwise set it to false.
Allows the user to modify the document. Set this parameter to true if you want to allow editing, otherwise set it to false.
Allows the user to copy or extract text and graphics from the document. Set this parameter to true if you want to allow copying, otherwise set it to false.
Allows the user to add annotations. Set this parameter to true if you want to allow adding annotations, otherwise set it to false.
Allows the user to fill in form fields. Set this parameter to true if you want to allow form filling, otherwise set it to false.
This permission only works with 128-bit encryption.
Enables copying or extracting for use with accessibility features. Set this parameter to true if you want to enable this permission, otherwise set it to false.
This permission only works with 128-bit encryption.
Allows the user to assemble the document. Set this parameter to true if you want to allow assembling, otherwise set it to false.
This permission only works with 128-bit encryption.
Allows high resolution printing of the document. Set this parameter to true if you want to enable this permission, otherwise set it to false.
This permission only works with 128-bit encryption.
You can regularly apply the method to determine if this method has been successful.
A combination of members of the PdfRight enumeration. The specified access permissions intended for further use when saving as a PDF document.
Saving the image as a PDF document specifying document properties and pdf rights.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
// Get the file path of the loaded image file.
string filePath = gdpictureImaging.GetLastPath();
string pdfPath = System.IO.Path.ChangeExtension(filePath, ".pdf");
// Get the current version of the GdPicture.NET toolkit.
string version = (gdpictureImaging.GetVersion()).ToString();
version = version.Insert(version.IndexOf('.') + 2, ".");
// Create pdf rights for saving.
PdfRight pdfRights = gdpictureImaging.PdfCreateRights(true, false, true, true, false, false, false, true);
// Define the document properties when saving, for example, the current version of the GdPicture.NET toolkit and the pdf rights.
gdpictureImaging.SaveAsPDF(imageID, filepath, "Saving image as PDF", "GdPicture ver." + version.ToString(), "For test", "image, pdf", "Orpalis", PdfEncryption.PdfEncryption256BitAES, pdfRights, "userpassw", "ownerpassw");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
else
MessageBox.Show("An image can't be created.\nError: " + gdpictureImaging.GetStat().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Converts the required RGB color, which is composed of a set of specified red, green and blue color components
to the CMY color composed of a set of resulting Cyan, Magenta and Yellow components.
The input value for the red component. Use the value between 0 and 255.
The input value for the green component. Use the value between 0 and 255.
The input value for the blue component. Use the value between 0 and 255.
Output parameter. The resulting value for the Cyan component between 0 and 255.
Output parameter. The resulting value for the Magenta component between 0 and 255.
Output parameter. The resulting value for the Yellow component between 0 and 255.
Converts the required RGB color, which is composed of a set of specified red, green and blue color components
to the CMYK color composed of a set of resulting Cyan, Magenta, Yellow and Black (Key) components.
The input value for the red component. Use the value between 0 and 255.
The input value for the green component. Use the value between 0 and 255.
The input value for the blue component. Use the value between 0 and 255.
Output parameter. The resulting value for the Cyan component between 0 and 255.
Output parameter. The resulting value for the Magenta component between 0 and 255.
Output parameter. The resulting value for the Yellow component between 0 and 255.
Output parameter. The resulting value for the Black (Key) component between 0 and 255.
Converts the required CMYK color, which is composed of a set of specified Cyan, Magenta, Yellow and Black (Key) color components
to the RGB color composed of a set of resulting red, green, and blue components.
The input value for the Cyan component. Use the value between 0 and 255.
The input value for the Magenta component. Use the value between 0 and 255.
The input value for the Yellow component. Use the value between 0 and 255.
The input value for the Black (Key) component. Use the value between 0 and 255.
Output parameter. The resulting value for the red component between 0 and 255.
Output parameter. The resulting value for the green component between 0 and 255.
Output parameter. The resulting value for the blue component between 0 and 255.
Converts the required CMY color, which is composed of a set of specified Cyan, Magenta and Yellow color components
to the RGB color composed of a set of resulting red, green, and blue components.
The input value for the Cyan component. Use the value between 0 and 255.
The input value for the Magenta component. Use the value between 0 and 255.
The input value for the Yellow component. Use the value between 0 and 255.
Output parameter. The resulting value for the red component between 0 and 255.
Output parameter. The resulting value for the green component between 0 and 255.
Output parameter. The resulting value for the blue component between 0 and 255.
Converts the required RGB color, which is composed of a set of specified red, green and blue color components
to the HSL color composed of a set of resulting hue, saturation and lightness components.
The input value for the red component. Use the value between 0 and 255.
The input value for the green component. Use the value between 0 and 255.
The input value for the blue component. Use the value between 0 and 255.
Output parameter. The resulting value for the hue component between -1 and 5.
Output parameter. The resulting value for the saturation component between 0 and 1.
Output parameter. The resulting value for the lightness component between 0 and 1.
Converts the required HSL color, which is composed of a set of specified hue, saturation and lightness color components
to the RGB color composed of a set of resulting red, green and blue components.
The input value for the hue component. Use the value between -1 and 5.
The input value for the saturation component. Use the value between 0 and 1.
The input value for the lightness component. Use the value between 0 and 1.
Output parameter. The resulting value for the red component between 0 and 255.
Output parameter. The resulting value for the green component between 0 and 255.
Output parameter. The resulting value for the blue component between 0 and 255.
Returns a Color object, that represents a color composed from a specified set of alpha, red, green and blue color components.
Returns a Color object, that represents a required color according to your specified parameters.
The value for the alpha component also known as a transparency. Use the value between 0 (full transparency) and 255 (full opacity).
The value for the red component. Use the value between 0 and 255.
The value for the green component. Use the value between 0 and 255.
The value for the blue component. Use the value between 0 and 255.
A Color object representing a required color.
Rendering an image with a circle onto the background image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Color backColor = gdpictureImaging.ARGB(255, 0, 255, 0); // Green color
Color circleColor = gdpictureImaging.ARGB(255, 255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGB(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Returns a Color object, that represents a color composed from a specified set of red, green and blue color components.
Returns a Color object, that represents a required color according to your specified parameters.
The value for the red component. Use the value between 0 and 255.
The value for the green component. Use the value between 0 and 255.
The value for the blue component. Use the value between 0 and 255.
A Color object representing a required color.
Rendering an image with a circle onto the background image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Color backColor = gdpictureImaging.ARGB(0, 255, 0); // Green color
Color circleColor = gdpictureImaging.ARGB(255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGB(0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Returns a Color object representing the required color, that is specified by a 32-bit ARGB value.
Returns a Color object, that represents a required color according to your specified parameters.
A 32-bit ARGB value specified the required color.
A Color object representing a required color.
Returns a 32-bit value, that represents a color composed from a specified set of alpha, red, green and blue color components.
The value for the alpha component also known as a transparency. Use the value between 0 (full transparency) and 255 (full opacity).
The value for the red component. Use the value between 0 and 255.
The value for the green component. Use the value between 0 and 255.
The value for the blue component. Use the value between 0 and 255.
A 32-bit value representing a required color.
Rendering an image with a circle onto the background image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int backColor = gdpictureImaging.ARGBI(255, 0, 255, 0); // Green color
int circleColor = gdpictureImaging.ARGBI(255, 255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGBI(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Returns the file path of the latest loaded or saved file using this GdPictureImaging object.
Be aware, that the stored value is never erased, for example, when releasing the image.
It is only overwritten with each new file loading or saving operation.
The file path of the latest loaded or saved file, otherwise an empty string.
Saving the image as a PDF document specifying document properties and retrieving the file name of the created image for further use.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
// Get the file path of the loaded image file.
string filePath = gdpictureImaging.GetLastPath();
string pdfPath = System.IO.Path.ChangeExtension(filePath, ".pdf");
// Get the current version of the GdPicture.NET toolkit.
string version = (gdpictureImaging.GetVersion()).ToString();
version = version.Insert(version.IndexOf('.') + 2, ".");
// Define the document properties when saving, for example, the current version of the GdPicture.NET toolkit.
gdpictureImaging.SaveAsPDF(imageID, pdfPath, false, "Saving image as PDF", "GdPicture ver." + version.ToString(), "For test", "image, pdf", "Orpalis");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
else
MessageBox.Show("An image can't be created.\nError: " + gdpictureImaging.GetStat().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Checks whether the specified image file is CMYK color space based.
The file path of the image file to be checked.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that this method does not change the last file path used with this GdPictureImaging object.
This method requires the Image Documents component to run.
true if the specified image file is using CMYK color space, otherwise false.
The method can be subsequently used to determine if this method has been successful.
Applying ICM correction when saving CMYK based image as a tiff image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
string filePath = "image.jpg";
if (gdpictureImaging.IsCMYKFile(filePath))
{
// Enable color correction.
gdpictureImaging.EnableICM(true);
int imageID = gdpictureImaging.CreateGdPictureImageFromFile(filePath);
gdpictureImaging.SaveAsTIFF(imageID, "output.tiff", true, TiffCompression.TiffCompressionJPEG, 90);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
}
Resets the region of interest (ROI). The method simply clears the coordinates and the dimensions of the ROI used by this GdPictureImaging object.
Be aware that this method does not reset the previously set error status.
Applies a gaussian filter to a region of interest set on an image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image_1080x720.jpg", true);
// Setg the blur intensity of the gaussian filter.
int kernel = 20;
// Set the region of interest.
gdpictureImaging.SetROI(300, 200, 500, 150);
// Applying the gaussian filter to the ROI.
gdpictureImaging.FxGaussian(imageID, kernel);
// Deleting the region of interest.
gdpictureImaging.ResetROI();
gdpictureImaging.SaveAsJPEG(imageID, "image_1080x720.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Defines the current region of interest (ROI) for further processing with this GdPictureImaging object by specifying its coordinates and dimensions.
You can use the method to clear the previously defined region of interest.
The horizontal (X) coordinate of the top left position of the ROI, in pixels.
The vertical (Y) coordinate of the top left position of the ROI, in pixels.
The required width of the ROI, in pixels.
The required height of the ROI, in pixels.
Please note, that the coordinates of the upper left corner of the processed image are set to (0, 0).
Be aware that this method does not reset the previously set error status.
This method requires the Image Documents component to run.
Applies a gaussian filter to a region of interest set on an image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image_1080x720.jpg", true);
// Set the blur intensity of the gaussian filter.
int kernel = 20;
// Set the region of interest.
gdpictureImaging.SetROI(300, 200, 500, 150);
// Applying the gaussian filter to the ROI.
gdpictureImaging.FxGaussian(imageID, kernel);
// Deleting the region of interest.
gdpictureImaging.ResetROI();
gdpictureImaging.SaveAsJPEG(imageID, "image_1080x720.jpg");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns an encoded string using the Base64 encoding algorithm from the given source string.
The source string to encode.
You can regularly apply the method to determine if this method has been successful.
This method requires the Image Documents component to run.
The resulting encoded string.
Returns a decoded string using the Base64 encoding algorithm from the given source string.
The source string to decode.
You can regularly apply the method to determine if this method has been successful.
This method requires the Image Documents component to run.
The resulting decoded string.
Returns the distance, in inches, between two specified points of the GdPicture image represented by its unique image identifier.
A unique image identifier of the GdPicture image representing the image in use.
The horizontal (X) coordinate of the first point, in pixels.
The vertical (Y) coordinate of the first point, in pixels.
The horizontal (X) coordinate of the second point, in pixels.
The vertical (Y) coordinate of the second point, in pixels.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
This method requires the Image Documents component to run.
The resulting distance between two points, in inches. The method can be subsequently used to determine if this method has been successful.
Uploads a specified file to a distant server using FTP transfer according to what you have specified.
This method requires the Image Documents component to run.
The full file path of the file to upload, for example "d:/images/myimage.jpg".
The host server name, for example "ftp.com".
The full file path of the file to create on the distant server, for example "/demo/image.jpg".
The user's login required to authenticate on the server.
The user's password required to authenticate on the server.
The FTP port number used. It is usually 21.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Uploading an image to a file located on a distant server using FTP transfer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Set the transferring options.
gdpictureImaging.SetFtpPassiveMode(true);
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.UploadFileToFTP(@"D:\images\image.jpg", "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Uploading failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Uploading using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Changes the packet size used for transferring data when creating the image from HTTP and FTP or when uploading the file to the FTP server. The initial value is 4096.
The new value for the packet size for FTP or HTTP transfer, for example 1024, 2048, 4096, 8192 etc.
Setting up the packet size for FTP or HTTP transfer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Set the transferring options.
gdpictureImaging.SetFtpPassiveMode(true);
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.UploadFileToFTP(@"D:\images\image.jpg", "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Uploading failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Uploading using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Set the packet size.
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.SaveToHTTP(imageID, GdPicture14.DocumentFormat.DocumentFormatJPEG, 75, "http://www.google.com/uploads/myimage.jpg") != GdPictureStatus.OK)
{
MessageBox.Show("Saving failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Saving to HTTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Paints the specified image, that is represented by its unique image identifier, with the required color.
The defined color is used to completely paint the image surface.
A unique image identifier of the GdPicture image representing the image in use.
A required color value to be set as the new background color. Use the method to obtain this value.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Paints the specified image, that is represented by its unique image identifier, with the required color.
The defined color is used to completely paint the image surface.
Paints the whole surface of the specified image, that is represented by its unique image identifier, with the required color.
A unique image identifier of the GdPicture image representing the image in use.
A required color object to be set as the new background color. Use the method to obtain this value.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Specifies if the FTP transfer mode used by method is Passive or not. The initial value is true.
Set this parameter to true, if you want to use the passive FTP transfer, otherwise set it to false.
Setting up the FTP transfer mode.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Set the transferring options.
gdpictureImaging.SetFtpPassiveMode(true);
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.UploadFileToFTP(@"D:\images\image.jpg", "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Uploading failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Uploading using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
// Set the active FTP transfer more.
gdpictureImaging.SetFtpPassiveMode(false);
if (gdpictureImaging.SaveToFTP(imageID, GdPicture14.DocumentFormat.DocumentFormatJPEG, 75, "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Saving failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Saving using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns the status of the last executed operation with the current GdPictureImaging object.
Use this method in the combination with all those, which return a value instead of a status, for example all CreateGdPictureImageFrom... methods.
Please note that to identify possible printing errors you should use the method
and to identify possible TWAIN errors you should use the method.
A member of the GdPictureStatus enumeration. If the last executed GdPictureImaging method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Retrieving the status of the last executed operation.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
// Get the file path of the loaded image file.
string filePath = gdpictureImaging.GetLastPath();
string pdfPath = System.IO.Path.ChangeExtension(filePath, ".pdf");
// Get the current version of the GdPicture.NET toolkit.
string version = (gdpictureImaging.GetVersion()).ToString();
version = version.Insert(version.IndexOf('.') + 2, ".");
// Define the document properties when saving, for example, the current version of the GdPicture.NET toolkit.
gdpictureImaging.SaveAsPDF(imageID, pdfPath, false, "Saving image as PDF", "GdPicture ver." + version.ToString(), "For test", "image, pdf", "Orpalis");
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
else
MessageBox.Show("An image can't be created.\nError: " + gdpictureImaging.GetStat().ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Set the transferring options.
gdpictureImaging.SetFtpPassiveMode(true);
gdpictureImaging.SetHttpTransferBufferSize(2048);
if (gdpictureImaging.UploadFileToFTP(@"D:\images\image.jpg", "ftp.com", "/demo/image.jpg", "user", "password", 21) != GdPictureStatus.OK)
{
MessageBox.Show("Uploading failed. Status: " + gdpictureImaging.GetStat() + "\nError: " + gdpictureImaging.GetLastTransferError(),
"Uploading using FTP", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Determines whether the specified GdPicture image represented by its unique image identifier has a standard 8-bit gray palette.
A unique image identifier of the GdPicture image representing the image in use.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
This method requires the Image Documents component to run.
true if the specified image is a standard 8-bit grayscale image, otherwise false.
The method can be subsequently used to determine if this method has been successful.
Returns the handle of the Windows desktop window. The desktop window is the one which covers the entire screen.
The desktop window is the area on top of which all icons and other windows are painted.
You can regularly apply the method to determine if this method has been successful.
The desktop Windows handle, as IntPtr value.
Returns the handle of the Windows desktop window. The desktop window is the one which covers the entire screen.
The desktop window is the area on top of which all icons and other windows are painted.
You can regularly apply the method to determine if this method has been successful.
The desktop Windows handle, as Integer value.
Creates thumbnail of custom size from a GdPicture image.
GdPicture image identifier. The image from which the thumbnail must be
done.
The width of the thumbnail to create.
The height of the thumbnail to create.
If both of Width and Height parameters are 0, a system-defined size is used.
This method requires the Image Documents component to run.
GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Working with thumbnails.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Create a thumbnail that is 100 pixels width and 200 pixels height.
int thumbnailID = gdpictureImaging.CreateThumbnail(imageID, 100, 200);
gdpictureImaging.SaveAsJPEG(thumbnailID, "thumbnail.jpg", 75);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
int thumbnailID = 0;
if (gdpictureImaging.HasAttachedThumbnail(imageID))
{
// Get the already attached thumbnail and save it as an image, then detach it.
thumbnailID = gdpictureImaging.GetAttachedThumbnail(imageID);
gdpictureImaging.SaveAsJPEG(thumbnailID, "thumbnail.jpg", 75);
gdpictureImaging.DetachThumbnail(imageID);
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
}
// Create a new thumbnail with a system-defined size and attach it to an image.
thumbnailID = gdpictureImaging.CreateThumbnail(imageID, 0, 0);
gdpictureImaging.AttachThumbnail(imageID, thumbnailID);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a High Quality thumbnail of custom size from a GdPicture image.
GdPicture image identifier. The image from which the HQ thumbnail must be created.
The width of the thumbnail to create.
The height of the thumbnail to create.
GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Generating a high quality custom size thumbnail from a jpeg image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Create a thumbnail that is 100 pixels width and 200 pixels height.
int thumbnailID = gdpictureImaging.CreateThumbnailHQ(imageID, 100, 200);
gdpictureImaging.SaveAsPNG(thumbnailID, "thumbnail.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a High Quality thumbnail of custom size from a GdPicture image.
This method fits the image thumbnail within a rectangle of specified dimensions having a specified
background color.
GdPicture image identifier. The image from which the HQ thumbnail must be created.
The width of the thumbnail to create.
The height of the thumbnail to create.
Background color of the thumbnail. A suitable color value can be obtained by using the ARGB() method.
GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Generating a high quality custom size thumbnail from a jpeg image with a background color.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Create a thumbnail with a black background that is 100 pixels width and 200 pixels height.
int thumbnailID = gdpictureImaging.CreateThumbnailHQ(imageID, 100, 200, Color.Black);
gdpictureImaging.SaveAsPNG(thumbnailID, "thumbnail.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a High Quality thumbnail of custom size from a GdPicture image.
This method fits the image thumbnail within a rectangle of specified dimensions having a specified
background color.
This method requires the Image Documents component to run.
GdPicture image identifier. The image from which the HQ thumbnail must be created.
The width of the thumbnail to create.
The height of the thumbnail to create.
Background color of the thumbnail. A suitable color value can be obtained by using the ARGB() method.
The page number to render, in the range [1 - PageCount]. Use 0 to render the currently selected page.
Specifies if GdPicture/XMP annotations must be rendered on the thumbnail.
Specifies if the generated thumbnail must be rotated according the internal ExifRotate tag.
GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creates a High Quality thumbnail of custom size from a GdPicture image.
This method fits the image thumbnail within a rectangle of specified dimensions having a specified
background color.
This method requires the Image Documents component to run.
GdPicture image identifier. The image from which the HQ thumbnail must be created.
The width of the thumbnail to create.
The height of the thumbnail to create.
A suitable color value can be obtained by using the ARGBI() method.
Background color of the thumbnail.
GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Generating a high quality custom size thumbnail from a jpeg image with a background color.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
// Create a thumbnail with a black background that is 100 pixels width and 200 pixels height.
int thumbnailID = gdpictureImaging.CreateThumbnailHQ(imageID, 100, 200, gdpictureImaging.ARGBI(255, 0, 0, 0));
gdpictureImaging.SaveAsPNG(thumbnailID, "thumbnail.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Creates a High Quality thumbnail of custom size from a file. This method tries to extract the embedded thumbnail from file metadata, if it is available.
It is particularly recommended to use this method to generate thumbnail from RAW image file.
The thumbnail can be fitted within a rectangle of specific dimensions having a specific background color.
This method requires the Image Documents component to run.
The path of the file to open. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
The width of the thumbnail to create. Use 0 to keep the embedded thumbnail width, if available, otherwise uses the initial bitmap width.
The height of the thumbnail to create. Use 0 to keep the embedded thumbnail height, if available, otherwise uses the initial bitmap height.
A suitable color value can be obtained by using the ARGB() method. The background color of the thumbnail if width and height parameters are provided.
GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Generating a high quality custom size thumbnail from a selected image file with a background color.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a thumbnail with a black background that is 100 pixels width and 200 pixels height.
// An empty string allows the control to prompt for selecting an input file.
int thumbnailID = gdpictureImaging.CreateThumbnailHQ("", 100, 200, gdpictureImaging.ARGB(255, 0, 0, 0));
gdpictureImaging.SaveAsPNG(thumbnailID, "thumbnail.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
}
Creates a High Quality thumbnail of custom size from a file. This method tries to extract the embedded thumbnail from file metadata, if it is available.
It is particularly recommended to use this method to generate thumbnail from RAW image file.
The thumbnail can be fitted within a rectangle of specific dimensions having a specific background color.
The path of the file to open. Can be an empty string. If empty, prompts the user to select a file. You can subsequently use the GetLastPath() method to retrieve the path of the selected file.
The width of the thumbnail to create. Use 0 to keep the embedded thumbnail width, if available, otherwise uses the initial bitmap width.
The height of the thumbnail to create. Use 0 to keep the embedded thumbnail height, if available, otherwise uses the initial bitmap height.
A suitable color value can be obtained by using the ARGBI() method. The background color of the thumbnail if width and height parameters are provided.
GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Generating a high quality custom size thumbnail from a selected image file with a background color.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// Create a thumbnail with a black background that is 100 pixels width and 200 pixels height.
// An empty string allows the control to prompt for selecting an input file.
int thumbnailID = gdpictureImaging.CreateThumbnailHQ("", 100, 200, gdpictureImaging.ARGBI(255, 0, 0, 0));
gdpictureImaging.SaveAsPNG(thumbnailID, "thumbnail.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
}
Creates a High Quality thumbnail of custom size from a stream. This method tries to extract the embedded thumbnail from file metadata, if it is available.
It is particularly recommended to use this method to generate thumbnail from RAW image file.
The thumbnail can be fitted within a rectangle of specific dimensions having a specific background color.
This method requires the Image Documents component to run.
System.IO.Stream object storing the image data.
The width of the thumbnail to create. Use 0 to keep the embedded thumbnail width, if available, otherwise uses the initial bitmap width.
The height of the thumbnail to create. Use 0 to keep the embedded thumbnail height, if available, otherwise uses the initial bitmap height.
A suitable color value can be obtained by using the ARGB() method. The background color of the thumbnail if width and height parameters are provided.
GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Creates a High Quality thumbnail of custom size from a stream. This method tries to extract the embedded thumbnail from file metadata, if it is available.
It is particularly recommended to use this method to generate thumbnail from RAW image file.
The thumbnail can be fitted within a rectangle of specific dimensions having a specific background color.
This method requires the Image Documents component to run.
System.IO.Stream object storing the image data.
The width of the thumbnail to create. Use 0 to keep the embedded thumbnail width, if available, otherwise uses the initial bitmap width.
The height of the thumbnail to create. Use 0 to keep the embedded thumbnail height, if available, otherwise uses the initial bitmap height.
A suitable color value can be obtained by using the ARGBI() method. The background color of the thumbnail if width and height parameters are provided.
GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Some images embed a thumbnail bitmap for previewing purpose. This method helps to determine if a specific GdPicture image has one.
GdPicture image identifier.
True if a thumbnail bitmap is attached to the image, False otherwise.
Use the GetStat() method to check if this method has completed successfully.
This method requires the Image Documents component to run.
Removing the existing thumbnail and creating and attaching a new one to a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
int thumbnailID = 0;
if (gdpictureImaging.HasAttachedThumbnail(imageID))
{
// Get the already attached thumbnail and save it as an image, then detach it.
thumbnailID = gdpictureImaging.GetAttachedThumbnail(imageID);
gdpictureImaging.SaveAsJPEG(thumbnailID, "thumbnail.jpg", 75);
gdpictureImaging.DetachThumbnail(imageID);
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
}
// Create a new thumbnail with a system-defined size and attach it to an image.
thumbnailID = gdpictureImaging.CreateThumbnail(imageID, 0, 0);
gdpictureImaging.AttachThumbnail(imageID, thumbnailID);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Returns, if available, the tumbnail attached to a specific GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
0: The image could not be created. Use the GetStat() method to determine the reason this method
failed.
Non-zero: GdPicture image identifier. The thumbnail Image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
The HasAttachedThumbnail() should be used prior in order to check that the image has a thumbnail attachment.
Removing the existing thumbnail and creating and attaching a new one to a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
int thumbnailID = 0;
if (gdpictureImaging.HasAttachedThumbnail(imageID))
{
// Get the already attached thumbnail and save it as an image, then detach it.
thumbnailID = gdpictureImaging.GetAttachedThumbnail(imageID);
gdpictureImaging.SaveAsJPEG(thumbnailID, "thumbnail.jpg", 75);
gdpictureImaging.DetachThumbnail(imageID);
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
}
// Create a new thumbnail with a system-defined size and attach it to an image.
thumbnailID = gdpictureImaging.CreateThumbnail(imageID, 0, 0);
gdpictureImaging.AttachThumbnail(imageID, thumbnailID);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Attaches a thumbnail bitmap to a GdPicture image. If the GdPicture image already embeds a thumbnail it will be replaced.
This method requires the Image Documents component to run.
GdPicture image identifier.
GdPicture image identifier. The thumbnail bitmap.
A member of the GdPictureStatus enumeration.
Removing the existing thumbnail and creating and attaching a new one to a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
int thumbnailID = 0;
if (gdpictureImaging.HasAttachedThumbnail(imageID))
{
// Get the already attached thumbnail and save it as an image, then detach it.
thumbnailID = gdpictureImaging.GetAttachedThumbnail(imageID);
gdpictureImaging.SaveAsJPEG(thumbnailID, "thumbnail.jpg", 75);
gdpictureImaging.DetachThumbnail(imageID);
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
}
// Create a new thumbnail with a system-defined size and attach it to an image.
thumbnailID = gdpictureImaging.CreateThumbnail(imageID, 0, 0);
gdpictureImaging.AttachThumbnail(imageID, thumbnailID);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Detaches a thumbnail bitmap to a GdPicture image.
This method requires the Image Documents component to run.
GdPicture image identifier.
A member of the GdPictureStatus enumeration.
Removing the existing thumbnail and creating and attaching a new one to a GdPicture image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
int thumbnailID = 0;
if (gdpictureImaging.HasAttachedThumbnail(imageID))
{
// Get the already attached thumbnail and save it as an image, then detach it.
thumbnailID = gdpictureImaging.GetAttachedThumbnail(imageID);
gdpictureImaging.SaveAsJPEG(thumbnailID, "thumbnail.jpg", 75);
gdpictureImaging.DetachThumbnail(imageID);
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
}
// Create a new thumbnail with a system-defined size and attach it to an image.
thumbnailID = gdpictureImaging.CreateThumbnail(imageID, 0, 0);
gdpictureImaging.AttachThumbnail(imageID, thumbnailID);
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(thumbnailID);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
If barcode detection is available, returns the number of bar code types that can be detected.
If Success, non zero: the number of bar code types that can be detected. Else 0 if fail. Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns a supported bar code type which can be detected by the opened source.
Index of the available bar code type. Must be a value between 1 and
TwainGetAvailableBarCodeTypeCount() returned value.
A member of the TwainBarCodeType enumeration.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
If barcode detection is enabled, returns the number of bar codes found on the last acquired image.
The number of bar codes found on the document image.
A value of 0 means the bar code engine was enabled but that no bar codes were found.
A value of -1 means the bar code engine was not enabled.
Before using this method make sure that the barcode detection was enabled by the
TwainSetBarcodeDetection() method.
Use the TwainBarCodeGetCount() method to determine how many barcodes have been detected on the last
acquired image.
Returns the text of a bar code found on the last acquired image.
The barcode number. Must be value between 1 and the number of detected
barcodes.
The barcode text.
Before using this method make sure that the barcode detection was enabled by the
TwainSetBarcodeDetection() method.
Use the TwainBarCodeGetCount() method to determine how many barcodes have been detected on the last
acquired image.
Returns the type of a bar code found on the last acquired image.
The barcode number. Must be value between 1 and the number of detected
barcodes.
A member of the TwainBarCodeType enumeration.
Before using this method make sure that the barcode detection was enabled by the
TwainSetBarcodeDetection() method.
Use the TwainBarCodeGetCount() method to determine how many barcodes have been detected on the last
acquired image.
Returns the X coordinate of a bar code found on the last acquired image.
The barcode number. Must be value between 1 and the number of detected
barcodes.
The barcode X coordinate. Return -1 if current source does not support X coordinate reporting.
Before using this method make sure that the barcode detection was enabled by the
TwainSetBarcodeDetection() method.
Use the TwainBarCodeGetCount() method to determine how many barcodes have been detected on the last
acquired image.
Returns the Y coordinate of a bar code found on the last acquired image.
The barcode number. Must be value between 1 and the number of detected
barcodes.
The barcode Y coordinate. Return -1 if current source does not support Y coordinate reporting.
Before using this method make sure that the barcode detection was enabled by the
TwainSetBarcodeDetection() method.
Use the TwainBarCodeGetCount() method to determine how many barcodes have been detected on the last
acquired image.
Returns the degree of certainty of a bar code the engine has in the accuracy of the information
obtained on the last acquired image.
The barcode number. Must be value between 1 and the number of detected
barcodes.
The barcode confidence. From 0 (no confidence) to 100 (supreme confidence). Return -1 if current
source does not support confidence reporting.
Before using this method make sure that the barcode detection was enabled by the
TwainSetBarcodeDetection() method.
Use the TwainBarCodeGetCount() method to determine how many barcodes have been detected on the last
acquired image.
Returns the orientation of a bar code found on the last acquired image.
The barcode number. Must be value between 1 and the number of detected
barcodes.
A member of the TwainBarCodeRotation enumeration.
Before using this method make sure that the barcode detection was enabled by the
TwainSetBarcodeDetection() method.
Use the TwainBarCodeGetCount() method to determine how many barcodes have been detected on the last
acquired image.
Specifies if the memory transfer mode shoud be used during acquisition processes.
True to enable memory transfer mode, False otherwise (native transfer mode). By default memory transfer mode is enabled.
Acquires a single image, from the currently selected Data Source.
If success, set the created GdPicture image as a GdPicture image.
By default, the default data source (DS) is opened, displays its dialog, and determines all the
parameters of the acquisition and transfer.
If you want to (try to) hide the DS dialog, see TwainSetHideUI.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
To set the TWAIN state to 4, use the TwainOpenDefaultSource() or TwainOpenSource() method.
This method requires the Document Capture (TWAIN / WIA) component to run.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
0: The image could not created. Use the GetStat(), TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Acquires a single image, from the currently selected Data Source.
If success, set the created GdPicture image as a GdPicture image.
By default, the default data source (DS) is opened, displays its dialog, and determines all the
parameters of the acquisition and transfer.
If you want to (try to) hide the DS dialog, see TwainSetHideUI.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
To set the TWAIN state to 4, use the TwainOpenDefaultSource() or TwainOpenSource() method.
This method requires the Document Capture (TWAIN / WIA) component to run.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
0: The image could not created. Use the GetStat(), TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Acquires a single image, from the currently selected Data Source to a DIB handle.
By default, the default data source (DS) is opened, displays its dialog, and determines all the
parameters of the acquisition and transfer.
If you want to (try to) hide the DS dialog, see TwainSetHideUI.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
To set the TWAIN state to 4, use the TwainOpenDefaultSource() or TwainOpenSource() method.
This method requires the Document Capture (TWAIN / WIA) component to run.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
0: The bitmap could not created. Use the GetStat(), TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Non-zero: DIB handle. This handle must be subsequently released using the MemoryUtils.Free() method.
Acquires a single image, from the currently selected Data Source to a DIB handle.
By default, the default data source (DS) is opened, displays its dialog, and determines all the
parameters of the acquisition and transfer.
If you want to (try to) hide the DS dialog, see TwainSetHideUI.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
To set the TWAIN state to 4, use the TwainOpenDefaultSource() or TwainOpenSource() method.
This method requires the Document Capture (TWAIN / WIA) component to run.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
0: The bitmap could not created. Use the GetStat(), TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Non-zero: DIB handle. This handle must be subsequently released using the MemoryUtils.Free() method.
Acquires a single image, from the currently selected Data Source to a file.
This method uses the file transfer mode.
The disk file mode is ideal when transferring large images that might encounter memory limitations
with Native or memory mode.
However, Disk File mode is a bit slower than other transfer mode.
By default, the default data source (DS) is opened, displays its dialog, and determines all the
parameters of the acquisition and transfer.
If you want to (try to) hide the DS dialog, see TwainSetHideUI.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
To set the TWAIN state to 4, use the TwainOpenDefaultSource() or TwainOpenSource() method.
Warning: To works, this method requires that the current Data source allows file transfer mode.
Use the TwainIsFileTransferModeAvailable() to check if the source support this mode of transfer.
The output image format should be negotiated with the TwainSetImageFileFormat() method.
The output image compression should be negotiated with the TwainSetCompression() method.
This method requires the Document Capture (TWAIN / WIA) component to run.
The path of the image file to create.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
A member of the GdPictureStatus enumeration.
Acquires a single image, from the currently selected Data Source to a file.
This method uses the file transfer mode.
The disk file mode is ideal when transferring large images that might encounter memory limitations
with Native or memory mode.
However, Disk File mode is a bit slower than other transfer mode.
-> The output image format should be negotiated with the TwainSetImageFileFormat() method.
-> The output image compression should be negotiated with the TwainSetCompression() method.
By default, the default data source (DS) is opened, displays its dialog, and determines all the
parameters of the acquisition and transfer.
If you want to (try to) hide the DS dialog, see TwainSetHideUI.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
To set the TWAIN state to 4, use the TwainOpenDefaultSource() or TwainOpenSource() method.
Warning: To works, this method requires that the current Data source allows file transfer mode.
Use the TwainIsFileTransferModeAvailable() to check if the source support this mode of transfer.
The path of the image file to create.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
A member of the GdPictureStatus enumeration.
Acquires a single image, from the currently selected Data Source to a file.
This method uses the memory transfer mode.
This method is ideal to reach the best transfer rate of the acquisition device.
The output image compression should be negotiated with the TwainSetCompression() method.
By default, the default data source (DS) is opened, displays its dialog, and determines all the
parameters of the acquisition and transfer.
If you want to (try to) hide the DS dialog, see TwainSetHideUI.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
To set the TWAIN state to 4, use the TwainOpenDefaultSource() or TwainOpenSource() method.
Warning: To works, this method requires that the current Data source allows memory transfer mode.
Use the TwainIsMemoryTransferModeAvailable() to check if the source support this mode of transfer.
This method requires the Document Capture (TWAIN / WIA) component to run.
The path of the image file to create.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
A member of the GdPictureStatus enumeration.
Acquires a single image, from the currently selected Data Source to a file.
This method uses the memory transfer mode.
This method is ideal to reach the best transfer rate of the acquisition device.
The output image compression should be negotiated with the TwainSetCompression() method.
By default, the default data source (DS) is opened, displays its dialog, and determines all the
parameters of the acquisition and transfer.
If you want to (try to) hide the DS dialog, see TwainSetHideUI.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
To set the TWAIN state to 4, use the TwainOpenDefaultSource() or TwainOpenSource() method.
Warning: To works, this method requires that the current Data source allows memory transfer mode.
Use the TwainIsMemoryTransferModeAvailable() to check if the source support this mode of transfer.
This method requires the Document Capture (TWAIN / WIA) component to run.
The path of the image file to create.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
A member of the GdPictureStatus enumeration.
Changes a specific TWAIN handling behavior of the SDK. This method is experimental and should be used on GdPicture staff advice only!
The ID of the behavior to control. Supported options are:
- 1: FORWARD_ALL_MSG. Forces the control to translate and dispatch all messages sent to the data source manager.
- 2: NEW_CALLBACK_MODEL. Enables the new callback model defined in the TWAIN 2.0 specifications.
- 3: FORCE_PROXY_WINDOWS. Forces the control to use it's own proxy windows to intercept windows messages.
- 4: NEW_CALLBACK_NO_HOOK. If NEW_CALLBACK_MODEL is activated, no message will be forwarded to the Data Source manager throught the DG_CONTROL/DAT_EVENT/MSG_PROCESSEVENT sequence.
True to enable the specified option, else False (default value for all options).
Starts to log twain operations into file.
The path of the log file to create / append.
True if success, else False (can't create or access to the log file).
Stops to log twain operations previously started by the TwainLogStart() method.
Saves to a file the current settings of the opened source, e.g. DPI, paper size, color format.
The file to save the current device configuration.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Saves to an array of bytes the current settings of the opened source, e.g. DPI, paper size, color format.
The array of bytes save the current device configuration.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Loads from a file, settings of the opened source, e.g. DPI, paper size, color format.
The file containing the current device configuration data.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Loads from an array of bytes, settings of the opened source, e.g. DPI, paper size, color format.
The array of bytes containing the current device configuration data.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Closes the open Data Source, if any.
If the source is enabled, disables it first.
True if success, else False. If there is not an open source, does nothing and returns TRUE.
This method should be called only if the TWAIN state is 4 (TWAIN_SOURCE_OPEN) or 5
(TWAIN_SOURCE_ENABLED).
If success, the TWAIN state must be <= 3 (TWAIN_SM_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Closes the Data Source Manager.
If a source is open, disables and closes it as needed.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
If the Source Manager is not open, does nothing and returns TRUE.
If success, the twain state must be <= 2 (TWAIN_SM_LOADED).
To get the TWAIN state, use the TwainGetState() method.
Closes the Data Source Manager.
If a source is open, disables and closes it as needed.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
If the Source Manager is not open, does nothing and returns TRUE.
If success, the twain state must be <= 2 (TWAIN_SM_LOADED).
To get the TWAIN state, use the TwainGetState() method.
Tells to the control to close or not the opened source after a scan process.
Set True to tell to the control to close the opened source after a
scan process, else False.
By default, the opened source is closed after a scan process. Use TwainSetAutoSourceClose(False) to
change this Behavior.
Tells to the control to favor retaining the source in an enabled state after a scan process.
Set true to tell to the control to retain source in an enabled state after a
scan process, else false.
By default, the opened source is disabled, then closed after a scan process. Use TwainSetKeepSourceEnabled(False) to
change this Behavior.
Disables the open Data Source, if any.
This closes the source's user interface.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
If there is not an enabled source, does nothing and returns TRUE.
Before using this method check that the TWAIN state is 5 (TWAIN_SOURCE_ENABLED).
If success, the twain state must be 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Asks to the opened source to enable or disable the duplex scanning mode.
Set True to enable duplex mode else False.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN).
To get the back of the acquired image, just another time an acquisition method.
To get the TWAIN state, use the TwainGetState() method.
Ask to the opened source to enable or not imprinter capability.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN). To get the
TWAIN state, use the TwainGetState() method.
Asks to the component to register your application into TWAIN.
Your application major number version.
Your application minor number version.
The language ID of your application.
The country ID of your application.
\Version information of your application.
The company name which provides the application.
The product family name.
The product name.
This method only if Twain state < 3 (TWAIN_SM_OPEN).
Use the GetStat() method to check if this method succeeded.
Asks if during the last acquisition process the user asked to close the device.
True if during the last acquisition process the user asked to close the device, else False.
Asks if the last acquisition process failed.
True if the last acquisition process failed , else False.
Signals the Data Source to stop all the transfers.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 7 (TWAIN_TRANSFERRING) or 6
(TWAIN_TRANSFER_READY).
If success, the twain state must be 5 (TWAIN_SOURCE_ENABLED).
To get the TWAIN state, use the TwainGetState() method.
Signals the Data Source to stop the current transfer.
Go to either State 6 (TWAIN_TRANSFER_READY) if it has more transfers ready, or to State 5
(TWAIN_SOURCE_ENABLED) if it does not.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 7 (TWAIN_TRANSFERRING).
To get the TWAIN state, use the TwainGetState() method.
If auto scan is turned ON, this command will stop the operation of the scanner’s automatic feeder. No
other action is taken. The application may then continue to transfer any images that have been
captured by the scanner.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 6 (TWAIN_TRANSFER_READY).
To get the TWAIN state, use the TwainGetState() method.
Returns the number of available printer mode.
If Success, non zero: The number of available printer mode. Else 0 if fail. Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Returns an available printer mode which can be used by the opened source in its current configuration.
Index of the available printer mode. Must be a value between 1 and
TwainGetAvailableImprinterModeCount() returned value.
If fail, returns -1 else if success, The selected file format value. A member of the
TwainPrinterModes enumeration.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Sets the current imprinter mode, if supported.
Top/Bottom refer to duplex devices, and indicate if the printer is writing on the top or the bottom of the sheet of paper.
Simplex devices use the top settings.
Before/After indicates whether printing occurs before or after the sheet of paper has been scanned.
Printer mode. A member of the TwainPrinterMode enumeration.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Returns the current imprinter mode, if any.
Top/Bottom refer to duplex devices, and indicate if the printer is writing on the top or the bottom of the sheet of paper.
Simplex devices use the top settings.
Before/After indicates whether printing occurs before or after the sheet of paper has been scanned.
A member of the TwainPrinterMode enumeration. If TWPR_UNSUPPORTED is returned, the capability is probably not supported by the current device -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Ask to the opened source if imprinter capability is currently enabled or not.
True if imprinter is currently enabled else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Ask to the opened source if imprinter capability is supported or not.
True if imprinter is supported else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Returns the starting page number with the current imprinter mode.
The starting page number.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Defines the starting page number with the current imprinter mode.
The starting page for the current imprinter mode.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Specifies the string that shall be used as suffix with the current imprinter mode.
The suffix to be used.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Returns the string that shall be used as suffix with the current imprinter mode.
The string to be used as suffix with the current imprinter mode.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Specifies the string that shall be used for printing with the current imprinter mode.
The string to be used for printing.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Returns the string that shall be used for printing with the current imprinter mode.
The string to be used for printing with the current imprinter mode.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN).
To get the TWAIN state, use the TwainGetState() method.
Returns a value indicating the last printed string by the device's imprinter.
The last printed string.
Returns the number of available file format values which can be used by the opened source in its
current configuration for file transfer mode.
If Success, non zero: The number of available file format values. Else 0 if fail. Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available image file format value which can be used by the opened source in its current
configuration for file transfer mode.
Index of the available file format value. Must be a value between 1 and
TwainGetAvailableImageFileFormatCount() returned value.
If fail, returns -1 else if success, The selected file format value. A member of the
TwainImageFileFormats enumeration.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Tries to set the current image file format to use by the selected twain source for file transfer
mode.
Image file format. A member of the TwainImageFileFormats enumeration.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the current image file format used by the selected twain source for file transfer mode.
If fail, TWFF_UNSUPPORTED : probably not supported by the current device -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
If success, Current file format to use in file transfer mode. A member of the GdPicture enumeration.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Tries to specifies the Reduction Method the Source should use to reduce the bit depth of the data.
Bit Depth reduction. A member of the TwainBitDepthReduction
enumeration.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns Reduction Method the Source should use to reduce the bit depth of the data.
Bit Depth reduction. A member of the TwainBitDepthReduction enumeration. TWBR_UNSUPPORTED If it is
not supported by the current device (Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.)
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Tries to set the current image compression to use by the selected twain source for file transfer
mode.
Since only certain file formats support compression, this capability must be negotiated after setting
the desired file format with the TwainSetImageFileFormat() method.
Image compression. A member of the TwainCompression enumeration.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the current image compression used by the selected twain source for file transfer mode.
Current file format to use in file transfer mode. A member of the TwainCompression enumeration.
TWCP_UNSUPPORTED If it is not supported by the current device (Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.)
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of available compression values which can be used by the opened source in its
current configuration for file transfer mode.
If Success, non zero: The number of available compression values. Else 0 if fail. Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available compression value which can be used by the opened source in its current
configuration for file transfer mode.
Index of the available file format value. Must be a value between 1 and
TwainGetAvailableCompressionCount() returned value.
If fail, returns -1 else if success, The selected compression value. A member of the TwainCompression
enumeration.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of available brightness values which can be used by the opened source in its
current configuration.
If Success, non zero: The number of available brightness values. Else 0 if fail. Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available brightness value which can be used by the opened source in its current
configuration.
Index of the available brightness value. Must be a value between 1 and
TwainGetAvailableBrightnessCount() returned value.
The selected brightness value. Else 0 if fail.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of available contrast values which can be used by the opened source in its
current configuration.
If Success, non zero: The number of available contrast values. Else 0 if fail -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available contrast value which can be used by the opened source in its current
configuration.
Index of the available contrast value. Must be a value between 1 and
TwainGetAvailableContrastCount() returned value.
The selected contrast value.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of available bit depths values which can be used by the opened source in its
current configuration.
If Success, non zero: The number of available bit depths values. Else 0 if fail -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available bit depth value which can be used by the opened source in its current
configuration.
Index of the available bit depth value. Must be a value between 1 and
TwainGetAvailableBitDepthCount() returned value.
The selected bit depth value.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of available pixel types values which can be used by the opened source in its
current configuration.
If Success, non zero: The number of available pixel types values. Else 0 if fail -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available pixel type value which can be used by the opened source in its current
configuration.
Index of the available pixel type value. Must be a value between 1 and
TwainGetAvailablePixelTypeCount() returned value.
TwainPixelType. The selected pixel type value. A member of the TwainPixelType enumeration.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of available X Resolutions values which can be used by the opened source in its
current configuration.
If Success, non zero: The number of available X Resolutions values. Else 0 if fail -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available X Resolution value which can be used by the opened source in its current
configuration.
Index of the available X Resolution. Must be a value between 1 and TwainGetAvailableXResolutionCount() returned value.
The X Resolution.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of available Y Resolutions values which can be used by the opened source in its
current configuration.
If Success, non zero: The number of available Y Resolutions values. Else 0 if fail -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available Y Resolution value which can be used by the opened source in its current
configuration.
Index of the available Y Resolution. Must be a value between 1 and TwainGetAvailableYResolutionCount() returned value.
The X Resolution.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of available values for the selected TWAIN capability which can be used with it
by the opened source in its current configuration.
A member of the TwainCapabilities enumeration.
If Success, non zero: Number of values available for the selected TWAIN capability. Else 0 if fail ->
Use TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available numeric value for the selected TWAIN capability which can be used by the opened
source in its current configuration.
This method should be used to determine what are the supported value which can be used with the
TwainSetCapCurrentNumeric() method.
A member of the TwainCapabilities enumeration.
Index of the available value. Must be a value between 1 and
TwainGetAvailableCapValuesCount() returned value.
The selected available value of the selected TWAIN capability.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
This method can be used to set the following types of capabilities: TWTY_INT8 , TWTY_INT16,
TWTY_INT32, TWTY_UINT8, TWTY_UINT16, TWTY_UINT32, TWTY_BOOL, TWTY_FIX32, TWTY_FRAME.
You can determine the type of each TWAIN capability using the TwainGetCapItemType method or looking
the twain references from http://www.twain.org
Returns an available string value for the selected TWAIN capability which can be used by the opened
source in its current configuration.
This method should be used to determine what are the supported value which can be used with the
TwainSetCapCurrentString() method.
A member of the TwainCapabilities enumeration.
Index of the available value. Must be a value between 1 and
TwainGetAvailableCapValuesCount() returned value.
The selected available value of the selected TWAIN capability.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
This method can be used to set the following types of capabilities: TWTY_STR32, TWTY_STR64,
TWTY_STR128, TWTY_STR255 .
You can determine the type of each TWAIN capability using the TwainGetCapItemType method or looking
the twain references from http://www.twain.org
Returns the Source’s support status of a specific TWAIN capability.
A member of the TwainCapabilities enumeration.
Returns if the source supports Get query with the specified capability.See TwainGetCapCurrentNumeric() and TwainGetCapCurrentString().
Returns if the source supports Set query with the specified capability. See TwainSetCapCurrentNumeric() and TwainSetCapCurrentString().
Returns if the source supports GetDefault query with the specified capability. See TwainGetCapDefaultNumeric() and TwainGetCapDefaultString().
Returns if the source supports GetCurrent query with the specified capability. See TwainGetCapCurrentNumeric() and TwainGetCapCurrentString().
Returns if the source supports Reset query with the specified capability. See: TwainResetCap().
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns as numeric, the current value of a TWAIN capability.
A member of the TwainCapabilities enumeration.
Returns the current value of the specified TWAIN capability.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
This method can be used to retrieve the following types of capabilities: TWTY_INT8 , TWTY_INT16,
TWTY_INT32, TWTY_UINT8, TWTY_UINT16, TWTY_UINT32, TWTY_BOOL, TWTY_FIX32, TWTY_FRAME.
You can determine the type of each TWAIN capability using the TwainGetCapItemType method or looking
the twain references from http://www.twain.org
Returns as numeric, the default value of a TWAIN capability.
A member of the TwainCapabilities enumeration.
Returns the default value of the specified TWAIN capability.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
This method can be used to retrieve the following types of capabilities: TWTY_INT8 , TWTY_INT16,
TWTY_INT32, TWTY_UINT8, TWTY_UINT16, TWTY_UINT32, TWTY_BOOL, TWTY_FIX32, TWTY_FRAME.
You can determine the type of each TWAIN capability using the TwainGetCapItemType method or looking
the twain references from http://www.twain.org
Returns the three parameters that define a Range for a TWAIN capability. Many capabilities allow
users to select their current value from a range of regularly spaced values. The capability can
specify the minimum and maximum acceptable values and the incremental step size between values. For
example, resolution might be supported from 100 to 600 in steps of 50 (100, 150, 200, ..., 550,
600).
A member of the TwainCapabilities enumeration.
Output parameter. Starting value in the range.
Output parameter. Final value in the range.
Output parameter. Increment from nMinValue to nMaxValue.
True if success, else False -> use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
This method can be used to set the following types of capabilities: TWTY_INT8 , TWTY_INT16,
TWTY_INT32, TWTY_UINT8, TWTY_UINT16, TWTY_UINT32, TWTY_BOOL, TWTY_FIX32, TWTY_FRAME.
You can determine the type of each TWAIN capability using the TwainGetCapItemType method or looking
the twain references from http://www.twain.org
Returns as string, the current value of a TWAIN capability.
A member of the TwainCapabilities enumeration.
Returns the current value of the specified TWAIN capability.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
This method can be used to retrieve the following types of capabilities: TWTY_STR32, TWTY_STR64,
TWTY_STR128, TWTY_STR255 .
You can determine the type of each TWAIN capability using the TwainGetCapItemType method or looking
the twain references from http://www.twain.org
Returns as string, the default value of a TWAIN capability.
A member of the TwainCapabilities enumeration.
Returns the default value of the specified TWAIN capability.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
This method can be used to retrieve the following types of capabilities: TWTY_STR32, TWTY_STR64,
TWTY_STR128, TWTY_STR255 .
You can determine the type of each TWAIN capability using the TwainGetCapItemType method or looking
the twain references from http://www.twain.org
Asks to the opened source if it has a document feeder.
True if the source indicates it has a document feeder else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
This method can returns FALSE with HP scanners with ADF.
Asks to the opened source if it has a flatbed.
True if the source indicates it has a flatbed else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Asks to the opened source if the document feeder is selected.
True if the document feeder is selected, else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the online statue of the current data source.
If TRUE, the physical hardware (e.g., scanner, digital camera, image database, etc.) that
represents the image source is attached, powered on, and communicating.
True if the current data source is powered on and communicating, else False.
This method can be issued at any time to determine the availability of the image source
Asks to the opened source to select or deselect the document feeder.
If TRUE, Source must acquire data from the document feeder acquire area.If
FALSE, Source must acquire data from the non-feeder acquire area like
flatbed area.
True if success, else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Asks to the opened source if there are documents in the feeder.
True if there are documents, else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
The document feeder must be selected to use this method. To enable the document feeder you need to
TwainSelectFeeder(True).
Changes the current value of a TWAIN capability from a numeric value.
The TwainGetAvailableCapValueNoNumeric() method should be used to determine what are the supported
value which can be used with this method.
A member of the TwainCapabilities enumeration.
A member of the TwainItemTypes enumeration.You can determine the
type of each TWAIN capability using the TwainGetCapItemType method or
looking the twain references from http://www.twain.org.
New value (as numeric) to set to the selected TWAIN capability.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Changes the current value of a TWAIN capability.
A member of the TwainCapabilities enumeration.
A member of the TwainItemTypes enumeration.You can determine the
type of each TWAIN capability using the TwainGetCapItemType method or
looking the twain references from http://www.twain.org.
New value to set to the selected TWAIN capability.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
This method can be used to set the following types of capabilities: TWTY_STR32, TWTY_STR64,
TWTY_STR128, TWTY_STR255.
Sets the current TWAIN capability value to default value.
A member of the TwainCapabilities enumeration.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the Item type used by a TWAIN capability.
A member of the TwainCapabilities enumeration.
A member of the Tags enumeration.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of bit per pixel for the current value of PixelType.
If success: bit depth value. Else 0 if fail -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
Ambiguity in the Specification prior to version 2.2 may result in some Data Sources reporting just the depth-per-channel.
In the majority of cases a value of 8 for ICAP_BITDEPTH when ICAP_PIXELTYPE is TWPT_RGB may be treated as if the bit depth is really 24.
Returns the dividing line between black and white. This is the value the Source will use to
threshold, if needed, when scanning B&W image.
Current threshold value between 0 and 255. -1 If it is not supported by the current device (Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.)
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Try to specify the dividing line between black and white. This is the value the Source will use to
threshold, if needed, when scanning B&W image.
Threshold value between 0 and 255.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Queries the current device for UI support for preview mode.
True if the Source supports preview UI else False: Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the color data formats There are two Options, "planar" And "chunky."
0 for Chunky or 1 for planar. -1 If it is not supported by the current device -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Try to specify the color data formats There are two Options, "planar" And "chunky".
0 for Chunky or 1 for Planar.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the pixel 'flavor' (0 is black or white).
CHOCOLATE means this pixel represents the darkest data value that can be generated by the device (the
darkest available optical value may measure greater than 0).
VANILLA means this pixel represents the lightest data value that can be generated by the device (the
lightest available optical value may measure greater than 0).
A member of the TwainPixelFlavor enumeration. returns TwainPixelFlavorUndefined (-1) if it is not
supported by the current device -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Try to specify the pixel 'flavor' (0 is black or white).
CHOCOLATE means this pixel represents the darkest data value that can be generated by the device (the
darkest available optical value may measure greater than 0).
VANILLA means this pixel represents the lightest data value that can be generated by the device (the
lightest available optical value may measure greater than 0).
A member of the TwainPixelFlavor enumeraion.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the current brightness.
If success: The TWAIN standard *says* that the range for this cap is -1000 ... +1000. If fail,
Returns -99999 -> Use TwainGetLastResultCode() and TwainGetLastConditionCode() methods for
diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the current contrast.
If Success: The TWAIN standard *says* that the range for this cap is -1000 ... +1000. If fail,
Returns -99999 -> Use TwainGetLastResultCode() and TwainGetLastConditionCode() methods for
diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Asks the source for the current pixel type.
TwainPixelType. A member of the TwainPixelType enumeration. -1 If fail -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the current resolution in Dot per inch of the selected scanner.
If success, non-zero value. If fail, -1 -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the name of the opened source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
The current source name.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the name of the opened source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
The current source name.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the name of the default TWAIN source into the dialog of source selection.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window. Returns the name of the default source: the source selected in the
Select Source dialog.
The default source name.
Returns the name of the default TWAIN source into the dialog of source selection.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window. Returns the name of the default source: the source selected in the
Select Source dialog.
The default source name.
Returns the duplex scanning support.
Can be:
0 = no support (or error) -> Use TwainGetLastResultCode() and TwainGetLastConditionCode() methods
for diagnosing the error.
1 = 1-pass duplex
2 = 2-pass duplex
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Asks if the user interface should be hidden or not during an acquisition process.
True if the user interface is hidden, else False.
Asks if the TWAIN Source's GUI runs as modal or modeless.
True if the TWAIN Source's GUI runs as modal else False (modless).
Returns a value indicating if the last transferred image represents the front or rear of the sheet of paper.
A member of the TwainPageSide enumeration.
Returns the last condition code from the last message sent to TWAIN.
A member of the TwainConditionCode enumeration.
Returns the last result code from the last message sent to TWAIN.
A member of the TwainResultCode enumeration.
If the result is not TWRC_SUCCESS, you can use the TwainGetLastConditionCode() method to check the
reason on this result.
Gets the current paper size.
A member of the TwainPaperSize enumeration.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
NONE (0) indicates that the maximum image size supported by the device is to be used.
Gets the number of pending transfers from the current TWAIN device.
The number of pending transfers from the TWAIN device.
Returns the number of available paper size values which can be used by the opened source.
If Success, non zero: The number of available paper size values. Else 0 if fail -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns an available paper size value which can be used by the opened source.
Index of the available paper size value. Must be a value between 1 and
TwainGetAvailablePaperSizeCount() returned value.
A member of the TwainPaperSize enumeration.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the maximum height of the scanning area (in inches).
Double.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the maximum width of the scanning area (in inches).
Double.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the number of sources available.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
Number of sources available.
Returns the number of sources available.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
Number of sources available.
Returns the name of an available TWAIN source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
The number of the source. Must be value between 1 and TwainGetSourceCount()
return. If the value provided in not in the expected range a TwainError
status is returned by a subsequent call of the GetStat() method.
The name of the source.
Returns the name of an available TWAIN source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
The number of the source. Must be value between 1 and TwainGetSourceCount()
return. If the value provided in not in the expected range a TwainError
status is returned by a subsequent call of the GetStat() method.
The name of the source.
Returns the family name of an available TWAIN source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
The number of the source. Must be value between 1 and TwainGetSourceCount()
return. If the value provided in not in the expected range a TwainError
status is returned by a subsequent call of the GetStat() method.
The name of the source.
Returns the family name of an available TWAIN source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
The number of the source. Must be value between 1 and TwainGetSourceCount()
return. If the value provided in not in the expected range a TwainError
status is returned by a subsequent call of the GetStat() method.
The name of the source.
Returns the manufacturer of an available TWAIN source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
The number of the source. Must be value between 1 and TwainGetSourceCount()
return. If the value provided in not in the expected range a TwainError
status is returned by a subsequent call of the GetStat() method.
The name of the source.
Returns the manufacturer of an available TWAIN source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
The number of the source. Must be value between 1 and TwainGetSourceCount()
return. If the value provided in not in the expected range a TwainError
status is returned by a subsequent call of the GetStat() method.
The name of the source.
Returns the version information of an available TWAIN source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
The number of the source. Must be value between 1 and TwainGetSourceCount()
return. If the value provided in not in the expected range a TwainError
status is returned by a subsequent call of the GetStat() method.
Returns Major revision number of the software.
Incremental revision number of the software.
Returns the language of the driver. A member of the TwainLanguage
enumeration.
Returns the origin country of the diver. A member of the TwainCountry
enumeration.
Returns the driver info. IE: "1.0b3 Beta release".
A member of the GdPictureStatus enumeration.
Returns the version information of an available TWAIN source.
A Window Handle IE: Me.Handle. In most applications you can use nothing but
on Citrix and WTS, this must be a top-level window or a child of a top level
window.
The number of the source. Must be value between 1 and TwainGetSourceCount()
return. If the value provided in not in the expected range a TwainError
status is returned by a subsequent call of the GetStat() method.
Returns Major revision number of the software.
Incremental revision number of the software.
Returns the language of the driver. A member of the TwainLanguage
enumeration.
Returns the origin country of the diver. A member of the TwainCountry
enumeration.
Returns the driver info. IE: "1.0b3 Beta release".
A member of the GdPictureStatus enumeration.
Gets the recent TWAIN state of the currently executed TWAIN session.
The TWAIN protocol defines seven states that exist in the TWAIN session in order to ensure the session is executed correctly.
For more details on TWAIN states, please refer to the TWAIN Specification.
Be aware that this is not the error status of the last executed TWAIN operation. For further explanation please refer to the example below.
Just to inform you that you can try the TWAIN functionality using one of TWAIN demo projects available in your installation folder.
A member of the TwainStatus enumeration. The current TWAIN state of the on-going TWAIN session.
This method find out if TWAIN is installed on the system.
It takes a little time on the first call.
True if twain is available else False
Ask to the opened source if duplex scanning is currently enabled or not.
True if duplex is currently enabled else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Asks to the opened source if the current data source supports file transfer mode.
True if the current data source supports file transfer, else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Asks to the opened source if the current data source supports memory transfer mode.
True if the current data source supports memory transfer, else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Ask to the opened source if the device supports a kind of pixel type.
A member of the TwainPixelType enumeration.
True if the (PixelType) pixel type is available else False.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Opens the default source (the TWAIN device) previously selected in the Source Manager's Select Source dialog box for further usage.
Be aware, that if some source is already opened, this method does nothing and returns true.
Please note that you need to call this method for each scanning process in order to ensure your TWAIN session is executed correctly.
You can also run this method if you need to set the TWAIN state to TwainStatus.TWAIN_SOURCE_OPEN (State 4) from previous states, which can only be
TwainStatus.TWAIN_SM_OPEN (State 3), TwainStatus.TWAIN_SM_LOADED (State 2) or TwainStatus.TWAIN_PRESESSION (State 1).
For more details on TWAIN states, please refer to the TWAIN Specification.
Opens the default TWAIN device previously selected in the Source Manager's Select Source dialog box for further processing using TWAIN.
A window handle, that will act as the Source's parent, means Me.Handle or this.Handle.
In most applications, you can use nothing, but on Citrix and WTS this must be a top-level window or a child of a top-level window.
Just to inform you, that the current TWAIN state is TwainStatus.TWAIN_SOURCE_OPEN (State 4) after successfully following this method.
Use the method to find out the current TWAIN state within the on-going session.
This method requires the Document Capture (TWAIN / WIA) component to run.
true if the method has been followed successfully, otherwise false.
It is recommend to use the and the methods to identify the specific reason for the method's failure, if any.
Opens the default source (the TWAIN device) previously selected in the Source Manager's Select Source dialog box for further usage.
Be aware, that if some source is already opened, this method does nothing and returns true.
Please note that you need to call this method for each scanning process in order to ensure your TWAIN session is executed correctly.
You can also run this method if you need to set the TWAIN state to TwainStatus.TWAIN_SOURCE_OPEN (State 4) from previous states, which can only be
TwainStatus.TWAIN_SM_OPEN (State 3), TwainStatus.TWAIN_SM_LOADED (State 2) or TwainStatus.TWAIN_PRESESSION (State 1).
For more details on TWAIN states, please refer to the TWAIN Specification.
A window handle, that will act as the Source's parent, means Me.Handle or this.Handle.
In most applications, you can use nothing, but on Citrix and WTS this must be a top-level window or a child of a top-level window.
Just to inform you, that the current TWAIN state is TwainStatus.TWAIN_SOURCE_OPEN (State 4) after successfully following this method.
Use the method to find out the current TWAIN state within the on-going session.
This method requires the Document Capture (TWAIN / WIA) component to run.
true if the method has been followed successfully, otherwise false.
It is recommend to use the and the methods to identify the specific reason for the method's failure, if any.
Opens the source with the given name.
If another source is open, closes it and attempts to open the specified source.
First this method for each scanning process or to set the TWAIN state to 4 (TWAIN_SOURCE_OPEN) when
the TWAIN state is 3 (TWAIN_SM_OPEN) or 2 (TWAIN_SM_LOADED) or 1 (TWAIN_PRESESSION).
A Window Handle IE: Me.Handle. In most applications you can use nothing
but on Citrix and WTS, this must be a top-level window or a child of a top
level window.
The name of the source to open.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
If this returns TRUE, TWAIN is in STATE 4 (TWAIN_SOURCE_OPEN).
This method requires the Document Capture (TWAIN / WIA) component to run.
Opens the source with the given name.
If another source is open, closes it and attempts to open the specified source.
First this method for each scanning process or to set the TWAIN state to 4 (TWAIN_SOURCE_OPEN) when
the TWAIN state is 3 (TWAIN_SM_OPEN) or 2 (TWAIN_SM_LOADED) or 1 (TWAIN_PRESESSION).
A Window Handle IE: Me.Handle. In most applications you can use nothing
but on Citrix and WTS, this must be a top-level window or a child of a top
level window.
The name of the source to open.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
If this returns TRUE, TWAIN is in STATE 4 (TWAIN_SOURCE_OPEN).
This method requires the Document Capture (TWAIN / WIA) component to run.
Asks to the opened device to reset the area to scan, sometimes called the ROI (Region of Interest).
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Displays the Source Manager's Select Source dialog box to enable selecting the TWAIN device for further usage.
This dialog lists all available installed devices and allows the user to select the default one for next use.
Displays the Source Manager's Select Source dialog for further processing using TWAIN.
A window handle, that will act as the Source's parent, means Me.Handle or this.Handle.
In most applications, you can use nothing, but on Citrix and WTS this must be a top-level window or a child of a top-level window.
Please note that to open the selected device you need to use the method.
true if the method has been followed successfully, otherwise false.
You can use the and the methods to determine the reason for the method's failure.
Here are possible reasons for returning false:
- The user canceled the Select Source dialog.
- The Source Manager found no data sources installed.
- There was a failure before the Select Source dialog could display.
Displays the Source Manager's Select Source dialog box to enable selecting the TWAIN device for further usage.
This dialog lists all available installed devices and allows the user to select the default one for next use.
A window handle, that will act as the Source's parent, means Me.Handle or this.Handle.
In most applications, you can use nothing, but on Citrix and WTS this must be a top-level window or a child of a top-level window.
Please note that to open the selected device you need to use the method.
true if the method has been followed successfully, otherwise false.
You can use the and the methods to determine the reason for the method's failure.
Here are possible reasons for returning false:
- The user canceled the Select Source dialog.
- The Source Manager found no data sources installed.
- There was a failure before the Select Source dialog could display.
Try to enable or disable autobrightness scanning.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
True to enable autobrightness, else False.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Try to enable or disable the Source’s automatic document feeding process.
If you enable auto feed scanning, this method selects the feeder.
So to start scanning pages from an ADF, just do: TwainSetAutoFeed(TRUE).
This method can returns FALSE with HP scanners with ADF.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
True to enable automatic document feeding, else False.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
If this option is available on opened source, try to enable or disable the automatic border
detection. It reduces or removes the border generated around an image by the scanner scanning its own
platen (the area not covered by the paper).
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
True to enable automatic border detection, else False.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Asks to the opened source if she can support the auto-size images capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support the auto-size images, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if she can support the image rotation capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support image rotation, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source to rotate the scanned image data prior to transfer.
The angle of rotation in degrees.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if success, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source for current rotation to apply to the scanned image data prior to transfer.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
The image rotation in degrees.
Asks to the opened source if she can support the image orientation capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support image rotation, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source to define which edge of the “paper†the image’s “top†is aligned with.
This information is used to adjust the frames to match the scanning orientation of the paper.
The image orientation mode. A member of the TwainOrientation enumeration.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if success, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source which edge of the “paper†the image’s “top†is aligned with.
This information is used to adjust the frames to match the scanning orientation of the paper.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
The image orientation mode. A member of the TwainOrientation enumeration.
Asks to the opened source if the auto-size images capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if the auto-size images is enabled, FALSE otherwise.
If this option is available on opened source, try to enable or disable the auto-size images.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
True to enable auto-size images, else False.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Asks to the opened source for current horizontal scaling to apply to the scanned image.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
The image horizontal scaling. A value of ‘1.0’ is equivalent to 100% scaling.
Asks to the opened source if she can support the image horizontal scaling capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support image XScaling, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Tries to set the current image horizontal scaling factor for the selected twain source.
The image horizontal scaling. A value of ‘1.0’ is equivalent to 100% scaling. Do not use values less than or equal to zero.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if success, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source for current algorithm used to remove noise for the selected twain source.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
The noise filter mode. A member of the TwainNoiseFilterMode enumeration.
Asks to the opened source if she can support the noise filter capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support image Noise Filter, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Tries to set the current algorithm used to remove noise for the selected twain source.
The noise filter mode. A member of the TwainNoiseFilterMode enumeration.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if success, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source for current vertical scaling to apply to the scanned image.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
The image vertical scaling. A value of ‘1.0’ is equivalent to 100% scaling.
Asks to the opened source if she can support the image vertical scaling capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support image YScaling, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Tries to set the current image vertical scaling factor for the selected twain source.
The image vertical scaling. A value of ‘1.0’ is equivalent to 100% scaling. Do not use values less than or equal to zero.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if success, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source for current Gamma correction value to apply to the scanned image.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
Gamma correction value for the image data.
Asks to the opened source if she can support the gamma correction capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support gamma correction, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Tries to set the current gamma correction value for the selected twain source.
Gamma correction value for the image data. Default value is 2.2.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if success, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if she can support the Automatic border detection capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support the Automatic border detection, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if the Automatic border detection capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if the automatic border detection is enabled, FALSE otherwise.
If this option is available on opened source, try to enable or disable the barcode detection.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
bool. True to enable barcode detection, else False.
bool. TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
If this option is available on opened source, try to enable or disable the automatic deskew
correction of an image. It may also affect the dimensions of the image.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
True to enable automatic deskew, else False.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Asks to the opened source if she can support the Automatic Deskew capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support the Automatic Deskew, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if she can support endorser / imprinter capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support endorser / imprinter, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Tries to specify the starting endorser / imprinter number for the next acquisition. All other
endorser/imprinter properties should be handled through the data source’s user interface.
The starting number for the endorser.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the starting endorser / imprinter number for the next acquisition.
The starting number for the endorser. -999999 If it is not supported by the current device -> Use
TwainGetLastResultCode() and TwainGetLastConditionCode() methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns a value indicating the last endorsed string by the device.
The last endorsed string.
Asks to the opened source if the Automatic Deskew capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if the automatic deskew is enabled, FALSE otherwise.
Asks to the opened source if she can support the Automatic discard blank images capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support the Automatic discard blank images, FALSE otherwise -> Use TwainGetLastResultCode()
and TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if the Automatic discard blank images capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if automatic discard blank page is enabled, FALSE otherwise.
If this option is available on opened source, try to enable or disable the automatic discard blank
page capability.
True to enable automatic discard blank images capability, else False.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
If this option is available on opened source, try to enable or disable the automatic rotation of
image capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
There are no criteria for how this automatic rotation is determined. A Source may use a field of
text, or some distinguishing non-text field, such as a barcode or a logo, or it may rely on form
recognition to help rotate the document.
True to enable automatic rotation, else False.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Asks to the opened source if she can support the Automatic rotation of images capability.
This capability depends on intelligent features within the Source to automatically rotate the image
to the correct position.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support the Automatic rotation, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if the automatic rotation of images capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if the automatic rotation is enabled, FALSE otherwise.
Asks to the opened source if she can support the automatic scan capability.
This capability is intended to boost the performance of a Source.
The fundamental assumption behind AutoScan is that the device is able to capture images without
waiting for the Application to request the image transfers.
The default behavior is undefined, because some high volume devices are capable of anything but
TwainIsAutoScanAvailable() return value being equal to TRUE.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support the automatic scan, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if the automatic scan capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if the automatic scan is enabled, FALSE otherwise.
Asks to the opened source if she can support the barcode detection capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
bool. TRUE if support the barcode detection, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if the barcode detection capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
bool. TRUE if the barcode detection is enabled, FALSE otherwise.
Asks to the opened source if she can support the automatic page feeding capability.
When AutoFeed capability is enabled, the Source will automatically feed the next page from the
document feeder after the number of frames negotiated for capture from each page are acquired.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support the automatic page feeding, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if the automatic page feeding capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if the automatic page feeding is enabled, FALSE otherwise.
Asks to the opened source if she can support the auto-brightness images capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support the auto-brightness images, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if the auto-brightness images capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if the auto-brightness images is enabled, FALSE otherwise.
Tries to enable or disable the auto scan scanning capability. Setting this to TRUE gives the scanner
permission to 'scan ahead'.
i.e. to pull pages from the feeder and scan them before they have been requested.
On high-speed scanners, you may have to enable auto scan to achieve the maximum scanning rate.
This will fail on most flatbeds & cameras, and some 'feeder'
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
True to enable autoscan, else False.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Asks to the opened source if she can support the automatic color detection capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if support the automatic color detection, FALSE otherwise -> Use TwainGetLastResultCode() and
TwainGetLastConditionCode() methods for diagnosing the error.
Asks to the opened source if the automatic color detection capability is enabled or not.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
TRUE if the automatic color detection is enabled, FALSE otherwise.
Tries to enable or disable the automatic color detection capability.
Before using this method check that the TWAIN state is TWAIN_SOURCE_OPEN (4)
To get the TWAIN state, use the TwainGetState() method.
True to enable autoscan, else False.
TRUE if successful, FALSE otherwise -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Specifies the number of bit per pixel for the current value of PixelType.
Bit Depth.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is >= 4 (TWAIN_SOURCE_OPEN)
Ambiguity in the Specification prior to version 2.2 may result in some Data Sources reporting just the depth-per-channel.
In the majority of cases a value of 8 for ICAP_BITDEPTH when ICAP_PIXELTYPE is TWPT_RGB may be treated as if the bit depth is really 24.
Tries to set the current brightness for the next acquisition.
The TWAIN standard *says* that the range for this cap is -1000 ... +1000.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Tries to set the current contrast for the next acquisition.
The TWAIN standard *says* that the range for this cap is -1000 ... +1000.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Tries to set the current pixel type for the selected twain source.
A member of the TwainPixelType enumeration.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Tries to set the current resolution (in both x & y).
Resolution is in dots per inch.
The new resolution.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
'The source may select this resolution, but don't assume it will.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Turns On or Off the Debug Mode of GDTWAIN.
Displays a message box for each step of the scanning process.
True to turn ON else False.
Specifies the path TWAIN Data Source Manager.
The TWAIN DSM is the windows library (dll) providing support for the TWAIN standard.
Can be TWAIN_32.DLL or TWAINDSM.DLL for TWAIN 2.0 support. By default, the toolkits searches the
Windows path for the TWAIN DSM but on Citrix the Windows directory can be redirected for users.
The path of the TWAIN Data Source Manager.
Turns On or Off the error message box of GDTWAIN.
Displays a message box for each error appends.
True to turn ON else False.
Specifies the physical area (a rectangle) to be acquired during the next image transfer.
Value of the left-most edge of the area to scan measured in inches.
Value of the top-most edge of the area to scan measured in inches.
Value of the right-most edge of the area to scan measured in inches. Note:
ImageWidth = Right - Left.
Value of the bottom-most edge of the area to scan measured in inches. Note:
ImageHeight = Bottom - Top.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Returns the physical area (a rectangle) to be acquired during the next image transfer.
Value of the left-most edge of the area to scan measured in inches.
Value of the top-most edge of the area to scan measured in inches.
Value of the right-most edge of the area to scan measured in inches. Note:
ImageWidth = Right - Left.
Value of the bottom-most edge of the area to scan measured in inches. Note:
ImageHeight = Bottom - Top.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Tells the source to hide or show the user interface before acquisition.
True to hide the UI, else False.
That this is only a request - some sources will ignore it!
If the user interface is hidden, you will probably want to set at least some of the basic acquisition
parameters yourself like resolution, Bit Depth...
Set TRUE to run the TWAIN Source's GUI modal or FALSE to run it modeless. Please note that to
successfully run modal, it may be necessary for the application to disable inputs to its windows
while the Source’s GUI is running.
True to run the source's GUI modal, else False.
Tells the source to show or hide progress indicators during acquisition.
True to show the progress indicators, else False.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Changes the multiple transfers mode for acquisition.
If set to False, all the pending transfers are canceled after the last
acquisition process.
The multiple transfers mode is automatically sets to True by the TwainSetAutoFeed(True) and the
TwainEnableDuplex(True) calls.
Sets the current paper size.
A member of the TwainPaperSize enumeration.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
NONE (0) indicates that the maximum image size supported by the device is to be used.
Negotiates with open Source the number of images application will accept.
Number of image to transfer. Xfers = -1 means all images.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Starts the selected device's settings dialog, if this is supported.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
You can use the TwainUserClosedSource method to determine if the user pressed the Cancel button of
the displayed interface.
Starts the selected device's settings dialog, if this is supported.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
You can use the TwainUserClosedSource method to determine if the user pressed the Cancel button of
the displayed interface.
Queries the selected device's for settings dialog support.
True if supported, else False
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Unloads the Data Source Manager and release the TWAIN32.DLL.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
This will fail if the Source Manager is open.
If success, the twain state must be 1 (TWAIN_PRESESSION).
To get the TWAIN state, use the TwainGetState() method.
Unloads the Data Source Manager and release the TWAIN32.DLL.
A Window Handle IE: Me.Handle. In most applications you can use nothing but on
Citrix and WTS, this must be a top-level window or a child of a top level
window.
True if success, else False -> Use TwainGetLastResultCode() and TwainGetLastConditionCode()
methods for diagnosing the error.
This will fail if the Source Manager is open.
If success, the twain state must be 1 (TWAIN_PRESESSION).
To get the TWAIN state, use the TwainGetState() method.
Select WIA device for capture. This method posts the WIA Source Manager's Select Source dialog box.
A member of the WiaSourceType enumeration. The type of source to select.
The WIA source identifier as string if success, else empty string. Use WiaGetLastError() methods for diagnosing the error.
Returns the number of sources available.
Number of sources available.
Returns the name of an available WIA source.
The number of the source. Must be value between 1 and WiaGetSourceCount()
return.
The name of the source.
Returns the name of the server on which an available WIA source is connected.
The number of the source. Must be value between 1 and WiaGetSourceCount()
return.
The server name? Shoud be 'local' for local usage.
Returns the version of the driver of an available WIA source.
The number of the source. Must be value between 1 and WiaGetSourceCount()
return.
The driver version.
Returns the version of the WIA protocol used by an available WIA source.
The number of the source. Must be value between 1 and WiaGetSourceCount()
return.
The WIA version.
Returns the description of an available WIA source.
The number of the source. Must be value between 1 and WiaGetSourceCount()
return.
The description of the source.
Returns the manufacturer name of an available WIA source.
The number of the source. Must be value between 1 and WiaGetSourceCount()
return.
The manufacturer name of the source.
Returns the type of an available WIA source.
The number of the source. Must be value between 1 and WiaGetSourceCount()
return.
A member of the WiaSourceType enumeration.
Returns the ID of an available WIA source.
The number of the source. Must be value between 1 and WiaGetSourceCount()
return.
The name of the source.
Returns the ID of the opened source.
The current source ID.
Opens a WIA source.
A WIA source identifier which can be retrieved with the WiaGetSourceID or the
WiaSelectSource methods.
True if success, False otherwhise. Use WiaGetLastError() methods for diagnosing the error.
\Closes the open Data Source, if any.
Acquires a single image, from the currently selected Data Source to a file.
The destination of the file.
A member of the WiaImageFormat enumeration.
A member of the GdPictureStatus enumeration.
Acquires a single image, from the currently selected Data Source to a file, in the native format
provided by the data source. The format of the image to be transferred can be determined calling the
WiaGetImageExtension() method. '''
The destination of the file.
A member of the GdPictureStatus enumeration.
Acquires a single image, from the currently selected Data Source to a file.
0: The image could not created. Use the GetStat() and WiaGetLastError() methods for diagnosing the
error.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Asks the currently selected Data Source to acquire an image, the return it as a GdPicture image. This method should be used with camera only.
0: The image could not created. Use the GetStat() and WiaGetLastError() methods for diagnosing the
error.
Non-zero: GdPicture image identifier. The created image. The ReleaseGdPictureImage() method must be subsequently used to release the image from the memory.
Undocumented method. Currently for support purpose only.
The WIA device property identifier.
The value of the property to set.
.
A member of the GdPictureStatus enumeration.
Undocumented method. Currently for support purpose only.
The WIA device property identifier.
Returns the current value of the property.
A member of the GdPictureStatus enumeration.
Launches the Microsoft Windows Scanner and Camera Wizard with the currently selected Data Source.
A member of the GdPictureStatus enumeration.
Returns the last status of the currently selected Data Source.
A member of the WiaStatus enumeration.
Asks to the opened source to select or deselect the document feeder.
If TRUE, Source must acquire data from the document feeder acquire area.If
FALSE, Source must acquire data from the non-feeder acquire area like
flatbed area.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Asks to the opened source if there are documents in the feeder.
True if there are documents, else False.
Asks to the opened source if the document feeder is selected.
True if the document feeder is selected, else False.
Asks to the opened source if it has a document feeder.
True if the source indicates it has a document feeder else False.
Asks to the opened source if it has a flatbed.
True if the source indicates it has a flatbed else False.
Ask to the opened source if duplex scanning is currently available or not.
True if duplex is currently available else False.
Ask to the opened source if duplex scanning is currently enabled or not.
True if duplex is currently enabled else False.
Ask to the opened source if duplex scanning is currently enabled or not.
TRUE to enabled duplex scanning mode else FALSE.
True if success, else False.
Starts the selected device's settings dialog.
A member of the GdPictureStatus enumeration.
Tells the source to show or hide progress indicators during acquisition.
True to show the progress indicators, else False.
Before using this method check that the TWAIN state is 4 (TWAIN_SOURCE_OPEN)
To get the TWAIN state, use the TwainGetState() method.
Tries to set the current vertical resolution.
Resolution is in dots per inch.
The new resolution.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Returns the current vertical resolution in Dot per inch of the selected device.
If success, non-zero value. If fail, -1. Use WiaGetLastError() methods for diagnosing the error.
Returns the number of supported vertical resolutions which can be used by the opened source in its
current configuration.
If Success, non zero: The number of supported vertical resolutions. Else 0 if fail. Use WiaGetLastError() methods for diagnosing the error.
Returns a supported vertical resolution which can be used by the opened source in its current configuration.
Index of the supported vertical resolution. Must be a value between 1 and WiaGetAvailableVerticalResolutionCount() returned value.
The supported vertical resolution.
Tries to set the current horizontal resolution.
Resolution is in dots per inch.
The new resolution.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Returns the current horizontal resolution in Dot per inch of the selected device.
If success, non-zero value. If fail, -1. Use WiaGetLastError() methods for diagnosing the error.
Returns the number of supported horizontal resolutions which can be used by the opened source in its current configuration.
If Success, non zero: The number of supported horizontal resolutions. Else 0 if fail. Use WiaGetLastError() methods for diagnosing the error.
Returns a supported horizontal resolution which can be used by the opened source in its current configuration.
Index of the supported horizontal resolution. Must be a value between 1 and WiaGetAvailableHorizontalResolutionCount() returned value.
The supported horizontal resolution.
Returns the number of supported brightness values which can be used by the opened source in its current configuration.
If Success, non zero: The number of supported brightness values. Else 0 if fail. Use WiaGetLastError() methods for diagnosing the error.
Returns the brightness value of the selected device.
If success: The standard *says* that the range for this cap is -1000 ... +1000. If fail,
Returns -99999. Use WiaGetLastError() methods for diagnosing the error.
Tries to set the current brightness.
The new brightness.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Returns a supported brightness value which can be used by the opened source in its current
configuration.
Index of the supported brightness value. Must be a value between 1 and
WiaGetAvailableBrightnessCount() returned value.
The supported brightness value.
Returns the number of supported contrast values which can be used by the opened source in its current configuration.
If Success, non zero: The number of supported contrast values. Else 0 if fail. Use WiaGetLastError() methods for diagnosing the error.
Returns the contrast value of the selected device.
If success: The standard *says* that the range for this cap is -1000 ... +1000. If fail,
Returns -99999. Use WiaGetLastError() methods for diagnosing the error.
Tries to set the current contrast.
The new contrast.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Returns a supported contrast value which can be used by the opened source in its current
configuration.
Index of the supported contrast value. Must be a value between 1 and
WiaGetAvailableContrastCount() returned value.
The supported contrast value.
Returns the current image intent setting for the selected device.
The driver chooses the bit depth, in dots per inch, and other settings that it determines are appropriate for the selected intent.
A member of the WiaImageIntent enumeration.
Returns the number of available image from the selected device, for example: the number of pictures
stored on the memory card of a digital camera.
A member of the WiaImageIntent enumeration.
Sets the index of the image to be transferred from the selected device.
The index of the image to be acquired. Must be a value between 1 and
WiaGetImageCount().
A member of the GdPictureStatus enumeration.
Gets the extension of the image to be transferred from the selected device.
A member of the GdPictureStatus enumeration.
\Sets the current image intent setting for the selected device.
The driver chooses the bit depth, in dots per inch, and other settings that it determines are appropriate for the selected intent.
The image intent to set.
True if success, False otherwise. Use WiaGetLastError() methods for diagnosing the error.
Returns the number of supported image intents which can be used by the opened source in its current configuration.
If Success, non zero: The number of supported image intents. Else 0 if fail. Use WiaGetLastError() methods for diagnosing the error.
Returns a supported image intent which can be used by the opened source in its current configuration.
Index of the supported image intent. Must be a value between 1 and WiaGetAvailableImageIntentCount() returned value.
A member of the WiaImageIntent enumeration.
Returns the current bits per pixel setting for the selected device.
The current bits per pixel setting.
Sets the current bits per pixel setting for the selected device.
The number of bits per pixel.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Returns the current channels per pixel setting for the selected device.
The current channels per pixel setting.
Sets the current channels per pixel setting for the selected device.
The number of channels per pixel.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Specifies the physical area (a rectangle) to be acquired during the next image transfer.
Horizontal start position of the area to scan measured in inches.
Vertical start position of the area to scan measured in inches.
Width of the area to scan measured in inches.
Height of the area to scan measured in inches.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Gets the current paper size.
A member of the WiaPageSize enumeration.
Sets the current paper size.
Page size. A member of the WiaPageSize enumeration.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Returns the physical area (a rectangle) to be acquired during the next image transfer.
Output parameter. Horizontal start position of the area to scan measured in inches.
Output parameter. Vertical start position of the area to scan measured in inches.
Output parameter. Width of the area to scan measured in inches.
Output parameter. Height of the area to scan measured in inches.
True if success, else False. Use WiaGetLastError() methods for diagnosing the error.
Returns the height of the bed of the current device.
The height of the bed in inches.
Returns the width of the bed of the current device.
The width of the bed in inches.
Returns the height of the feeder of the current device.
The height of the feeder in inches.
Returns the width of the feeder of the current device.
The width of the feeder in inches.
Disposes already used GdPictureImaging object completely. All related resources used by this object are released.
Be aware, that all unreleased images (GdPicture images) allocated by this object will remain available in the memory
until they are destroyed by the method of any other GdPictureImaging object.
You can also use the method to destroy all allocated image resources
from the memory in one step.
Please note that you need to release all allocated image resources after being used.
GdPictureImaging Constructor
A standard constructor for the GdPictureImaging class. It initializes an instance of the GdPictureImaging class, which subsequently represents
a wrapper for all the image resources you want to process. You will need this object to perform all available operations with your image files.
Processed image resources are identified by their unique image indentifier, so you need to initialize only one GdPictureImaging object
to handle all your image files.
As the best practice, we recommend going with one GdPictureImaging object for all processing image resources.
At the same, be aware, that you need to release all allocated image resources after being used.
Provides multi-zone OCR (Optical Character Recognition) functionality for processing different regions
of an image with independent configuration settings.
The class enables advanced OCR scenarios where different zones
within a single image require different processing configurations. Each zone can have its own:
- OCR context mode (single line, word, document, sparse text, etc.)
- Character filtering (whitelist/blacklist)
- Character size constraints
- Dictionary settings
- Speed vs. accuracy tradeoff
This class wraps the Tesseract OCR engine and provides GdPicture-specific enhancements including
advanced preprocessing, refinement algorithms, and result extraction methods.
Initializes a new instance of the class with default settings.
The constructor initializes the toolkit, resets all parameters to defaults, and sets up the
OCR results storage. If Tesseract dictionaries are available in a default location, the
is automatically configured.
Default values:
- OCRMode:
- MaxThreadCount: Number of processor cores
- OrientationDetectionAccuracyLevel: 10 (maximum)
- Timeout: 0 (no timeout)
- EnablePreprocessing: true
Initializes a new instance of the class with specified settings.
The OCR settings to apply. If null, default settings will be used.
The constructor initializes the toolkit, applies the provided settings (or defaults if null),
and sets up the OCR results storage. If a resources folder is not specified in settings and
Tesseract dictionaries are available in a default location, the
is automatically configured.
Gets or sets the path to the folder containing Tesseract OCR dictionary files (.traineddata).
The full path to the resources folder, or an empty string if not set.
This folder should contain the Tesseract language data files (*.traineddata) required for
OCR processing. When set, the class automatically scans the folder to populate the list
of available languages accessible via .
If not explicitly set, the property defaults to the system's Tesseract dictionary path
as determined by the constructor. Changing this property resets any previously selected
dictionaries via or .
Common locations for Tesseract data files:
- Windows: C:\Program Files\GdPicture.NET 14\Redist\Tesseract
- Linux: /usr/share/tesseract-ocr/tessdata/
Resets all OCR parameters to their default values.
A indicating the operation result. Returns on success.
This method restores all settings to their initial defaults:
- OCRMode:
- MaxThreadCount: Number of processor cores
- OrientationDetectionAccuracyLevel: 10
- Timeout: 0 (no timeout)
- ResourcesFolder: Empty string
Additionally, this method clears all selected dictionaries (set via
or ) and resets any custom Tesseract variables set via
.
Applies the specified OCR settings to this instance.
The settings to apply.
This method updates all configurable OCR parameters based on the provided settings object.
Any previously configured custom Tesseract variables are cleared when applying new settings.
Clears all selected language dictionaries.
A indicating the operation result. Returns on success.
This method removes all languages that were added via or
. After calling this method, the OCR engine will use
the default English dictionary unless languages are added again.
This is useful when you need to switch between different language sets during processing
without resetting other OCR parameters.
Gets the number of available language dictionaries in the current .
The count of available language dictionaries, or 0 if no resources folder is set or no dictionaries are found.
This method returns the number of recognized Tesseract language data files (.traineddata) found
in the . Only languages that are mapped in the internal language
dictionary are counted.
Use to retrieve individual language identifiers by index,
or to get all available languages at once.
Retrieves the language identifier at the specified index from the list of available languages.
The zero-based index of the language to retrieve.
An value representing the language at the specified index,
or if the index is out of range.
The index must be between 0 and - 1.
If an invalid index is provided, will return .
This method is useful for iterating through all available languages in the current
.
Retrieves a list of all available language dictionaries in the current .
A list of values representing all available languages,
or null if no resources folder is configured.
This method returns a copy of the internal language list. Only languages with corresponding
.traineddata files in the are included.
If the method returns null, check which will return
, indicating that no resources folder has been set.
Adds a custom dictionary for OCR processing by specifying its filename (without extension).
The dictionary filename without the .traineddata extension (e.g., "eng" for eng.traineddata).
A indicating the operation result.
Returns on success,
if the dictionary file doesn't exist,
or if the parameter is null or whitespace.
This method allows you to load custom-trained Tesseract dictionaries that may not be part of
the standard enumeration. The dictionary file must exist in the
current .
You can add multiple dictionaries, and they will be combined during OCR processing. This is
useful for multilingual documents or when using specialized dictionaries for technical terminology.
Adds a language dictionary for OCR processing using a predefined language identifier.
An value specifying the language to add.
A indicating the operation result.
Returns on success,
if the dictionary file doesn't exist,
or if the language is .
This method adds the specified language dictionary for use during OCR processing. The corresponding
.traineddata file must exist in the current . Multiple languages
can be added for multilingual OCR.
When multiple languages are added, Tesseract will use all of them during recognition, which may
improve accuracy for multilingual documents but can increase processing time.
Adds a language dictionary using a Tesseract language code string.
The Tesseract language code (e.g., "eng", "fra", "deu").
A indicating the operation result.
This is a convenience method that parses the language code string and calls
. Common language codes include:
eng (English), fra (French), deu (German), spa (Spanish), ita (Italian),
por (Portuguese), nld (Dutch), rus (Russian), chi_sim (Chinese Simplified),
chi_tra (Chinese Traditional), jpn (Japanese), kor (Korean), ara (Arabic).
Parses a Tesseract language code string (e.g. "eng", "fra") to the corresponding
enum value. Returns when
the code is not recognised.
Sets a Tesseract configuration variable to customize OCR behavior.
The name of the Tesseract variable to set.
The value to assign to the variable.
A indicating the operation result. Returns on success.
This method allows direct access to Tesseract's internal configuration variables for advanced
customization. These variables control low-level OCR engine behavior beyond what is exposed
through standard properties.
Common Tesseract variables include:
- load_system_dawg - Load main dictionary (0 or 1)
- load_freq_dawg - Load frequent words dictionary (0 or 1)
- language_model_penalty_non_dict_word - Penalty for non-dictionary words
- language_model_penalty_non_freq_dict_word - Penalty for infrequent words
- tessedit_char_whitelist - Allowed characters (whitelist)
- tessedit_char_blacklist - Forbidden characters (blacklist)
Note: Variables set through this method are cleared when is called.
Detects and returns the orientation of the current image.
The detected rotation angle in degrees. Possible values are 0, 90, 180, or 270 degrees.
This method performs orientation detection on the image set via .
It runs a lightweight OCR analysis to determine if the page has been rotated and returns
the clockwise rotation angle needed to correct the orientation.
The accuracy of detection is controlled by the property.
Note that this method does not automatically correct the orientation; it only detects it.
Check after calling this method to verify success.
Gets the detected page rotation angle from a completed OCR result.
The unique identifier of the OCR result, as returned by .
The rotation angle in degrees (0, 90, 180, or 270), or 0 if the result ID is invalid.
This method retrieves the page rotation that was detected during OCR processing when
the EnableOrientationDetection was enabled. The rotation angle indicates
how much the page was rotated from its correct orientation.
If the OCR result ID is invalid, will return .
Gets the detected page skew angle from a completed OCR result.
The unique identifier of the OCR result, as returned by .
The skew angle in degrees, or 0 if the result ID is invalid. Positive values indicate
clockwise skew, negative values indicate counterclockwise skew.
This method retrieves the page skew (tilt) that was detected during OCR processing when
was enabled. The skew angle represents how much the
text lines deviate from horizontal alignment.
Typical skew angles range from -45° to +45°. The OCR engine automatically compensates
for detected skew during recognition to improve accuracy.
If the OCR result ID is invalid, will return .
Performs multi-zone OCR on the current image using the specified zones.
A list of objects defining the regions to process and their configurations.
Outputs a list of objects, one for each zone, containing the detailed OCR results.
A unique identifier (OCR result ID) for the combined OCR results, which can be used with result extraction
methods, or an empty string if the operation fails.
This method processes multiple zones on the image set via , with each zone
having independent OCR settings. The zones are processed according to their individual configurations,
and the results are stored internally for later retrieval.
The returned OCR result ID can be used with methods like ,
, ,
and many others to extract and export the OCR results.
Use to check the operation status. Release results when no longer needed using
or .
Performs multi-zone OCR on the current image using the specified zones and stores results with a custom identifier.
A custom identifier for storing the OCR results. If null or empty, an automatic ID will be generated.
Must be unique; if the ID already exists, the method will fail.
A list of objects defining the regions to process and their configurations.
Outputs a list of objects, one for each zone, containing the detailed OCR results.
The OCR result ID (either the provided custom ID or an auto-generated one) if successful,
or an empty string if the operation fails.
This overload allows you to specify a custom identifier for the OCR results, making it easier to
manage and reference specific result sets. If the specified ID already exists in storage,
will return .
Common use case: When processing multiple pages, you can use page numbers or descriptive names
as result IDs (e.g., "page_1", "invoice_header", etc.).
Performs specialized multi-zone OCR with a specific context mode (MICR, MRZ, etc.).
The special OCR context to use, such as ,
, or .
A list of objects defining the regions to process.
Outputs a list of objects containing the detailed OCR results for each zone.
A unique identifier for the OCR results if successful, or an empty string if the operation fails.
This overload is used for specialized OCR scenarios that require specific recognition algorithms:
- - Magnetic Ink Character Recognition (E13B font)
- - MICR CMC7 font (used in European checks)
- - Machine Readable Zone (passports, ID cards)
Note: Using specialized contexts may require additional licensing features.
Check for licensing-related errors.
Serializes an OCR result to a string representation for storage or transmission.
The unique identifier of the OCR result to serialize.
A string containing the serialized OCR result data, or an empty string if the operation fails.
This method converts the complete OCR result (including page layout, text, positions, confidence
scores, and all hierarchical data) into a string format that can be stored in a database, file,
or transmitted over a network.
The serialized data can be deserialized back into a object using
the PageLayout deserialization methods.
If the OCR result ID is invalid, will return .
Other errors during serialization will be reflected in the status as well.
Sets the image to be processed by OCR.
The unique identifier of a GdPicture image object.
A indicating the operation result. Returns on success.
This method must be called before or
to specify which image should be processed. The image must be
a valid GdPicture image created through the GdPicture.NET imaging toolkit.
The image is referenced internally and should not be released until OCR processing is complete.
For best OCR results, images should have a resolution of at least 300 DPI and good contrast.
Releases a specific OCR result from memory.
The unique identifier of the OCR result to release.
A indicating the operation result.
Returns if the result was successfully released,
or if the result ID is invalid.
This method removes the specified OCR result from internal storage, freeing the associated memory.
Once released, the result ID can no longer be used with result extraction methods.
It's recommended to release OCR results when they are no longer needed to minimize memory usage,
especially when processing large numbers of pages or zones.
Releases all OCR results from memory.
A indicating the operation result. Always returns .
This method clears all stored OCR results, freeing associated memory. After calling this method,
all previously returned OCR result IDs become invalid and cannot be used with result extraction methods.
Use this method when you've finished processing all results and want to ensure complete cleanup,
or when starting a new batch of OCR operations.
Calculates the average confidence score across all recognized words in an OCR result.
The unique identifier of the OCR result.
The average confidence score as an integer between 0 and 100, where 100 represents highest confidence,
or 0 if the result ID is invalid.
This method provides a quick quality metric for the overall OCR result. Higher average confidence
scores generally indicate better recognition quality, though individual word confidences may vary.
The confidence score is computed by averaging the confidence values of all recognized words in the result.
Use this to assess OCR quality or decide whether manual verification is needed.
If the OCR result ID is invalid, will return .
Gets the number of text blocks in the OCR result.
The unique identifier of the OCR result obtained from .
The count of text blocks, or 0 if the OCR result ID is invalid.
A block represents a rectangular region of the page containing text with consistent properties
such as type, orientation, and writing direction. The OCR engine automatically segments the
page into blocks during the layout analysis phase.
Use this method to determine the range for iterating through blocks with other Block-related
methods like , , etc.
If the method fails (returns 0), check to determine the error.
A status of indicates an invalid OCR result ID.
Gets the type classification of the specified text block.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
An value representing the block's content type, or if invalid parameters are provided.
Block types classify the content and purpose of text regions. Common types include:
- - Regular paragraph text
- - Title or heading text
- - Sidebar or callout text
- - Table content
- - Vertically oriented text
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or block index.
Gets the special format classification of the specified text block.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
An value representing the block's special format type, or if invalid parameters are provided or no special format is detected.
Special formats identify structured data patterns within text blocks, such as:
- - Magnetic Ink Character Recognition (bank checks)
- - Machine Readable Zone (passports, ID cards)
- - No special format detected
When a special format is detected, use to retrieve
the structured data extracted from that format.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or block index.
Gets the structured data extracted from a block with a special format.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
A string containing the structured special format data, or an empty string if invalid parameters are provided or no special format data is available.
This method retrieves the parsed and structured data from blocks with special formats such as
MICR (bank check routing/account numbers) or MRZ (passport/ID card data).
The format and content of the returned string depends on the
value returned by :
- For : Contains routing number, account number, and check number
- For : Contains structured passport or ID card data
- For : Returns empty string
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or block index.
Gets the writing direction of text within the specified block.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
An value indicating the text flow direction, or if invalid parameters are provided.
The writing direction indicates how text flows within the block:
- - Latin, Cyrillic scripts (English, French, Russian, etc.)
- - Arabic, Hebrew scripts
- - Traditional Chinese, Japanese vertical text
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or block index.
Gets the orientation angle of the specified text block.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
An value indicating the block's rotation angle, or if invalid parameters are provided.
The orientation represents the rotation of the text block relative to the page's normal orientation:
- - 0° (normal orientation)
- - 90° clockwise
- - 180° rotation
- - 270° clockwise (90° counter-clockwise)
This value is determined during the orientation detection phase if is enabled.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or block index.
Gets the top coordinate of the specified block's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
The Y-coordinate of the top edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle.
Gets the left coordinate of the specified block's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
The X-coordinate of the left edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle.
Gets the bottom coordinate of the specified block's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
The Y-coordinate of the bottom edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle.
Gets the right coordinate of the specified block's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
The X-coordinate of the right edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle.
Gets the number of paragraphs contained within the specified block.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
The count of paragraphs in the block, or 0 if invalid parameters are provided.
A paragraph is a group of text lines that form a logical unit within a block. The OCR engine
detects paragraph boundaries based on spacing, indentation, and layout analysis.
Use this method with to iterate through
all paragraphs in a specific block.
Gets the index of the first paragraph in the specified block.
The unique identifier of the OCR result obtained from .
The zero-based index of the block. Must be between 0 and - 1.
The zero-based index of the first paragraph within the block, or 0 if invalid parameters are provided.
Gets the total number of paragraphs recognized in the OCR result.
The unique identifier of the OCR result obtained from .
The total count of paragraphs across all blocks in the OCR result, or 0 if invalid parameters are provided.
A paragraph is a logical grouping of text lines within a block. The OCR engine detects paragraph
boundaries based on spacing, indentation, and layout analysis. Each paragraph represents a cohesive
unit of text, such as a paragraph in a document or a distinct section of text.
Gets the top coordinate of the specified paragraph's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the paragraph. Must be between 0 and - 1.
The Y-coordinate of the top edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle of the paragraph.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or paragraph index.
Gets the left coordinate of the specified paragraph's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the paragraph. Must be between 0 and - 1.
The X-coordinate of the left edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle of the paragraph.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or paragraph index.
Gets the bottom coordinate of the specified paragraph's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the paragraph. Must be between 0 and - 1.
The Y-coordinate of the bottom edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle of the paragraph.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or paragraph index.
Gets the right coordinate of the specified paragraph's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the paragraph. Must be between 0 and - 1.
The X-coordinate of the right edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle of the paragraph.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or paragraph index.
Gets the text alignment (justification) of the specified paragraph.
The unique identifier of the OCR result obtained from .
The zero-based index of the paragraph. Must be between 0 and - 1.
An value indicating the paragraph's text alignment, or if invalid parameters are provided.
The justification property indicates how text is aligned within the paragraph:
- - Text is aligned to the left margin (most common for Western languages)
- - Text is centered between margins
- - Text is aligned to the right margin
- - Alignment could not be determined
The OCR engine determines justification by analyzing the spacing and alignment patterns of text lines
within the paragraph. This information can be useful for document layout reconstruction and formatting.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or paragraph index.
Gets the number of text lines contained within the specified paragraph.
The unique identifier of the OCR result obtained from .
The zero-based index of the paragraph. Must be between 0 and - 1.
The count of text lines in the paragraph, or 0 if invalid parameters are provided.
A text line represents a single horizontal line of text within the paragraph. Use this method
in combination with to iterate through
all text lines in a specific paragraph.
Gets the index of the parent block that contains the specified paragraph.
The unique identifier of the OCR result obtained from .
The zero-based index of the paragraph. Must be between 0 and - 1.
The zero-based index of the parent block, or 0 if invalid parameters are provided.
This method returns the index of the block that contains the specified paragraph, allowing you
to navigate from paragraph level up to block level in the OCR result hierarchy. The hierarchy
is structured as: Blocks contain Paragraphs, which contain Text Lines, which contain Words, which contain Characters.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or paragraph index.
Gets the index of the first text line in the specified paragraph.
The unique identifier of the OCR result obtained from .
The zero-based index of the paragraph. Must be between 0 and - 1.
The zero-based index of the first text line within the paragraph, or -1 if invalid parameters are provided.
Use this method in combination with to iterate through
all text lines in a paragraph. Text lines within a paragraph are stored sequentially, so you can access
them by adding an offset to the first line index.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or paragraph index.
Gets the total number of text lines in the OCR result.
The unique identifier of the OCR result obtained from .
The total count of text lines across all paragraphs and blocks, or 0 if the OCR result ID is invalid.
A text line represents a single horizontal line of text within a paragraph. Text lines are the building blocks
of paragraphs and contain one or more words. This method returns the total number of text lines across the entire
OCR result, allowing you to iterate through all text lines sequentially.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID.
Gets the top coordinate of the specified text line's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the text line. Must be between 0 and - 1.
The Y-coordinate of the top edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle of the text line.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or text line index.
Gets the left coordinate of the specified text line's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the text line. Must be between 0 and - 1.
The X-coordinate of the left edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle of the text line.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or text line index.
Gets the bottom coordinate of the specified text line's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the text line. Must be between 0 and - 1.
The Y-coordinate of the bottom edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle of the text line.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or text line index.
Gets the right coordinate of the specified text line's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the text line. Must be between 0 and - 1.
The X-coordinate of the right edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0).
Use in conjunction with , ,
and to get the complete bounding rectangle of the text line.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or text line index.
Gets the number of words contained within the specified text line.
The unique identifier of the OCR result obtained from .
The zero-based index of the text line. Must be between 0 and - 1.
The count of words in the text line, or 0 if invalid parameters are provided.
A word represents a sequence of characters separated by whitespace. Use this method
in combination with to iterate through
all words in a specific text line.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or text line index.
Gets the recognized text content of the specified text line.
The unique identifier of the OCR result obtained from .
The zero-based index of the text line. Must be between 0 and - 1.
The text string containing all recognized text in the line, including spaces between words, or an empty string if invalid parameters are provided.
This method reconstructs the complete text content of a text line by concatenating all words
in the line with their appropriate spacing. The text preserves the spacing between words as
detected by the OCR engine.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or text line index.
Gets the index of the parent paragraph that contains the specified text line.
The unique identifier of the OCR result obtained from .
The zero-based index of the text line. Must be between 0 and - 1.
The zero-based index of the parent paragraph, or 0 if invalid parameters are provided.
This method returns the index of the paragraph that contains the specified text line, allowing you
to navigate from text line level up to paragraph level in the OCR result hierarchy. The hierarchy
is structured as: Blocks contain Paragraphs, which contain Text Lines, which contain Words, which contain Characters.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or text line index.
Gets the index of the first word in the specified text line.
The unique identifier of the OCR result obtained from .
The zero-based index of the text line. Must be between 0 and - 1.
The zero-based index of the first word within the text line, or -1 if invalid parameters are provided.
Use this method in combination with to iterate through
all words in a text line. Words within a text line are stored sequentially, so you can access
them by adding an offset to the first word index.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or text line index.
Gets the total number of words recognized in the OCR result.
The unique identifier of the OCR result obtained from .
The total count of words in the OCR result, or 0 if invalid parameters are provided.
Words are individual recognized text units within text lines. Each word represents a sequence of
characters separated by whitespace. Use this method to determine the total number of words across
all text lines in the OCR result.
Words are indexed from 0 to - 1. Use word indices with other
word-level methods such as , ,
and position methods to access detailed information about each word.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID.
Gets the recognized text string for the specified word.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The recognized text string of the word, or an empty string if invalid parameters are provided.
This method returns the complete text content of a word by concatenating all characters that
belong to it. Words are individual text units within text lines, typically separated by whitespace
in the original document.
Use this method in combination with other word-level methods to extract detailed information
about each word, including its position, confidence score, and language detection results.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the parent text line index for the specified word.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The zero-based index of the parent text line, or 0 if invalid parameters are provided.
This method identifies which text line contains the specified word. Text lines are horizontal
sequences of words in the recognized text. Use this method to navigate from word-level to
line-level information in the OCR result hierarchy.
The OCR result has a hierarchical structure: zones contain text blocks, blocks contain paragraphs,
paragraphs contain text lines, text lines contain words, and words contain characters.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the estimated font size of the specified word in pixels.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The estimated font size in pixels (rounded to nearest integer), or 0 if invalid parameters are provided.
The font size is estimated based on the heights of characters within the word. This provides
an approximation of the original font size in the source document, measured in pixels rather
than points. The value is useful for layout analysis, text formatting, and identifying
headings or emphasized text.
Font size estimation considers character heights and baseline positioning. Larger font sizes
typically indicate headings, titles, or emphasized text, while smaller sizes suggest body text
or footnotes.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the top Y-coordinate of the specified word's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The Y-coordinate of the top edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0), with Y values
increasing downward. Use in conjunction with ,
, and to get
the complete bounding rectangle of the word.
The bounding rectangle represents the minimum rectangular area that contains all pixels
of the word. This information is essential for highlighting recognized words, creating
clickable regions, or performing layout analysis.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the left X-coordinate of the specified word's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The X-coordinate of the left edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0), with X values
increasing rightward. Use in conjunction with ,
, and to get
the complete bounding rectangle of the word.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the bottom Y-coordinate of the specified word's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The Y-coordinate of the bottom edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0), with Y values
increasing downward. Use in conjunction with ,
, and to get
the complete bounding rectangle of the word.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the right X-coordinate of the specified word's bounding rectangle.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The X-coordinate of the right edge in pixels, or 0 if invalid parameters are provided.
Coordinates are relative to the top-left corner of the original image (0,0), with X values
increasing rightward. Use in conjunction with ,
, and to get
the complete bounding rectangle of the word.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the number of spaces that should precede the specified word for proper text reconstruction.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The number of spaces before the word, or 0 if invalid parameters are provided or no spaces precede the word.
This value helps reconstruct the original spacing and layout of the text by indicating how many
space characters should be inserted before a word. The OCR engine analyzes horizontal gaps between
words and estimates the appropriate number of spaces based on average character width.
A value of 0 indicates the word is at the start of a line or immediately follows another word
without spacing. Values greater than 1 indicate multiple consecutive spaces, which often occur
in tabular data, aligned columns, or indented text.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the confidence score for the specified word, indicating OCR recognition accuracy.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
A confidence score from 0 to 100, where higher values indicate better recognition accuracy,
or 0 if invalid parameters are provided.
The confidence score represents the OCR engine's certainty about the recognition accuracy
of a word. Scores range from 0 (lowest confidence) to 100 (highest confidence). Higher
scores generally indicate clearer source text, better image quality, or words validated
against dictionaries.
Word confidence is typically calculated as the average of character-level confidence scores.
Low confidence scores may indicate poor image quality, unusual fonts, degraded text, or
words not found in the active dictionaries.
Use confidence scores to:
- Filter out unreliable recognition results
- Prioritize manual review of low-confidence words
- Assess overall OCR quality for a document
- Trigger fallback processing for poor-quality regions
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets a value indicating whether the specified word was found and validated in a dictionary.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
if the word was found in a dictionary; if not found in
any dictionary or if invalid parameters are provided.
Dictionary validation is an important quality indicator for OCR results. When the OCR engine
finds a word in its active language dictionaries, it typically indicates higher recognition
accuracy. Words not found in dictionaries may be:
- Proper nouns (names, places, brands)
- Technical terms or domain-specific jargon
- Abbreviations or acronyms
- Numbers or alphanumeric codes
- Misspellings or recognition errors
Dictionary validation can help distinguish between legitimate out-of-vocabulary words and
actual recognition errors. Combine this with for
more robust quality assessment.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the detected language code for the specified word.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
A language code string (e.g., "eng" for English, "fra" for French, "deu" for German),
or an empty string if invalid parameters are provided or language detection was not performed.
The OCR engine can detect the language of individual words, which is especially useful for
multilingual documents. The language code follows ISO 639-3 standards (three-letter codes)
for Tesseract language data files. Common language codes include:
- "eng" - English
- "fra" - French
- "deu" - German
- "spa" - Spanish
- "ita" - Italian
- "por" - Portuguese
- "jpn" - Japanese
- "chi_sim" - Simplified Chinese
Language detection is based on character patterns, dictionary matches, and statistical analysis.
When multiple languages are configured for OCR processing, the engine automatically selects
the most probable language for each word.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the number of characters in the specified word.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The count of characters in the word, or 0 if invalid parameters are provided.
This method returns the total number of characters that compose a word. Use it in combination
with to iterate through all characters
within a specific word and access character-level details such as individual confidence scores,
positions, and character values.
Character-level iteration enables fine-grained analysis of OCR results, including:
- Identifying specific characters with low confidence
- Analyzing character spacing and kerning
- Extracting glyph-level positioning for advanced layout reconstruction
- Performing character-by-character validation or correction
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the index of the first character in the specified word.
The unique identifier of the OCR result obtained from .
The zero-based index of the word. Must be between 0 and - 1.
The zero-based index of the first character within the word, or -1 if invalid parameters are provided.
Use this method in combination with to iterate through
all characters within a word. Characters belonging to a word are stored sequentially in the character
array, so you can access them by adding an offset to the first character index.
This enables detailed character-level analysis, which is particularly useful for:
- Quality assurance - examining individual character confidence scores
- Custom post-processing - applying character-level corrections
- Advanced typography - analyzing character spacing and positioning
- Glyph extraction - obtaining precise character bounding boxes
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or word index.
Gets the total number of characters recognized across all text zones in the OCR result.
The unique identifier of the OCR result obtained from .
The total count of characters in the OCR result, or 0 if an invalid OCR result ID is provided.
Characters represent the finest level of granularity in the OCR hierarchy (zones → blocks → lines → words → characters).
Each character is an individual glyph or letter recognized by the OCR engine, such as 'A', '5', or '&'.
This method returns the total number of characters across all zones, blocks, lines, and words in the OCR result.
Use it to iterate through all characters sequentially using character-level methods like:
- - Gets the character's value
- - Gets the recognition confidence
- , , , - Gets the character's bounding box coordinates
- - Gets alternative recognition candidates
- - Gets the parent word index
Character-level access is useful for:
- Fine-grained confidence analysis at the glyph level
- Character-by-character positioning for precise text extraction
- Identifying and correcting low-confidence characters
- Analyzing character alternatives for ambiguous recognitions (e.g., '0' vs 'O', '1' vs 'l')
- Building custom text validation or correction logic
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID.
Gets the top Y coordinate of the specified character's bounding box in pixels.
The unique identifier of the OCR result obtained from .
The zero-based index of the character. Must be between 0 and - 1.
The top Y coordinate of the character's bounding box in pixels, or 0 if invalid parameters are provided.
This method returns the top edge Y coordinate of the character's bounding box, representing the vertical position
of the uppermost point of the character glyph. The coordinate is measured in pixels from the top-left corner
of the image (origin at 0,0), and the bounding box has been transformed according to any image rotations
or transformations applied during OCR processing.
Use this method in combination with , ,
and to determine the complete bounding box of a character. This is useful for:
- Precise character positioning and layout reconstruction
- Visual highlighting or annotation of individual characters
- Character-level extraction and cropping from the source image
- Analyzing vertical alignment and baseline positioning
- Building custom redaction or masking at character granularity
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or character index.
Gets the left X coordinate of the specified character's bounding box in pixels.
The unique identifier of the OCR result obtained from .
The zero-based index of the character. Must be between 0 and - 1.
The left X coordinate of the character's bounding box in pixels, or 0 if invalid parameters are provided.
This method returns the left edge X coordinate of the character's bounding box, representing the horizontal position
of the leftmost point of the character glyph. The coordinate is measured in pixels from the top-left corner
of the image (origin at 0,0), and the bounding box has been transformed according to any image rotations
or transformations applied during OCR processing.
Use this method in combination with , ,
and to determine the complete bounding box of a character. This is useful for:
- Precise character positioning and horizontal alignment analysis
- Character spacing and kerning measurements
- Character-level text extraction at specific positions
- Building character-based coordinate mappings
- Detecting character overlaps or layout anomalies
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or character index.
Gets the bottom Y coordinate of the specified character's bounding box in pixels.
The unique identifier of the OCR result obtained from .
The zero-based index of the character. Must be between 0 and - 1.
The bottom Y coordinate of the character's bounding box in pixels, or 0 if invalid parameters are provided.
This method returns the bottom edge Y coordinate of the character's bounding box, representing the vertical position
of the lowermost point of the character glyph. The coordinate is measured in pixels from the top-left corner
of the image (origin at 0,0), and the bounding box has been transformed according to any image rotations
or transformations applied during OCR processing.
Use this method in combination with , ,
and to determine the complete bounding box of a character. This is useful for:
- Calculating character heights and vertical dimensions
- Analyzing baseline positions and text alignment
- Detecting descenders in characters like 'g', 'j', 'p', 'q', 'y'
- Vertical spacing and line height analysis
- Character-level image cropping and extraction
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or character index.
Gets the right X coordinate of the specified character's bounding box in pixels.
The unique identifier of the OCR result obtained from .
The zero-based index of the character. Must be between 0 and - 1.
The right X coordinate of the character's bounding box in pixels, or 0 if invalid parameters are provided.
This method returns the right edge X coordinate of the character's bounding box, representing the horizontal position
of the rightmost point of the character glyph. The coordinate is measured in pixels from the top-left corner
of the image (origin at 0,0), and the bounding box has been transformed according to any image rotations
or transformations applied during OCR processing.
Use this method in combination with , ,
and to determine the complete bounding box of a character. This is useful for:
- Calculating character widths and horizontal dimensions
- Measuring inter-character spacing and kerning
- Determining text flow direction and reading order
- Character-level image cropping with precise boundaries
- Detecting wide characters or ligatures
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or character index.
Gets the recognition confidence score for the specified character.
The unique identifier of the OCR result obtained from .
The zero-based index of the character. Must be between 0 and - 1.
A confidence value between 0 and 100, where 100 represents maximum confidence in the recognition accuracy,
or 0 if invalid parameters are provided.
Character confidence indicates how certain the OCR engine is about the recognition of an individual glyph.
This is the finest granularity of confidence measurement in the OCR hierarchy, providing insight into the
reliability of each recognized character. Higher values indicate greater certainty, while lower values
suggest the character recognition may be ambiguous or uncertain.
Confidence scores are useful for:
- Identifying potentially misrecognized characters for manual review
- Implementing quality thresholds for automated processing
- Prioritizing characters for alternative candidate analysis
- Building confidence heatmaps or visual quality indicators
- Training data selection for machine learning models
Character-level confidence can differ from word-level confidence. A word may have high overall confidence
even if individual characters vary in their confidence scores, or vice versa. Use character confidence
when you need fine-grained quality assessment of specific glyphs.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or character index.
Gets the recognized character value (glyph) at the specified index.
The unique identifier of the OCR result obtained from .
The zero-based index of the character. Must be between 0 and - 1.
The recognized character as a value, or a rejection character code if invalid parameters are provided.
This method returns the individual character (glyph) recognized by the OCR engine at the specified position.
Characters represent the finest granularity of text recognition and can include letters, digits, punctuation marks,
symbols, and whitespace characters. Each character is a single unit that, when combined with others, forms
words, lines, blocks, and zones in the OCR hierarchy.
Common use cases for character-level access:
- Fine-grained text extraction at the glyph level
- Character-by-character validation and correction
- Analyzing specific character patterns (e.g., finding all digits or punctuation)
- Building character frequency distributions for quality analysis
- Identifying potentially confused characters (e.g., '0' vs 'O', '1' vs 'l', '5' vs 'S')
When a character has low confidence or is ambiguous, consider checking alternative recognition candidates
using , ,
and . This enables you to implement
intelligent correction logic for common OCR confusions.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or character index.
Gets the number of alternative recognition candidates for the specified character.
The unique identifier of the OCR result obtained from .
The zero-based index of the character. Must be between 0 and - 1.
The number of alternative recognition candidates available for the character, or 0 if no alternatives exist or invalid parameters are provided.
Gets the character value of a specific alternative recognition candidate.
The unique identifier of the OCR result obtained from .
The zero-based index of the character. Must be between 0 and - 1.
The zero-based index of the alternative candidate. Must be between 0 and - 1.
The alternative character value as a , or a rejection character code if invalid parameters are provided.
Gets the confidence score for a specific alternative recognition candidate.
The unique identifier of the OCR result obtained from .
The zero-based index of the character. Must be between 0 and - 1.
The zero-based index of the alternative candidate. Must be between 0 and - 1.
A confidence value between 0 and 100 for the alternative character, where 100 represents maximum confidence,
or 0 if invalid parameters are provided.
Gets the total number of form fields detected in the OCR result.
The unique identifier of the OCR result obtained from .
The number of detected form fields, or 0 if no form fields were found or if invalid parameters are provided.
Form fields represent key-value pairs extracted from structured forms such as invoices, applications,
questionnaires, and other document templates. Each form field consists of:
- Key (Label): The field name or prompt text (e.g., "Name:", "Date:", "Total:", "Invoice Number:")
- Value: The filled-in data or content (e.g., "John Smith", "2024-01-15", "$100.00", "INV-2024-001")
- Type: The classification of the field (Text, Numeric, Date, Checkbox, etc.)
This method returns the total count of form fields, which can then be accessed individually using
zero-based indexing (0 to Count - 1) with the other form field methods:
- - Get the label/field name
- - Get the bounding box of the label
- - Get the filled-in value
- - Get the bounding box of the value
- - Get the field type classification
If the method fails, check to determine the error.
A status of indicates successful retrieval.
A status of indicates an invalid OCR result ID.
Gets the bounding rectangle of the form field's key (label) area.
The unique identifier of the OCR result obtained from .
The zero-based index of the form field. Must be between 0 and - 1.
Output parameter that receives the X-coordinate of the left edge of the key's bounding box in pixels.
Output parameter that receives the Y-coordinate of the top edge of the key's bounding box in pixels.
Output parameter that receives the width of the key's bounding box in pixels.
Output parameter that receives the height of the key's bounding box in pixels.
if the bounding rectangle was successfully retrieved, otherwise an error status.
Check with for detailed error information.
The bounding rectangle is defined by:
- Left: The X-coordinate of the left edge, measured in pixels from the image's left edge
- Top: The Y-coordinate of the top edge, measured in pixels from the image's top edge
- Width: The horizontal span of the rectangle in pixels
- Height: The vertical span of the rectangle in pixels
Coordinates are relative to the top-left corner of the original image (0,0), with X values increasing
rightward and Y values increasing downward. The bounding box is automatically transformed to account
for any image rotation or transformations applied during OCR processing.
Gets the recognized text content of the form field's key (label).
The unique identifier of the OCR result obtained from .
The zero-based index of the form field. Must be between 0 and - 1.
The text string containing the recognized key (label) text, or an empty string if invalid parameters are provided or no key text exists.
This method retrieves the OCR-recognized text of a form field's key (label), which is the descriptive
text that identifies the purpose of the field. The key text typically appears to the left of or above
the field value, and often ends with a colon or other punctuation.
Gets the bounding rectangle of the form field's value area.
The unique identifier of the OCR result obtained from .
The zero-based index of the form field. Must be between 0 and - 1.
Output parameter that receives the X-coordinate of the left edge of the value's bounding box in pixels.
Output parameter that receives the Y-coordinate of the top edge of the value's bounding box in pixels.
Output parameter that receives the width of the value's bounding box in pixels.
Output parameter that receives the height of the value's bounding box in pixels.
if the bounding rectangle was successfully retrieved, otherwise an error status.
Check with for detailed error information.
This method retrieves the spatial coordinates of a form field's value region. The value is the
filled-in data or content that corresponds to the field's key (label). Examples include:
- "John Smith" for a "Name:" field
- "2024-01-15" or "01/15/2024" for a "Date:" field
- "$1,234.56" or "1234.56" for amount fields
- "123 Main Street, Apt 4B" for an "Address:" field
- "john.doe@example.com" for an "Email:" field
- "[X]" or checkmark symbols for checkbox fields
The bounding rectangle is defined by:
- Left: The X-coordinate of the left edge, measured in pixels from the image's left edge
- Top: The Y-coordinate of the top edge, measured in pixels from the image's top edge
- Width: The horizontal span of the rectangle in pixels
- Height: The vertical span of the rectangle in pixels
Coordinates are relative to the top-left corner of the original image (0,0), with X values increasing
rightward and Y values increasing downward. The bounding box is automatically transformed to account
for any image rotation or transformations applied during OCR processing.
If the method fails, check to determine the error.
A status of indicates successful retrieval.
A status of indicates an invalid OCR result ID or field index.
Gets the classification type of the form field based on its content and structure.
The unique identifier of the OCR result obtained from .
The zero-based index of the form field. Must be between 0 and - 1.
A enumeration value representing the field's type classification, or if invalid parameters are provided.
This method returns the automatically detected type classification for a form field. The classification
is based on analysis of the field's content, formatting patterns, and contextual clues from the key (label) text.
This information helps applications process field values appropriately and apply correct validation rules.
If the method fails, check to determine the error.
A status of indicates successful retrieval.
A status of indicates an invalid OCR result ID or field index.
Gets the total number of key-value pairs detected in the OCR result through intelligent document understanding.
The unique identifier of the OCR result obtained from .
The number of detected key-value pairs, or 0 if no key-value pairs were found or if invalid parameters are provided.
Key-value pairs represent semantically linked label-data associations extracted from documents using advanced
natural language understanding and document structure analysis. Unlike simple form field extraction, key-value
pair detection employs machine learning to understand document semantics, context, and relationships between
text elements, making it suitable for both structured forms and semi-structured documents.
Key differences from form field extraction:
- Semantic Understanding: Uses NLP to understand field meanings and normalize field names
- Type Detection: Automatically classifies data types (dates, currencies, numbers, etc.)
- Association Strength: Evaluates the reliability of key-value relationships
- Flexible Layouts: Handles various document formats without rigid structure requirements
Note: This feature requires the Intelligent Document Processing license feature.
Key-value pair detection provides enhanced semantic understanding compared to traditional form field extraction.
Gets the key (label) text of a specific key-value pair from the OCR result.
The unique identifier of the OCR result obtained from .
The zero-based index of the key-value pair. Must be between 0 and - 1.
The key (label) text as it appears in the document, or an empty string if the key is null or if invalid parameters are provided.
This method retrieves the human-readable label or prompt text that identifies a data field in the document.
The key represents the descriptive text that precedes or identifies the associated value, such as "Invoice Number:",
"Total Amount:", "Customer Name:", "Date:", etc.
Gets the value (data) text of a specific key-value pair from the OCR result.
The unique identifier of the OCR result obtained from .
The zero-based index of the key-value pair. Must be between 0 and - 1.
The value (data) text as recognized from the document, or an empty string if the value is null or if invalid parameters are provided.
This method retrieves the actual data content associated with a key-value pair. The value represents
the filled-in information, user input, or data field content that corresponds to the key label.
This is the substantive information extracted from the document, such as "INV-2024-001" for an
invoice number, "$1,250.00" for a total amount, or "Acme Corporation" for a customer name.
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or pair index.
Gets the bounding rectangle coordinates of the key (label) text for a specific key-value pair.
The unique identifier of the OCR result obtained from .
The zero-based index of the key-value pair. Must be between 0 and - 1.
Returns the X-coordinate of the left edge of the bounding rectangle in pixels.
Returns the Y-coordinate of the top edge of the bounding rectangle in pixels.
Returns the width of the bounding rectangle in pixels.
Returns the height of the bounding rectangle in pixels.
A value indicating success or the specific error that occurred.
Returns on success, or if the OCR result ID or pair index is invalid.
This method retrieves the precise spatial coordinates of the key (label) text within the document image.
The bounding rectangle defines the smallest rectangle that fully contains all characters of the key text,
enabling visual highlighting, annotation, redaction, or region-based analysis of document fields.
Coordinate system and rectangle properties:
- Origin: Top-left corner of the image (0, 0)
- Left: X-coordinate of the leftmost edge of the key text
- Top: Y-coordinate of the topmost edge of the key text
- Width: Horizontal extent of the key text in pixels
- Height: Vertical extent of the key text in pixels
- Units: All coordinates are in pixels relative to the original image dimensions
- Right Edge: Can be calculated as Left + Width
- Bottom Edge: Can be calculated as Top + Height
If the method fails, check the returned value.
Common failure scenarios include invalid OCR result IDs, out-of-range pair indices,
or null key objects. When the method fails, all output parameters are set to 0.
Gets the bounding rectangle coordinates of the value (data) text for a specific key-value pair.
The unique identifier of the OCR result obtained from .
The zero-based index of the key-value pair. Must be between 0 and - 1.
Returns the X-coordinate of the left edge of the bounding rectangle in pixels.
Returns the Y-coordinate of the top edge of the bounding rectangle in pixels.
Returns the width of the bounding rectangle in pixels.
Returns the height of the bounding rectangle in pixels.
A value indicating success or the specific error that occurred.
Returns on success, or if the OCR result ID or pair index is invalid.
This method retrieves the precise spatial coordinates of the value (data) text within the document image.
The bounding rectangle defines the smallest rectangle that fully contains all characters of the value text,
enabling visual highlighting of extracted data, validation workflows, data masking, or extraction verification.
Coordinate system and rectangle properties:
- Origin: Top-left corner of the image (0, 0)
- Left: X-coordinate of the leftmost edge of the value text
- Top: Y-coordinate of the topmost edge of the value text
- Width: Horizontal extent of the value text in pixels
- Height: Vertical extent of the value text in pixels
- Units: All coordinates are in pixels relative to the original image dimensions
- Right Edge: Can be calculated as Left + Width
- Bottom Edge: Can be calculated as Top + Height
If the method fails, check the returned value.
Common failure scenarios include invalid OCR result IDs, out-of-range pair indices,
or null value objects. When the method fails, all output parameters are set to 0.
Gets the semantic data type classification of the value for a specific key-value pair.
The unique identifier of the OCR result obtained from .
The zero-based index of the key-value pair. Must be between 0 and - 1.
A enumeration value indicating the semantic classification of the value data,
or if the type could not be determined or if invalid parameters are provided.
This method provides intelligent semantic classification of extracted value data beyond simple text recognition.
Using natural language processing and pattern recognition, the system automatically identifies the type of
information represented by each value, enabling type-aware data processing, validation, and storage.
Common DataType classifications include:
- Text: General text content, names, descriptions, or unclassified strings
- Numeric: Pure numbers without specific semantic meaning (counts, quantities, IDs)
- Currency: Monetary amounts with or without currency symbols ($1,250.00, EUR 500, etc.)
- Date: Date values in various formats (01/15/2024, January 15, 2024, 2024-01-15, etc.)
- Time: Time values (10:30 AM, 14:45, etc.)
- DateTime: Combined date and time values
- Percentage: Percentage values (25%, 0.25, etc.)
- Phone: Telephone numbers in various formats
- Email: Email addresses
- URL: Web addresses and URLs
- Boolean: Yes/No, True/False, checkbox states
- Unknown: Type could not be determined or is ambiguous
Benefits of type-aware processing:
- Smart Validation: Apply type-specific validation rules (date ranges, currency formats, phone patterns)
- Proper Storage: Store values in appropriate database column types (DateTime, Decimal, etc.)
- Format Normalization: Convert values to standardized formats for consistency
- Type Conversion: Parse strings into strongly-typed objects for business logic
- Error Detection: Identify OCR errors by validating against expected types
- User Experience: Present appropriate UI controls (date pickers, numeric spinners, etc.)
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or pair index.
Gets the standardized public name (normalized field identifier) for a specific key-value pair.
The unique identifier of the OCR result obtained from .
The zero-based index of the key-value pair. Must be between 0 and - 1.
A standardized, machine-readable field identifier string (e.g., "invoice_number", "total_amount", "customer_name"),
or an empty string if the public name could not be determined or if invalid parameters are provided.
This method returns a normalized, standardized identifier for the field, enabling consistent programmatic
access to document data regardless of how the field label appears in the original document. The public name
provides semantic field identification that bridges the gap between human-readable labels and machine-processable identifiers.
Public name characteristics:
- Standardized Format: Uses snake_case convention (lowercase with underscores)
- Language Independent: Normalized to English regardless of source document language
- Consistent Across Variations: Maps multiple label variations to a single identifier
- Semantic Identity: Represents the meaning/purpose of the field, not just its label
- Machine-Friendly: Suitable for use as variable names, dictionary keys, or database column names
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or pair index.
An empty string may be returned if the field could not be mapped to a known public name.
Gets the OCR confidence score for a specific key-value pair, indicating the overall quality and reliability of the recognition.
The unique identifier of the OCR result obtained from .
The zero-based index of the key-value pair. Must be between 0 and - 1.
A confidence score between 0.0 and 100.0, where higher values indicate better recognition quality,
or 0.0 if the confidence could not be determined or if invalid parameters are provided.
This method returns a confidence score that reflects the OCR engine's assessment of recognition accuracy
for the key-value pair. The score combines multiple quality factors including character recognition certainty,
image quality, text clarity, and pattern matching confidence to provide an overall reliability metric.
Confidence score interpretation:
- 90-100: Excellent - Very high confidence, minimal risk of errors, suitable for automated processing
- 80-89: Good - High confidence, low error risk, appropriate for most automated workflows
- 70-79: Fair - Moderate confidence, some risk of errors, consider human review for critical data
- 60-69: Poor - Lower confidence, elevated error risk, recommend human verification
- Below 60: Very Poor - Low confidence, high error probability, requires manual review
Factors that influence confidence scores:
- Image Quality: Resolution, contrast, brightness, noise levels
- Text Clarity: Font readability, character distinctness, print quality
- Recognition Ambiguity: Similar-looking characters (O/0, I/l/1, S/5), unclear symbols
- Document Condition: Skew, wrinkles, stains, fading, degradation
- Layout Complexity: Overlapping text, dense layouts, unusual fonts
- Pattern Matching: How well the value matches expected patterns for its data type
If the method fails, check to determine the error.
A status of indicates an invalid OCR result ID or pair index.
Note: Confidence scores reflect OCR recognition quality but do not guarantee semantic correctness.
Combine confidence assessment with data type validation, pattern matching, and business logic for comprehensive quality control.
Determines whether the key-value association for a specific pair is strong and reliable based on spatial proximity and semantic analysis.
The unique identifier of the OCR result obtained from .
The zero-based index of the key-value pair. Must be between 0 and - 1.
true if the key-value association is considered strong and reliable; false if the association is weak, ambiguous, or uncertain,
or if invalid parameters are provided.
This method evaluates the reliability and certainty of the association between a key (label) and its corresponding value (data).
The intelligent document processing engine analyzes multiple factors including spatial relationships, layout patterns,
semantic context, and document structure to determine whether the detected pairing is trustworthy. Strong associations
indicate high confidence that the key and value are genuinely related, while weak associations suggest ambiguity or uncertainty.
Factors that determine association strength:
- Spatial Proximity: Keys and values that are physically close tend to have stronger associations
- Layout Alignment: Proper horizontal or vertical alignment between key-value pairs
- Consistent Patterns: Following recognized form patterns (label-colon-value, table structures, etc.)
- Semantic Coherence: The value type matches what would be expected for the key (e.g., "Date:" followed by a date)
- Clear Delineation: Unambiguous boundaries between fields, minimal interference from nearby text
- Strong Field Names: Keys with well-recognized, standard terminology (e.g., "Invoice Number:", "Total:")
- Layout Confidence: The overall document structure is clear and follows known patterns
Returns the number of columns in a specific table detected in the OCR result.
The unique identifier of the OCR result obtained from a multizone OCR operation.
The zero-based index of the table. Must be between 0 and GetTableCount() - 1.
The number of columns in the specified table. Returns 0 if:
- The OCR result ID is invalid
- The TableIdx is out of range
- The table has no columns (empty table)
This method returns the total number of columns (vertical divisions) in the table structure. Columns
represent the vertical organization of data, with each column typically containing related information
of the same type (e.g., all product names, all quantities, all prices).
Column indexing is zero-based, meaning valid column indices range from 0 to GetTableColumnCount() - 1.
Use this value to iterate through all columns when processing table data horizontally or when extracting
specific column data.
Common use cases include:
- Table structure validation: Verifying tables have expected column counts
- Data export: Determining CSV/Excel column dimensions before extraction
- Column-wise processing: Iterating through vertical data sets (e.g., summing all values in a price column)
- Layout analysis: Understanding table complexity and data organization
Check the operation status using . If this method returns 0 but you expected columns,
verify that the table index is valid and that the table was properly detected.
Related methods for table structure analysis:
- - Get the number of rows (horizontal divisions)
- - Get the bounding rectangle of a specific column
- - Extract text from cells using column and row indices
Returns the number of rows in a specific table detected in the OCR result.
The unique identifier of the OCR result obtained from a multizone OCR operation.
The zero-based index of the table. Must be between 0 and GetTableCount() - 1.
The number of rows in the specified table. Returns 0 if:
- The OCR result ID is invalid
- The TableIdx is out of range
- The table has no rows (empty table)
This method returns the total number of rows (horizontal divisions) in the table structure. Rows
represent the horizontal organization of data, with each row typically containing a complete record
or data entry (e.g., one invoice line item, one transaction, one person's information).
Row indexing is zero-based, meaning valid row indices range from 0 to GetTableRowCount() - 1.
The first row (index 0) often contains column headers, while subsequent rows contain data entries.
Use this value to iterate through all rows when processing table data vertically.
Common use cases include:
- Data counting: Determining the number of records, line items, or entries in a table
- Table structure validation: Verifying tables have expected row counts
- Data export: Determining CSV/Excel row dimensions before extraction
- Row-wise processing: Iterating through horizontal data sets (e.g., processing each invoice line item)
- Pagination: Calculating how many items are on a page or in a section
Check the operation status using . If this method returns 0 but you expected rows,
verify that the table index is valid and that the table was properly detected.
Related methods for table structure analysis:
- - Get the number of columns (vertical divisions)
- - Get the bounding rectangle of a specific row
- - Extract text from cells using row and column indices
- - Determine if a cell in a row is a header
Retrieves the bounding rectangle of a specific row within a table detected in the OCR result.
The unique identifier of the OCR result obtained from a multizone OCR operation.
The zero-based index of the table. Must be between 0 and GetTableCount() - 1.
The zero-based row index. Must be between 0 and GetTableRowCount() - 1.
Output parameter that receives the X-coordinate of the row's left edge, in pixels from the left of the image.
Output parameter that receives the Y-coordinate of the row's top edge, in pixels from the top of the image.
Output parameter that receives the width of the row bounding rectangle, in pixels.
Output parameter that receives the height of the row bounding rectangle, in pixels.
A value indicating the operation result:
- - The row rectangle was successfully retrieved
- - The OCR result ID is invalid, or any index is out of range
The row bounding rectangle represents the entire horizontal span of a table row, encompassing all
cells within that row from the leftmost column to the rightmost column. A row is a horizontal division
in the table structure that typically contains a complete data record or entry.
The coordinate system origin (0,0) is at the top-left corner of the OCR'd image. All measurements are in pixels
and correspond to the original image resolution. Row rectangles can be used for:
- Visual highlighting: Drawing borders or backgrounds for entire rows in UI applications
- Row extraction: Cropping specific rows for focused analysis or processing
- Height analysis: Identifying row sizing patterns, multi-line content, or spacing issues
- Header detection: Distinguishing header rows from data rows based on positioning
- Alternate row styling: Implementing zebra-striping or highlighting patterns
If the operation fails, all output parameters (Left, Top, Width, Height) are set to 0. Always check
the return value or call to verify success before using the rectangle coordinates.
Related methods for row operations:
- - Get the total number of rows in the table
- - Get rectangle for individual cells within the row
- - Extract text from cells in the row
- - Get rectangle for columns (vertical divisions)
- - Determine if cells in the row are headers
Extracts the recognized text from an OCR result with default formatting.
The unique identifier of the OCR result.
The recognized text as a string, or an empty string if the result ID is invalid.
This method extracts plain text from the OCR result with text formatting enabled, which attempts
to preserve paragraph structure, line breaks, and spacing from the original document layout.
This is equivalent to calling with EnableTextFormatting set to true.
Extracts the recognized text from an OCR result with optional formatting.
The unique identifier of the OCR result.
true to preserve document formatting (paragraphs, line breaks, spacing);
false to return unformatted text with minimal whitespace.
The recognized text as a string, or an empty string if the result ID is invalid.
When is true, the method attempts to preserve the
visual layout of the original document, including paragraph breaks, line spacing, and indentation.
This is useful when the document structure is important.
When is false, the method returns the text with
minimal formatting, joining words with single spaces. This is useful for text analysis or when
layout preservation is not needed.
If the OCR result ID is invalid, will return .
Saves a single OCR result as plain text to a file with specified encoding format.
The unique identifier of the OCR result obtained from .
The full path to the output text file to be created. If the file exists, it will be overwritten.
The text encoding format to use for the output file:
- - UTF-16 encoding (Unicode, 2 bytes per character)
- - UTF-8 encoding (variable-length, 1-4 bytes per character)
to preserve the original line breaks and layout structure from the OCR result;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the text file was successfully created.
Check for detailed error information if the operation fails.
This method exports OCR results to a plain text format, which is the simplest and most universal
output format. Plain text files contain only character data without formatting, styling, or layout
information beyond basic line breaks and spacing.
The parameter significantly affects the output structure:
- When , each text line detected by OCR appears on a separate line in the output,
preserving the visual layout of the original document. This is useful for structured documents like forms, tables, or poetry.
- When , text flows continuously with line breaks removed within paragraphs,
making the output more suitable for reading as continuous prose. Paragraph boundaries are still preserved with double line breaks.
Saves a single OCR result as HTML to a file, preserving text formatting and layout structure.
The unique identifier of the OCR result obtained from .
The full path to the output HTML file to be created. If the file exists, it will be overwritten.
to preserve the original line breaks and layout structure from the OCR result;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the HTML file was successfully created.
Check for detailed error information if the operation fails.
This method exports OCR results to HTML format, which provides a structured, web-compatible output
that preserves text layout, formatting, and can include styling information. HTML output is ideal
for web applications, preview interfaces, and scenarios where text formatting and structure matter.
The generated HTML includes:
- Proper document structure with DOCTYPE, html, head, and body tags
- UTF-8 character encoding declaration for international text support
- Paragraph tags (<p>) for text blocks
- Line breaks (<br/>) when is
- Semantic HTML structure that can be easily styled with CSS
Layout preservation behavior:
- When is , each OCR text line becomes a separate
line in the HTML with <br/> tags, maintaining the original document layout. Use this for forms, tables, or
documents where visual layout is important.
- When is , text flows naturally in paragraphs
without artificial line breaks, making it more readable in web browsers and responsive designs. Paragraph boundaries
are still preserved.
Advantages of HTML format over plain text:
- Can be viewed directly in any web browser
- Supports styling and formatting through CSS
- Maintains document structure with semantic tags
- Easy to integrate into web applications
- Better suited for displaying mixed content (text, tables, etc.)
Saves a single OCR result as a Microsoft Word document (DOCX format) to a file.
The unique identifier of the OCR result obtained from .
The full path to the output DOCX file to be created. If the file exists, it will be overwritten.
to preserve the original line breaks and layout structure from the OCR result;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the DOCX file was successfully created.
Check for detailed error information if the operation fails.
This method exports OCR results to Microsoft Word's DOCX format (Office Open XML), creating a fully
editable document that can be opened in Microsoft Word, LibreOffice, Google Docs, and other word
processors. DOCX is ideal when you need professional document output with proper formatting that
can be further edited or styled.
The generated DOCX document includes:
- Properly structured Office Open XML format compatible with Word 2007 and later
- Text content organized in paragraphs
- Line breaks when is
- Default styling that can be customized in word processors
- Full Unicode support for international characters
Layout preservation behavior:
- When is , each OCR text line is preserved
as a separate line within the document, maintaining the original layout. This is useful for forms, structured
documents, or cases where the original layout must be preserved for reference.
- When is , text flows naturally in paragraphs,
creating a more polished document suitable for reports, letters, and general document editing. Line breaks within
paragraphs are removed, but paragraph boundaries are maintained.
Saves multiple OCR results as plain text to a single file with specified encoding format.
A collection of OCR result identifiers obtained from .
Each result will be concatenated in the output file in the order provided.
The full path to the output text file to be created. If the file exists, it will be overwritten.
The text encoding format to use for the output file:
- - UTF-16 encoding (Unicode, 2 bytes per character)
- - UTF-8 encoding (variable-length, 1-4 bytes per character)
to preserve the original line breaks and layout structure from the OCR results;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the text file was successfully created.
Check for detailed error information if the operation fails.
This method exports multiple OCR results to a single plain text file, which is particularly useful
for processing multi-page documents or combining results from multiple OCR operations. Each result
is appended sequentially, creating a unified text document.
Multi-page processing behavior:
- Results are concatenated in the order they appear in
- Each page or result maintains its own paragraph structure
- Page boundaries are typically separated by paragraph breaks
- All results use the same encoding format specified in
Common use cases for multi-result export:
- Processing multi-page documents where each page was OCR'd separately
- Combining results from multiple document zones or regions
- Creating a single searchable text file from a document collection
- Batch processing scenarios where consolidated output is preferred
Common error conditions:
- - One or more OCR result IDs are invalid or have been released
- - Unable to create the output file (check directory permissions and disk space)
Saves a single OCR result as plain text to a stream with specified encoding format.
The unique identifier of the OCR result obtained from .
The writable stream to which the text content will be written. The stream position will be advanced by the number of bytes written.
The text encoding format to use for the output:
- - UTF-16 encoding (Unicode, 2 bytes per character)
- - UTF-8 encoding (variable-length, 1-4 bytes per character)
to preserve the original line breaks and layout structure from the OCR result;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the text was successfully written to the stream.
Check for detailed error information if the operation fails.
This method exports OCR results to a stream, providing flexibility for scenarios where direct file
system access is not desired or possible. Stream-based export is useful for web applications,
in-memory processing, network transmission, or integration with other streaming APIs.
Saves multiple OCR results as plain text to a stream with specified encoding format.
A collection of OCR result identifiers obtained from .
Each result will be concatenated in the output stream in the order provided.
The writable stream to which the text content will be written. The stream position will be advanced by the number of bytes written.
The text encoding format to use for the output:
- - UTF-16 encoding (Unicode, 2 bytes per character)
- - UTF-8 encoding (variable-length, 1-4 bytes per character)
to preserve the original line breaks and layout structure from the OCR results;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the text was successfully written to the stream.
Check for detailed error information if the operation fails.
This method combines the benefits of multi-result export with stream-based output, making it ideal
for processing multi-page documents in scenarios where direct file access is not available or desired.
Results are concatenated sequentially to the provided stream.
This overload is particularly useful for:
- Web APIs that need to return multi-page OCR results as HTTP response streams
- Cloud storage scenarios where files are uploaded via streaming APIs
- Processing pipelines that compress or encrypt data on-the-fly
- Large document processing where memory efficiency is critical
Saves a single OCR result as HTML to a stream, preserving text formatting and layout structure.
The unique identifier of the OCR result obtained from .
The writable stream to which the HTML content will be written. The stream position will be advanced by the number of bytes written.
to preserve the original line breaks and layout structure from the OCR result;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the HTML was successfully written to the stream.
Check for detailed error information if the operation fails.
This method exports OCR results to HTML format via a stream, combining the benefits of web-compatible
output with flexible stream-based delivery. This is particularly useful for web applications that need
to serve OCR results directly without creating temporary files.
Saves multiple OCR results as HTML to a single file, preserving text formatting and layout structure.
A collection of OCR result identifiers obtained from .
Each result will be included in the HTML document in the order provided.
The full path to the output HTML file to be created. If the file exists, it will be overwritten.
to preserve the original line breaks and layout structure from the OCR results;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the HTML file was successfully created.
Check for detailed error information if the operation fails.
This method exports multiple OCR results to a single HTML document, ideal for creating web-viewable
versions of multi-page documents. Each result's content is incorporated into the same HTML structure,
maintaining readability and proper document flow.
Saves multiple OCR results as HTML to a stream, preserving text formatting and layout structure.
A collection of OCR result identifiers obtained from .
Each result will be included in the HTML output in the order provided.
The writable stream to which the HTML content will be written. The stream position will be advanced by the number of bytes written.
to preserve the original line breaks and layout structure from the OCR results;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the HTML was successfully written to the stream.
Check for detailed error information if the operation fails.
This method combines multi-result HTML export with stream-based output, ideal for web applications
serving multi-page document previews or APIs returning HTML representations of entire documents
without creating temporary files.
Saves a single OCR result as a Microsoft Word document (DOCX format) to a stream.
The unique identifier of the OCR result obtained from .
The writable stream to which the DOCX content will be written. The stream position will be advanced by the number of bytes written.
to preserve the original line breaks and layout structure from the OCR result;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the DOCX was successfully written to the stream.
Check for detailed error information if the operation fails.
This method exports OCR results to DOCX format via a stream, useful for web applications, APIs,
or cloud storage scenarios where direct file creation is not desired. The resulting stream contains
a complete, valid Office Open XML document that can be saved or transmitted.
Saves multiple OCR results as a Microsoft Word document (DOCX format) to a single file.
A collection of OCR result identifiers obtained from .
Each result will be included in the Word document in the order provided.
The full path to the output DOCX file to be created. If the file exists, it will be overwritten.
to preserve the original line breaks and layout structure from the OCR results;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the DOCX file was successfully created.
Check for detailed error information if the operation fails.
This method exports multiple OCR results to a single Word document, ideal for converting multi-page
scanned documents into editable DOCX files. All pages are combined into one continuous document
that can be opened and edited in Microsoft Word or compatible word processors.
Saves multiple OCR results as a Microsoft Word document (DOCX format) to a stream.
A collection of OCR result identifiers obtained from .
Each result will be included in the Word document in the order provided.
The writable stream to which the DOCX content will be written. The stream position will be advanced by the number of bytes written.
to preserve the original line breaks and layout structure from the OCR results;
to flow the text continuously, removing line breaks within paragraphs while maintaining paragraph separations.
A value indicating the result of the operation.
Returns if the DOCX was successfully written to the stream.
Check for detailed error information if the operation fails.
This method combines multi-result DOCX export with stream-based output, ideal for web applications
or services that need to generate downloadable Word documents from multi-page OCR results without
creating temporary files on disk.
Saves multiple OCR results as a Microsoft Excel spreadsheet (XLSX format) to a file.
A collection of OCR result identifiers obtained from .
Each result will be processed, and any detected tables will be exported to the spreadsheet.
The full path to the output XLSX file to be created. If the file exists, it will be overwritten.
Optional configuration for spreadsheet formatting. Pass to use default options.
This parameter allows customization of cell styling, table structure, and worksheet organization.
A value indicating the result of the operation.
Returns if the XLSX file was successfully created.
Check for detailed error information if the operation fails.
This method exports table structures detected in OCR results to Excel XLSX format. It's specifically
designed for documents containing tabular data, converting OCR-detected tables into editable Excel
worksheets. This is ideal for processing invoices, financial reports, data sheets, and any structured
tabular content.
Use to control:
- Worksheet naming and organization
- Cell formatting (alignment, borders, fonts)
- Column width and row height settings
- Header row treatment
Common use cases:
- Converting scanned financial documents to editable spreadsheets
- Processing invoices and extracting line item tables
- Digitizing paper-based data collection forms
- Extracting tabular data from reports for analysis
Saves a specific table or all tables from a single OCR result as a Microsoft Excel spreadsheet (XLSX format) to a file.
The unique identifier of the OCR result obtained from .
The full path to the output XLSX file to be created. If the file exists, it will be overwritten.
The zero-based index of the table to export. Use -1 (default) to export all tables from the OCR result.
To get the table count, use .
Optional configuration for spreadsheet formatting. Pass to use default options.
This parameter allows customization of cell styling, table structure, and worksheet organization.
A value indicating the result of the operation.
Returns if the XLSX file was successfully created.
Check for detailed error information if the operation fails.
This method provides granular control over table export from a single OCR result. You can export
a specific table by index, or all detected tables by using = -1.
This is particularly useful when processing documents with multiple tables where selective export is needed.
Saves multiple OCR results as a Microsoft Excel spreadsheet (XLSX format) to a stream.
A collection of OCR result identifiers obtained from .
Each result will be processed, and any detected tables will be exported to the spreadsheet.
The writable stream to which the XLSX content will be written. The stream position will be advanced by the number of bytes written.
Optional configuration for spreadsheet formatting. Pass to use default options.
This parameter allows customization of cell styling, table structure, and worksheet organization.
A value indicating the result of the operation.
Returns if the XLSX was successfully written to the stream.
Check for detailed error information if the operation fails.
This method combines multi-result table export with stream-based output, ideal for web applications
or services that need to generate downloadable Excel files from multi-page documents without creating
temporary files. All detected tables across all results are included in the spreadsheet.
Saves a specific table or all tables from a single OCR result as a Microsoft Excel spreadsheet (XLSX format) to a stream.
The unique identifier of the OCR result obtained from .
The writable stream to which the XLSX content will be written. The stream position will be advanced by the number of bytes written.
The zero-based index of the table to export. Use -1 to export all tables from the OCR result.
To get the table count, use .
Optional configuration for spreadsheet formatting. Pass to use default options.
This parameter allows customization of cell styling, table structure, and worksheet organization.
A value indicating the result of the operation.
Returns if the XLSX was successfully written to the stream.
Check for detailed error information if the operation fails.
This method exports table data to Excel format via a stream with granular control over which table(s)
to include. It's useful for web applications serving dynamically generated Excel files or APIs that
provide selective table export functionality without file system access.
Saves an OCR result in binary serialized format to a stream for later restoration or archival.
The unique identifier of the OCR result obtained from .
The writable stream to which the binary data will be written. The stream position will be advanced by the number of bytes written.
A value indicating the result of the operation.
Returns if the OCR result was successfully serialized to the stream.
Check for detailed error information if the operation fails.
This method serializes the complete OCR result including all recognized text, layout information,
confidence scores, coordinates, and metadata into a binary format. The serialized data can be
stored for later use, transmitted over networks, or archived for long-term retention.
Retrieves the status of the last executed operation.
A value indicating the result of the most recent operation.
indicates success.
This method should be called after any operation to verify its success or failure. Many methods
in this class set the internal status, which can be retrieved using this method.
Common status values include:
- - Operation completed successfully
- - Invalid parameter or result ID
- - Required dictionary file not found
- - Operation was aborted (e.g., timeout)
Best practice: Always check after calling methods that return non-status values
(e.g., strings, integers) to ensure the operation succeeded.
Extracts all detected key-value pairs from an OCR result as a formatted string.
The unique identifier of the OCR result.
A string containing all detected key-value pairs in a formatted representation,
or null if the result ID is invalid.
This method returns all key-value pairs detected during OCR processing in a string format.
Key-value pairs are typically found in forms and structured documents where field names (keys)
are associated with corresponding values.
This feature requires the Intelligent Document Processing license feature. If the feature
is not licensed, the method may fail or return limited results.
For more granular access to key-value pairs, use methods like ,
, and .
Gets or sets a value indicating whether GdPicture-specific enhancements are disabled during OCR processing.
true to disable GdPicture enhancements and use standard Tesseract OCR only;
false to enable GdPicture enhancements. Default is false.
By default, GdPicture.NET applies proprietary enhancements on top of the standard Tesseract OCR engine,
including advanced preprocessing, noise reduction, and refinement algorithms. These enhancements typically
improve recognition accuracy.
Setting this property to true disables these enhancements and uses the Tesseract engine in its
standard configuration. This may be useful for:
- Comparing results with standard Tesseract implementations
- Troubleshooting recognition issues
- Achieving faster processing at the expense of accuracy
Retrieves the complete page layout structure for an OCR result.
The unique identifier of the OCR result.
A object containing the complete hierarchical structure of the OCR result,
or null if the result ID is invalid.
The object provides access to the complete OCR result structure, including:
- Blocks - Top-level regions of the page
- Paragraphs - Text paragraphs within blocks
- Text Lines - Individual lines of text
- Words - Individual words with confidence scores
- Characters - Individual characters with alternatives
- Tables - Detected table structures with cells
- Form Fields - Detected form fields (key-value pairs)
This method provides direct access to the internal PageLayout structure, allowing advanced
processing and custom result extraction beyond the standard get methods.
The GdPictureOCR class offers the comprehensive optical character recognition (OCR) support.
It is used as a wrapper class to allow you easily process the OCR on your documents and to find out required results in one place.
You need to create an object of this class to fully perform the OCR on your files. This object allows you to set all required OCR parameters and
subsequently it enables you to very easily find out the OCR results.
GdPictureOCR Constructor
How to use the instance of the GdPictureOCR class to process the OCR on your documents.
Dim caption As String = "Example: GdPictureOCR class"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the image you want to process.
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
'Continue ...
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Continue ...
End Using
string caption = "Example: GdPictureOCR class";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the image you want to process.
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int wordCount = gdpictureOCR.GetWordCount(resID);
//Continue ...
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Continue ...
}
Creates a new instance of the GdPictureOCR class. This instance represents a wrapper, that you will need to perform all available OCR operations.
At the same it enables you to find out all required results in one place.
Using only this object you are able to set available parameters required for OCR processes, run the process itself and also to check
results in one place.
A new instance of the GdPictureOCR class.
How to create and initialize a GdPictureOCR object.
'The first option:
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.CharacterSet = "0123456789"
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.LanguageModelPenaltyNonDictWords = 0.2F
gdpictureOCR.LanguageModelPenaltyNonFreqDictWords = 0.25F
gdpictureOCR.MaxCharHeight = 100
gdpictureOCR.MaxCharWidth = 10
gdpictureOCR.MinCharHeight = 50
gdpictureOCR.MinCharWidth = 5
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
gdpictureOCR.Timeout = 500
gdpictureOCR.Dispose()
'The second option:
'The very good practice is to use the keyword "using".
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.CharacterSet = "0123456789"
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.LanguageModelPenaltyNonDictWords = 0.2F
gdpictureOCR.LanguageModelPenaltyNonFreqDictWords = 0.25F
gdpictureOCR.MaxCharHeight = 100
gdpictureOCR.MaxCharWidth = 10
gdpictureOCR.MinCharHeight = 50
gdpictureOCR.MinCharWidth = 5
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
gdpictureOCR.Timeout = 500
'You can do your another stuff with gdpictureOCR here.
End Using
//The first option:
GdPictureOCR gdpictureOCR = new GdPictureOCR();
gdpictureOCR.CharacterSet = "0123456789";
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.LanguageModelPenaltyNonDictWords = 0.2F;
gdpictureOCR.LanguageModelPenaltyNonFreqDictWords = 0.25F;
gdpictureOCR.MaxCharHeight = 100;
gdpictureOCR.MaxCharWidth = 10;
gdpictureOCR.MinCharHeight = 50;
gdpictureOCR.MinCharWidth = 5;
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.Timeout = 500;
gdpictureOCR.Dispose();
//The second option:
//The very good practice is to use the keyword "using".
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.CharacterSet = "0123456789";
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.LanguageModelPenaltyNonDictWords = 0.2F;
gdpictureOCR.LanguageModelPenaltyNonFreqDictWords = 0.25F;
gdpictureOCR.MaxCharHeight = 100;
gdpictureOCR.MaxCharWidth = 10;
gdpictureOCR.MinCharHeight = 50;
gdpictureOCR.MinCharWidth = 5;
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.Timeout = 500;
//You can do your another stuff with gdpictureOCR here.
}
Defines the OCR mode to be used during subsequent OCR processes. You can choose between speed or accuracy.
It is recommended to set this parameter to OCRMode.FavorAccuracy for low quality images.
The default value is OCRMode.FavorAccuracy.
How to set the required OCR mode.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//You can do your another stuff with gdpictureOCR here.
}
Specifies the maximun number of threads this instance can allocate.
The default value is equal to the number of logical cores of the hosting machin.
Use 1 to disable multi-threading support.
Specifies if image preprocessing is activated.
The default value is true.
Specifies the OCR detection's accuracy level. It must be a value in the range 1 (worst accuracy, best speed) to 10 (best accuracy, worst speed).
The default value is 10.
How to balance between speed and accuracy.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.EnableOrientationDetection = True
gdpictureOCR.OrientationDetectionAccuracyLevel = 5
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpicturePDF.EnableOrientationDetection = true;
gdpictureOCR.OrientationDetectionAccuracyLevel = 5;
//You can do your another stuff with gdpictureOCR here.
}
Specifies, whether the engine will try to detect the page skew automatically during subsequent OCR processes.
Please be aware that enabling the automatic page skew detection may noticeably slow down the engine's performance in some cases.
The default value is false, that means the automatic detection of a page skew is not activated.
How to enable the automatic page skew detection.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.EnableSkewDetection = True
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.EnableSkewDetection = true;
//You can do your another stuff with gdpictureOCR here.
}
Specifies, whether the engine will try to detect the page orientation, means the page standard rotation,
automatically during subsequent OCR processes. Enabling this options may noticeably slow down the engine's performance.
Please be aware that enabling the automatic page orientation detection may noticeably slow down the engine's performance.
The default value is false, that means the automatic detection of a page orientation is not activated.
How to enable the automatic page orientation detection.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.EnableOrientationDetection = True
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.EnableOrientationDetection = true;
//You can do your another stuff with gdpictureOCR here.
}
Specifies the OCR context to be used during subsequent OCR processes.
You have to inform the engine of the layout type of the data you want to process.
The default value is OCRContext.OCRContextDocument.
How to set the required OCR context.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
//You can do your another stuff with gdpictureOCR here.
}
Specifies the penalty applied by the engine to all words, that are not listed in the dictionary (word_dawg / user_words wordlists).
It must be a value within the interval from 0 to 1.
The default value is 0.15F.
How to change the penalty value.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.LanguageModelPenaltyNonDictWords = 0.2F
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.LanguageModelPenaltyNonDictWords = 0.2F;
//You can do your another stuff with gdpictureOCR here.
}
Specifies if the OCR engine must try to vigorously remove noise during the recognition process.
It corresponds to the tesseract textord_heavy_nr parameter.
The default value is false.
How to enable vigorously removing noise.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.EnableVigorousDespeckle = True
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.EnableVigorousDespeckle = true;
//You can do your another stuff with gdpictureOCR here.
}
Specifies the penalty applied by the engine to all words, that are not listed in the frequent words dictionary (freq_dawg wordlist).
It must be a value within the interval from 0 to 1.
The default value is 0.1F.
How to change the penalty value.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.LanguageModelPenaltyNonFreqDictWords = 0.25F
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.LanguageModelPenaltyNonFreqDictWords = 0.25F;
//You can do your another stuff with gdpictureOCR here.
}
Defines, whether the engine should load the main dictionary for all added languages.
The default value is true.
How to disable the main dictionary.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.LoadMainDictionary = False
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.LoadMainDictionary = false;
//You can do your another stuff with gdpictureOCR here.
}
Defines, whether the engine should load the frequent words of the dictionaries for all added languages.
The default value is true.
How to disable the frequent words dictionary.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.LoadFreqWordsDictionary = False
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.LoadFreqWordsDictionary = false;
//You can do your another stuff with gdpictureOCR here.
}
Specifies the minimal accepted height, in pixels, for each recognized character.
The default valus is 0, means no limit is used.
How to define the required minimal height of a recognized character.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.MinCharHeight = 50
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.MinCharHeight = 50;
//You can do your another stuff with gdpictureOCR here.
}
Specifies the maximal accepted height, in pixels, for each recognized character.
The default valus is 0, means no limit is used.
How to define the required maximal height of a recognized character.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.MaxCharHeight = 100
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.MaxCharHeight = 100;
//You can do your another stuff with gdpictureOCR here.
}
Specifies the minimal accepted width, in pixels, for each recognized character.
The default valus is 0, means no limit is used.
How to define the required minimal width of a recognized character.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.MinCharWidth = 5
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.MinCharWidth = 5;
//You can do your another stuff with gdpictureOCR here.
}
Specifies the maximal accepted width, in pixels, for each recognized character.
The default valus is 0, means no limit is used.
How to define the required maximal width of a recognized character.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.MaxCharWidth = 10
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.MaxCharWidth = 10;
//You can do your another stuff with gdpictureOCR here.
}
Defines the time interval, means timeout, in milliseconds, that specifies the maximum time allowed for subsequent OCR processes
before they are automatically interrupted.
The default value is 0 (no timeout).
How to change the timeout value.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.Timeout = 5000 '5 seconds
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.Timeout = 5000; //5 seconds
//You can do your another stuff with gdpictureOCR here.
}
Specifies the path to the directory containing the engine resources (mostly dictionaries).
The proper path is usually within your standard installation and it looks like @\GdPicture.Net 14\redist\OCR.
Of course you can specify your own path as well.
The default value is an empty string.
How to specify the correct path to OCR dictionaries.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
//You can do your another stuff with gdpictureOCR here.
}
Defines the restricted recognition characters, so called characters whitelist, that are allowed during subsequent OCR processes.
The recognition is limited to the provided characters, that means the engine returns only the specified characters when processing.
For example, if you want to recognize only numeric characters, set this parameter to "0123456789".
If you want to recognize only uppercase letters, set it to "ABCDEFGHIJKLMNOPQRSTUVWXYZ". Set this parameter to the empty string
to recognize all characters.
The default value is an empty string, means no limit is used.
How to specify the required white list of characters.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.CharacterSet = "0123456789"
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.CharacterSet = "0123456789";
//You can do your another stuff with gdpictureOCR here.
}
Specifies the number of expected symbols to detect and decode.
Use 0 if this number is undefined.
The default value is 0.
Defines the restricted recognition characters, so called characters blacklist, that are not allowed to recognize during subsequent OCR processes. The
recognition is disabled for the provided characters, that means the engine doesn't consider the specified characters when processing.
For example, if you want to disable/not recognize the characters "0X@", set this parameter to "0X@".
The default value is an empty string, means no limit is used.
How to specify the required black list of characters.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
gdpictureOCR.CharacterBlackList = "1234"
'You can do your another stuff with gdpictureOCR here.
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
gdpictureOCR.CharacterBlackList = "1234";
//You can do your another stuff with gdpictureOCR here.
}
Resets all parameters of the current GdPictureOCR object to their default values, including added languages, custom dictionaries and internal engine variables.
This does not apply to OCR results used in the current object.
Please note, that not only all GdPictureOCR internal variables are reset to their default values, but also all internal variables of the Tesseract engine
are reset to their default values as well.
Also be aware, that used OCR results in the current GdPictureOCR object are not released using this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset all internal variables.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set some GdPictureOCR variables.
gdpictureOCR.Context = OCRContext.OCRContextRawLine
gdpictureOCR.CharacterSet = ",./<>?"
gdpictureOCR.Timeout = 1000
'Some some Tesseract variables.
gdpictureOCR.SetVariable("chop_enable", "T")
gdpictureOCR.SetVariable("use_new_state_cost", "F")
gdpictureOCR.SetVariable("enable_new_segsearch", "0")
gdpictureOCR.SetVariable("edges_max_children_per_outline", "40")
'Reset all internal variables to their default values.
gdpictureOCR.ResetParameters()
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set some GdPictureOCR variables.
gdpictureOCR.Context = OCRContext.OCRContextRawLine;
gdpictureOCR.CharacterSet = ",./<>?";
gdpictureOCR.Timeout = 1000;
//Set some Tesseract variables.
gdpictureOCR.SetVariable("chop_enable", "T");
gdpictureOCR.SetVariable("use_new_state_cost", "F");
gdpictureOCR.SetVariable("enable_new_segsearch", "0");
gdpictureOCR.SetVariable("textord_force_make_prop_words", "F");
gdpictureOCR.SetVariable("edges_max_children_per_outline", "40");
//Reset all internal variables to their default values.
gdpictureOCR.ResetParameters();
}
Resets, means completely release, all previously added languages and dictionaries by the
and the methods.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to release already specified languages and dictionaries.
Dim caption As String = "Example: ResetSelectedDictionaries"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
'Reset previously added languages, if any.
gdpictureOCR.ResetSelectedDictionaries()
'Add only the french language.
If gdpictureOCR.AddLanguage(OCRLanguage.French) = GdPictureStatus.OK Then
'You can do your another stuff with gdpictureOCR here.
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: ResetSelectedDictionaries";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
//Reset previously added languages, if any.
gdpictureOCR.ResetSelectedDictionaries();
//Add only the french language.
if (gdpictureOCR.AddLanguage(OCRLanguage.French) == GdPictureStatus.OK)
{
//You can do your another stuff with gdpictureOCR here.
}
else
{
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
}
Returns a number of all known language dictionaries available in the currently defined resource folder.
Please ensure that you have correctly set up your prefered resource folder for OCR dictionaries.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of all known language dictionaries available in the current resource folder.
Please always use the method to determine if this method has been successful.
How to find out the number of all available languages in the specified resource folder.
Dim caption As String = "Example: GetAvailableLanguageCount"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
Dim count As Integer = gdpictureOCR.GetAvailableLanguageCount()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
If count > 0 Then
Dim list As IList(Of OCRLanguage) = gdpictureOCR.GetAvailableLanguages()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim languages As String = list.ElementAt(0).ToString()
Dim lang As OCRLanguage = 0
For idx As Integer = 1 To count - 1
lang = list.ElementAt(idx)
languages = languages + ", " + lang.ToString()
Next
MessageBox.Show("The number of available languages: " + count.ToString() + vbCrLf + "Languages:" + vbCrLf + languages, caption)
Else
MessageBox.Show("The GetAvailableLanguages() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("No languages are available in this resource folder: " + gdpictureOCR.ResourcesFolder, caption)
End If
Else
MessageBox.Show("The GetAvailableLanguageCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: GetAvailableLanguageCount";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
int count = gdpictureOCR.GetAvailableLanguageCount();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
if (count > 0)
{
IList<OCRLanguage> list = gdpictureOCR.GetAvailableLanguages();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string languages = list.ElementAt(0).ToString();
OCRLanguage lang = 0;
for (int idx = 1; idx < count; idx++)
{
lang = list.ElementAt(idx);
languages = languages + ", " + lang.ToString();
}
MessageBox.Show("The number of available languages: " + count.ToString() + "\nLanguages:\n" + languages, caption);
}
else
{
MessageBox.Show("The GetAvailableLanguages() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("No languages are available in this resource folder: " + gdpictureOCR.ResourcesFolder, caption);
}
else
{
MessageBox.Show("The GetAvailableLanguageCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
}
Returns a name of the specific known language dictionary available in the currently defined resource folder according to the index you have specified.
You can use the method to determine the number of all available language dictionaries.
The index is simply an integer value within the interval from 0 to -1.
The language dictionary index. It must be an integer value between 0 and -1.
Please ensure that you have correctly set up your prefered resource folder for OCR dictionaries.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the OCRLanguage enumeration. A specified language dictionary.
Please always use the method to determine if this method has been successful.
How to find out if the required language dictionary is available in the current resource folder.
Dim caption As String = "Example: GetAvailableLanguage"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
Dim count As Integer = gdpictureOCR.GetAvailableLanguageCount()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
If count > 0 Then
Dim lang As OCRLanguage = 0
Dim found As Boolean = False
For idx As Integer = 0 To count - 1
lang = gdpictureOCR.GetAvailableLanguage(idx)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
found = (lang = OCRLanguage.English)
If found Then Exit For
Else
MessageBox.Show("The GetAvailableLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then MessageBox.Show("The number of available languages: " + count.ToString() + vbCrLf + "English: " + found.ToString(), caption)
Else
MessageBox.Show("No languages are available in this resource folder: " + gdpictureOCR.ResourcesFolder, caption)
End If
Else
MessageBox.Show("The GetAvailableLanguageCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: GetAvailableLanguage";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
int count = gdpictureOCR.GetAvailableLanguageCount();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
if (count > 0)
{
OCRLanguage lang = 0;
Boolean found = false;
for (int idx = 0; idx < count; idx++)
{
lang = gdpictureOCR.GetAvailableLanguage(idx);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
found = (lang == OCRLanguage.English);
if (found) break;
}
else
{
MessageBox.Show("The GetAvailableLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
break;
}
}
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The number of available languages: " + count.ToString() + "\nEnglish: " + found.ToString(), caption);
}
else
MessageBox.Show("No languages are available in this resource folder: " + gdpictureOCR.ResourcesFolder, caption);
}
else
MessageBox.Show("The GetAvailableLanguageCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
Returns a name list of all known language dictionaries available in the currently defined resource folder.
Please ensure that you have correctly set up your prefered resource folder for OCR dictionaries.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The name list of all known language dictionaries available in the current resource folder.
Please always use the method to determine if this method has been successful.
How to find out all available languages in the specified resource folder.
Dim caption As String = "Example: GetAvailableLanguages"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
Dim count As Integer = gdpictureOCR.GetAvailableLanguageCount()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
If count > 0 Then
Dim list As IList(Of OCRLanguage) = gdpictureOCR.GetAvailableLanguages()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim languages As String = list.ElementAt(0).ToString()
Dim lang As OCRLanguage = 0
For idx As Integer = 1 To count - 1
lang = list.ElementAt(idx)
languages = languages + ", " + lang.ToString()
Next
MessageBox.Show("The number of available languages: " + count.ToString() + vbCrLf + "Languages:" + vbCrLf + languages, caption)
Else
MessageBox.Show("The GetAvailableLanguages() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("No languages are available in this resource folder: " + gdpictureOCR.ResourcesFolder, caption)
End If
Else
MessageBox.Show("The GetAvailableLanguageCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: GetAvailableLanguages";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
int count = gdpictureOCR.GetAvailableLanguageCount();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
if (count > 0)
{
IList<OCRLanguage> list = gdpictureOCR.GetAvailableLanguages();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string languages = list.ElementAt(0).ToString();
OCRLanguage lang = 0;
for (int idx = 1; idx < count; idx++)
{
lang = list.ElementAt(idx);
languages = languages + ", " + lang.ToString();
}
MessageBox.Show("The number of available languages: " + count.ToString() + "\nLanguages:\n" + languages, caption);
}
else
{
MessageBox.Show("The GetAvailableLanguages() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("No languages are available in this resource folder: " + gdpictureOCR.ResourcesFolder, caption);
}
else
{
MessageBox.Show("The GetAvailableLanguageCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
}
Adds a custom language dictionary from the defined resource folder to be used during subsequent OCR processes. You are able to add multiple custom
languages by calling this method for each custom language file according to your preference. The specified language is then added internally in the
current GdPictureOCR object.
The name of the custom language dictionary file located in the defined resource folder.
For example, you can use "eng2" for the dictionary file named eng2.traineddata.
This language dictionary is then added in the current GdPictureOCR object for subsequent use together with the previously added languages.
Please ensure that the specified custom language dictionary file is located in the currently defined resource folder.
You can download additional language dictionary files here.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add multiple custom languages to be used by OCR.
Dim caption As String = "Example: AddCustomDictionary"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
'To add your custom english, german and french language, do the following:
If (gdpictureOCR.AddCustomDictionary("eng2") = GdPictureStatus.OK) AndAlso
(gdpictureOCR.AddCustomDictionary("deu2") = GdPictureStatus.OK) AndAlso
(gdpictureOCR.AddCustomDictionary("fra2") = GdPictureStatus.OK) Then
'You can do your another stuff with gdpictureOCR here.
Else
MessageBox.Show("The AddCustomDictionary() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: AddCustomDictionary";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
//To add your custom english, german and french language, do the following:
if ((gdpictureOCR.AddCustomDictionary("eng2") == GdPictureStatus.OK) &&
(gdpictureOCR.AddCustomDictionary("fra2") == GdPictureStatus.OK) &&
(gdpictureOCR.AddCustomDictionary("deu") == GdPictureStatus.OK))
{
//You can do your another stuff with gdpictureOCR here.
}
else
{
MessageBox.Show("The AddCustomDictionary() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
}
Adds a known language from the defined resource folder to be used during subsequent OCR processes. You are able to add multiple languages by calling this
method for each language according to your preference. The specified language is then added internally in the current GdPictureOCR object.
A member of the OCRLanguage enumeration. A new language, that is added in the current GdPictureOCR object
for subsequent use together with the previously added languages.
Please ensure that the language dictionary file for the required language is located in the currently defined resource folder.
You can find these files within your standard installation usually in the directory @\GdPicture.Net 14\redist\OCR or you can download
additional language dictionary files here.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add multiple languages to be used by OCR.
Dim caption As String = "Example: AddLanguage"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
'To add the english, the german and the french language, do the following:
If (gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK) AndAlso
(gdpictureOCR.AddLanguage(OCRLanguage.German) = GdPictureStatus.OK) AndAlso
(gdpictureOCR.AddLanguage(OCRLanguage.French) = GdPictureStatus.OK) Then
'You can do your another stuff with gdpictureOCR here.
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: AddLanguage";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Specify your resource folder for OCR dictionaries.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
//To add the english, the german and the french language, do the following:
if ((gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK) &&
(gdpictureOCR.AddLanguage(OCRLanguage.German) == GdPictureStatus.OK) &&
(gdpictureOCR.AddLanguage(OCRLanguage.French) == GdPictureStatus.OK))
{
//You can do your another stuff with gdpictureOCR here.
}
else
{
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
}
Sets up a specified value for an internal parameter of the OCR engine. The Tesseract engine has a large number of control parameters to modify its behavior.
The name of the parameter. You can find a wide range of possible variables listed in Tesseract-OCR parameters.
The value for the specified parameter.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK
We strongly recommend always checking this status first.
How to set the required variables of the Tesseract engine.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Some examples of Tesseract variables:
gdpictureOCR.SetVariable("chop_enable", "T")
gdpictureOCR.SetVariable("use_new_state_cost", "F")
gdpictureOCR.SetVariable("segment_segcost_rating", "F")
gdpictureOCR.SetVariable("enable_new_segsearch", "0")
gdpictureOCR.SetVariable("language_model_ngram_on", "0")
gdpictureOCR.SetVariable("textord_force_make_prop_words", "F")
gdpictureOCR.SetVariable("edges_max_children_per_outline", "40")
'You can find more variables here:
'http://www.sk-spell.sk.cx/tesseract-ocr-parameters-in-302-version
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Some examples of Tesseract variables:
gdpictureOCR.SetVariable("chop_enable", "T");
gdpictureOCR.SetVariable("use_new_state_cost", "F");
gdpictureOCR.SetVariable("segment_segcost_rating", "F");
gdpictureOCR.SetVariable("enable_new_segsearch", "0");
gdpictureOCR.SetVariable("language_model_ngram_on", "0");
gdpictureOCR.SetVariable("textord_force_make_prop_words", "F");
gdpictureOCR.SetVariable("edges_max_children_per_outline", "40");
//You can find more variables here:
//http://www.sk-spell.sk.cx/tesseract-ocr-parameters-in-302-version
}
Computes the page orientation of the image previously set by the method.
In order to correct the resulting orientation, you need to rotate the image by the following angle: 360 - returned value.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note that you need to set up the required image before running this method together with setting up the dictionary and the language as well.
Just to remind you, that you need to rotate the image by the angle 360 - returned value to correct the possible page orientation before running the OCR.
The page orientation, in degrees, determining the clockwise rotation applied to the given image. The returned value can only be 0, 90, 180 or 270.
Please always use the method to determine if this method has been successful.
How to correct the page orientation for the given image before processing the OCR.
Dim caption As String = "Example: GetOrientation"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Setting these properties is mandatory for using this method.
'Specify your path.
gdpictureOCR.ResourcesFolder = "D:\\GdPicture.NET 14\\Redist\\OCR"
'Specify your language.
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Load the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If gdpictureImaging.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Check the image orientation.
Dim orientation As Integer = gdpictureOCR.GetOrientation()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
If orientation <> 0 Then
If gdpictureImaging.RotateAngle(image, 360 - orientation) <> GdPictureStatus.OK Then
MessageBox.Show("The image is rotated, but the RotateAngle() method has failed with the status: " + gdpictureImaging.GetStat.ToString, caption)
Else
orientation = 0
End If
End If
'Continue if image is properly oriented.
If orientation = 0 Then
'Set up the required OCR parameters and continue with the process.
End If
Else
MessageBox.Show("The GetOrientation() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
End Using
string caption = "Example: GetOrientation";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Setting these properties is mandatory to be able to using this method.
gdpictureOCR.ResourcesFolder = "D:\\GdPicture.NET 14\\Redist\\OCR"; //Specify your path.
gdpictureOCR.AddLanguage(OCRLanguage.English); //Specify your language.
//Load the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Check the image orientation.
int orientation = gdpictureOCR.GetOrientation();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
if (orientation != 0)
{
if (gdpictureImaging.RotateAngle(image, 360 - orientation) != GdPictureStatus.OK)
MessageBox.Show("The image is rotated, but the RotateAngle() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
else
orientation = 0;
}
//Continue if image is properly oriented.
if (orientation == 0)
{
//Set up the required OCR parameters and continue with the process.
}
}
else
MessageBox.Show("The GetOrientation() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
{
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
}
gdpictureImaging.Dispose();
}
Returns the page rotation, in degrees, clockwise, detected during a specific OCR process.
The unique result identifier of the executed OCR process obtained by the method.
The decteced page rotation.
Returns the page skew angle, in degrees, clockwise, detected during a specific OCR process.
The unique result identifier of the executed OCR process obtained by the method.
The decteced page skew angle.
Runs the OCR on the image previously set by the method and using the available parameters you have previously specified within the current
GdPictureOCR object. The result of this process, identifiable by its unique ID, is internally attached to the current GdPictureOCR object as well.
Please note, that the accuracy and the speed depend on the selected OCR mode (balance between speed and accuracy).
Executes the OCR using the available parameters you have specified within the current GdPictureOCR object.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have set all required parameters, first of all the image, before you start the new OCR process. This method uses the GdPictureImage
object previously set by the method. Setting up an image is a mandatory step before running any OCR process.
Just to inform you, that releasing already used OCR results by the method can improve the memory management if you run more OCR processes in a row.
A unique result identifier of the executed OCR process. Please always use the method to determine if this method has been successful.
How to run more OCR processes on the same image with different settings.
Dim caption As String = "Example: RunOCR"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Display the standard open file dialog to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim result1 As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsText(result1, "OCR_result1.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
Dim result2 As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsText(result2, "OCR_result2.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: RunOCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string result1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsText(result1, "OCR_result1.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
string result2 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsText(result2, "OCR_result2.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Runs the OCR on the image previously set by the method and using the available parameters you have previously specified within the current
GdPictureOCR object. You are allowed to set the custom result identifier you prefer using this method. The result of this process, identifiable by this
custom ID, is internally attached to the current GdPictureOCR object as well.
Please note, that the accuracy and the speed depend on the selected OCR mode (balance between speed and accuracy).
Executes the OCR using the available parameters you have specified within the current GdPictureOCR object.
A unique result identifier of the executed OCR process, that is used to identify the OCR result.
You can define your preferable value. If you leave this parameter null or empty, a new identifier is automatically generated.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have set all required parameters, first of all the image, before you start the new OCR process. This method uses the GdPictureImage
object previously set by the method. Setting up an image is a mandatory step before running any OCR process.
Also be aware, that you can only reuse the result ID if you first release it using the method before the next use. Releasing already used
OCR results can improve the memory management if you run more OCR processes in a row.
A unique result identifier of the executed OCR process. If the method has been successfully followed, then the custom identifier passed as a parameter is
returned, if it is properly defined.
Please always use the method to determine if this method has been successful.
How to use the custom result identifier when running the OCR.
Dim caption As String = "Example: RunOCR"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Define the custom result identifier.
Dim resID As String = "MyResult"
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
gdpictureOCR.RunOCR(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsText(resID, "OCR_result1.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the previous OCR result to make your new result identifier unique.
'This is the only way how to reuse your custom result identifier.
If gdpictureOCR.ReleaseOCRResult(resID) = GdPictureStatus.OK Then
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
gdpictureOCR.RunOCR(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsText(resID, "OCR_result2.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The ReleaseOCRResult() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: RunOCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Define the custom result identifier.
string resID = "MyResult";
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
gdpictureOCR.RunOCR(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsText(resID, "OCR_result1.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the previous OCR result to make your new result identifier unique.
//This is the only way how to reuse your custom result identifier.
if (gdpictureOCR.ReleaseOCRResult(resID) == GdPictureStatus.OK)
{
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
gdpictureOCR.RunOCR(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsText(resID, "OCR_result2.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The ReleaseOCRResult() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Runs the OCR on the image previously set by the method and using a special context.
A special context allows triggering a specific layout analysis and OCR engines in order to maximize accuracy and speed on the detection of specific items.
A member of the OCRSpecialContext specifying the special context to use.
Special context can be added on demand to our team of researchers, feel free to contact us!
Please check the documentation related to the OCRSpecialContext to obtain more information about a specific special context.
A unique result identifier of the executed OCR process or an empty string in case of failure.
Please always use the method to determine if this method has been successful.
Returns the whole OCR result based on internal GdPicture structures serialized as json string.
A unique result identifier of the executed OCR process obtained by the method.
The whole OCR result based on internal GdPicture structures serialized as json string.
Sets up the specified image object, so that it is subsequently used when you start the next OCR process. This step is mandatory before running any OCR.
This aproach permits you to highly improve performance when running multiple subsequent OCR processes on the same image, for example using different regions
of interest or using different charsets, etc.
A unique image identifier of the created image object. You can take advantages
of the GdPictureImaging class
and its methods to obtain this identifier.
Please note that setting up an image is a mandatory step before running any OCR process. This approach allows you to take all benefits of the
speed optimization when performing OCR.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK
We strongly recommend always checking this status first.
How to set the image you want to process and how to subsequently run the OCR on this image.
Dim caption As String = "Example: SetImage"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Display the standard open file dialog to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Run the OCR process.
Dim result As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsText(result, "my_first_OCR_result.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SetImage";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Run the OCR process.
string result = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsText(result, "my_first_OCR_result.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Releases an OCR result specified by its unique identifier. Each OCR result, identifiable by its unique ID, is internally attached to that GdPictureOCR
object, which has executed the OCR process. By disposing of the current GdPictureOCR object you also release all attached OCR results.
A unique result identifier of the executed OCR process obtained by the method.
Please be aware, that each OCR result is internally linked to the GdPictureOCR object, that has executed the OCR process.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to release the OCR result to subsequently reuse the custom result identifier.
Dim caption As String = "Example: ReleaseOCRResult"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Define the custom result identifier.
Dim resID As String = "MyResult"
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
gdpictureOCR.RunOCR(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsText(resID, "OCR_result1.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the previous OCR result to make your new result identifier unique.
'This is the only way how to reuse your custom result identifier.
If gdpictureOCR.ReleaseOCRResult(resID) = GdPictureStatus.OK Then
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
gdpictureOCR.RunOCR(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsText(resID, "OCR_result2.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The ReleaseOCRResult() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: ReleaseOCRResult";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Define the custom result identifier.
string resID = "MyResult";
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
gdpictureOCR.RunOCR(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsText(resID, "OCR_result1.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the previous OCR result to make your new result identifier unique.
//This is the only way how to reuse your custom result identifier.
if (gdpictureOCR.ReleaseOCRResult(resID) == GdPictureStatus.OK)
{
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
gdpictureOCR.RunOCR(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsText(resID, "OCR_result2.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The ReleaseOCRResult() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Releases all results of all previously executed OCR processes within the current GdPictureOCR object. Each OCR result is internally attached to that
GdPictureOCR object, which has executed the OCR process. By disposing of the current GdPictureOCR object you also release all attached OCR results.
Please be aware, that each OCR result is internally linked to the GdPictureOCR object, that has executed the OCR process.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to release already used OCR results to improve memory management.
Dim caption As String = "Example: ReleaseOCRResults"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.TiffCreateMultiPageFromFile("")
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
'This example expects that the input tiff file has 2 pages.
If gdpictureImaging.TiffGetPageCount(image) <> 2 Then
MessageBox.Show("This example expects 2 pages tiff files.", caption)
Goto [Error]
End If
'Select the first page.
If gdpictureImaging.TiffSelectPage(image, 1) <> GdPictureStatus.OK Then
MessageBox.Show("The TiffSelectPage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
Goto [Error]
End If
'Set the image.
gdpictureOCR.SetImage(image)
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The SetImage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
GoTo [error]
End If
'Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789"
'Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion")
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
'Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200)
'Define the character set for addresses.
gdpictureOCR.CharacterSet = ""
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
'Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion")
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
'Analyze your OCR results using the identifiers "PhoneNumberRegion" And "AddressRegion".
'Continue ...
'Prepare GdPictureOCR for the next process.
'Release unused results for better memory management.
gdpictureOCR.ReleaseOCRResults()
'Reset region of interest to the whole page.
gdpictureOCR.ResetROI()
gdpictureOCR.Context = OCRContext.OCRContextDocument
'Select the second page.
If gdpictureImaging.TiffSelectPage(image, 2) <> GdPictureStatus.OK Then
MessageBox.Show("The TiffSelectPage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
Goto [Error]
End If
'Set another image.
gdpictureOCR.SetImage(image)
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The SetImage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
GoTo [error]
End If
'Run the OCR process.
Dim pageText As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
Dim text As String = gdpictureOCR.GetOCRResultText(pageText)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The text on the page is : " + vbCrLf + text, caption)
Else
MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
[error]:
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: ReleaseOCRResults";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.TiffCreateMultiPageFromFile("");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
//This example expects that the input tiff file has 2 pages.
if (gdpictureImaging.TiffGetPageCount(image) != 2)
{
MessageBox.Show("This example expects 2 pages tiff files.", caption);
goto error;
}
//Select the first page.
if (gdpictureImaging.TiffSelectPage(image, 1) != GdPictureStatus.OK)
{
MessageBox.Show("The TiffSelectPage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
goto error;
}
//Set the image.
gdpictureOCR.SetImage(image);
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The SetImage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789";
//Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion");
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200);
//Define the character set for addresses.
gdpictureOCR.CharacterSet = "";
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
//Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion");
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Analyze your OCR results using the identifiers "PhoneNumberRegion" and "AddressRegion".
//Continue ...
//Prepare GdPictureOCR for the next process.
//Release unused results for better memory management.
gdpictureOCR.ReleaseOCRResults();
//Reset region of interest to the whole page.
gdpictureOCR.ResetROI();
gdpictureOCR.Context = OCRContext.OCRContextDocument;
//Select the second page.
if (gdpictureImaging.TiffSelectPage(image, 2) != GdPictureStatus.OK)
{
MessageBox.Show("The TiffSelectPage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
goto error;
}
//Set another image.
gdpictureOCR.SetImage(image);
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The SetImage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Run the OCR process.
string pageText = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
string text = gdpictureOCR.GetOCRResultText(pageText);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The text on the page is : \n" + text, caption);
}
else
{
MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
error:
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the average word confidence of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the average word confidence in the range 0 (worst accuracy) to 100 (best accuracy).
Please always use the method to determine if this method has been successful.
How to find out the average word confidence of the processed OCR.
Dim caption As String = "Example: GetAverageWordConfidence"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
'Set up the image you want to process. This step is mandatory.
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim wordConf As Integer = gdpictureOCR.GetAverageWordConfidence(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The average word confidence of this OCR result is: " + wordConf, caption)
Else
MessageBox.Show("The GetAverageWordConfidence() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Continue ...
End Using
string caption = "Example: GetAverageWordConfidence";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
//Set up the image you want to process. This step is mandatory.
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordConf = gdpictureOCR.GetAverageWordConfidence(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The average word confidence of this OCR result is: " + wordConf, caption);
else
MessageBox.Show("The GetAverageWordConfidence() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Continue ...
}
Returns the number of blocks within a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of recognized blocks. Please always use the method to determine if this method has been successful.
How to find out the number of recognized blocks within the OCR result and some of the block's properties.
Dim caption As String = "Example: GetBlockCount"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Purple)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpicturePDF.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + ":" + vbCrLf + "Type: " + gdpictureOCR.GetBlockType(resID, i).ToString()
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i)
message = message + vbCrLf + " Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString()
Dim left As Integer = gdpictureOCR.GetBlockLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetBlockTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized blocks to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show(The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockCount";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Purple);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + ":\nType: " + gdpictureOCR.GetBlockType(resID, i).ToString();
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i);
message = message + "\n Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString();
int left = gdpictureOCR.GetBlockLeft(resID, i);
int top = gdpictureOCR.GetBlockTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized blocks to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the type of the specified block within a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The type of the specified block. A member of the OCRBlockType enumeration.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized blocks within the OCR result and some of the block's properties.
Dim caption As String = "Example: GetBlockType"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Purple)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + ":" + vbCrLf + "Type: " + gdpictureOCR.GetBlockType(resID, i).ToString()
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i)
message = message + vbCrLf + " Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString()
Dim left As Integer = gdpictureOCR.GetBlockLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetBlockTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized blocks to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockType";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Purple);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + ":\nType: " + gdpictureOCR.GetBlockType(resID, i).ToString();
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i);
message = message + "\n Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString();
int left = gdpictureOCR.GetBlockLeft(resID, i);
int top = gdpictureOCR.GetBlockTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized blocks to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the special format of the specified block within a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The special format of the specified block. A member of the OCRBlockSpecialFormat enumeration.
Please always use the method to determine if this method has been successful.
Returns the special format data of the specified block within a specified OCR result, as JSON format.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The special format of the specified block. A member of the OCRBlockSpecialFormat enumeration.
Please always use the method to determine if this method has been successful.
Returns the writing direction of the specified block, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The writing direction of the specified block. A member of the OCRWritingDirection enumeration.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized blocks within the OCR result and some of the block's properties.
Dim caption As String = "Example: GetBlockWritingDirection"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Purple)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + ":" + vbCrLf + "Type: " + gdpictureOCR.GetBlockType(resID, i).ToString()
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i)
message = message + vbCrLf + " Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString()
Dim left As Integer = gdpictureOCR.GetBlockLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetBlockTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized blocks to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockWritingDirection";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Purple);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + ":\nType: " + gdpictureOCR.GetBlockType(resID, i).ToString();
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i);
message = message + "\n Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString();
int left = gdpictureOCR.GetBlockLeft(resID, i);
int top = gdpictureOCR.GetBlockTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized blocks to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the orientation of the specified block, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The writing orientation of the specified block. A member of the OCRBlockOrientation enumeration.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized blocks within the OCR result and some of the block's properties.
Dim caption As String = "Example: GetBlockWritingDirection"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Purple)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + ":" + vbCrLf + "Type: " + gdpictureOCR.GetBlockType(resID, i).ToString()
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i)
message = message + " Writing orientation: " + gdpictureOCR.GetBlockOrientation(resID, i)
message = message + vbCrLf + " Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString()
Dim left As Integer = gdpictureOCR.GetBlockLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetBlockTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized blocks to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockWritingDirection";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Purple);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + ":\nType: " + gdpictureOCR.GetBlockType(resID, i).ToString();
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i);
message = message + " Writing orientation: " + gdpictureOCR.GetBlockOrientation(resID, i);
message = message + "\n Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString();
int left = gdpictureOCR.GetBlockLeft(resID, i);
int top = gdpictureOCR.GetBlockTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized blocks to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the top y-coordinate of the bounding box of the specified block, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the block's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized blocks within the OCR result and some of the block's properties.
Dim caption As String = "Example: GetBlockTop"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Purple)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + ":" + vbCrLf + "Type: " + gdpictureOCR.GetBlockType(resID, i).ToString()
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i)
message = message + vbCrLf + " Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString()
Dim left As Integer = gdpictureOCR.GetBlockLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetBlockTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized blocks to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockTop";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Purple);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + ":\nType: " + gdpictureOCR.GetBlockType(resID, i).ToString();
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i);
message = message + "\n Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString();
int left = gdpictureOCR.GetBlockLeft(resID, i);
int top = gdpictureOCR.GetBlockTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized blocks to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the left x-coordinate of the bounding box of the specified block, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the block's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized blocks within the OCR result and some of the block's properties.
Dim caption As String = "Example: GetBlockLeft"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Purple)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + ":" + vbCrLf + "Type: " + gdpictureOCR.GetBlockType(resID, i).ToString()
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i)
message = message + vbCrLf + " Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString()
Dim left As Integer = gdpictureOCR.GetBlockLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetBlockTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized blocks to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockLeft";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Purple);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + ":\nType: " + gdpictureOCR.GetBlockType(resID, i).ToString();
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i);
message = message + "\n Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString();
int left = gdpictureOCR.GetBlockLeft(resID, i);
int top = gdpictureOCR.GetBlockTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized blocks to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the bottom y-coordinate of the bounding box of the specified block, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the block's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized blocks within the OCR result and some of the block's properties.
Dim caption As String = "Example: GetBlockBottom"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Purple)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + ":" + vbCrLf + "Type: " + gdpictureOCR.GetBlockType(resID, i).ToString()
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i)
message = message + vbCrLf + " Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString()
Dim left As Integer = gdpictureOCR.GetBlockLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetBlockTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized blocks to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockBottom";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Purple);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + ":\nType: " + gdpictureOCR.GetBlockType(resID, i).ToString();
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i);
message = message + "\n Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString();
int left = gdpictureOCR.GetBlockLeft(resID, i);
int top = gdpictureOCR.GetBlockTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized blocks to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the right x-coordinate of the bounding box of the specified block, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the block's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized blocks within the OCR result and some of the block's properties.
Dim caption As String = "Example: GetBlockRight"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Purple)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + ":" + vbCrLf + "Type: " + gdpictureOCR.GetBlockType(resID, i).ToString()
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i)
message = message + vbCrLf + " Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString()
Dim left As Integer = gdpictureOCR.GetBlockLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetBlockTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized blocks to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockRight";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Purple);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + ":\nType: " + gdpictureOCR.GetBlockType(resID, i).ToString();
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i);
message = message + "\n Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString();
int left = gdpictureOCR.GetBlockLeft(resID, i);
int top = gdpictureOCR.GetBlockTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized blocks to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of paragraphs within the specified block, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of recognized paragraphs within the specified block. Please always use the method to determine if this method has been successful.
How to find out the number of recognized blocks within the OCR result and some of the block's properties.
Dim caption As String = "Example: GetBlockParagraphCount"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Purple)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + ":" + vbCrLf + "Type: " + gdpictureOCR.GetBlockType(resID, i).ToString()
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i)
message = message + vbCrLf + " Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString()
Dim left As Integer = gdpictureOCR.GetBlockLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetBlockTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized blocks to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockParagraphCount";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Purple);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + ":\nType: " + gdpictureOCR.GetBlockType(resID, i).ToString();
message = message + " Writing direction: " + gdpictureOCR.GetBlockWritingDirection(resID, i);
message = message + "\n Paragraphs: " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString();
int left = gdpictureOCR.GetBlockLeft(resID, i);
int top = gdpictureOCR.GetBlockTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetBlockRight(resID, i) - left, gdpictureOCR.GetBlockBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized blocks to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the index of the first paragraph in the specified block, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the block within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the first paragraph in the specified block. Please always use the method to determine if this method has been successful.
How to find out the number of paragraphs within a block, that is a part of the same OCR result.
Dim caption As String = "Example: GetBlockFirstParagraphIndex"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized blocks: " + blockCount.ToString() + vbCrLf
For i As Integer = 0 To blockCount - 1
message = message + "The block nr." + i.ToString() + "contains " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString() + " paragraphs." + vbCrLf
message = message + " The first paragraph index is : " + gdpictureOCR.GetBlockFirstParagraphIndex(resID, i).ToString() + vbCrLf
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetBlockFirstParagraphIndex";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "0123456789";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized blocks: " + blockCount.ToString() + "\n";
for (int i = 0; i < blockCount; i++)
{
message = message + "The block nr." + i.ToString() + "contains " + gdpictureOCR.GetBlockParagraphCount(resID, i).ToString() + " paragraphs.\n";
message = message + " The first paragraph index is : " + gdpictureOCR.GetBlockFirstParagraphIndex(resID, i).ToString() + "\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
MessageBox.Show("Done!", caption);
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of paragraphs within a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of recognized paragraphs. Please always use the method to determine if this method has been successful.
How to find out the number of recognized paragraphs within the OCR result and some of the paragraph's properties.
Dim caption As String = "Example: GetParagraphCount"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
For i As Integer = 0 To paragraphCount - 1
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines." + vbCrLf
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString()
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized paragraphs to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetParagraphCount";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + "\n";
for (int i = 0; i < paragraphCount; i++)
{
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines.\n";
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString();
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetParagraphLeft(resID, i);
int top = gdpictureOCR.GetParagraphTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetParagraphRight(resID, i) - left, gdpictureOCR.GetParagraphBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized paragraphs to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the top y-coordinate of the bounding box of the specified paragraph, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the paragraph within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the paragraph's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized paragraphs within the OCR result and some of the paragraph's properties.
Dim caption As String = "Example: GetParagraphTop"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
For i As Integer = 0 To paragraphCount - 1
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines." + vbCrLf
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString()
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized paragraphs to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetParagraphTop";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + "\n";
for (int i = 0; i < paragraphCount; i++)
{
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines.\n";
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString();
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetParagraphLeft(resID, i);
int top = gdpictureOCR.GetParagraphTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetParagraphRight(resID, i) - left, gdpictureOCR.GetParagraphBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized paragraphs to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the left x-coordinate of the bounding box of the specified paragraph, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the paragraph within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the paragraph's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized paragraphs within the OCR result and some of the paragraph's properties.
Dim caption As String = "Example: GetParagraphLeft"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
For i As Integer = 0 To paragraphCount - 1
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines." + vbCrLf
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString()
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized paragraphs to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetParagraphLeft";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + "\n";
for (int i = 0; i < paragraphCount; i++)
{
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines.\n";
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString();
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetParagraphLeft(resID, i);
int top = gdpictureOCR.GetParagraphTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetParagraphRight(resID, i) - left, gdpictureOCR.GetParagraphBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized paragraphs to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the bottom y-coordinate of the bounding box of the specified paragraph, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the paragraph within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the paragraph's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized paragraphs within the OCR result and some of the paragraph's properties.
Dim caption As String = "Example: GetParagraphBottom"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
For i As Integer = 0 To paragraphCount - 1
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines." + vbCrLf
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString()
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized paragraphs to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetParagraphBottom";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + "\n";
for (int i = 0; i < paragraphCount; i++)
{
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines.\n";
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString();
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetParagraphLeft(resID, i);
int top = gdpictureOCR.GetParagraphTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetParagraphRight(resID, i) - left, gdpictureOCR.GetParagraphBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized paragraphs to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the right x-coordinate of the bounding box of the specified paragraph, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the paragraph within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the paragraph's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized paragraphs within the OCR result and some of the paragraph's properties.
Dim caption As String = "Example: GetParagraphRight"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
For i As Integer = 0 To paragraphCount - 1
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines." + vbCrLf
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString()
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized paragraphs to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetParagraphRight";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + "\n";
for (int i = 0; i < paragraphCount; i++)
{
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines.\n";
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString();
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetParagraphLeft(resID, i);
int top = gdpictureOCR.GetParagraphTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetParagraphRight(resID, i) - left, gdpictureOCR.GetParagraphBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized paragraphs to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the justification of the specified paragraph, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the paragraph within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The paragraph's justification. A member of the OCRParagraphJustification enumeration.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized paragraphs within the OCR result and some of the paragraph's properties.
Dim caption As String = "Example: GetParagraphJustification"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
For i As Integer = 0 To paragraphCount - 1
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines." + vbCrLf
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString()
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized paragraphs to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetParagraphJustification";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + "\n";
for (int i = 0; i < paragraphCount; i++)
{
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines.\n";
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString();
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetParagraphLeft(resID, i);
int top = gdpictureOCR.GetParagraphTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetParagraphRight(resID, i) - left, gdpictureOCR.GetParagraphBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized paragraphs to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of text lines within the specified paragraph, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the paragraph within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of text lines within a paragraph. Please always use the method to determine if this method has been successful.
How to find out the number of recognized paragraphs within the OCR result and some of the paragraph's properties.
Dim caption As String = "Example: GetParagraphTextLineCount"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
For i As Integer = 0 To paragraphCount - 1
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines." + vbCrLf
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString()
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized paragraphs to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetParagraphTextLineCount";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + "\n";
for (int i = 0; i < paragraphCount; i++)
{
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines.\n";
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString();
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetParagraphLeft(resID, i);
int top = gdpictureOCR.GetParagraphTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetParagraphRight(resID, i) - left, gdpictureOCR.GetParagraphBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized paragraphs to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the index of the block, which incorporates the specified paragraph, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the paragraph within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the block, which involves the required paragraph. Please always use the method to determine if this method has been successful.
How to determine, which paragraph belongs to which block in the OCR result.
Dim caption As String = "Example: GetParagraphBlockIndex"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR()
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
'Setting up the image is mandatory.
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim message As String = ""
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim blockCount As Integer = gdpictureOCR.GetBlockCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of all recognized blocks: " + blockCount.ToString() + vbCrLf
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of all recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
For i As Integer = 0 To paragraphCount - 1
message = message + "The paragraph nr." + i.ToString() + " is included in the block nr." +
gdpictureOCR.GetParagraphBlockIndex(resID, i).ToString() = "." + vbCrLf
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetParagraphBlockIndex";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int blockCount = gdpictureOCR.GetBlockCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of all recognized blocks: " + blockCount.ToString() + "\n";
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of all recognized paragraphs: " + paragraphCount.ToString() + "\n";
for (int i = 0; i < paragraphCount; i++)
{
message = message + "The paragraph nr." + i.ToString() + " is included in the block nr." +
gdpictureOCR.GetParagraphBlockIndex(resID, i).ToString() + ".\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the index of the first text line in the specified paragraph, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the paragraph within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the first text line in the specified paragraph. Please always use the method to determine if this method has beensuccessful.
How to find out the number of recognized paragraphs within the OCR result and some of the paragraph's properties.
Dim caption As String = "Example: GetParagraphFirstTextLineIndex"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
For i As Integer = 0 To paragraphCount - 1
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines." + vbCrLf
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString()
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized paragraphs to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetParagraphFirstTextLineIndex";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized paragraphs: " + paragraphCount.ToString() + "\n";
for (int i = 0; i < paragraphCount; i++)
{
message = message + "The paragraph nr." + i.ToString() + " contains " + gdpictureOCR.GetParagraphTextLineCount(resID, i).ToString() + " text lines.\n";
message = message + " The paragraph is justified: " + gdpictureOCR.GetParagraphJustification(resID, i).ToString();
message = message + " The first text line index is " + gdpictureOCR.GetParagraphFirstTextLineIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetParagraphLeft(resID, i);
int top = gdpictureOCR.GetParagraphTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetParagraphRight(resID, i) - left, gdpictureOCR.GetParagraphBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized paragraphs to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of text lines within a specified OCR result.
The resulting value doesn't contain any empty lines, as they are not provided in the OCR result.
The unique result identifier of the executed OCR process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note that the resulting value doesn't contain any empty lines, if they have been recognized.
The number of recognized lines in text. Please always use the method to determine if this method has been successful.
How to find out the number of recognized text lines within the OCR result and some of the text line's properties.
Dim caption As String = "Example: GetTextLineCount"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim linesCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized text lines: " + linesCount.ToString() + vbCrLf
For i As Integer = 0 To linesCount - 1
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words." + vbCrLf
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized text lines to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetTextLineCount";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int linesCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized text lines: " + linesCount.ToString() + "\n";
for (int i = 0; i < linesCount; i++)
{
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words.\n";
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetTextLineLeft(resID, i);
int top = gdpictureOCR.GetTextLineTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized text lines to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the top y-coordinate of the bounding box of the specified line, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the text line within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the text line's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized text lines within the OCR result and some of the text line's properties.
Dim caption As String = "Example: GetTextLineTop"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim linesCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized text lines: " + linesCount.ToString() + vbCrLf
For i As Integer = 0 To linesCount - 1
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words." + vbCrLf
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized text lines to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetTextLineTop";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int linesCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized text lines: " + linesCount.ToString() + "\n";
for (int i = 0; i < linesCount; i++)
{
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words.\n";
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetTextLineLeft(resID, i);
int top = gdpictureOCR.GetTextLineTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized text lines to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the left x-coordinate of the bounding box of the specified text line, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the text line within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the text line's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized text lines within the OCR result and some of the text line's properties.
Dim caption As String = "Example: GetTextLineLeft"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim linesCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized text lines: " + linesCount.ToString() + vbCrLf
For i As Integer = 0 To linesCount - 1
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words." + vbCrLf
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized text lines to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetTextLineLeft";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int linesCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized text lines: " + linesCount.ToString() + "\n";
for (int i = 0; i < linesCount; i++)
{
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words.\n";
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetTextLineLeft(resID, i);
int top = gdpictureOCR.GetTextLineTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized text lines to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the bottom y-coordinate of the bounding box of the specified text line, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the text line within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the text line's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized text lines within the OCR result and some of the text line's properties.
Dim caption As String = "Example: GetTextLineBottom"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim linesCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized text lines: " + linesCount.ToString() + vbCrLf
For i As Integer = 0 To linesCount - 1
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words." + vbCrLf
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized text lines to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetTextLineBottom";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int linesCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized text lines: " + linesCount.ToString() + "\n";
for (int i = 0; i < linesCount; i++)
{
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words.\n";
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetTextLineLeft(resID, i);
int top = gdpictureOCR.GetTextLineTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized text lines to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the right x-coordinate of the bounding box of the specified text line, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the text line within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the text line's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized text lines within the OCR result and some of the text line's properties.
Dim caption As String = "Example: GetTextLineRight"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim linesCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized text lines: " + linesCount.ToString() + vbCrLf
For i As Integer = 0 To linesCount - 1
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words." + vbCrLf
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized text lines to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetTextLineRight";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int linesCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized text lines: " + linesCount.ToString() + "\n";
for (int i = 0; i < linesCount; i++)
{
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words.\n";
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetTextLineLeft(resID, i);
int top = gdpictureOCR.GetTextLineTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized text lines to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of words within the specified text line, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the text line within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of words within a text line. Please always use the method to determine if this method has been successful.
How to find out the number of recognized text lines within the OCR result and some of the text line's properties.
Dim caption As String = "Example: GetTextLineWordCount"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim linesCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized text lines: " + linesCount.ToString() + vbCrLf
For i As Integer = 0 To linesCount - 1
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words." + vbCrLf
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized text lines to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetTextLineWordCount";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int linesCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized text lines: " + linesCount.ToString() + "\n";
for (int i = 0; i < linesCount; i++)
{
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words.\n";
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetTextLineLeft(resID, i);
int top = gdpictureOCR.GetTextLineTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized text lines to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Gets the value of the specified line, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the line within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the specified line. Please always use the method to determine if this method has been successful.
How to find out the recognized lines.
Dim caption As String = "Example: GetTextLineValue"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim linesCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized text lines: " + linesCount.ToString() + vbCrLf
Dim line As String = ""
For i As Integer = 0 To linesCount - 1
message = message + i.ToString() + ":"
line = gdpictureOCR.GetTextLineValue(resID, i)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + line
Else
message = message + gdpictureOCR.GetStat().ToString()
End If
message += vbCrLf
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetTextLineValue";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int linesCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized text lines: " + linesCount.ToString() + "\n";
string line = "";
for (int i = 0; i < linesCount; i++)
{
message = message + i.ToString() + ":";
line = gdpictureOCR.GetTextLineValue(resID, i);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK) message = message + line;
else message = message + gdpictureOCR.GetStat().ToString();
message += "\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the index of the paragraph, which incorporates the specified text line, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the text line within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the paragraph, which involves the required text line. Please always use the method to determine if this method has been successful.
How to determine, which text line belongs to which paragraph in the OCR result.
Dim caption As String = "Example: GetTextLineParagraphIndex"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR()
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
'Setting up the image is mandatory.
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim message As String = ""
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim paragraphCount As Integer = gdpictureOCR.GetParagraphCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of all recognized paragraphs: " + paragraphCount.ToString() + vbCrLf
Dim linesCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of all recognized text lines: " + linesCount.ToString() + vbCrLf
For i As Integer = 0 To linesCount - 1
message = message + "The line nr." + i.ToString() + " is included in the paragraph nr." +
gdpictureOCR.GetTextLineParagraphIndex(resID, i).ToString() + "." + vbCrLf
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetTextLineParagraphIndex";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = gdpictureOCR.GetParagraphCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of all recognized paragraphs: " + paragraphCount.ToString() + "\n";
int linesCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of all recognized text lines: " + linesCount.ToString() + "\n";
for (int i = 0; i < linesCount; i++)
{
message = message + "The line nr." + i.ToString() + " is included in the paragraph nr." +
gdpictureOCR.GetTextLineParagraphIndex(resID, i).ToString() + ".\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the index of the first word in the specified text line, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the text line within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the first word in the specified text line. Please always use the method to determine if this method has been successful.
How to find out the number of recognized text lines within the OCR result and some of the text line's properties.
Dim caption As String = "Example: GetTextLineFirstWordIndex"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Olive)
gdpicturePDF.SetLineWidth(2)
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
Dim message As String = Nothing
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim linesCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of recognized text lines: " + linesCount.ToString() + vbCrLf
For i As Integer = 0 To linesCount - 1
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words." + vbCrLf
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + "." + vbCrLf
Dim left As Integer = gdpictureOCR.GetTextLineLeft(resID, i)
Dim top As Integer = gdpictureOCR.GetTextLineTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized text lines to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString())
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetTextLineFirstWordIndex";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Olive);
gdpicturePDF.SetLineWidth(2);
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
string message = "";
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int linesCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of recognized text lines: " + linesCount.ToString() + "\n";
for (int i = 0; i < linesCount; i++)
{
message = message + "The line nr." + i.ToString() + " contains " + gdpictureOCR.GetTextLineWordCount(resID, i).ToString() + " words.\n";
message = message + " The first word index is " + gdpictureOCR.GetTextLineFirstWordIndex(resID, i).ToString() + ".\n";
int left = gdpictureOCR.GetTextLineLeft(resID, i);
int top = gdpictureOCR.GetTextLineTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetTextLineRight(resID, i) - left, gdpictureOCR.GetTextLineBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized text lines to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of words within a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of recognized words. Please always use the method to determine if this method has been successful.
How to find out the number of recognized words within the OCR result.
Dim caption As String = "Example: GetWordCount"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
MessageBox.Show("The number of recognized words: " + wordCount.ToString(), caption)
'Continue with analyzing the result ...
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordCount";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The number of recognized words: " + wordCount.ToString(), caption);
//Continue with analyzing the result ...
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the value of the specified word, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the specified word. Please always use the method to determine if this method has been successful.
How to find out the recognized words.
Dim caption As String = "Example: GetWordValue"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim content As String = "", word = ""
For i As Integer = 0 To wordCount - 1
word = gdpictureOCR.GetWordValue(resID, i)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
content = content + " " + word
End If
Next
MessageBox.Show("The number of recognized words: " + wordCount.ToString() + "" + vbCrLf + "Content: " + content, caption)
'Continue with analyzing the result ...
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordValue";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string content = "", word = "";
for (int i = 0; i < wordCount; i++)
{
word = gdpictureOCR.GetWordValue(resID, i);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
content = content + " " + word;
}
MessageBox.Show("The number of recognized words: " + wordCount.ToString() + "\nContent: " + content, caption);
//Continue with analyzing the result ...
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the index of the line, which incorporates the specified word, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the line, which involves the required word. Please always use the method to determine if this method has been successful.
How to determine, which word belongs to which line in the OCR result.
Dim caption As String = "Example: GetWordLineIndex"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR()
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
'Setting up the image is mandatory.
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim lineCount As Integer = gdpictureOCR.GetTextLineCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of all recognized text lines: " + lineCount.ToString() + vbCrLf
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of all recognized words: " + wordCount.ToString() + vbCrLf
For i As Integer = 0 To wordCount - 1
message = message + "The word nr." + i.ToString() + " is included in the line nr." +
gdpictureOCR.GetWordLineIndex(resID, i).ToString() + "." + vbCrLf
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordLineIndex";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "";
int lineCount = gdpictureOCR.GetTextLineCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of all recognized text lines: " + lineCount.ToString() + "\n";
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of all recognized words: " + wordCount.ToString() + "\n";
for (int i = 0; i < wordCount; i++)
{
message = message + "The word nr." + i.ToString() + " is included in the line nr." +
gdpictureOCR.GetWordLineIndex(resID, i).ToString() + ".\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the name of the detected font of the specified word, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The font family name of the specified word. Please always use the method to determine if this method has been successful.
How to find out the number of recognized words within the OCR result and some of the word's properties.
Dim caption As String = "Example: GetWordFontFamilyName"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
'Release default languages.
gdpictureOCR.ResetSelectedDictionaries()
'Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak)
gdpictureOCR.AddLanguage(OCRLanguage.Czech)
'Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200)
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized words: " + wordCount.ToString()
'Analyze the results.
For i As Integer = 0 To wordCount - 1
message = message + vbCrLf + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) + vbCrLf +
message = " Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() + vbCrLf +
" monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString()
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordFontFamilyName";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
//Release default languages.
gdpictureOCR.ResetSelectedDictionaries();
//Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak);
gdpictureOCR.AddLanguage(OCRLanguage.Czech);
//Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200);
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized words: " + wordCount.ToString();
//Analyze the results.
for (int i = 0; i < wordCount; i++)
{
message = message + "\n" + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) +
message = "\n Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() +
"\n: monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the size of the detected font of the specified word, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The font size of the specified word, in points. Please always use the method to determine if this method has been successful.
How to find out the number of recognized words within the OCR result and some of the word's properties.
Dim caption As String = "Example: GetWordFontSize"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
'Release default languages.
gdpictureOCR.ResetSelectedDictionaries()
'Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak)
gdpictureOCR.AddLanguage(OCRLanguage.Czech)
'Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200)
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized words: " + wordCount.ToString()
'Analyze the results.
For i As Integer = 0 To wordCount - 1
message = message + vbCrLf + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) + vbCrLf +
message = " Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() + vbCrLf +
" monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString()
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when + "/" + gdpictureOCR.GetStat().ToString(). Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordFontSize";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
//Release default languages.
gdpictureOCR.ResetSelectedDictionaries();
//Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak);
gdpictureOCR.AddLanguage(OCRLanguage.Czech);
//Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200);
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized words: " + wordCount.ToString();
//Analyze the results.
for (int i = 0; i < wordCount; i++)
{
message = message + "\n" + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) +
message = "\n Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() +
"\n: monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns, if the detected font of the specified word is monospaced (aka fixed-pitch, fixed-width, or non-proportional font).
The word is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true, if the word's detected font is monospaced, otherwise false.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized words within the OCR result and some of the word's properties.
Dim caption As String = "Example: GetWordFontIsMonospaced"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
'Release default languages.
gdpictureOCR.ResetSelectedDictionaries()
'Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak)
gdpictureOCR.AddLanguage(OCRLanguage.Czech)
'Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200)
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized words: " + wordCount.ToString()
'Analyze the results.
For i As Integer = 0 To wordCount - 1
message = message + vbCrLf + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) + vbCrLf +
message = " Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() + vbCrLf +
" monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString()
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordFontIsMonospaced";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
//Release default languages.
gdpictureOCR.ResetSelectedDictionaries();
//Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak);
gdpictureOCR.AddLanguage(OCRLanguage.Czech);
//Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200);
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized words: " + wordCount.ToString();
//Analyze the results.
for (int i = 0; i < wordCount; i++)
{
message = message + "\n" + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) +
message = "\n Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() +
"\n: monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns, if the detected font of the specified word is a serif font. The word is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true, if the word's detected font is serif, otherwise false.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized words within the OCR result and some of the word's properties.
Dim caption As String = "Example: GetWordFontIsSerif"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
'Release default languages.
gdpictureOCR.ResetSelectedDictionaries()
'Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak)
gdpictureOCR.AddLanguage(OCRLanguage.Czech)
'Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200)
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized words: " + wordCount.ToString()
'Analyze the results.
For i As Integer = 0 To wordCount - 1
message = message + vbCrLf + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) + vbCrLf +
message = " Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() + vbCrLf +
" monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString()
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordFontIsSerif";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
//Release default languages.
gdpictureOCR.ResetSelectedDictionaries();
//Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak);
gdpictureOCR.AddLanguage(OCRLanguage.Czech);
//Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200);
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized words: " + wordCount.ToString();
//Analyze the results.
for (int i = 0; i < wordCount; i++)
{
message = message + "\n" + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) +
message = "\n Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() +
"\n: monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns, if the detected font of the specified word is a small-caps font. The word is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true, if the word's detected font is small-caps, otherwise false.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized words within the OCR result and some of the word's properties.
Dim caption As String = "Example: GetWordFontIsSmallcaps"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
'Release default languages.
gdpictureOCR.ResetSelectedDictionaries()
'Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak)
gdpictureOCR.AddLanguage(OCRLanguage.Czech)
'Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200)
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized words: " + wordCount.ToString()
'Analyze the results.
For i As Integer = 0 To wordCount - 1
message = message + vbCrLf + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) + vbCrLf +
message = " Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() + vbCrLf +
" monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString()
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordFontIsSmallcaps";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
//Release default languages.
gdpictureOCR.ResetSelectedDictionaries();
//Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak);
gdpictureOCR.AddLanguage(OCRLanguage.Czech);
//Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200);
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized words: " + wordCount.ToString();
//Analyze the results.
for (int i = 0; i < wordCount; i++)
{
message = message + "\n" + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) +
message = "\n Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() +
"\n: monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the style of the detected font of the specified word, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The font style of the specified word. A member of the FontStyle enumeration.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized words within the OCR result and some of the word's properties.
Dim caption As String = "Example: GetWordFontStyle"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
'Release default languages.
gdpictureOCR.ResetSelectedDictionaries()
'Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak)
gdpictureOCR.AddLanguage(OCRLanguage.Czech)
'Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200)
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized words: " + wordCount.ToString()
'Analyze the results.
For i As Integer = 0 To wordCount - 1
message = message + vbCrLf + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) + vbCrLf +
message = " Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() + vbCrLf +
" monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString()
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordFontStyle";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
//Release default languages.
gdpictureOCR.ResetSelectedDictionaries();
//Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak);
gdpictureOCR.AddLanguage(OCRLanguage.Czech);
//Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200);
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized words: " + wordCount.ToString();
//Analyze the results.
for (int i = 0; i < wordCount; i++)
{
message = message + "\n" + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) +
message = "\n Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() +
"\n: monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the top y-coordinate of the bounding box of the specified word, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the word's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to get the position of recognized words within the OCR result.
Dim caption As String = "Example: GetWordTop"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim left As Integer = gdpictureOCR.GetWordLeft(resID, 0)
Dim top As Integer = gdpictureOCR.GetWordTop(resID, 0)
If gdpicturePDF.DrawRectangle(left, top,
gdpictureOCR.GetWordRight(resID, wordCount - 1) - left,
gdpictureOCR.GetWordBottom(resID, wordCount - 1) - top,
False, True) = GdPictureStatus.OK Then
MessageBox.Show("The recognized phone number area has been successfully drawn.", caption)
End If
'Save the page with drawn recognized phone number to the New PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordTop";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int left = gdpictureOCR.GetWordLeft(resID, 0);
int top = gdpictureOCR.GetWordTop(resID, 0);
if (gdpicturePDF.DrawRectangle(left, top,
gdpictureOCR.GetWordRight(resID, wordCount - 1) - left,
gdpictureOCR.GetWordBottom(resID, wordCount - 1) - top,
false, true) == GdPictureStatus.OK)
MessageBox.Show("The recognized phone number area has been successfully drawn.", caption);
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the left x-coordinate of the bounding box of the specified word, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the word's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to get the position of recognized words within the OCR result.
Dim caption As String = "Example: GetWordLeft"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim left As Integer = gdpictureOCR.GetWordLeft(resID, 0)
Dim top As Integer = gdpictureOCR.GetWordTop(resID, 0)
If gdpicturePDF.DrawRectangle(left, top,
gdpictureOCR.GetWordRight(resID, wordCount - 1) - left,
gdpictureOCR.GetWordBottom(resID, wordCount - 1) - top,
False, True) = GdPictureStatus.OK Then
MessageBox.Show("The recognized phone number area has been successfully drawn.", caption)
End If
'Save the page with drawn recognized phone number to the New PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordLeft";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int left = gdpictureOCR.GetWordLeft(resID, 0);
int top = gdpictureOCR.GetWordTop(resID, 0);
if (gdpicturePDF.DrawRectangle(left, top,
gdpictureOCR.GetWordRight(resID, wordCount - 1) - left,
gdpictureOCR.GetWordBottom(resID, wordCount - 1) - top,
false, true) == GdPictureStatus.OK)
MessageBox.Show("The recognized phone number area has been successfully drawn.", caption);
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the bottom y-coordinate of the bounding box of the specified word, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the word's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to get the position of recognized words within the OCR result.
Dim caption As String = "Example: GetWordBottom"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim left As Integer = gdpictureOCR.GetWordLeft(resID, 0)
Dim top As Integer = gdpictureOCR.GetWordTop(resID, 0)
If gdpicturePDF.DrawRectangle(left, top,
gdpictureOCR.GetWordRight(resID, wordCount - 1) - left,
gdpictureOCR.GetWordBottom(resID, wordCount - 1) - top,
False, True) = GdPictureStatus.OK Then
MessageBox.Show("The recognized phone number area has been successfully drawn.", caption)
End If
'Save the page with drawn recognized phone number to the New PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordBottom";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int left = gdpictureOCR.GetWordLeft(resID, 0);
int top = gdpictureOCR.GetWordTop(resID, 0);
if (gdpicturePDF.DrawRectangle(left, top,
gdpictureOCR.GetWordRight(resID, wordCount - 1) - left,
gdpictureOCR.GetWordBottom(resID, wordCount - 1) - top,
false, true) == GdPictureStatus.OK)
MessageBox.Show("The recognized phone number area has been successfully drawn.", caption);
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the right x-coordinate of the bounding box of the specified word, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the word's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to get the position of recognized words within the OCR result.
Dim caption As String = "Example: GetWordRight"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim left As Integer = gdpictureOCR.GetWordLeft(resID, 0)
Dim top As Integer = gdpictureOCR.GetWordTop(resID, 0)
If gdpicturePDF.DrawRectangle(left, top,
gdpictureOCR.GetWordRight(resID, wordCount - 1) - left,
gdpictureOCR.GetWordBottom(resID, wordCount - 1) - top,
False, True) = GdPictureStatus.OK Then
MessageBox.Show("The recognized phone number area has been successfully drawn.", caption)
End If
'Save the page with drawn recognized phone number to the New PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordRight";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int left = gdpictureOCR.GetWordLeft(resID, 0);
int top = gdpictureOCR.GetWordTop(resID, 0);
if (gdpicturePDF.DrawRectangle(left, top,
gdpictureOCR.GetWordRight(resID, wordCount - 1) - left,
gdpictureOCR.GetWordBottom(resID, wordCount - 1) - top,
false, true) == GdPictureStatus.OK)
MessageBox.Show("The recognized phone number area has been successfully drawn.", caption);
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of spaces before the specified word, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of recognized spaces. Please always use the method to determine if this method has been successful.
How to find out the number of spaces before the recognized word within the OCR result.
Dim caption As String = "Example: GetWordSpacesBefore"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
MessageBox.Show("The number of recognized words: " + wordCount.ToString(), caption)
If wordCount > 0 Then
Dim spaces As Integer = gdpictureOCR.GetWordSpacesBefore(resID, 0)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
MessageBox.Show("The number of spaces before the first word: " + spaces.ToString(), caption)
End If
End If
'Continue with analyzing the result ...
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordSpacesBefore";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The number of recognized words: " + wordCount.ToString(), caption);
if (wordCount > 0)
{
int spaces = gdpictureOCR.GetWordSpacesBefore(resID, 0);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The number of spaces before the first word: " + spaces.ToString(), caption);
}
//Continue with analyzing the result ...
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns, the specified word confidence within a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The confidence of the specified word in the range [0 - 100].
Please always use the method to determine if this method has been successful.
Returns, if the specified word within a specified OCR result, has been found in the added dictionaries.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true, if the specified word has been found in the added dictionaries, otherwise false.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized words within the OCR result and some of the word's properties.
Dim caption As String = "Example: GetWordIsFromDictionary"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
'Release default languages.
gdpictureOCR.ResetSelectedDictionaries()
'Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak)
gdpictureOCR.AddLanguage(OCRLanguage.Czech)
'Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200)
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized words: " + wordCount.ToString()
'Analyze the results.
For i As Integer = 0 To wordCount - 1
message = message + vbCrLf + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) + vbCrLf +
message = " Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() + vbCrLf +
" monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString()
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordIsFromDictionary";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
//Release default languages.
gdpictureOCR.ResetSelectedDictionaries();
//Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak);
gdpictureOCR.AddLanguage(OCRLanguage.Czech);
//Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200);
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized words: " + wordCount.ToString();
//Analyze the results.
for (int i = 0; i < wordCount; i++)
{
message = message + "\n" + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) +
message = "\n Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() +
"\n: monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the name of the language used to recognize the specified word, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The name of the used language. Please always use the method to determine if this method has been successful.
How to find out the number of recognized words within the OCR result and some of the word's properties.
Dim caption As String = "Example: GetWordRecognitionLanguage"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
'Release default languages.
gdpictureOCR.ResetSelectedDictionaries()
'Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak)
gdpictureOCR.AddLanguage(OCRLanguage.Czech)
'Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
gdpictureOCR.CharacterSet = ""
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200)
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized words: " + wordCount.ToString()
'Analyze the results.
For i As Integer = 0 To wordCount - 1
message = message + vbCrLf + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) + vbCrLf +
message = " Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() + vbCrLf +
" monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString()
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordRecognitionLanguage";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
//Release default languages.
gdpictureOCR.ResetSelectedDictionaries();
//Add required languages.
gdpictureOCR.AddLanguage(OCRLanguage.Slovak);
gdpictureOCR.AddLanguage(OCRLanguage.Czech);
//Set up the OCR mode.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
gdpictureOCR.CharacterSet = "";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 200);
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized words: " + wordCount.ToString();
//Analyze the results.
for (int i = 0; i < wordCount; i++)
{
message = message + "\n" + i.ToString() + ".word: " + gdpictureOCR.GetWordValue(resID, i) +
message = " IsFromDict: " + gdpictureOCR.GetWordIsFromDictionary(resID, i).ToString() +
message = " Language: " + gdpictureOCR.GetWordRecognitionLanguage(resID, i) +
message = "\n Font: " + gdpictureOCR.GetWordFontFamilyName(resID, i) +
" size: " + gdpictureOCR.GetWordFontSize(resID, i).ToString() +
" style: " + gdpictureOCR.GetWordFontStyle(resID, i).ToString() +
"\n: monospaced" + gdpictureOCR.GetWordFontIsMonospaced(resID, i).ToString() +
" serif" + gdpictureOCR.GetWordFontIsSerif(resID, i).ToString() +
" smallcaps" + gdpictureOCR.GetWordFontIsSmallcaps(resID, i).ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of characters within the specified word, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of characters. Please always use the method to determine if this method has been successful.
How to find out the number of characters in the recognized word within the OCR result.
Dim caption As String = "Example: GetWordCharacterCount"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim content As String = "", word As String = ""
Dim charAll As Integer = 0, charCount As Integer = 0
For i As Integer = 0 To wordCount - 1
word = gdpictureOCR.GetWordValue(resID, i)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
content = content + " " + word
End If
charCount = gdpictureOCR.GetWordCharacterCount(resID, i)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
charAll = charAll + charCount
End If
Dim index As Integer = gdpictureOCR.GetWordFirstCharacterIndex(resID, i)
'Continue with analyzing the result ...
Next
MessageBox.Show("The number of recognized words: " + wordCount.ToString() + vbCrLf +
"The number of recognized characters in all words: " + charAll.ToString() + vbCrLf +
"Content: " + content, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordCharacterCount";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string content = "", word = "";
int charAll = 0, charCount = 0;
for (int i = 0; i < wordCount; i++)
{
word = gdpictureOCR.GetWordValue(resID, i);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
content = content + " " + word;
charCount = gdpictureOCR.GetWordCharacterCount(resID, i);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
charAll = charAll + charCount;
int index = gdpictureOCR.GetWordFirstCharacterIndex(resID, i);
//Continue with analyzing the result ...
}
MessageBox.Show("The number of recognized words: " + wordCount.ToString() +
"\nThe number of recognized characters in all words: " + charAll.ToString() +
"\nContent: " + content, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the index of the first character in the specified word, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the word within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the first character of the specified word. Please always use the method to determine if this method has been successful.
How to retrieve the index of the first character in the recognized word.
Dim caption As String = "Example: GetWordFirstCharacterIndex"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim content As String = "", word As String = ""
Dim charAll As Integer = 0, charCount As Integer = 0
For i As Integer = 0 To wordCount - 1
word = gdpictureOCR.GetWordValue(resID, i)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
content = content + " " + word
End If
charCount = gdpictureOCR.GetWordCharacterCount(resID, i)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
charAll = charAll + charCount
End If
Dim index As Integer = gdpictureOCR.GetWordFirstCharacterIndex(resID, i)
'Continue with analyzing the result ...
Next
MessageBox.Show("The number of recognized words: " + wordCount.ToString() + vbCrLf +
"The number of recognized characters in all words: " + charAll.ToString() + vbCrLf +
"Content: " + content, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetWordFirstCharacterIndex";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string content = "", word = "";
int charAll = 0, charCount = 0;
for (int i = 0; i < wordCount; i++)
{
word = gdpictureOCR.GetWordValue(resID, i);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
content = content + " " + word;
charCount = gdpictureOCR.GetWordCharacterCount(resID, i);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
charAll = charAll + charCount;
int index = gdpictureOCR.GetWordFirstCharacterIndex(resID, i);
//Continue with analyzing the result ...
}
MessageBox.Show("The number of recognized words: " + wordCount.ToString() +
"\nThe number of recognized characters in all words: " + charAll.ToString() +
"\nContent: " + content, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString());
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of characters within a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of recognized characters. Please always use the method to determine if this method has been successful.
How to find out the number of recognized characters within the OCR result and some of the character's properties.
Dim caption As String = "Example: GetCharacterCount"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set the New origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Orchid)
gdpicturePDF.SetLineWidth(2)
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim charCount As Integer = gdpictureOCR.GetCharacterCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized characters: " + charCount.ToString()
Dim phonenumber As String = ""
Dim left As Integer = 0, right As Integer = 0, top As Integer = 0, bottom As Integer = 0
For i As Integer = 0 To charCount - 1
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i)
If i = 0 Then
left = gdpictureOCR.GetCharacterLeft(resID, i)
top = gdpictureOCR.GetCharacterTop(resID, i)
End If
If i = charCount - 1 Then
right = gdpictureOCR.GetCharacterRight(resID, i)
bottom = gdpictureOCR.GetCharacterBottom(resID, i)
End If
Next
message = message + vbCrLf + "The phone number is: " + phonenumber
If gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized phone number to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetCharacterCount";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Orchid);
gdpicturePDF.SetLineWidth(2);
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int charCount = gdpictureOCR.GetCharacterCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized characters: " + charCount.ToString();
string phonenumber = "";
int left = 0, right = 0, top = 0, bottom = 0;
for (int i = 0; i < charCount; i++)
{
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i);
if (i == 0)
{
left = gdpictureOCR.GetCharacterLeft(resID, i);
top = gdpictureOCR.GetCharacterTop(resID, i);
}
if (i == charCount - 1)
{
right = gdpictureOCR.GetCharacterRight(resID, i);
bottom = gdpictureOCR.GetCharacterBottom(resID, i);
}
}
message = message + "\nThe phone number is: " + phonenumber;
if (gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the top y-coordinate of the bounding box of the specified character, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and (OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the character's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized characters within the OCR result and some of the character's properties.
Dim caption As String = "Example: GetCharacterTop"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set the New origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Orchid)
gdpicturePDF.SetLineWidth(2)
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim charCount As Integer = gdpictureOCR.GetCharacterCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized characters: " + charCount.ToString()
Dim phonenumber As String = ""
Dim left As Integer = 0, right As Integer = 0, top As Integer = 0, bottom As Integer = 0
For i As Integer = 0 To charCount - 1
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i)
If i = 0 Then
left = gdpictureOCR.GetCharacterLeft(resID, i)
top = gdpictureOCR.GetCharacterTop(resID, i)
End If
If i = charCount - 1 Then
right = gdpictureOCR.GetCharacterRight(resID, i)
bottom = gdpictureOCR.GetCharacterBottom(resID, i)
End If
Next
message = message + vbCrLf + "The phone number is: " + phonenumber
If gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized phone number to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetCharacterTop";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Orchid);
gdpicturePDF.SetLineWidth(2);
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int charCount = gdpictureOCR.GetCharacterCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized characters: " + charCount.ToString();
string phonenumber = "";
int left = 0, right = 0, top = 0, bottom = 0;
for (int i = 0; i < charCount; i++)
{
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i);
if (i == 0)
{
left = gdpictureOCR.GetCharacterLeft(resID, i);
top = gdpictureOCR.GetCharacterTop(resID, i);
}
if (i == charCount - 1)
{
right = gdpictureOCR.GetCharacterRight(resID, i);
bottom = gdpictureOCR.GetCharacterBottom(resID, i);
}
}
message = message + "\nThe phone number is: " + phonenumber;
if (gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the left x-coordinate of the bounding box of the specified character, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and GetCharacterCount(OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the character's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized characters within the OCR result and some of the character's properties.
Dim caption As String = "Example: GetCharacterLeft"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set the New origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Orchid)
gdpicturePDF.SetLineWidth(2)
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim charCount As Integer = gdpictureOCR.GetCharacterCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized characters: " + charCount.ToString()
Dim phonenumber As String = ""
Dim left As Integer = 0, right As Integer = 0, top As Integer = 0, bottom As Integer = 0
For i As Integer = 0 To charCount - 1
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i)
If i = 0 Then
left = gdpictureOCR.GetCharacterLeft(resID, i)
top = gdpictureOCR.GetCharacterTop(resID, i)
End If
If i = charCount - 1 Then
right = gdpictureOCR.GetCharacterRight(resID, i)
bottom = gdpictureOCR.GetCharacterBottom(resID, i)
End If
Next
message = message + vbCrLf + "The phone number is: " + phonenumber
If gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized phone number to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetCharacterLeft";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Orchid);
gdpicturePDF.SetLineWidth(2);
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int charCount = gdpictureOCR.GetCharacterCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized characters: " + charCount.ToString();
string phonenumber = "";
int left = 0, right = 0, top = 0, bottom = 0;
for (int i = 0; i < charCount; i++)
{
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i);
if (i == 0)
{
left = gdpictureOCR.GetCharacterLeft(resID, i);
top = gdpictureOCR.GetCharacterTop(resID, i);
}
if (i == charCount - 1)
{
right = gdpictureOCR.GetCharacterRight(resID, i);
bottom = gdpictureOCR.GetCharacterBottom(resID, i);
}
}
message = message + "\nThe phone number is: " + phonenumber;
if (gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the bottom y-coordinate of the bounding box of the specified character, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and GetCharacterCount(OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the character's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized characters within the OCR result and some of the character's properties.
Dim caption As String = "Example: GetCharacterBottom"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set the New origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Orchid)
gdpicturePDF.SetLineWidth(2)
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim charCount As Integer = gdpictureOCR.GetCharacterCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized characters: " + charCount.ToString()
Dim phonenumber As String = ""
Dim left As Integer = 0, right As Integer = 0, top As Integer = 0, bottom As Integer = 0
For i As Integer = 0 To charCount - 1
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i)
If i = 0 Then
left = gdpictureOCR.GetCharacterLeft(resID, i)
top = gdpictureOCR.GetCharacterTop(resID, i)
End If
If i = charCount - 1 Then
right = gdpictureOCR.GetCharacterRight(resID, i)
bottom = gdpictureOCR.GetCharacterBottom(resID, i)
End If
Next
message = message + vbCrLf + "The phone number is: " + phonenumber
If gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized phone number to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetCharacterBottom";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Orchid);
gdpicturePDF.SetLineWidth(2);
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int charCount = gdpictureOCR.GetCharacterCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized characters: " + charCount.ToString();
string phonenumber = "";
int left = 0, right = 0, top = 0, bottom = 0;
for (int i = 0; i < charCount; i++)
{
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i);
if (i == 0)
{
left = gdpictureOCR.GetCharacterLeft(resID, i);
top = gdpictureOCR.GetCharacterTop(resID, i);
}
if (i == charCount - 1)
{
right = gdpictureOCR.GetCharacterRight(resID, i);
bottom = gdpictureOCR.GetCharacterBottom(resID, i);
}
}
message = message + "\nThe phone number is: " + phonenumber;
if (gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the right x-coordinate of the bounding box of the specified character, that is a part of a specified OCR result.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and GetCharacterCount(OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the character's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out the number of recognized characters within the OCR result and some of the character's properties.
Dim caption As String = "Example: GetCharacterRight"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set the New origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Orchid)
gdpicturePDF.SetLineWidth(2)
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim charCount As Integer = gdpictureOCR.GetCharacterCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized characters: " + charCount.ToString()
Dim phonenumber As String = ""
Dim left As Integer = 0, right As Integer = 0, top As Integer = 0, bottom As Integer = 0
For i As Integer = 0 To charCount - 1
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i)
If i = 0 Then
left = gdpictureOCR.GetCharacterLeft(resID, i)
top = gdpictureOCR.GetCharacterTop(resID, i)
End If
If i = charCount - 1 Then
right = gdpictureOCR.GetCharacterRight(resID, i)
bottom = gdpictureOCR.GetCharacterBottom(resID, i)
End If
Next
message = message + vbCrLf + "The phone number is: " + phonenumber
If gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized phone number to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetCharacterRight";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Orchid);
gdpicturePDF.SetLineWidth(2);
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int charCount = gdpictureOCR.GetCharacterCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized characters: " + charCount.ToString();
string phonenumber = "";
int left = 0, right = 0, top = 0, bottom = 0;
for (int i = 0; i < charCount; i++)
{
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i);
if (i == 0)
{
left = gdpictureOCR.GetCharacterLeft(resID, i);
top = gdpictureOCR.GetCharacterTop(resID, i);
}
if (i == charCount - 1)
{
right = gdpictureOCR.GetCharacterRight(resID, i);
bottom = gdpictureOCR.GetCharacterBottom(resID, i);
}
}
message = message + "\nThe phone number is: " + phonenumber;
if (gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the confidence of the specified character, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and GetCharacterCount(OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The confidence of the specified character in the range [0 - 100]. Please always use the method to determine if this method has been successful.
How to find out the confidence of the character recognized by the OCR.
Dim caption As String = "Example: GetCharacterConfidence"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set the New origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Orchid)
gdpicturePDF.SetLineWidth(2)
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = "@"
'Run the OCR process to recognize the character.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim charCount As Integer = gdpictureOCR.GetCharacterCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized characters: " + charCount.ToString() + vbCrLf
Dim left As Integer = 0, top As Integer = 0
For i As Integer = 0 To charCount - 1
message = message + " The confidence of the character nr. " + i.ToString() + " is: " + gdpictureOCR.GetCharacterConfidence(resID, i).ToString()
left = gdpictureOCR.GetCharacterLeft(resID, i)
top = gdpictureOCR.GetCharacterTop(resID, i)
If gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetCharacterRight(resID, i) - left, gdpictureOCR.GetCharacterBottom(resID, i) - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized phone number to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetCharacterConfidence";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Orchid);
gdpicturePDF.SetLineWidth(2);
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "@";
//Run the OCR process to recognize the character.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int charCount = gdpictureOCR.GetCharacterCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized characters: " + charCount.ToString() + "\n";
int left = 0, top = 0;
for (int i = 0; i < charCount; i++)
{
message = message + " The confidence of the character nr. " + i.ToString() + " is: " + gdpictureOCR.GetCharacterConfidence(resID, i).ToString();
left = gdpictureOCR.GetCharacterLeft(resID, i);
top = gdpictureOCR.GetCharacterTop(resID, i);
if (gdpicturePDF.DrawRectangle(left, top, gdpictureOCR.GetCharacterRight(resID, i) - left, gdpictureOCR.GetCharacterBottom(resID, i) - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Gets the value of the specified character, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and GetCharacterCount(OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the specified character. Please always use the method to determine if this method has been successful.
How to find out the number of recognized characters within the OCR result and some of the character's properties.
Dim caption As String = "Example: GetCharacterValue"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Set the New origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetLineColor(Color.Orchid)
gdpicturePDF.SetLineWidth(2)
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine
gdpictureOCR.CharacterSet = "0123456789"
'Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Run the OCR process to recognize the phone number.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim charCount As Integer = gdpictureOCR.GetCharacterCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of recognized characters: " + charCount.ToString()
Dim phonenumber As String = ""
Dim left As Integer = 0, right As Integer = 0, top As Integer = 0, bottom As Integer = 0
For i As Integer = 0 To charCount - 1
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i)
If i = 0 Then
left = gdpictureOCR.GetCharacterLeft(resID, i)
top = gdpictureOCR.GetCharacterTop(resID, i)
End If
If i = charCount - 1 Then
right = gdpictureOCR.GetCharacterRight(resID, i)
bottom = gdpictureOCR.GetCharacterBottom(resID, i)
End If
Next
message = message + vbCrLf + "The phone number is: " + phonenumber
If gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, False, True) = GdPictureStatus.OK Then
message = message + " Drawn: yes" + vbCrLf
Else
message = message + " Drawn: no" + vbCrLf
End If
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
'Save the page with drawn recognized phone number to the new PDF document.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetCharacterValue";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set the new origin for better coordinates handling.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetLineColor(Color.Orchid);
gdpicturePDF.SetLineWidth(2);
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextSingleLine;
gdpictureOCR.CharacterSet = "0123456789";
//Set up the area to be processed by the OCR.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Run the OCR process to recognize the phone number.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int charCount = gdpictureOCR.GetCharacterCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of recognized characters: " + charCount.ToString();
string phonenumber = "";
int left = 0, right = 0, top = 0, bottom = 0;
for (int i = 0; i < charCount; i++)
{
phonenumber = phonenumber + gdpictureOCR.GetCharacterValue(resID, i);
if (i == 0)
{
left = gdpictureOCR.GetCharacterLeft(resID, i);
top = gdpictureOCR.GetCharacterTop(resID, i);
}
if (i == charCount - 1)
{
right = gdpictureOCR.GetCharacterRight(resID, i);
bottom = gdpictureOCR.GetCharacterBottom(resID, i);
}
}
message = message + "\nThe phone number is: " + phonenumber;
if (gdpicturePDF.DrawRectangle(left, top, right - left, bottom - top, false, true) == GdPictureStatus.OK)
message = message + " Drawn: yes\n";
else
message = message + " Drawn: no\n";
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
//Save the page with drawn recognized phone number to the new PDF document.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of alternative symbols of a specific character recognized by the engine.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and GetCharacterCount(OCRResultID) - 1.
The number of alternative characters, if any.
Returns the value of specific alternative character.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and GetCharacterCount(OCRResultID) - 1.
The 0-based index of the alternative character. It must be a value between 0 and GetCharacterAlternativeCount(OCRResultID, CharacterIdx) - 1.
The value of specific alternative character
Returns the confidence of specific alternative character.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and GetCharacterCount(OCRResultID) - 1.
The 0-based index of the alternative character. It must be a value between 0 and GetCharacterAlternativeCount(OCRResultID, CharacterIdx) - 1.
The confidence of specific alternative character, in the range [0 - 100].
Returns the index of the word, which incorporates the specified character, that is a part of a specified OCR result.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the character within the specified OCR result. It must be a value between 0 and GetCharacterCount(OCRResultID) - 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the word, which involves the required character. Please always use the method to determine if this method has been successful.
How to determine, which character belongs to which word in the OCR result.
Dim caption As String = "Example: GetCharacterWordIndex"
Dim gdpictureOCR As GdPictureOCR = New GdPictureOCR()
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Load the PDF document.
If gdpicturePDF.LoadFromFile("input.pdf", False) = GdPictureStatus.OK Then
'Select the first page.
gdpicturePDF.SelectPage(1)
'Render this page to a 200 DPI image.
Dim image As Integer = gdpicturePDF.RenderPageToGdPictureImage(200, True)
'Setting up the image is mandatory.
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\Path\To\GdPicture.NET 14\Redist\OCR"
gdpictureOCR.AddLanguage(OCRLanguage.English)
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument
gdpictureOCR.CharacterSet = "@"
'Run the OCR process to recognize the character.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim wordCount As Integer = gdpictureOCR.GetWordCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of all recognized words: " + wordCount.ToString() + vbCrLf
Dim charCount As Integer = gdpictureOCR.GetCharacterCount(resID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
message = message + "The number of all recognized characters: " + charCount.ToString() + vbCrLf
For i As Integer = 0 To charCount - 1
message = message + "The character nr." + i.ToString() + " is included in the word nr." +
gdpictureOCR.GetCharacterWordIndex(resID, i).ToString() + "." + vbCrLf
Next
MessageBox.Show(message, caption)
'Continue with analyzing the result ...
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the image.
GdPictureDocumentUtilities.DisposeImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
'Close the document.
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Release resources.
gdpictureOCR.ReleaseOCRResults()
gdpictureOCR.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetCharacterWordIndex";
GdPictureOCR gdpictureOCR = new GdPictureOCR();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Load the PDF document.
if (gdpicturePDF.LoadFromFile("input.pdf", false) == GdPictureStatus.OK)
{
//Select the first page.
gdpicturePDF.SelectPage(1);
//Render this page to a 200 DPI image.
int image = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Set up the OCR parameters.
gdpictureOCR.ResourcesFolder = "C:\\Path\\To\\GdPicture.NET 14\\Redist\\OCR";
gdpictureOCR.AddLanguage(OCRLanguage.English);
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Set up the OCR context and the character list.
gdpictureOCR.Context = OCRContext.OCRContextDocument;
gdpictureOCR.CharacterSet = "@";
//Run the OCR process to recognize the character.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
int wordCount = gdpictureOCR.GetWordCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string message = "The number of all recognized words: " + wordCount.ToString() + "\n";
int charCount = gdpictureOCR.GetCharacterCount(resID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of all recognized characters: " + charCount.ToString() + "\n";
for (int i = 0; i < charCount; i++)
{
message = message + "The character nr." + i.ToString() + " is included in the word nr." +
gdpictureOCR.GetCharacterWordIndex(resID, i).ToString() + ".\n";
}
MessageBox.Show(message, caption);
//Continue with analyzing the result ...
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurred when running the OCR. Status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the image.
GdPictureDocumentUtilities.DisposeImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpicturePDF.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
//Close the document.
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
//Release resources.
gdpictureOCR.ReleaseOCRResults();
gdpictureOCR.Dispose();
gdpicturePDF.Dispose();
Returns the number of extracted form fields within a specified OCR result.
Form fields extraction is automatically performed during each OCR process.
The unique result identifier of the executed OCR process obtained by the method.
The number of extracted form fields
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the location of the key part of a specified form field.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the form field pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
Returns the left x-coordinate of the field key's bounding box, in pixels.
Returns the top y-coordinate of the field key's bounding box, in pixels.
Returns the width of the field key's bounding box, in pixels.
Returns the width of the field key's bounding box, in pixels.
A member of the GdPictureStatus enumeration.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the text of a specified form field.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the form field pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The key text.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the location of the value part of a specified form field.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the form field pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
Returns the left x-coordinate of the field value's bounding box, in pixels.
Returns the top y-coordinate of the field value's bounding box, in pixels.
Returns the width of the field value's bounding box, in pixels.
Returns the width of the field value's bounding box, in pixels.
A member of the GdPictureStatus enumeration.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the text of the key of a specified form field.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the form field pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The field text.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the type of a specified form field.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the form field pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
A member of the FormFieldType enumeration.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the number of extracted key-value pairs within a specified OCR result.
Key-value pairs extraction is automatically performed during each OCR process.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The number of detected key-value pairs.
Extracting key-value pairs from an image.
string caption = "Example: KVP/OCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.EnableSkewDetection = true;
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureOCR.SetImage(image);
string ocrResultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string keyValuePairsData = "";
for (int pairIdx = 0; pairIdx < gdpictureOCR.GetKeyValuePairCount(ocrResultID); pairIdx++)
{
if (pairIdx != 0)
{
keyValuePairsData += "\n";
}
keyValuePairsData += "Name: " + gdpictureOCR.GetKeyValuePairKeyString(ocrResultID, pairIdx) + " | " +
"Value: " + gdpictureOCR.GetKeyValuePairValueString(ocrResultID, pairIdx) + " | " +
"Type: " + gdpictureOCR.GetKeyValuePairDataType(ocrResultID, pairIdx).ToString() + " | " +
"Accuracy: " + Math.Round(gdpictureOCR.GetKeyValuePairConfidence(ocrResultID, pairIdx), 1).ToString() + "%";
}
MessageBox.Show(keyValuePairsData, caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the string representation of the key part of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the key-value pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The string representation of the key.
Extracting key-value pairs from an image.
string caption = "Example: KVP/OCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.EnableSkewDetection = true;
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureOCR.SetImage(image);
string ocrResultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string keyValuePairsData = "";
for (int pairIdx = 0; pairIdx < gdpictureOCR.GetKeyValuePairCount(ocrResultID); pairIdx++)
{
if (pairIdx != 0)
{
keyValuePairsData += "\n";
}
keyValuePairsData += "Name: " + gdpictureOCR.GetKeyValuePairKeyString(ocrResultID, pairIdx) + " | " +
"Value: " + gdpictureOCR.GetKeyValuePairValueString(ocrResultID, pairIdx) + " | " +
"Type: " + gdpictureOCR.GetKeyValuePairDataType(ocrResultID, pairIdx).ToString() + " | " +
"Accuracy: " + Math.Round(gdpictureOCR.GetKeyValuePairConfidence(ocrResultID, pairIdx), 1).ToString() + "%";
}
MessageBox.Show(keyValuePairsData, caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the string representation of the value part of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the key-value pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The string representation of the value.
Extracting key-value pairs from an image.
string caption = "Example: KVP/OCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.EnableSkewDetection = true;
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureOCR.SetImage(image);
string ocrResultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string keyValuePairsData = "";
for (int pairIdx = 0; pairIdx < gdpictureOCR.GetKeyValuePairCount(ocrResultID); pairIdx++)
{
if (pairIdx != 0)
{
keyValuePairsData += "\n";
}
keyValuePairsData += "Name: " + gdpictureOCR.GetKeyValuePairKeyString(ocrResultID, pairIdx) + " | " +
"Value: " + gdpictureOCR.GetKeyValuePairValueString(ocrResultID, pairIdx) + " | " +
"Type: " + gdpictureOCR.GetKeyValuePairDataType(ocrResultID, pairIdx).ToString() + " | " +
"Accuracy: " + Math.Round(gdpictureOCR.GetKeyValuePairConfidence(ocrResultID, pairIdx), 1).ToString() + "%";
}
MessageBox.Show(keyValuePairsData, caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the location of the key part of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the key-value pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
Returns the left x-coordinate of the key's bounding box, in pixels.
Returns the top y-coordinate of the key's bounding box, in pixels.
Returns the width of the key's bounding box, in pixels.
Returns the width of the key's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Extracting key-value pairs from an image.
string caption = "Example: KVP/OCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.EnableSkewDetection = true;
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureOCR.SetImage(image);
string ocrResultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string keyValuePairsData = "";
for (int pairIdx = 0; pairIdx < gdpictureOCR.GetKeyValuePairCount(ocrResultID); pairIdx++)
{
if (pairIdx != 0)
{
keyValuePairsData += "\n";
}
keyValuePairsData += "Name: " + gdpictureOCR.GetKeyValuePairKeyString(ocrResultID, pairIdx) + " | " +
"Value: " + gdpictureOCR.GetKeyValuePairValueString(ocrResultID, pairIdx) + " | " +
"Type: " + gdpictureOCR.GetKeyValuePairDataType(ocrResultID, pairIdx).ToString() + " | " +
"Accuracy: " + Math.Round(gdpictureOCR.GetKeyValuePairConfidence(ocrResultID, pairIdx), 1).ToString() + "%";
}
MessageBox.Show(keyValuePairsData, caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the location of the value part of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the key-value pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
Returns the left x-coordinate of the value's bounding box, in pixels.
Returns the top y-coordinate of the value's bounding box, in pixels.
Returns the width of the value's bounding box, in pixels.
Returns the width of the value's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Extracting key-value pairs from an image.
string caption = "Example: KVP/OCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.EnableSkewDetection = true;
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureOCR.SetImage(image);
string ocrResultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string keyValuePairsData = "";
for (int pairIdx = 0; pairIdx < gdpictureOCR.GetKeyValuePairCount(ocrResultID); pairIdx++)
{
if (pairIdx != 0)
{
keyValuePairsData += "\n";
}
keyValuePairsData += "Name: " + gdpictureOCR.GetKeyValuePairKeyString(ocrResultID, pairIdx) + " | " +
"Value: " + gdpictureOCR.GetKeyValuePairValueString(ocrResultID, pairIdx) + " | " +
"Type: " + gdpictureOCR.GetKeyValuePairDataType(ocrResultID, pairIdx).ToString() + " | " +
"Accuracy: " + Math.Round(gdpictureOCR.GetKeyValuePairConfidence(ocrResultID, pairIdx), 1).ToString() + "%";
}
MessageBox.Show(keyValuePairsData, caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the data type of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the key-value pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
A member of the DataType enumeration specifying the identified data type of the pair.
Extracting key-value pairs from an image.
string caption = "Example: KVP/OCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.EnableSkewDetection = true;
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureOCR.SetImage(image);
string ocrResultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string keyValuePairsData = "";
for (int pairIdx = 0; pairIdx < gdpictureOCR.GetKeyValuePairCount(ocrResultID); pairIdx++)
{
if (pairIdx != 0)
{
keyValuePairsData += "\n";
}
keyValuePairsData += "Name: " + gdpictureOCR.GetKeyValuePairKeyString(ocrResultID, pairIdx) + " | " +
"Value: " + gdpictureOCR.GetKeyValuePairValueString(ocrResultID, pairIdx) + " | " +
"Type: " + gdpictureOCR.GetKeyValuePairDataType(ocrResultID, pairIdx).ToString() + " | " +
"Accuracy: " + Math.Round(gdpictureOCR.GetKeyValuePairConfidence(ocrResultID, pairIdx), 1).ToString() + "%";
}
MessageBox.Show(keyValuePairsData, caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the detection confidence a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the key-value pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The detection confidence, in the range [0 - 100].
Extracting key-value pairs from an image.
string caption = "Example: KVP/OCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.EnableSkewDetection = true;
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureOCR.SetImage(image);
string ocrResultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string keyValuePairsData = "";
for (int pairIdx = 0; pairIdx < gdpictureOCR.GetKeyValuePairCount(ocrResultID); pairIdx++)
{
if (pairIdx != 0)
{
keyValuePairsData += "\n";
}
keyValuePairsData += "Name: " + gdpictureOCR.GetKeyValuePairKeyString(ocrResultID, pairIdx) + " | " +
"Value: " + gdpictureOCR.GetKeyValuePairValueString(ocrResultID, pairIdx) + " | " +
"Type: " + gdpictureOCR.GetKeyValuePairDataType(ocrResultID, pairIdx).ToString() + " | " +
"Accuracy: " + Math.Round(gdpictureOCR.GetKeyValuePairConfidence(ocrResultID, pairIdx), 1).ToString() + "%";
}
MessageBox.Show(keyValuePairsData, caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns whether a specific key-value pair is strong.
A pair is marked as strong when a semantic relationship have been established during the detection process.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the key-value pair within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
Extracting key-value pairs from an image.
string caption = "Example: KVP/OCR";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
gdpictureOCR.EnableSkewDetection = true;
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
gdpictureOCR.SetImage(image);
string ocrResultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
string keyValuePairsData = "";
for (int pairIdx = 0; pairIdx < gdpictureOCR.GetKeyValuePairCount(ocrResultID); pairIdx++)
{
if (pairIdx != 0)
{
keyValuePairsData += "\n";
}
keyValuePairsData += "Name: " + gdpictureOCR.GetKeyValuePairKeyString(ocrResultID, pairIdx) + " | " +
"Value: " + gdpictureOCR.GetKeyValuePairValueString(ocrResultID, pairIdx) + " | " +
"Type: " + gdpictureOCR.GetKeyValuePairDataType(ocrResultID, pairIdx).ToString() + " | " +
"Accuracy: " + Math.Round(gdpictureOCR.GetKeyValuePairConfidence(ocrResultID, pairIdx), 1).ToString() + "%";
}
MessageBox.Show(keyValuePairsData, caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the number of detected tables within a specified OCR result.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The number of detected tables.
using GdPictureImaging img = new GdPictureImaging();
int invoiceId = img.CreateGdPictureImageFromHTTP("https://passportpdfapi.com/", "test/invoice.png", 443);
if (img.GetStat() != GdPictureStatus.OK)
{
Console.WriteLine($"An error occurred during image loading ({img.GetStat()})");
return;
}
using GdPictureOCR ocr = new GdPictureOCR();
ocr.ResourcesFolder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:\\GdPicture.Net 14\\redist\\OCR" : "/mnt/c/GdPicture.Net 14/redist/OCR";
ocr.OCRMode = OCRMode.FavorAccuracy;
ocr.AddLanguage(OCRLanguage.French);
ocr.SetImage(invoiceId);
string ocrResultId = ocr.RunOCR();
if (ocr.GetStat() == GdPictureStatus.OK)
{
Console.WriteLine();
for (int tableIdx = 0; tableIdx < ocr.GetTableCount(ocrResultId); tableIdx++)
{
int colCount = ocr.GetTableColumnCount(ocrResultId, tableIdx);
int rowCount = ocr.GetTableRowCount(ocrResultId, tableIdx);
string[,] tableContent = new string[colCount, rowCount];
int[] maxLinesInRows = new int[rowCount];
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
tableContent[colIdx, rowIdx] = ocr.GetTableCellText(ocrResultId, tableIdx, colIdx, rowIdx);
}
}
// Compute table formatting
int[] widestCellInColumn = new int[colCount];
for (int colIdx = 0; colIdx < colCount; colIdx++)
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
if (tableContent[colIdx, rowIdx].Length > widestCellInColumn[colIdx])
{
widestCellInColumn[colIdx] = tableContent[colIdx, rowIdx].Length;
}
}
int rowLength = widestCellInColumn.Sum() + (3 * colCount);
string separator = new string('=', (int)Math.Truncate((double)rowLength / 2) - 4);
// Print table
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
//if first two column is consired as header, consider the entire row as header
bool isHorizontalHeaderRow = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, 0) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, 0);
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
bool isCurrentRowHeader = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, rowIdx) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, rowIdx);
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
string prettifiedCell = tableContent[colIdx, rowIdx].Replace(Environment.NewLine, "").PadRight(widestCellInColumn[colIdx]);
Console.Write($" {prettifiedCell} |{(!isHorizontalHeaderRow ? "|" : null)}");
}
Console.WriteLine();
if (isCurrentRowHeader)
{
Console.WriteLine(new string('=', rowLength)); //If header row, write a header separator
}
}
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
Console.WriteLine();
}
ocr.ReleaseOCRResult(ocrResultId);
img.ReleaseGdPictureImage(invoiceId);
}
else
{
Console.WriteLine($"OCR result : {ocr.GetStat()}");
}
Returns the location of a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
Returns the left x-coordinate of the table's bounding box, in pixels.
Returns the top y-coordinate of the table's bounding box, in pixels.
Returns the width of the table's bounding box, in pixels.
Returns the width of the table's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the location of a cell in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The 0-based index of the cell's column in a detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The 0-based index of the cell's row in a detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
Returns the left x-coordinate of the cell's bounding box, in pixels.
Returns the top y-coordinate of the cell's bounding box, in pixels.
Returns the width of the cell's bounding box, in pixels.
Returns the width of the cell's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the text content of a cell in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The 0-based index of the cell's column in a detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The 0-based index of the cell's row in a detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The text content of the cell.
using GdPictureImaging img = new GdPictureImaging();
int invoiceId = img.CreateGdPictureImageFromHTTP("https://passportpdfapi.com/", "test/invoice.png", 443);
if (img.GetStat() != GdPictureStatus.OK)
{
Console.WriteLine($"An error occurred during image loading ({img.GetStat()})");
return;
}
using GdPictureOCR ocr = new GdPictureOCR();
ocr.ResourcesFolder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:\\GdPicture.Net 14\\redist\\OCR" : "/mnt/c/GdPicture.Net 14/redist/OCR";
ocr.OCRMode = OCRMode.FavorAccuracy;
ocr.AddLanguage(OCRLanguage.French);
ocr.SetImage(invoiceId);
string ocrResultId = ocr.RunOCR();
if (ocr.GetStat() == GdPictureStatus.OK)
{
Console.WriteLine();
for (int tableIdx = 0; tableIdx < ocr.GetTableCount(ocrResultId); tableIdx++)
{
int colCount = ocr.GetTableColumnCount(ocrResultId, tableIdx);
int rowCount = ocr.GetTableRowCount(ocrResultId, tableIdx);
string[,] tableContent = new string[colCount, rowCount];
int[] maxLinesInRows = new int[rowCount];
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
tableContent[colIdx, rowIdx] = ocr.GetTableCellText(ocrResultId, tableIdx, colIdx, rowIdx);
}
}
// Compute table formatting
int[] widestCellInColumn = new int[colCount];
for (int colIdx = 0; colIdx < colCount; colIdx++)
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
if (tableContent[colIdx, rowIdx].Length > widestCellInColumn[colIdx])
{
widestCellInColumn[colIdx] = tableContent[colIdx, rowIdx].Length;
}
}
int rowLength = widestCellInColumn.Sum() + (3 * colCount);
string separator = new string('=', (int)Math.Truncate((double)rowLength / 2) - 4);
// Print table
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
//if first two column is consired as header, consider the entire row as header
bool isHorizontalHeaderRow = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, 0) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, 0);
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
bool isCurrentRowHeader = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, rowIdx) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, rowIdx);
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
string prettifiedCell = tableContent[colIdx, rowIdx].Replace(Environment.NewLine, "").PadRight(widestCellInColumn[colIdx]);
Console.Write($" {prettifiedCell} |{(!isHorizontalHeaderRow ? "|" : null)}");
}
Console.WriteLine();
if (isCurrentRowHeader)
{
Console.WriteLine(new string('=', rowLength)); //If header row, write a header separator
}
}
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
Console.WriteLine();
}
ocr.ReleaseOCRResult(ocrResultId);
img.ReleaseGdPictureImage(invoiceId);
}
else
{
Console.WriteLine($"OCR result : {ocr.GetStat()}");
}
Returns the number of columns in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The number of columns.
using GdPictureImaging img = new GdPictureImaging();
int invoiceId = img.CreateGdPictureImageFromHTTP("https://passportpdfapi.com/", "test/invoice.png", 443);
if (img.GetStat() != GdPictureStatus.OK)
{
Console.WriteLine($"An error occurred during image loading ({img.GetStat()})");
return;
}
using GdPictureOCR ocr = new GdPictureOCR();
ocr.ResourcesFolder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:\\GdPicture.Net 14\\redist\\OCR" : "/mnt/c/GdPicture.Net 14/redist/OCR";
ocr.OCRMode = OCRMode.FavorAccuracy;
ocr.AddLanguage(OCRLanguage.French);
ocr.SetImage(invoiceId);
string ocrResultId = ocr.RunOCR();
if (ocr.GetStat() == GdPictureStatus.OK)
{
Console.WriteLine();
for (int tableIdx = 0; tableIdx < ocr.GetTableCount(ocrResultId); tableIdx++)
{
int colCount = ocr.GetTableColumnCount(ocrResultId, tableIdx);
int rowCount = ocr.GetTableRowCount(ocrResultId, tableIdx);
string[,] tableContent = new string[colCount, rowCount];
int[] maxLinesInRows = new int[rowCount];
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
tableContent[colIdx, rowIdx] = ocr.GetTableCellText(ocrResultId, tableIdx, colIdx, rowIdx);
}
}
// Compute table formatting
int[] widestCellInColumn = new int[colCount];
for (int colIdx = 0; colIdx < colCount; colIdx++)
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
if (tableContent[colIdx, rowIdx].Length > widestCellInColumn[colIdx])
{
widestCellInColumn[colIdx] = tableContent[colIdx, rowIdx].Length;
}
}
int rowLength = widestCellInColumn.Sum() + (3 * colCount);
string separator = new string('=', (int)Math.Truncate((double)rowLength / 2) - 4);
// Print table
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
//if first two column is consired as header, consider the entire row as header
bool isHorizontalHeaderRow = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, 0) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, 0);
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
bool isCurrentRowHeader = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, rowIdx) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, rowIdx);
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
string prettifiedCell = tableContent[colIdx, rowIdx].Replace(Environment.NewLine, "").PadRight(widestCellInColumn[colIdx]);
Console.Write($" {prettifiedCell} |{(!isHorizontalHeaderRow ? "|" : null)}");
}
Console.WriteLine();
if (isCurrentRowHeader)
{
Console.WriteLine(new string('=', rowLength)); //If header row, write a header separator
}
}
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
Console.WriteLine();
}
ocr.ReleaseOCRResult(ocrResultId);
img.ReleaseGdPictureImage(invoiceId);
}
else
{
Console.WriteLine($"OCR result : {ocr.GetStat()}");
}
Returns the location of a column in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The 0-based index of the cell's column in a detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
Returns the left x-coordinate of the column's bounding box, in pixels.
Returns the top y-coordinate of the column's bounding box, in pixels.
Returns the width of the column's bounding box, in pixels.
Returns the width of the column's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the number of rows in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The number of rows.
using GdPictureImaging img = new GdPictureImaging();
int invoiceId = img.CreateGdPictureImageFromHTTP("https://passportpdfapi.com/", "test/invoice.png", 443);
if (img.GetStat() != GdPictureStatus.OK)
{
Console.WriteLine($"An error occurred during image loading ({img.GetStat()})");
return;
}
using GdPictureOCR ocr = new GdPictureOCR();
ocr.ResourcesFolder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:\\GdPicture.Net 14\\redist\\OCR" : "/mnt/c/GdPicture.Net 14/redist/OCR";
ocr.OCRMode = OCRMode.FavorAccuracy;
ocr.AddLanguage(OCRLanguage.French);
ocr.SetImage(invoiceId);
string ocrResultId = ocr.RunOCR();
if (ocr.GetStat() == GdPictureStatus.OK)
{
Console.WriteLine();
for (int tableIdx = 0; tableIdx < ocr.GetTableCount(ocrResultId); tableIdx++)
{
int colCount = ocr.GetTableColumnCount(ocrResultId, tableIdx);
int rowCount = ocr.GetTableRowCount(ocrResultId, tableIdx);
string[,] tableContent = new string[colCount, rowCount];
int[] maxLinesInRows = new int[rowCount];
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
tableContent[colIdx, rowIdx] = ocr.GetTableCellText(ocrResultId, tableIdx, colIdx, rowIdx);
}
}
// Compute table formatting
int[] widestCellInColumn = new int[colCount];
for (int colIdx = 0; colIdx < colCount; colIdx++)
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
if (tableContent[colIdx, rowIdx].Length > widestCellInColumn[colIdx])
{
widestCellInColumn[colIdx] = tableContent[colIdx, rowIdx].Length;
}
}
int rowLength = widestCellInColumn.Sum() + (3 * colCount);
string separator = new string('=', (int)Math.Truncate((double)rowLength / 2) - 4);
// Print table
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
//if first two column is consired as header, consider the entire row as header
bool isHorizontalHeaderRow = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, 0) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, 0);
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
bool isCurrentRowHeader = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, rowIdx) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, rowIdx);
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
string prettifiedCell = tableContent[colIdx, rowIdx].Replace(Environment.NewLine, "").PadRight(widestCellInColumn[colIdx]);
Console.Write($" {prettifiedCell} |{(!isHorizontalHeaderRow ? "|" : null)}");
}
Console.WriteLine();
if (isCurrentRowHeader)
{
Console.WriteLine(new string('=', rowLength)); //If header row, write a header separator
}
}
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
Console.WriteLine();
}
ocr.ReleaseOCRResult(ocrResultId);
img.ReleaseGdPictureImage(invoiceId);
}
else
{
Console.WriteLine($"OCR result : {ocr.GetStat()}");
}
Returns the location of a row in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The 0-based index of the row's column in a detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
Returns the left x-coordinate of the row's bounding box, in pixels.
Returns the top y-coordinate of the row's bounding box, in pixels.
Returns the width of the row's bounding box, in pixels.
Returns the width of the row's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Specify whether if the cell's coordinate is located in the table's header.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The unique result identifier of the executed OCR process obtained by the method.
The 0-based index of the detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The 0-based index of the cell's column in a detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
The 0-based index of the cell's row in a detected table within the specified OCR result.
It must be a value between 0 and (OCRResultID) - 1.
True if the specified cell is part of the header, false otherwise.
Please always use the method to determine if this method has been successful.
using GdPictureImaging img = new GdPictureImaging();
int invoiceId = img.CreateGdPictureImageFromHTTP("https://passportpdfapi.com/", "test/invoice.png", 443);
if (img.GetStat() != GdPictureStatus.OK)
{
Console.WriteLine($"An error occurred during image loading ({img.GetStat()})");
return;
}
using GdPictureOCR ocr = new GdPictureOCR();
ocr.ResourcesFolder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:\\GdPicture.Net 14\\redist\\OCR" : "/mnt/c/GdPicture.Net 14/redist/OCR";
ocr.OCRMode = OCRMode.FavorAccuracy;
ocr.AddLanguage(OCRLanguage.French);
ocr.SetImage(invoiceId);
string ocrResultId = ocr.RunOCR();
if (ocr.GetStat() == GdPictureStatus.OK)
{
Console.WriteLine();
for (int tableIdx = 0; tableIdx < ocr.GetTableCount(ocrResultId); tableIdx++)
{
int colCount = ocr.GetTableColumnCount(ocrResultId, tableIdx);
int rowCount = ocr.GetTableRowCount(ocrResultId, tableIdx);
string[,] tableContent = new string[colCount, rowCount];
int[] maxLinesInRows = new int[rowCount];
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
tableContent[colIdx, rowIdx] = ocr.GetTableCellText(ocrResultId, tableIdx, colIdx, rowIdx);
}
}
// Compute table formatting
int[] widestCellInColumn = new int[colCount];
for (int colIdx = 0; colIdx < colCount; colIdx++)
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
if (tableContent[colIdx, rowIdx].Length > widestCellInColumn[colIdx])
{
widestCellInColumn[colIdx] = tableContent[colIdx, rowIdx].Length;
}
}
int rowLength = widestCellInColumn.Sum() + (3 * colCount);
string separator = new string('=', (int)Math.Truncate((double)rowLength / 2) - 4);
// Print table
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
//if first two column is consired as header, consider the entire row as header
bool isHorizontalHeaderRow = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, 0) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, 0);
for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
{
bool isCurrentRowHeader = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, rowIdx) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, rowIdx);
for (int colIdx = 0; colIdx < colCount; colIdx++)
{
string prettifiedCell = tableContent[colIdx, rowIdx].Replace(Environment.NewLine, "").PadRight(widestCellInColumn[colIdx]);
Console.Write($" {prettifiedCell} |{(!isHorizontalHeaderRow ? "|" : null)}");
}
Console.WriteLine();
if (isCurrentRowHeader)
{
Console.WriteLine(new string('=', rowLength)); //If header row, write a header separator
}
}
Console.WriteLine($"{separator} Table {tableIdx} {separator}");
Console.WriteLine();
}
ocr.ReleaseOCRResult(ocrResultId);
img.ReleaseGdPictureImage(invoiceId);
}
else
{
Console.WriteLine($"OCR result : {ocr.GetStat()}");
}
Returns the recognized text of the provided OCR result, identifiable by its unique ID, as a formatted string.
The empty lines, if recognized, are not provided in the resulting text.
A unique result identifier of the executed OCR process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you that the resulting text provided by this method doesn't contain any empty lines, if they have been recognized.
The resulting recognized text of the executed OCR process. Please always use the method to determine if this method has been successful.
How to retrieve the resulting text after processing the OCR.
Dim caption As String = "Example: GetOCRResultText"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Load the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If gdpictureImaging.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Run the OCR process.
Dim resultID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Check the result.
Dim text As String = gdpictureOCR.GetOCRResultText(resultID)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The OCR result is: " + vbCrLf + text, caption)
Else
MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: GetOCRResultText";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Load the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Run the OCR process.
string resultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Check the result.
string text = gdpictureOCR.GetOCRResultText(resultID);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The OCR result is: \n" + text, caption);
else
MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the recognized text of the provided OCR result, identifiable by its unique ID, as a string.
The empty lines, if recognized, are not provided in the resulting text.
A unique result identifier of the executed OCR process obtained by the method.
Specifies if the produced text must be formatted to better reflect the input document layout.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you that the resulting text provided by this method doesn't contain any empty lines, if they have been recognized.
The resulting recognized text of the executed OCR process. Please always use the method to determine if this method has been successful.
How to retrieve the resulting text after processing the OCR.
Dim caption As String = "Example: GetOCRResultText"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Load the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If gdpictureImaging.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Run the OCR process.
Dim resultID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Check the result.
Dim text As String = gdpictureOCR.GetOCRResultText(resultID, True)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The OCR result is: " + vbCrLf + text, caption)
Else
MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: GetOCRResultText";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Load the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Run the OCR process.
string resultID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Check the result.
string text = gdpictureOCR.GetOCRResultText(resultID, true);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The OCR result is: \n" + text, caption);
else
MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat().ToString() + "/" + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided OCR result, identifiable by its unique ID, to a text file.
Saves the specified OCR result to a text file.
A unique result identifier of the executed OCR process obtained by the method. It specifies the OCR result you want to save.
The path to the file where the result will be saved. If the specified file already exists, it will be overwritten.
The text format of the output text file. A member of the OCROutputTextFormat enumeration.
The flag indicating whether to keep line breaks or not when saving the result.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the results to text files when processing the OCR on the same image with different settings.
Dim caption As String = "Example: SaveAsText"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Display the standard open file dialog to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim result1 As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsText(result1, "OCR_result1.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
Dim result2 As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsText(result2, "OCR_result2.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsText";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string result1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsText(result1, "OCR_result1.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
string result2 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsText(result2, "OCR_result2.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided OCR result, identifiable by its unique ID, to a html file.
Saves the specified OCR result to a html file.
A unique result identifier of the executed OCR process obtained by the method. It specifies the OCR result you want to save.
The path to the file where the result will be saved. If the specified file already exists, it will be overwritten.
The flag indicating whether to keep line breaks or not when saving the result.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the results to html files when processing the OCR on the same image with different settings.
Dim caption As String = "Example: SaveAsHTML"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Display the standard open file dialog to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim result1 As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsHTML(result1, "OCR_result1.html", True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
Dim result2 As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsHTML(result2, "OCR_result2.html", True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsHTML";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string result1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsHTML(result1, "OCR_result1.html", true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
string result2 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsHTML(result2, "OCR_result2.html", true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided OCR result, identifiable by its unique ID, to a docx file.
Saves the specified OCR result to a docx file.
A unique result identifier of the executed OCR process obtained by the method. It specifies the OCR result you want to save.
The path to the file where the result will be saved. If the specified file already exists, it will be overwritten.
The flag indicating whether to keep line breaks or not when saving the result.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the results to docx files when processing the OCR on the same image with different settings.
Dim caption As String = "Example: SaveAsDOCX"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Display the standard open file dialog to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim result1 As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsDOCX(result1, "OCR_result1.docx", True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
Dim result2 As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
'Save the result.
If gdpictureOCR.SaveAsDOCX(result2, "OCR_result2.docx", True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsDOCX";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string result1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsDOCX(result1, "OCR_result1.docx", true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
string result2 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Save the result.
if (gdpictureOCR.SaveAsDOCX(result2, "OCR_result2.docx", true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided collection of OCR results, identifiable by their unique IDs, to a text file.
Saves the specified OCR results to a text file.
A collection of the unique OCR result identifiers. It specifies the OCR results you want to save.
The path to the file where the results will be saved. If the specified file already exists, it will be overwritten.
The text format of the output text file. A member of the OCROutputTextFormat enumeration.
The flag indicating whether to keep line breaks or not when saving the results.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a collection of the OCR results to a text file.
Dim caption As String = "Example: SaveAsText"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim resID1 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID1)
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
Dim resID2 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID2)
Else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
If results.Count > 0 Then
'Save the results.
If gdpictureOCR.SaveAsText(results, "OCR_results.txt", OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat.ToString + " or " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsText";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
List<string> results = new List<string>();
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string resID1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID1);
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
string resID2 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID2);
else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
if (results.Count > 0)
{
//Save the results.
if (gdpictureOCR.SaveAsText(results, "OCR_results.txt", OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR results has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided OCR result, identifiable by its unique ID, to a stream in the text format.
Saves the specified OCR result to a text file.
A unique result identifier of the executed OCR process obtained by the method. It vthe OCR result you want to save.
A Stream object where the result will be saved to. This Stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use.
The text format of the output text file. A member of the OCROutputTextFormat enumeration.
The flag indicating whether to keep line breaks or not when saving the result.
The output stream should be open for writing and should be closed/disposed by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the result to a text-formatted stream when processing the OCR on the selected image.
Dim caption As String = "Example: SaveAsText"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Load the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If gdpictureImaging.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim oStream As System.IO.FileStream = New System.IO.FileStream("OCR_result.txt", System.IO.FileMode.Create)
'Save the result.
If gdpictureOCR.SaveAsText(resID, oStream, OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
oStream.Dispose()
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsText";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Load the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
System.IO.FileStream oStream = new System.IO.FileStream("OCR_result.txt", System.IO.FileMode.Create);
//Save the result.
if (gdpictureOCR.SaveAsText(resID, oStream, OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
oStream.Dispose();
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided collection of OCR results, identifiable by their unique IDs, to a stream in the text format.
Saves the specified OCR results to a text file.
A collection of the unique OCR result identifiers. It specifies the OCR results you want to save.
A Stream object where the results will be saved to. This Stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use.
The text format of the output text file. A member of the OCROutputTextFormat enumeration.
The flag indicating whether to keep line breaks or not when saving the results.
The output stream should be open for writing and should be closed/disposed by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a collection of the OCR results to a text-formatted stream.
Dim caption As String = "Example: SaveAsText"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789"
'Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion")
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
results.Add("PhoneNumberRegion")
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200)
'Define the character set for addresses.
gdpictureOCR.CharacterSet = ""
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
'Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion")
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
results.Add("AddressRegion")
Else
MessageBox.Show("The second OCR process has failed with the status: " & gdpictureOCR.GetStat().ToString(), caption)
End If
If results.Count > 0 Then
'Save the results.
Dim oStream As System.IO.FileStream = New System.IO.FileStream("OCR_result.txt", System.IO.FileMode.Create)
If gdpictureOCR.SaveAsText(results, oStream, OCROutputTextFormat.Utf16, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
oStream.Dispose()
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsText";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
List<string> results = new List<string>();
//Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789";
//Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion");
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add("PhoneNumberRegion");
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200);
//Define the character set for addresses.
gdpictureOCR.CharacterSet = "";
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
//Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion");
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add("AddressRegion");
else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
if (results.Count > 0)
{
System.IO.FileStream oStream = new System.IO.FileStream("OCR_result.txt", System.IO.FileMode.Create);
if (gdpictureOCR.SaveAsText(results, oStream, OCROutputTextFormat.Utf16, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR results has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
oStream.Dispose();
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided OCR result, identifiable by its unique ID, to a stream in the html format.
Saves the specified OCR result to a html file.
A unique result identifier of the executed OCR process obtained by the method. It specifies the OCR result you want to save.
A Stream object where the result will be saved to. This Stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use.
The flag indicating whether to keep line breaks or not when saving the result.
The output stream should be open for writing and should be closed/disposed by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the result to a stream in the html format when processing the OCR on the selected image.
Dim caption As String = "Example: SaveAsHTML"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Load the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If gdpictureImaging.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim oStream As System.IO.FileStream = New System.IO.FileStream("OCR_result.html", System.IO.FileMode.Create)
'Save the result.
If gdpictureOCR.SaveAsHTML(resID, oStream, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
oStream.Dispose()
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsHTML";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Load the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
System.IO.FileStream oStream = new System.IO.FileStream("OCR_result.html", System.IO.FileMode.Create);
//Save the result.
if (gdpictureOCR.SaveAsHTML(resID, oStream, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
oStream.Dispose();
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided collection of OCR results, identifiable by their unique IDs, to a html file.
Saves the specified OCR results to a html file.
A collection of the unique OCR result identifiers. It specifies the OCR results you want to save.
The path to the file where the result will be saved. If the specified file already exists, it will be overwritten.
The flag indicating whether to keep line breaks or not when saving the results.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a collection of the OCR results to a html file.
Dim caption As String = "Example: SaveAsHTML"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim resID1 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID1)
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
Dim resID2 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID2)
Else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
If results.Count > 0 Then
'Save the results.
If gdpictureOCR.SaveAsHTML(results, "OCR_results.html", True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat.ToString + " or " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsHTML";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
List<string> results = new List<string>();
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string resID1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID1);
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
string resID2 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID2);
else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
if (results.Count > 0)
{
//Save the results.
if (gdpictureOCR.SaveAsHTML(results, "OCR_results.html", true) == GdPictureStatus.OK)
MessageBox.Show("The OCR results has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided collection of OCR results, identifiable by their unique IDs, to a stream in the html format.
Saves the specified OCR results to a html file.
A collection of the unique OCR result identifiers. It specifies the OCR results you want to save.
A Stream object where the result will be saved to. This Stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use.
The flag indicating whether to keep line breaks or not when saving the results.
The output stream should be open for writing and should be closed/disposed by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a collection of the OCR results to a stream in the html format.
Dim caption As String = "Example: SaveAsHTML"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789"
'Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion")
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
results.Add("PhoneNumberRegion")
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200)
'Define the character set for addresses.
gdpictureOCR.CharacterSet = ""
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
'Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion")
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
results.Add("AddressRegion")
Else
MessageBox.Show("The second OCR process has failed with the status: " & gdpictureOCR.GetStat().ToString(), caption)
End If
If results.Count > 0 Then
'Save the results.
Dim oStream As System.IO.FileStream = New System.IO.FileStream("OCR_result.txt", System.IO.FileMode.Create)
If gdpictureOCR.SaveAsHTML(results, oStream, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
oStream.Dispose()
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsHTML";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
List<string> results = new List<string>();
//Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789";
//Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion");
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add("PhoneNumberRegion");
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200);
//Define the character set for addresses.
gdpictureOCR.CharacterSet = "";
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
//Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion");
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add("AddressRegion");
else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
if (results.Count > 0)
{
System.IO.FileStream oStream = new System.IO.FileStream("OCR_result.html", System.IO.FileMode.Create);
if (gdpictureOCR.SaveAsHTML(results, oStream, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR results has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsHTML() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
oStream.Dispose();
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided OCR result, identifiable by its unique ID, to a stream in the docx format.
Saves the specified OCR result to a docx file.
A unique result identifier of the executed OCR process obtained by the method. It specifies the OCR result you want to save.
A Stream object where the result will be saved to. This Stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use.
The flag indicating whether to keep line breaks or not when saving the result.
The output stream should be open for writing and should be closed/disposed by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the result to a stream in docx format when processing the OCR on the selected image.
Dim caption As String = "Example: SaveAsDOCX"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Load the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If gdpictureImaging.GetStat = GdPictureStatus.OK AndAlso
gdpictureOCR.SetImage(image) = GdPictureStatus.OK Then
'Setting up the image is mandatory.
'Run the OCR process.
Dim resID As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
Dim oStream As System.IO.FileStream = New System.IO.FileStream("OCR_result.docx", System.IO.FileMode.Create)
'Save the result.
If gdpictureOCR.SaveAsDOCX(resID, oStream, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR result has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
oStream.Dispose()
Else
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsDOCX";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Load the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK)) //Setting up the image is mandatory.
{
//Run the OCR process.
string resID = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
System.IO.FileStream oStream = new System.IO.FileStream("OCR_result.docx", System.IO.FileMode.Create);
//Save the result.
if (gdpictureOCR.SaveAsDOCX(resID, oStream, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR result has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
oStream.Dispose();
}
else
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when creating or setting up the image. Status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided collection of OCR results, identifiable by their unique IDs, to a docx file.
Saves the specified OCR results to a docx file.
A collection of the unique OCR result identifiers. It specifies the OCR results you want to save.
The path to the file where the results will be saved. If the specified file already exists, it will be overwritten.
The flag indicating whether to keep line breaks or not when saving the results.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a collection of the OCR results to a docx file.
Dim caption As String = "Example: SaveAsDOCX"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim resID1 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID1)
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
Dim resID2 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID2)
Else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
If results.Count > 0 Then
'Save the results.
If gdpictureOCR.SaveAsDOCX(results, "OCR_results.docx", True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat.ToString + " or " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsDOCX";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
List<string> results = new List<string>();
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string resID1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID1);
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
string resID2 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID2);
else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
if (results.Count > 0)
{
//Save the results.
if (gdpictureOCR.SaveAsDOCX(results, "OCR_results.docx", true) == GdPictureStatus.OK)
MessageBox.Show("The OCR results has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided collection of OCR results, identifiable by their unique IDs, to a stream in the docx format.
Saves the specified OCR results to a docx file.
A collection of the unique OCR result identifiers. It specifies the OCR results you want to save.
A Stream object where the results will be saved to. This Stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use.
The flag indicating whether to keep line breaks or not when saving the results.
The output stream should be open for writing and should be closed/disposed by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a collection of the OCR results to a stream in the docx format.
Dim caption As String = "Example: SaveAsDOCX"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789"
'Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion")
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
results.Add("PhoneNumberRegion")
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
'Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200)
'Define the character set for addresses.
gdpictureOCR.CharacterSet = ""
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
'Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion")
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
results.Add("AddressRegion")
Else
MessageBox.Show("The second OCR process has failed with the status: " & gdpictureOCR.GetStat().ToString(), caption)
End If
If results.Count > 0 Then
'Save the results.
Dim oStream As System.IO.FileStream = New System.IO.FileStream("OCR_result.docx", System.IO.FileMode.Create)
If gdpictureOCR.SaveAsDOCX(results, oStream, True) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
oStream.Dispose()
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsDOCX";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
List<string> results = new List<string>();
//Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789";
//Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion");
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add("PhoneNumberRegion");
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200);
//Define the character set for addresses.
gdpictureOCR.CharacterSet = "";
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
//Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion");
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add("AddressRegion");
else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
if (results.Count > 0)
{
System.IO.FileStream oStream = new System.IO.FileStream("OCR_result.docx", System.IO.FileMode.Create);
if (gdpictureOCR.SaveAsDOCX(results, oStream, true) == GdPictureStatus.OK)
MessageBox.Show("The OCR results has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsDOCX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
oStream.Dispose();
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided collection of OCR results, identifiable by their unique IDs, to an xlsx file.
Saves the specified OCR results to an xlsx file.
A collection of the unique OCR result identifiers. It specifies the OCR results you want to save.
The path to the file where the results will be saved. If the specified file already exists, it will be overwritten.
The class that handles different options requested by a GdPictureOCR instance to export OCR result to a spreadsheet document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a collection of the OCR results to an xlsx file.
Dim caption As String = "Example: SaveAsXLSX"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim resID1 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID1)
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
Dim resID2 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID2)
Else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
If results.Count > 0 Then
'Save the results.
Dim spreadsheetOptions As GdPictureOCR.SpreadsheetOptions = New GdPictureOCR.SpreadsheetOptions() With {
.SeparateTables = false
}
If gdpictureOCR.SaveAsXLSX(results, "OCR_results.xlsx", spreadsheetOptions) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsXLSX() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat.ToString + " or " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsXLSX";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
List<string> results = new List<string>();
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string resID1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID1);
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
string resID2 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID2);
else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
if (results.Count > 0)
{
//Save the results.
GdPictureOCR.SpreadsheetOptions spreadsheetOptions = new GdPictureOCR.SpreadsheetOptions()
{
SeparateTables = false
};
if (gdpictureOCR.SaveAsXLSX(results, "OCR_results.xlsx", spreadsheetOptions) == GdPictureStatus.OK)
MessageBox.Show("The OCR results has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsXLSX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the table, specified by its index, to an xlsx file.
Saves the specified table to an XLSX file.
An OCR result identifiers. It specifies the OCR result containing the table you want to save.
The path to the file where the results will be saved. If the specified file already exists, it will be overwritten.
A table index. It specifies the table you want to save.
The class that handles different options requested by a GdPictureOCR instance to export OCR result to a spreadsheet document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a specific table to an xlsx file.
Dim caption As String = "Example: SaveAsXLSX"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim resID1 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
'Checks if at least one table was found
If gdpictureOCR.GetTableCount(resID1) > 0 Then
Dim spreadsheetOptions As GdPictureOCR.SpreadsheetOptions = New GdPictureOCR.SpreadsheetOptions() With {
.SeparateTables = false
}
'Save the first table.
If gdpictureOCR.SaveAsXLSX(resID1, "OCR_result.xlsx", 0, spreadsheetOptions) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsXLSX() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
Else
MessageBox.Show("No table was detected on the input document")
End If
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat.ToString + " or " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsXLSX";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Run the OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string resID1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Checks if at least one table was found
if (gdpictureOCR.GetTableCount(resID1) > 0)
{
GdPictureOCR.SpreadsheetOptions spreadsheetOptions = new GdPictureOCR.SpreadsheetOptions()
{
SeparateTables = false
};
//Save the first table.
if (gdpictureOCR.SaveAsXLSX(resID1, "OCR_result.xlsx", 0, spreadsheetOptions) == GdPictureStatus.OK)
MessageBox.Show("The table has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsXLSX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("No table was detected on the input document");
}
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the provided collection of OCR results, identifiable by their unique IDs, to a stream in the xlsx format.
Saves the specified OCR results to an xlsx file.
A collection of the unique OCR result identifiers. It specifies the OCR results you want to save.
A Stream object where the results will be saved to. This Stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use.
The class that handles different options requested by a GdPictureOCR instance to export OCR result to a spreadsheet document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a collection of the OCR results to an xlsx file.
Dim caption As String = "Example: SaveAsXLSX"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim resID1 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID1)
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy
'Run the second OCR process.
Dim resID2 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
results.Add(resID2)
Else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
If results.Count > 0 Then
'Save the results.
Dim oStream As System.IO.FileStream = New System.IO.FileStream("OCR_results.xlsx", System.IO.FileMode.Create)
Dim spreadsheetOptions As GdPictureOCR.SpreadsheetOptions = New GdPictureOCR.SpreadsheetOptions() With {
.SeparateTables = false
}
If gdpictureOCR.SaveAsXLSX(results, oStream, spreadsheetOptions) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsXLSX() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat.ToString + " or " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsXLSX";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
List<string> results = new List<string>();
//Run the first OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string resID1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID1);
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Change OCR settings.
gdpictureOCR.OCRMode = OCRMode.FavorAccuracy;
//Run the second OCR process.
string resID2 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
results.Add(resID2);
else
MessageBox.Show("The second OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
if (results.Count > 0)
{
//Save the results.
System.IO.FileStream oStream = new System.IO.FileStream("OCR_results.xlsx", System.IO.FileMode.Create);
GdPictureOCR.SpreadsheetOptions spreadsheetOptions = new GdPictureOCR.SpreadsheetOptions()
{
SeparateTables = false
};
if (gdpictureOCR.SaveAsXLSX(results, oStream, spreadsheetOptions) == GdPictureStatus.OK)
MessageBox.Show("The OCR results has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsXLSX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Saves the table, specified by its index, to a stream in the XLSX format.
Saves the specified table to an XLSX file.
An OCR result identifiers. It specifies the OCR result containing the table you want to save.
A Stream object where the results will be saved to. This Stream object must be initialized before it can be sent into this method
and it should remain open for subsequent use.
A table index. It specifies the table you want to save.
The class that handles different options requested by a GdPictureOCR instance to export OCR result to a spreadsheet document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save a specific table to an xlsx file.
Dim caption As String = "Example: SaveAsXLSX"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
Dim results As List(Of String) = New List(Of String)()
'Run the first OCR process.
'Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
Dim resID1 As String = gdpictureOCR.RunOCR
If gdpictureOCR.GetStat = GdPictureStatus.OK Then
'Checks if at least one table was found
If gdpictureOCR.GetTableCount(resID1) > 0 Then
Dim spreadsheetOptions As GdPictureOCR.SpreadsheetOptions = New GdPictureOCR.SpreadsheetOptions() With {
.SeparateTables = false
}
'Save the first table.
Dim oStream As System.IO.FileStream = New System.IO.FileStream("OCR_result.xlsx", System.IO.FileMode.Create)
If gdpictureOCR.SaveAsXLSX(resID1, oStream, 0, spreadsheetOptions) = GdPictureStatus.OK Then
MessageBox.Show("The OCR results has been successfully saved.", caption)
Else
MessageBox.Show("The SaveAsXLSX() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
Else
MessageBox.Show("No table was detected on the input document")
End If
Else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat.ToString + " or " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat.ToString, caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SaveAsXLSX";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Run the OCR process.
//Note that gdpictureOCR.OCRMode = OCRMode.FavorSpeed by default.
string resID1 = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
//Checks if at least one table was found
if (gdpictureOCR.GetTableCount(resID1) > 0)
{
GdPictureOCR.SpreadsheetOptions spreadsheetOptions = new GdPictureOCR.SpreadsheetOptions()
{
SeparateTables = false
};
//Save the first table.
System.IO.FileStream oStream = new System.IO.FileStream("OCR_result.xlsx", System.IO.FileMode.Create);
if (gdpictureOCR.SaveAsXLSX(resID1, oStream, 0, spreadsheetOptions) == GdPictureStatus.OK)
MessageBox.Show("The table has been successfully saved.", caption);
else
MessageBox.Show("The SaveAsXLSX() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
else
MessageBox.Show("No table was detected on the input document");
}
else
MessageBox.Show("The first OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Resets the previously specified region of interest, means completely removes the region's data.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the used region of interest.
Dim caption As String = "Example: ResetROI"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.TiffCreateMultiPageFromFile("")
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
'This example expects that the input tiff file has 2 pages.
If gdpictureImaging.TiffGetPageCount(image) <> 2 Then
MessageBox.Show("This example expects 2 pages tiff files.", caption)
Goto [Error]
End If
'Select the first page.
If gdpictureImaging.TiffSelectPage(image, 1) <> GdPictureStatus.OK Then
MessageBox.Show("The TiffSelectPage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
Goto [Error]
End If
'Set the image. This step is mandatory.
gdpictureOCR.SetImage(image)
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The SetImage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
GoTo [error]
End If
'Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789"
'Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion")
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
'Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200)
'Define the character set for addresses.
gdpictureOCR.CharacterSet = ""
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
'Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion")
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
'Analyze your OCR results using the identifiers "PhoneNumberRegion" And "AddressRegion".
'Continue ...
'Prepare GdPictureOCR for the next process.
'Release unused results for better memory management.
gdpictureOCR.ReleaseOCRResults()
'Reset region of interest to the whole page.
gdpictureOCR.ResetROI()
gdpictureOCR.Context = OCRContext.OCRContextDocument
'Select the second page.
gdpictureImaging.ReleaseGdPictureImage(image)
If gdpictureImaging.TiffSelectPage(image, 2) <> GdPictureStatus.OK Then
MessageBox.Show("The TiffSelectPage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
Goto [Error]
End If
'Set another image.
gdpictureOCR.SetImage(image)
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The SetImage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
GoTo [error]
End If
'Run the OCR process.
Dim pageText As String = gdpictureOCR.RunOCR()
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
Dim text As String = gdpictureOCR.GetOCRResultText(pageText)
If gdpictureOCR.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The text on the page is : " + vbCrLf + text, caption)
Else
MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
[error]:
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: ResetROI";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.TiffCreateMultiPageFromFile("");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
//This example expects that the input tiff file has 2 pages.
if (gdpictureImaging.TiffGetPageCount(image) != 2)
{
MessageBox.Show("This example expects 2 pages tiff files.", caption);
goto error;
}
//Select the first page.
if (gdpictureImaging.TiffSelectPage(image, 1) != GdPictureStatus.OK)
{
MessageBox.Show("The TiffSelectPage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
goto error;
}
//Set the image. This step is mandatory.
gdpictureOCR.SetImage(image);
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The SetImage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789";
//Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion");
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200);
//Define the character set for addresses.
gdpictureOCR.CharacterSet = "";
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
//Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion");
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Analyze your OCR results using the identifiers "PhoneNumberRegion" and "AddressRegion".
//Continue ...
//Prepare GdPictureOCR for the next process.
//Releasing unused results for better memory management.
gdpictureOCR.ReleaseOCRResults();
//Reset region of interest to the whole page.
gdpictureOCR.ResetROI();
gdpictureOCR.Context = OCRContext.OCRContextDocument;
//Select the second page.
gdpictureImaging.ReleaseGdPictureImage(image);
if (gdpictureImaging.TiffSelectPage(image, 2) != GdPictureStatus.OK)
{
MessageBox.Show("The TiffSelectPage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
goto error;
}
//Set another image.
gdpictureOCR.SetImage(image);
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The SetImage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Run the OCR process.
string pageText = gdpictureOCR.RunOCR();
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
string text = gdpictureOCR.GetOCRResultText(pageText);
if (gdpictureOCR.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The text on the page is : \n" + text, caption);
}
else
{
MessageBox.Show("The GetOCRResultText() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
}
error:
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Sets up the new region of interest (ROI) of an image, that is subsequently processed using the OCR.
Only the specified region is included into the next OCR process.
The x-coordinate of the upper-left point of the region of interest, in pixels, measured from the upper-left corner of the image.
The y-coordinate of the upper-left point of the region of interest, in pixels, measured from the upper-left corner of the image.
The width of the region of interest, in pixels.
The height of the region of interest, in pixels.
The point, that represents the upper-left corner of the image, has the coordinates (0,0).
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up different regions of interest for different OCR processes.
Dim caption As String = "Example: SetROI"
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\GdPicture.Net 14\redist\OCR"
If gdpictureOCR.AddLanguage(OCRLanguage.English) = GdPictureStatus.OK Then
'Set up the image you want to process.
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureOCR.SetImage(image) = GdPictureStatus.OK) Then
'Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50)
'Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789"
'Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion")
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
'Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200)
'Define the character set for addresses.
gdpictureOCR.CharacterSet = ""
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock
'Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion")
If gdpictureOCR.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The OCR process has failed with the status: " & gdpictureOCR.GetStat().ToString(), caption)
Goto [Error]
End If
'Analyze your OCR results using the identifiers "PhoneNumberRegion" And "AddressRegion".
'Continue ...
[error]:
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
Else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption)
End If
gdpictureOCR.ReleaseOCRResults()
End Using
string caption = "Example: SetROI";
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
gdpictureOCR.ResourcesFolder = "\\GdPicture.Net 14\\redist\\OCR";
if (gdpictureOCR.AddLanguage(OCRLanguage.English) == GdPictureStatus.OK)
{
//Set up the image you want to process.
GdPictureImaging gdpictureImaging = new GdPictureImaging();
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureOCR.SetImage(image) == GdPictureStatus.OK))
{
//Define the required ROI.
gdpictureOCR.SetROI(100, 100, 200, 50);
//Define the character set for phone numbers.
gdpictureOCR.CharacterSet = "0123456789";
//Run the OCR process.
gdpictureOCR.RunOCR("PhoneNumberRegion");
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Reset the required ROI.
gdpictureOCR.SetROI(150, 300, 200, 200);
//Define the character set for addresses.
gdpictureOCR.CharacterSet = "";
gdpictureOCR.Context = OCRContext.OCRContextSingleBlock;
//Run the OCR process.
gdpictureOCR.RunOCR("AddressRegion");
if (gdpictureOCR.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The OCR process has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
goto error;
}
//Analyze your OCR results using the identifiers "PhoneNumberRegion" and "AddressRegion".
//Continue ...
error:
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
}
else
MessageBox.Show("The AddLanguage() method has failed with the status: " + gdpictureOCR.GetStat().ToString(), caption);
gdpictureOCR.ReleaseOCRResults();
}
Returns the status of the last executed operation with the current GdPictureOCR object.
Use this method in the combination with all those, which return a value instead of a status.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to check the if the called method has been followed without errors.
Using gdpictureOCR As GdPictureOCR = New GdPictureOCR()
'Set up your prefered parameters for OCR.
'Run the OCR process.
Dim result As String = gdpictureOCR.RunOCR()
'Check the status.
Dim status As GdPictureStatus = gdpictureOCR.GetStat()
If status = GdPictureStatus.OK Then
'The method has been followed without errors.
'Continue ...
Else
'Some error occurred.
MessageBox.Show("The OCR process has failed with the status: " + status.ToString(), "Example: GetStat")
End If
End Using
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//Set up your prefered parameters for OCR.
//Run the OCR process.
string result = gdpictureOCR.RunOCR();
//Check the status.
GdPictureStatus status = gdpictureOCR.GetStat();
if (status == GdPictureStatus.OK)
{
//The method has been followed without errors.
//Continue ...
}
else
{
//Some error occurred.
MessageBox.Show("The OCR process has failed with the status: " + status.ToString(), "Example: GetStat");
}
}
Implementation of the IDispose interface specific code.
Implementation of the IDispose interface specific code.
Disposes of the GdPictureOCR object completely. All related resources used by this object are released.
All used OCR results within the current GdPictureOCR object are released too.
Please note, that by disposing of the current GdPictureOCR object you also release all linked OCR results.
GdPictureOCR Constructor
How to create and dispose of a GdPictureOCR object.
'The elementary use of the Dispose() method.
Dim gdpictureOCR As New GdPictureOCR()
'You can do your stuff with gdpictureOCR here.
gdpictureOCR.Dispose()
'The very good practice is to use the keyword "using".
Using gdpictureOCR As New GdPictureOCR()
'You can do your stuff with gdpictureOCR here.
'You do not need to call the Dispose() method, it is called automatically inside the "using" statement.
End Using
//The elementary use of the Dispose() method.
GdPictureOCR gdpictureOCR = new GdPictureOCR();
//You can do your stuff with gdpictureOCR here.
gdpictureOCR.Dispose();
//The very good practice is to use the keyword "using".
using (GdPictureOCR gdpictureOCR = new GdPictureOCR())
{
//You can do your stuff with gdpictureOCR here.
//You do not need to call the Dispose() method, it is called automatically inside the "using" statement.
}
Output outputs the OCR results using the provided output.
The object to use for the output.
A collection with the identifiers for the character recognition results.
The stream to write the result to.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Call this method before starting an OCR process.
This method requires the OCR component to run.
Call this method at the end of each OCR process.
GetAvailableLanguages retrieves the languages available within the provided folder.
The path to te folder to analyze.
Returns a list of available languages
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
GetDictionariesAsString retrieves the string describing the dictionaries to the engine.
An array with the dictionaries.
The string to be provided to the engine.
Reset the last error to the default value.
Retrieves the roi, corrected with the properties of the image ready to be ocred.
The coordinates of the roi.
The OCR mode.
The minimum character height.
The minimum character width.
The maximum character height.
The maximum character width.
The timeout.
Specifies the names of the dictionaries to use during subsequent OCR processes.
The dictionary path.
The known doctionaries available in the resource folder.
The character set.
The expectged number of symbols to be recognized.
The character black list.
The roi.
The last error.
License features checked for the current OCR operation.
The object to deal with Tesseract Ocr
The flag indicating whether the object is disposed or not.
The storage for the OCR result.
The penalty to apply to words not in the dictionary (word_dawg / user_words wordlists).
The penalty to apply to words not in the frequent words dictionary (freq_dawg wordlist).
Controls whether or not to load the main dictionary for the selected language.
Controls whether or not to load the frequent words dictionary for the selected language.
The map between the languages and the dictionaries.
The penalty to apply to words not in the dictionary (word_dawg / user_words wordlists).
The penalty to apply to words not in the frequent words dictionary (freq_dawg wordlist).
Controls whether or not to load the main dictionary for the selected language.
Controls whether or not to load the frequent words dictionary for the selected language.
This class handles different options requested by a GdPictureOCR instance to export OCR result to a spreadsheet document.
Specifies whether to save each table in a different sheet within the spreadsheet.
The default value is false.
A class that represents a GdPicture Office Templater for creating and processing Office document templates.
Loads a Office file containing the placeholders that need replacing.
The path to the Office file to load.
The of the operation.
using GdPicture14;
string sourceFile = "file.docx";
string outputFile = "output.docx";
GdPictureOfficeTemplate template = GdPictureOfficeDefaultTemplateBuilder.CreateTemplate()
.AddPlaceholderReplacement(placeholder: "placeholder1", replacementValue: "replacementValue 1")
.AddPlaceholderReplacement(placeholder: "placeholder2", replacementValue: "replacementValue 2");
GdPictureOfficeTemplateConfiguration configuration = new GdPictureOfficeTemplateConfiguration
{
Delimiter = new GdPictureOfficeTemplateDelimiter
{
Start = "{{",
End = "}}"
}
};
using GdPictureOfficeTemplater templater = new();
GdPictureStatus status = templater.SetTemplate(template, configuration);
if (status == GdPictureStatus.OK)
{
status = templater.LoadFromFile(sourceFile);
if (status == GdPictureStatus.OK)
{
status = templater.Process();
if (status == GdPictureStatus.OK)
{
status = templater.SaveToFile(outputFile);
Console.WriteLine("Save status: " + status);
}
}
}
Console.WriteLine("Last status: " + templater.GetStat() + Environment.NewLine);
Loads a Office template file stream containing the placeholders that need replacing.
The Office template file stream containing the template data.
The of the operation.
using GdPicture14;
string outputFile = "output.docx";
GdPictureOfficeTemplate template = GdPictureOfficeDefaultTemplateBuilder.CreateTemplate()
.AddPlaceholderReplacement(placeholder: "placeholder1", replacementValue: "replacementValue 1")
.AddPlaceholderReplacement(placeholder: "placeholder2", replacementValue: "replacementValue 2");
GdPictureOfficeTemplateConfiguration configuration = new GdPictureOfficeTemplateConfiguration
{
Delimiter = new GdPictureOfficeTemplateDelimiter
{
Start = "{{",
End = "}}"
}
};
using GdPictureOfficeTemplater templater = new();
GdPictureStatus status = templater.SetTemplate(template, configuration);
if (status == GdPictureStatus.OK)
{
var fileStream = new FileStream("input.docx", FileMode.Open, FileAccess.Read);
status = templater.LoadFromStream(fileStream);
if (status == GdPictureStatus.OK)
{
status = templater.Process();
if (status == GdPictureStatus.OK)
{
status = templater.SaveToFile(outputFile);
Console.WriteLine("Save status: " + status);
}
}
}
Console.WriteLine("Last status: " + templater.GetStat() + Environment.NewLine);
Sets the template and its configuration for use in replacement operations.
The template model (containing placeholder values) to use.
The configuration for template replacement.
The of the operation.
using GdPicture14;
string sourceFile = "file.docx";
string outputFile = "output.docx";
GdPictureOfficeTemplate template = GdPictureOfficeDefaultTemplateBuilder.CreateTemplate()
.AddPlaceholderReplacement(placeholder: "placeholder1", replacementValue: "replacementValue 1")
.AddPlaceholderReplacement(placeholder: "placeholder2", replacementValue: "replacementValue 2");
GdPictureOfficeTemplateConfiguration configuration = new GdPictureOfficeTemplateConfiguration
{
Delimiter = new GdPictureOfficeTemplateDelimiter
{
Start = "{{",
End = "}}"
}
};
using GdPictureOfficeTemplater templater = new();
GdPictureStatus status = templater.SetTemplate(template, configuration);
if (status == GdPictureStatus.OK)
{
status = templater.LoadFromFile(sourceFile);
if (status == GdPictureStatus.OK)
{
status = templater.Process();
if (status == GdPictureStatus.OK)
{
status = templater.SaveToFile(outputFile);
Console.WriteLine("Save status: " + status);
}
}
}
Console.WriteLine("Last status: " + templater.GetStat() + Environment.NewLine);
Sets the template and its configuration from a JSON string for use in replacement operations.
A JSON string representing the template and its configuration.
{
"config": {
"delimiter": {
"start": "{{",
"end": "}}"
}
},
"model": {
"placeholder1": "Value 1",
"placeholder2": "Value 2"
}
}
{
'$schema': 'http://json-schema.org/draft-04/schema#',
'type': 'object',
'properties': {
'config': {
'type': 'object',
'properties': {
'delimiter': {
'type': 'object',
'properties': {
'start': { 'type': 'string', 'minLength': 1 },
'end': { 'type': 'string', 'minLength': 1 }
},
'required': [ 'start', 'end' ]
}
},
'required': [ 'delimiter' ]
},
'model': {
'type': 'object',
'minProperties': 1
}
},
'required': [ 'config', 'model' ]
}
Processes the loaded template, replacing placeholders with actual values.
The of the operation.
using GdPicture14;
string sourceFile = "file.docx";
string outputFile = "output.docx";
string json = @"
{
'config': {
'delimiter': {
'start': '{{',
'end': '}}'
}
},
'model': {
'placeholder1': 'replacementValue 1',
'placeholder2': 'replacementValue 2'
}
}";
using GdPictureOfficeTemplater templater = new();
GdPictureStatus status = templater.SetTemplate(json);
if (status == GdPictureStatus.OK)
{
status = templater.LoadFromFile(sourceFile);
if (status == GdPictureStatus.OK)
{
status = templater.Process();
if (status == GdPictureStatus.OK)
{
status = templater.SaveToFile(outputFile);
Console.WriteLine("Save status: " + status);
}
}
}
Console.WriteLine("Last status: " + templater.GetStat() + Environment.NewLine);
using GdPicture14;
string sourceFile = "file.docx";
string outputFile = "output.docx";
GdPictureOfficeTemplate template = GdPictureOfficeDefaultTemplateBuilder.CreateTemplate()
.AddPlaceholderReplacement(placeholder: "placeholder1", replacementValue: "replacementValue 1")
.AddPlaceholderReplacement(placeholder: "placeholder2", replacementValue: "replacementValue 2");
GdPictureOfficeTemplateConfiguration configuration = new GdPictureOfficeTemplateConfiguration
{
Delimiter = new GdPictureOfficeTemplateDelimiter
{
Start = "{{",
End = "}}"
}
};
using GdPictureOfficeTemplater templater = new();
GdPictureStatus status = templater.SetTemplate(template, configuration);
if (status == GdPictureStatus.OK)
{
status = templater.LoadFromFile(sourceFile);
if (status == GdPictureStatus.OK)
{
status = templater.Process();
if (status == GdPictureStatus.OK)
{
status = templater.SaveToFile(outputFile);
Console.WriteLine("Save status: " + status);
}
}
}
Console.WriteLine("Last status: " + templater.GetStat() + Environment.NewLine);
Saves the processed template to a stream.
The stream where the processed template will be saved.
The of the operation.
using GdPicture14;
string inputFile = "output.docx";
GdPictureOfficeTemplate template = GdPictureOfficeDefaultTemplateBuilder.CreateTemplate()
.AddPlaceholderReplacement(placeholder: "placeholder1", replacementValue: "replacementValue 1")
.AddPlaceholderReplacement(placeholder: "placeholder2", replacementValue: "replacementValue 2");
GdPictureOfficeTemplateConfiguration configuration = new GdPictureOfficeTemplateConfiguration
{
Delimiter = new GdPictureOfficeTemplateDelimiter
{
Start = "{{",
End = "}}"
}
};
using GdPictureOfficeTemplater templater = new();
GdPictureStatus status = templater.SetTemplate(template, configuration);
if (status == GdPictureStatus.OK)
{
status = templater.LoadFromFile(inputFile);
if (status == GdPictureStatus.OK)
{
status = templater.Process();
if (status == GdPictureStatus.OK)
{
using var outfileFileStream = new FileStream("output.docx", FileMode.OpenOrCreate, FileAccess.Write);
status = templater.SaveToStream(outfileFileStream);
Console.WriteLine("Save status: " + status);
}
}
}
Console.WriteLine("Last status: " + templater.GetStat() + Environment.NewLine);
Saves the processed template to a file.
The path to the file where the processed template will be saved.
The of the operation.
using GdPicture14;
string inputFile = "output.docx";
GdPictureOfficeTemplate template = GdPictureOfficeDefaultTemplateBuilder.CreateTemplate()
.AddPlaceholderReplacement(placeholder: "placeholder1", replacementValue: "replacementValue 1")
.AddPlaceholderReplacement(placeholder: "placeholder2", replacementValue: "replacementValue 2");
GdPictureOfficeTemplateConfiguration configuration = new GdPictureOfficeTemplateConfiguration
{
Delimiter = new GdPictureOfficeTemplateDelimiter
{
Start = "{{",
End = "}}"
}
};
using GdPictureOfficeTemplater templater = new();
GdPictureStatus status = templater.SetTemplate(template, configuration);
if (status == GdPictureStatus.OK)
{
status = templater.LoadFromFile(inputFile);
if (status == GdPictureStatus.OK)
{
status = templater.Process();
if (status == GdPictureStatus.OK)
{
status = templater.SaveToFile("output.docx");
Console.WriteLine("Save status: " + status);
}
}
}
Console.WriteLine("Last status: " + templater.GetStat() + Environment.NewLine);
Returns the of the last executed operation
by the current instance.
Gets the template and its configuration as a JSON string.
A JSON representation of the template and its configuration.
Disposes of the resources used by the instance.
The GdPicturePDF class is responsible for almost all PDF features that GdPicture.NET toolkit offers. It is used as a wrapper class to allow you easily operate with PDF documents.
You need to create an object of this class to fully work with PDF files. This object subsequently represents a wrapper for the currently loaded PDF document.
GdPicturePDF Constructor
How to load a PDF file using the GdPicturePDF class.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("MyPDF.pdf", False)
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been loaded successfully.", "GdPicturePDF")
Else
MessageBox.Show("The file has failed to load with the status: " + status.ToString(), "GdPicturePDF")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("MyPDF.pdf", false);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file has been loaded successfully.", "GdPicturePDF");
}
else
{
MessageBox.Show("The file has failed to load with the status: " + status.ToString(), "GdPicturePDF");
}
gdpicturePDF.Dispose();
This event is raised right before a page is to be printed.
Please check the corresponded for given parameters.
The page number of the page to be printed.
The number of pages left for printing.
Gets or sets a value indicating whether the print job should be canceled. Switching this value to true will subsequently terminate the printing job.
This event is raised right after a page has been successfully printed.
Please check the corresponded for given parameters.
The page number of the already printed page.
The number of pages left for printing.
Gets or sets a value indicating whether the print job should be canceled. Switching this value to true will subsequently terminate the printing job.
This event is triggered when OCR is requested to an external engine.
Specifies the identifier of the GdPicture Image into which the OCR must be performed.
A PdfOcrOptions instance specifying the options requested to the OCR engine.
A member of the GdPictureStatus enumeration that must be returned by the event subscriber.
A string specifying the encoding format of the serialized OCR result returned by the event subscriber.
Please check the reference guide (Programming / OCR) to obtain the possible encoding list and models into which the data must be serialized.
The ocr result, as string, encoded in the format specified by the ResultEncodingParameter.
Use the SetOverrideOcrEngine() method to specify that an external OCR engine must be used.
This event is raised immediately after the specified page has been processed using the or the methods.
Please check the corresponded for given parameters.
The event is always triggered within the caller thread of the method.
The PDF to PDF-OCR sample included in the PDF examples section
within the GdPicture.NET Reference Guide demonstrates the usage of this event.
'Add the event.
WithEvents gdpicturePDF As GdPicture14.GdPicturePDF
gdpicturePDF = New GdPicturePDF()
AddHandler gdpicturePDF.OcrPagesProgress, AddressOf OcrPagesProgress
'Define the event.
Sub OcrPagesProgress(ByVal Status As GdPictureStatus, ByVal PageNo As Integer, ByVal Processed As Integer, ByVal Count As Integer, ByRef Cancel As Boolean) Handles gdpicturePDF.OcrPagesProgress
'Do your stuff here.
End Sub
//Add the event.
GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.OcrPagesProgress += OcrPagesProgress;
//Define the event.
void OcrPagesProgress(GdPictureStatus status, int PageNo, int Processed, int Count, ref bool Cancel)
{
//Do your stuff here.
}
A member of the GdPictureStatus enumeration. The resulting status of the processed page.
The page number of the processed page.
The number of pages already processed.
The number of pages to be processed.
Cancellation parameter. Switching it to true permits to cancel the process on pending pages.
This event is raised just before the specified page is going to be processed using the or the methods.
Please check the corresponded for given parameters.
The event is always triggered within the caller thread of the method.
The PDF to PDF-OCR sample included in the PDF examples section
within the GdPicture.NET Reference Guide demonstrates the usage of this event.
'Add the event.
WithEvents gdpicturePDF As GdPicture14.GdPicturePDF
gdpicturePDF = New GdPicturePDF()
AddHandler gdpicturePDF.BeforePageOcr, AddressOf BeforePageOcr
'Define the event.
Sub BeforePageOcr(ByVal PageNo As Integer, ByRef Cancel As Boolean) Handles gdpicturePDF.BeforePageOcr
'Do your stuff here.
End Sub
//Add the event.
GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.BeforePageOcr += BeforePageOcr;
//Define the event.
void BeforePageOcr(int PageNo, ref bool Cancel)
{
//Do your stuff here.
}
The page number of the page to be processed.
Cancellation parameter. Switching it to true permits to cancel the process on this specific page.
This event is raised when a specified image is ready to be sent to the OCR engine during the process invoked by the or the methods.
It is fired after the event. This event is particularly useful to apply your specific custom pre-processing to the image before recognizing it.
Please check the corresponded for given parameters.
The event is always triggered within the caller thread of the method.
The PDF to PDF-OCR sample included in the PDF examples section
within the GdPicture.NET Reference Guide demonstrates the usage of this event.
'Add the event.
WithEvents gdpicturePDF As GdPicture14.GdPicturePDF
gdpicturePDF = New GdPicturePDF()
AddHandler gdpicturePDF.PageBitmapOcrReady, AddressOf PageBitmapOcrReady
'Define the event.
Sub PageBitmapOcrReady(ByVal PageNo As Integer, ByVal ImageID As Integer) Handles gdpicturePDF.PageBitmapOcrReady
'Do your stuff here.
End Sub
//Add the event.
GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.PageBitmapOcrReady += PageBitmapOcrReady;
//Define the event.
void PageBitmapOcrReady(int PageNo, int ImageID)
{
//Do your stuff here.
}
The page number of the page to be processed.
A unique image identifier of the GdPictureImage object representing the required image, that will be processed by the OCR engine.
This event is raised after the whole OCR process, invoked by the or the methods, has been terminated.
Please check the corresponded for given parameters.
The event is always triggered within the caller thread of the method.
The PDF to PDF-OCR sample included in the PDF examples section
within the GdPicture.NET Reference Guide demonstrates the usage of this event.
'Add the event.
WithEvents gdpicturePDF As GdPicture14.GdPicturePDF
gdpicturePDF = New GdPicturePDF()
AddHandler gdpicturePDF.OcrPagesDone, AddressOf OcrPagesDone
'Define the event.
Sub OcrPagesDone(status As GdPictureStatus) Handles gdpicturePDF.OcrPagesDone
'Do your stuff here.
End Sub
//Add the event.
GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.OcrPagesDone += OcrPagesDone;
//Define the event.
void OcrPagesDone(GdPictureStatus status)
{
//Do your stuff here.
}
A member of the GdPictureStatus enumeration. The resulting status of the finished OCR process.
Loads the source document according to a file path you have specified. A PDF file is loaded straightforward, a text file is converted into the PDF document.
No other file formats are allowed. You can also specify, if the file will be loaded into memory or not according to the next file operation.
Be aware that the file is locked for another use if the parameter LoadInMemory is set to false.
The file path of the source document. Supported formats are text files and PDF files.
Specifies if the document content will be loaded into memory (true). Loading the document content directly into memory results in
a better manipulation performance, but it consumes more memory. If you load a file into memory, you can subsequently overwrite or delete the file.
The predefind value is false.
If you need to use the read/write access mode when loading the file, please use the method.
Be aware that the required file is locked for another use if you set the parameter LoadInMemory to false.
The origin's location and the measurement unit for any loaded document are reset to their default values: PdfOrigin.PdfOriginBottomLeft, PdfMeasurementUnit.PdfMeasurementUnitPoint.
The document's first page is automatically set as the current page after loading.
Sometimes a PDF document can be password protected. You can use the method to determine if a PDF is encrypted or not.
If it is encrypted, you should use the method to decrypt it with the user or owner password.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Dim caption As String = "Example: LoadFromFile"
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("Text_File.txt", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("PDF_File.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: LoadFromFile";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.LoadFromFile("Text_File.txt", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("PDF_File.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The PDF file has been saved successfully.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), caption);
}
}
Dim caption As String = "Example: LoadFromFile"
Using gdpicturePDF As New GdPicturePDF()
'The file will load into memory.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", True)
If status = GdPictureStatus.OK Then
If gdpicturePDF.ClonePage(1) = GdPictureStatus.OK Then
'The file will be overwritten.
status = gdpicturePDF.SaveToFile("test.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been overwritten and saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
End If
gdpicturePDF.CloseDocument()
'The file will not load into memory.
status = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
If gdpicturePDF.DeletePage(1) = GdPictureStatus.OK Then
'The file will not be overwritten.
status = gdpicturePDF.SaveToFile("test.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been overwritten and saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: LoadFromFile";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
//The file will load into memory.
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", true);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.ClonePage(1) == GdPictureStatus.OK)
{
//The file will be overwritten.
status = gdpicturePDF.SaveToFile("test.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The PDF file has been overwritten and saved successfully.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
}
gdpicturePDF.CloseDocument();
//The file will not load into memory.
status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.DeletePage(1) == GdPictureStatus.OK)
{
//The file will not be overwritten.
status = gdpicturePDF.SaveToFile("test.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The PDF file has been overwritten and saved successfully.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), caption);
}
}
Loads the source document from an http uri.
This method requires the HTML Conversion and PDF Processing component to run.
A System.Uri object. This source to load the content from.
A member of the GdPictureStatus enumeration.
Loads the source document according to a file path you have specified. A PDF file is loaded straightforward, a text file is converted into the PDF
document. No other file formats are allowed. You can also specify an access to the loaded file, which can be read or read/write according to the next file operation.
This method can be useful if you need to allow access to the required file from more sources.
The file path of the source document. Supported formats are text files and PDF files.
Specifies if the file should be opened in read/write access mode (true).
Setting this parameter to true allows you to subsequently save the modified parts of the handled PDF document to the same source file.
The origin's location and the measurement unit for any loaded document are reset to their default values: PdfOrigin.PdfOriginBottomLeft, PdfMeasurementUnit.PdfMeasurementUnitPoint.
The document's first page is automatically set as the current page after loading.
Sometimes a PDF document can be password protected. You can use the method to determine if a PDF is encrypted or not. If it is encrypted, you
should use the method to decrypt it with the user or owner password.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Dim caption As String = "Example: LoadFromFileEx"
Using gdpicturePDF As New GdPicturePDF()
'The file access mode will be read/write.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFileEx("test.pdf", True)
If status = GdPictureStatus.OK Then
Dim fontRes As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontRes, 10, 10, "The quick brown fox jumps over the lazy dog.") = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFileInc("test.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been saved and overwritten successfully.", caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
End Using
string caption = "Example: LoadFromFileEx";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
//The file access mode will be read/write.
GdPictureStatus status = gdpicturePDF.LoadFromFileEx("test.pdf", true);
if (status == GdPictureStatus.OK)
{
string fontRes = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontRes, 10, 10, "The quick brown fox jumps over the lazy dog.") == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFileInc("test.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The PDF file has been saved and overwritten successfully.", caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
}
Dim caption As String = "Example: LoadFromFileEx"
Dim oSrcPDF As New GdPicturePDF()
Dim oDstPDF As New GdPicturePDF()
'File access mode will be read/write.
Dim status As GdPictureStatus = oDstPDF.LoadFromFileEx("doc1.pdf", True)
If status = GdPictureStatus.OK Then
'The file will not load into memory.
status = oSrcPDF.LoadFromFile("doc2.pdf", False)
If status = GdPictureStatus.OK Then
Dim srcPageCount As Integer = oSrcPDF.GetPageCount()
status = oSrcPDF.GetStat()
If status = GdPictureStatus.OK Then
For i As Integer = 1 To srcPageCount
status = oDstPDF.ClonePage(oSrcPDF, i)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The ClonePage() method has failed on the page " + i.ToString() + " with the status:" + status.ToString(), caption)
Exit For
End If
Next
If status = GdPictureStatus.OK Then
If oDstPDF.SaveToFileInc("doc1.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been overwritten and saved successfully.", caption)
End If
End If
End If
Else
MessageBox.Show("The source file can't be loaded.", caption)
End If
Else
MessageBox.Show("The destination file can't be loaded.", caption)
End If
oDstPDF.Dispose()
oSrcPDF.Dispose()
string caption = "Example: LoadFromFileEx";
GdPicturePDF oSrcPDF = new GdPicturePDF();
GdPicturePDF oDstPDF = new GdPicturePDF();
//File access mode will be read/write.
GdPictureStatus status = oDstPDF.LoadFromFileEx("doc1.pdf", true);
if (status == GdPictureStatus.OK)
{
//The file will not load into memory.
status = oSrcPDF.LoadFromFile("doc2.pdf", false);
if (status == GdPictureStatus.OK)
{
int srcPageCount = oSrcPDF.GetPageCount();
status = oSrcPDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int i = 1; i <= srcPageCount; i++)
{
status = oDstPDF.ClonePage(oSrcPDF, i);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The ClonePage() method has failed on the page " + i.ToString() + " with the status:" + status.ToString(), caption);
break;
}
}
if (status == GdPictureStatus.OK)
{
if (oDstPDF.SaveToFileInc("doc1.pdf") == GdPictureStatus.OK)
MessageBox.Show("The PDF file has been overwritten and saved successfully.", caption);
}
}
}
else
MessageBox.Show("The source file can't be loaded.", caption);
}
else
MessageBox.Show("The destination file can't be loaded.", caption);
oDstPDF.Dispose();
oSrcPDF.Dispose();
Loads the PDF document from a previously instantiated Stream object according to what you have specified. The only supported file format for the input stream is the PDF format.
A Stream object. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Specifies whether the instance is in charge of disposing the input stream when it is not needed anymore. Default value is false.
The origin's location and the measurement unit for any loaded document are reset to their default values: PdfOrigin.PdfOriginBottomLeft, PdfMeasurementUnit.PdfMeasurementUnitPoint.
The document's first page is automatically set as the current page after loading.
Sometimes a PDF document can be password protected. You can use the method to determine if a PDF is encrypted or not. If it is encrypted, you
should use the method to decrypt it with the user or owner password.
Please note that the input stream should remain open and can only be closed/disposed of by the user after a call to the is made.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to find out the number of pages in a PDF document loaded from a stream.
Dim PdfDoc As System.IO.Stream = New System.IO.FileStream("test.pdf", System.IO.FileMode.Open)
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromStream(PdfDoc)
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF document contains " + gdpicturePDF.GetPageCount().ToString() + " pages.", "Example: LoadFromStream")
Else
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Example: LoadFromStream")
End If
gdpicturePDF.Dispose()
PdfDoc.Dispose()
System.IO.Stream PdfDoc = new System.IO.FileStream("test.pdf", System.IO.FileMode.Open);
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromStream(PdfDoc);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("This PDF document contains " + gdpicturePDF.GetPageCount().ToString() + " pages.", "Example: LoadFromStream");
}
else
{
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Example: LoadFromStream");
}
gdpicturePDF.Dispose();
PdfDoc.Dispose();
Loads the PDF document from a previously instantiated IStream object according to what you have specified. The only supported file format for the input stream object is the PDF format.
An IStream object. This object must be initialized before it can be sent into this method and it should remain open for subsequent use.
The origin's location and the measurement unit for any loaded document are reset to their default values: PdfOrigin.PdfOriginBottomLeft, PdfMeasurementUnit.PdfMeasurementUnitPoint.
The document's first page is automatically set as the current page after loading.
Sometimes a PDF document can be password protected. You can use the method to determine if a PDF is encrypted or not.
If it is encrypted, you should use the method to decrypt it with the user or owner password.
Please note that the input stream should remain open and can only be closed/disposed of by the user after a call to the method is made.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
IStream is an interface, so you don't create an IStream object directly, you should rather implement this interface and then pass the required object. From that reason we don't add any example here.
Prepares a brand new empty PDF document within a GdPicturePDF object. You will always need an object of the GdPicturePDF class to create a new PDF document.
Please note that a newly created GdPicturePDF object does not automatically create a new PDF document. The created PDF document also does not contain any pages.
You are also able to reuse the created GdPicturePDF object for manipulation with another PDF document simply by calling this method again.
This method prepares a brand new empty PDF document within a GdPicturePDF object. You will always need an object of the GdPicturePDF class to create a new PDF document.
Just to inform you, that the toolkit will create the PDF document conformed to the lowest PDF version (version 1.3 is the minimum) based on what the output PDF document will contain.
This is the same as what the method does if you use the PdfConformance.PDF parameter.
The origin's location and the measurement unit for any newly created document are reset to their default values: PdfOrigin.PdfOriginBottomLeft, PdfMeasurementUnit.PdfMeasurementUnitPoint.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
GdPicturePDF Constructor
Using gdpicturePDF As New GdPicturePDF()
'A brand new empty document without any page.
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(500, 500) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 200, 250, "Hello World") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_HelloWorld.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", "Example: NewPDF")
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: NewPDF")
End If
End If
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), "Example: NewPDF")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
//A brand new empty document without any page.
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(500, 500) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 200, 250, "Hello World") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_HelloWorld.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", "Example: NewPDF");
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: NewPDF");
}
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), "Example: NewPDF");
}
}
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status <> GdPictureStatus.OK Then
GoTo [end]
End If
status = gdpicturePDF.NewPage(500, 500)
If status <> GdPictureStatus.OK Then
GoTo [end]
End If
status = gdpicturePDF.SaveToFile("FirstPDF.pdf")
If status <> GdPictureStatus.OK Then
GoTo [end]
End If
MessageBox.Show("The FirstPDF.pdf document with one page has been successfully saved.", "Example: NewPDF")
status = gdpicturePDF.CloseDocument()
If status <> GdPictureStatus.OK Then
GoTo [end]
End If
status = gdpicturePDF.NewPDF()
If status <> GdPictureStatus.OK Then
GoTo [end]
End If
status = gdpicturePDF.NewPage(500, 500)
If status <> GdPictureStatus.OK Then
GoTo [end]
End If
status = gdpicturePDF.SaveToFile("SecondPDF.pdf")
If status <> GdPictureStatus.OK Then
GoTo [end]
End If
MessageBox.Show("The SecondPDF.pdf document with one page has been successfully saved.", "Example: NewPDF")
[end]:
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status != GdPictureStatus.OK) goto end;
status = gdpicturePDF.NewPage(500, 500);
if (status != GdPictureStatus.OK) goto end;
status = gdpicturePDF.SaveToFile("FirstPDF.pdf");
if (status != GdPictureStatus.OK) goto end;
MessageBox.Show("The FirstPDF.pdf document with one page has been successfully saved.", "Example: NewPDF");
status = gdpicturePDF.CloseDocument();
if (status != GdPictureStatus.OK) goto end;
status = gdpicturePDF.NewPDF();
if (status != GdPictureStatus.OK) goto end;
status = gdpicturePDF.NewPage(500, 500);
if (status != GdPictureStatus.OK) goto end;
status = gdpicturePDF.SaveToFile("SecondPDF.pdf");
if (status != GdPictureStatus.OK) goto end;
MessageBox.Show("The SecondPDF.pdf document with one page has been successfully saved.", "Example: NewPDF");
end:
gdpicturePDF.Dispose();
Prepares a brand new empty PDF document within a GdPicturePDF object. The PDF conformance level of this PDF document will be set according to the parameter specified by you.
PDF/A is an ISO-standardized version of the PDF specialized for the digital preservation of electronic documents. It is a subset of the PDF standard which
excludes those PDF features that give rise to concerns about security and the ability to archive documents long term.
You will always need an object of the GdPicturePDF class to create a new common PDF or PDF/A document.
Please note that a newly created GdPicturePDF object does not automatically create a new document. The created document also does not contain any pages. You are also able to reuse the created GdPicturePDF
object for manipulation with another PDF document simply by calling this method again.
This method prepares a brand new empty PDF document within a GdPicturePDF object. You will always need an object of the GdPicturePDF class to create a new PDF document.
A member of the PdfConformance enumeration. Specifies the required conformance to the PDF or PDF/A standard of a newly created PDF document.
Setting this parameter to PdfConformance.PDF does the same as what the method does.
If you use the value of the PdfConformance.PDF, the toolkit will create the PDF document conformed to the lowest PDF version (version 1.3 is the minimum) based on what the output PDF document will contain.
The origin's location and the measurement unit for any newly created document are reset to their default values: PdfOrigin.PdfOriginBottomLeft, PdfMeasurementUnit.PdfMeasurementUnitPoint.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
GdPicturePDF Constructor
How to create a new single page PDF/A-1a compliant document with the "Hello World" written in the middle of the first page.
Using gdpicturePDF As New GdPicturePDF()
'A brand new empty document without any page.
Dim status As GdPictureStatus = gdpicturePDF.NewPDF(PdfConformance.PDF_A_1a)
If status = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(500, 500) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 200, 250, "Hello World") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_HelloWorld.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", "Example: NewPDF")
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: NewPDF")
End If
End If
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The NewPDF(PdfConformance.PDF_A_1a) method has failed with the status: " + status.ToString(), "Example: NewPDF")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
//A brand new empty document without any page.
GdPictureStatus status = gdpicturePDF.NewPDF(PdfConformance.PDF_A_1a);
if (status == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(500, 500) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 200, 250, "Hello World") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_HelloWorld.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", "Example: NewPDF");
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: NewPDF");
}
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The NewPDF(PdfConformance.PDF_A_1a) method has failed with the status: " + status.ToString(), "Example: NewPDF");
}
}
Converts text input, defined as a string, into a multipage (if required) PDF document.
A member of the PdfConformance enumeration. Specifies the required conformance to the PDF or PDF/A standard of a newly created PDF document.
If you use the value of the PdfConformance.PDF, the toolkit will create the PDF document conformed to the lowest PDF version (version 1.3 is the minimum) based on what the output PDF document will contain.
Please note that the fonts are always embedded in a PDF/A compliant file regardless of what you specify in the Embedded parameter.
Sets the page width of a new PDF document in points.
Sets the page height of a new PDF document in points.
Sets the width of the left margin on pages in points.
Sets the height of the top margin on pages in points.
Sets the width of the right margin on pages in points.
Sets the height of the bottom margin on pages in points.
A member of the TextAlignment enumeration. Specifies the horizontal alignment of the text within the bounding box.
Contains the input text as a string. This text will be set as a content of a new PDF document.
Sets the text size in points.
Specifies the name of the font to write the input text in.
Sets the font weight. Set this parameter to true if you want to use bold font, otherwise set it to false.
Sets the font style. Set this parameter to true if you want to use italic font, otherwise set it to false.
Specifies the font embedding. Set this parameter to true if you want to embed the font into a newly created PDF document, otherwise set it to false.
Please note that embedding the font inside the PDF document always increases the document's size. But for a better portability of PDF documents it is
recommended to embed the fonts into the files. The fonts are always embedded in a PDF/A compliant file regardless of the Embedded parameter.
Also the font you specify needs to allow copying to be embedded into a PDF file. The fonts under copyright cannot be copied.
Specifies if the font's bounding box should be used to determine the height of the font. It is set to false by default. You can set it to true for better calculation of the line spacing.
Please note that 1 point = 1/72 inch.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to create a PDF file from the text input.
Dim myFile As New System.IO.StreamReader("MyTextFile.txt")
Dim content As String = myFile.ReadToEnd()
myFile.Close()
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.CreateFromText(PdfConformance.PDF_A_1b, 595, 842, 10, 10, 10, 10, TextAlignment.TextAlignmentNear, content, 12, "Arial", False, False, True, False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("PDFfromText.pdf", False)
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF has been created successfully.", "Example: CreateFromText")
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: CreateFromText")
End If
Else
MessageBox.Show("The CreateFromText() method has failed with the status: " + status.ToString(), "Example: CreateFromText")
End If
gdpicturePDF.Dispose()
System.IO.StreamReader myFile = new System.IO.StreamReader("MyTextFile.txt");
string content = myFile.ReadToEnd();
myFile.Close();
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.CreateFromText(PdfConformance.PDF_A_1b, 595, 842, 10, 10, 10, 10, TextAlignment.TextAlignmentNear, content, 12, "Arial", false, false, true, false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("PDFfromText.pdf", false);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("Your new PDF has been created successfully.", "Example: CreateFromText");
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: CreateFromText");
}
}
else
{
MessageBox.Show("The CreateFromText() method has failed with the status: " + status.ToString(), "Example: CreateFromText");
}
gdpicturePDF.Dispose();
Clears the cache resources belonging to the loaded PDF document.
Most of the memory used by the toolkit have been allocated by the .NET garbage collector.
Consequently all the unused memory will be available after the next garbage collection.
The GdPictureDocumentUtilities.ForceGarbageCollection can be used to force a garbage collection.
A member of the GdPictureStatus enumeration.
Closes the currently loaded PDF document and releases any related resources from memory.
Instead of calling this method in most cases just ensure that the object is properly disposed of.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to determine the number of pages in the PDF document.
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This document contains " + pageCount.ToString() + " pages.", "Example: CloseDocument")
End If
status = gdpicturePDF.CloseDocument()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The CloseDocument() method has failed with the status: " + status.ToString(), "Example: CloseDocument")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: CloseDocument")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("This document contains " + pageCount.ToString() + " pages.", "Example: CloseDocument");
status = gdpicturePDF.CloseDocument();
if (status != GdPictureStatus.OK)
MessageBox.Show("The CloseDocument() method has failed with the status: " + status.ToString(), "Example: CloseDocument");
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: CloseDocument");
}
}
Creates a new action of the type Launch. A launch action launches an application or opens or prints a document.
The file name of the application to be launched or the document to be opened or printed, in standard Windows pathname format.
Specifies the default directory (related to the FileName and the Operation parameters) in standard DOS syntax.
It is a Windows-specific parameter and it is optional, so if you are not sure, please use an empty string.
A parameter string to be passed to the application designated by the FileName parameter. It is a Windows-specific parameter and it is optional, so if you are not sure, please use an empty string.
A member of the PdfActionLaunchOperation enumeration. It is a Windows-specific parameter and it is optional, so if you are not sure, please use the value of PdfActionLaunchOperation.ActionLaunchOperationUndefined.
Specifies whether to open the related document (see the FileName parameter) in a new window. If the value is set to false, the specified document replaces the current document in the same window. This value is ignored if the specified document is not a PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Also be careful about the PDF/A conformance of the current document. Executable file launches are forbidden in the PDF/A compliant documents.
The unique action identifier of the newly created action of the type Launch. The method can be subsequently used to determine if this method has been successful.
You can subsequently apply this identifier when creating actions using these methods: , , or .
How to create a form field of the type button with the associated Launch action. Clicking this button in the created PDF document results in the opening of the Notepad.exe application.
Dim gdpicturePDF As New GdPicturePDF()
Dim failedMethod As String = "NewPDF()"
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
failedMethod = "NewPage() or SelectPage()"
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso (gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
failedMethod = "AddStandardFont()"
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failedMethod = "AddPushButtonFormField()"
Dim fieldID As Integer = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 1, "Submit", "Open notepad.exe", fontResName, 6, 255, 0, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failedMethod = "NewActionLaunch()"
Dim actionID As Integer = gdpicturePDF.NewActionLaunch("notepad.exe", "", "", PdfActionLaunchOperation.ActionLaunchOperationUndefined, True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failedMethod = "SetFormFieldAction() or SaveToFile()"
If (gdpicturePDF.SetFormFieldAction(fieldID, actionID) = GdPictureStatus.OK) AndAlso (gdpicturePDF.SaveToFile("button_action.pdf") = GdPictureStatus.OK) Then
failedMethod = ""
MessageBox.Show("The PDF document containing the button associated with the Launch action has been saved successfully.", "Example: NewActionLaunch")
End If
End If
End If
End If
End If
End If
If failedMethod <> "" Then
MessageBox.Show("The " + failedMethod + " method has failed. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionLaunch")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string failedMethod = "NewPDF()";
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
failedMethod = "NewPage() or SelectPage()";
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
{
failedMethod = "AddStandardFont()";
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failedMethod = "AddPushButtonFormField()";
int fieldID = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 1, "Submit", "Open notepad.exe", fontResName, 6, 255, 0, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failedMethod = "NewActionLaunch()";
int actionID = gdpicturePDF.NewActionLaunch("notepad.exe", "", "", PdfActionLaunchOperation.ActionLaunchOperationUndefined, true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failedMethod = "SetFormFieldAction() or SaveToFile()";
if ((gdpicturePDF.SetFormFieldAction(fieldID, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("button_action.pdf") == GdPictureStatus.OK))
{
failedMethod = "";
MessageBox.Show("The PDF document containing the button associated with the Launch action has been saved successfully.", "Example: NewActionLaunch");
}
}
}
}
}
}
if (failedMethod != "")
MessageBox.Show("The " + failedMethod + " method has failed. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionLaunch");
gdpicturePDF.Dispose();
Creates a new action of the type GoTo. A go-to action changes the view to a specified destination (page, location, and magnification factor) in the currently loaded PDF document.
A member of the PdfDestinationType enumeration. Sets up a particular view of a destination page specified by the Page parameter.
The destination page number in the current document. It must be a value from 1 to .
The horizontal (left) coordinate of the document window's position according to the specified DestinationType parameter. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The horizontal (right) coordinate of the document window's position according to the specified DestinationType parameter. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (bottom) coordinate of the document window's position according to the specified DestinationType parameter. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (top) coordinate of the document window's position according to the specified DestinationType parameter. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The zoom factor to use when displaying the destination page according to the DestinationType configuration. Please use the value of 1 to represent the 100% zoom,
2 means 200%, 0,5 means 50%, etc. The value of 0 means that the current zoom value should remain unchanged.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All values of the coordinates are expressed in the current units defined by the method according to the current coordinate space defined by the method.
The unique action identifier of the newly created action of the type GoTo. The method can be subsequently used to determine if this method has been successful.
You can subsequently apply this identifier when creating actions using these methods: , , or .
Dim caption As String = "Example: NewActionGoTo"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("testPDF.pdf", False)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim actionID As Integer = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, 10, 1, 0, 0, 5, 3)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetViewerOpenAction(actionID)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("open_action.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The PDF document with the specified OpenAction has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
Else
MessageBox.Show("The SetViewerOpenAction() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewActionGoTo() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
Dim caption As String = "Example: NewActionGoTo"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim failure As Boolean = True
Dim i As Integer = 0
Do
i += 1
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim bookMarkID As Integer = gdpicturePDF.NewBookmark(0, "Move to the page " + i.ToString())
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetBookmarkAction(bookMarkID, actionID)
failure = (status <> GdPictureStatus.OK)
End If
End If
End If
If failure Then
MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Loop While Not failure AndAlso i < 10
If Not failure AndAlso (gdpicturePDF.SaveToFile("bookmarks_actions.pdf") = GdPictureStatus.OK) Then
MessageBox.Show("The new file has been saved successfully.", caption)
Else
MessageBox.Show("The new file can't be saved.", caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The new file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NewActionGoTo";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("testPDF.pdf", false);
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
int actionID = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, 10, 1, 0, 0, 5, 3);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetViewerOpenAction(actionID);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("open_action.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The PDF document with the specified OpenAction has been saved successfully.", caption);
}
else
{
MessageBox.Show("The file can't be saved.", caption);
}
}
else
{
MessageBox.Show("The SetViewerOpenAction() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The NewActionGoTo() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
string caption = "Example: NewActionGoTo";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
bool failure = true;
int i = 0;
do
{
i++;
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int bookMarkID = gdpicturePDF.NewBookmark(0, "Move to the page " + i.ToString());
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetBookmarkAction(bookMarkID, actionID);
failure = (status != GdPictureStatus.OK);
}
}
}
if (failure)
{
MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
} while (!failure && i < 10);
if (!failure && (gdpicturePDF.SaveToFile("bookmarks_actions.pdf") == GdPictureStatus.OK))
{
MessageBox.Show("The new file has been saved successfully.", caption);
}
else
{
MessageBox.Show("The new file can't be saved.", caption);
}
}
else
{
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The new file can't be created.", caption);
}
gdpicturePDF.Dispose();
Creates a new action of the type GoTo. A go-to action changes the view to a specified destination (page, location, and magnification factor) in the currently loaded PDF document.
A member of the PdfDestinationType enumeration. Sets up a particular view of a destination page specified by the Page parameter.
The destination page number in the current document. It must be a value from 1 to .
The horizontal (left) coordinate of the document window's position according to the specified DestinationType parameter. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The horizontal (right) coordinate of the document window's position according to the specified DestinationType parameter. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (bottom) coordinate of the document window's position according to the specified DestinationType parameter. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (top) coordinate of the document window's position according to the specified DestinationType parameter. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The zoom factor to use when displaying the destination page according to the DestinationType configuration. Please use the value of 1 to represent the 100% zoom,
Set to true if you want the action to retain actual left coordinate (Left parameter is ignored), otherwise set to false.
Set to true if you want the action to retain actual top coordinate (Top parameter is ignored), otherwise set to false.
2 means 200%, 0,5 means 50%, etc. The value of 0 means that the current zoom value should remain unchanged.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All values of the coordinates are expressed in the current units defined by the method according to the current coordinate space defined by the method.
The unique action identifier of the newly created action of the type GoTo. The method can be subsequently used to determine if this method has been successful.
You can subsequently apply this identifier when creating actions using these methods: , , or .
Creates a new action of the type GoToR. A go-to remote action jumps to a destination in another PDF file instead of the current file, as it is for an ordinary go-to action.
In other words, a GoToR action changes the view to a specified destination (page, location, and magnification factor) in a specified file.
A member of the PdfDestinationType enumeration. Sets up a particular view of a destination to jump specified by the this action.
The relative path of the file in which the destination is located.
Specifies whether to open the destination document in a new window. If the value is set to false, the destination document replaces the current document in the same window.
The destination page number located in the File parameter.
The horizontal (left) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in
the currently set units according to the currently used coordinate space, see the Remarks section below.
The horizontal (right) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed
in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (bottom) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (top) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed
in the currently set units according to the currently used coordinate space, see the Remarks section below.
The zoom factor to use when displaying the destination page according to the DestinationType configuration. Please use the value of 1 to represent the 100% zoom,
2 means 200%, 0,5 means 50%, etc. The value of 0 means that the current zoom value should remain unchanged.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All values of the coordinates are expressed in the current units defined by the method according to the current coordinate space defined by the method.
The unique action identifier of the newly created action of the type GoToR. The method can be subsequently used to determine if this method has been successful.
You can subsequently apply this identifier when creating actions using these methods: , , or .
How to create a link associated with the GoToR action. The example creates two PDF documents which are linked together through the links associated with the GoToR action.
Dim caption As String = "Example: NewActionGoToR"
Dim gdpicturePDF As New GdPicturePDF()
Dim failure As Boolean = True
Dim textSize As Single = 12, textWidth As Single = 0, textHeight As Single = 0
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'The creation of the first pdf1.pdf document.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf2.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf1.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat().ToString(), caption)
Else
failure = True
status = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'The creation of the second pdf2.pdf document.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf1.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf2.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat(), caption)
Else
MessageBox.Show("The example HAS been successfully followed." + vbCrLf + "Both newly created PDF documents are linked together.", caption)
End If
End If
gdpicturePDF.Dispose()
string caption = "Example: NewActionGoToR";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
bool failure = true;
float textSize = 12, textWidth = 0, textHeight = 0;
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//The creation of the first pdf1.pdf document.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf2.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf1.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat().ToString(), caption);
else
{
failure = true;
status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//The creation of the second pdf2.pdf document.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf1.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf2.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat(), caption);
else
MessageBox.Show("The example HAS been successfully followed.\nBoth newly created PDF documents are linked together.", caption);
}
gdpicturePDF.Dispose();
Creates a new action of the type GoToR. A go-to remote action jumps to a destination in another PDF file instead of the current file, as it is for an ordinary go-to action.
In other words, a GoToR action changes the view to a specified destination (page, location, and magnification factor) in a specified file.
A member of the PdfDestinationType enumeration. Sets up a particular view of a destination to jump specified by the this action.
The relative path of the file in which the destination is located.
Specifies whether to open the destination document in a new window. If the value is set to false, the destination document replaces the current document in the same window.
The destination page number located in the File parameter.
The horizontal (left) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed in
the currently set units according to the currently used coordinate space, see the Remarks section below.
The horizontal (right) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed
in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (bottom) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
The vertical (top) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is expressed
in the currently set units according to the currently used coordinate space, see the Remarks section below.
The zoom factor to use when displaying the destination page according to the DestinationType configuration. Please use the value of 1 to represent the 100% zoom,
Set to true if you want the action to retain actual left coordinate (Left parameter is ignored), otherwise set to false.
Set to true if you want the action to retain actual top coordinate (Top parameter is ignored), otherwise set to false.
2 means 200%, 0,5 means 50%, etc. The value of 0 means that the current zoom value should remain unchanged.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All values of the coordinates are expressed in the current units defined by the method according to the current coordinate space defined by the method.
The unique action identifier of the newly created action of the type GoToR. The method can be subsequently used to determine if this method has been successful.
You can subsequently apply this identifier when creating actions using these methods: , , or .
How to create a link associated with the GoToR action. The example creates two PDF documents which are linked together through the links associated with the GoToR action.
Creates a new action of the type JavaScript. A JavaScript action (introduced in PDF 1.3) causes a script to be compiled and executed
by the JavaScript interpreter. JavaScript implements objects, methods, and properties that enable you to manipulate PDF files, modify the appearance of PDF
files, etc. You can tie JavaScript code to a specific PDF document, a page or a field, and much more.
You can read more about the content and effects of JavaScript scripts in the JavaScript for Acrobat API Reference.
A text string containing a JavaScript script to be executed when the action is triggered.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Also be careful about the PDF/A conformance of the current PDF document. JavaScript actions are forbidden in the PDF/A compliant documents.
The unique action identifier of the newly created action of the type JavaScript. The method can be subsequently used to determine if this method has been successful.
You can subsequently apply this identifier when creating actions using these methods: , , or .
How to create a form field of the type button with the associated JavaScript action.
Clicking this button in the created PDF document results in running the script. The alert window displays the string Hello! .
Dim gdpicturePDF As New GdPicturePDF()
Dim failedMethod As String = "NewPDF()"
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
failedMethod = "NewPage() or SelectPage()"
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
failedMethod = "AddStandardFont()"
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failedMethod = "AddPushButtonFormField()"
Dim fieldID As Integer = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 1, "Submit", "Hello!", fontResName, 6, 255, 0, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failedMethod = "NewActionJavaScript()"
Dim javaScript As String = "app.alert(""Hello!"");"
Dim actionID As Integer = gdpicturePDF.NewActionJavaScript(javaScript)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
failedMethod = "SetFormFieldAction() or SaveToFile()"
If (gdpicturePDF.SetFormFieldAction(fieldID, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("button_action_javascript.pdf") = GdPictureStatus.OK) Then
failedMethod = ""
MessageBox.Show("The PDF document containing the button associated with the JavaScript action has been saved successfully.", "Example: NewActionJavaScript")
End If
End If
End If
End If
End If
End If
If failedMethod <> "" Then
MessageBox.Show("The " + failedMethod + " method has failed. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionJavaScript")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string failedMethod = "NewPDF()";
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
failedMethod = "NewPage() or SelectPage()";
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
{
failedMethod = "AddStandardFont()";
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failedMethod = "AddPushButtonFormField()";
int fieldID = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 1, "Submit", "Hello!", fontResName, 6, 255, 0, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failedMethod = "NewActionJavaScript()";
string javaScript = "app.alert(\"Hello!\");";
int actionID = gdpicturePDF.NewActionJavaScript(javaScript);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failedMethod = "SetFormFieldAction() or SaveToFile()";
if ((gdpicturePDF.SetFormFieldAction(fieldID, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("button_action_javascript.pdf") == GdPictureStatus.OK))
{
failedMethod = "";
MessageBox.Show("The PDF document containing the button associated with the JavaScript action has been saved successfully.", "Example: NewActionJavaScript");
}
}
}
}
}
}
if (failedMethod != "")
MessageBox.Show("The " + failedMethod + " method has failed. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionJavaScript");
gdpicturePDF.Dispose();
Creates a new action of the type URI. A URI action causes a URI to be resolved. A uniform resource identifier (URI) is a string that identifies (resolves to) a resource on the Internet - typically
a file that is the destination of a hypertext link. URIs are described in RFC 2396 - Uniform Resource Identifier (URI).
The uniform resource identifier to resolve, encoded in 7-bit ASCII. For example "http://www.gdpicture.com".
A flag specifying whether to track the mouse position when the URI is resolved. The default value is false.
This entry only applies to actions triggered by the user's clicking an annotation; it is ignored for actions associated with bookmarks or with a document's OpenAction entry.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Also be careful about the PDF/A conformance of the current PDF document. External content references (hypertext links) are forbidden in the PDF/A compliant documents.
The unique action identifier of the newly created action of the type URI. The method can be subsequently used to determine if this method has been successful.
You can subsequently apply this identifier when creating actions using these methods: , , or .
Dim gdpicturePDF As New GdPicturePDF()
Dim failedMethod As String = "NewPDF()"
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
failedMethod = "NewPage() or SelectPage()"
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso (gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
failedMethod = "AddStandardFont()"
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failedMethod = "AddPushButtonFormField()"
Dim fieldID As Integer = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 1, "Submit", "Open http://www.gdpicture.com", fontResName, 6, 255, 0, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failedMethod = "NewActionURI()"
Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
failedMethod = "SetFormFieldAction() or SaveToFile()"
If (gdpicturePDF.SetFormFieldAction(fieldID, actionID) = GdPictureStatus.OK) AndAlso (gdpicturePDF.SaveToFile("button_action.pdf") = GdPictureStatus.OK) Then
failedMethod = ""
MessageBox.Show("The PDF document containing the button associated with the URI action has been saved successfully.", "Example: NewActionURI")
End If
End If
End If
End If
End If
End If
If failedMethod <> "" Then
MessageBox.Show("The " + failedMethod + " method has failed. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionURI")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string failedMethod = "NewPDF()";
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
failedMethod = "NewPage() or SelectPage()";
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
{
failedMethod = "AddStandardFont()";
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourier);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failedMethod = "AddPushButtonFormField()";
int fieldID = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 1, "Submit", "Open http://www.gdpicture.com", fontResName, 6, 255, 0, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failedMethod = "NewActionURI()";
int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failedMethod = "SetFormFieldAction() or SaveToFile()";
if ((gdpicturePDF.SetFormFieldAction(fieldID, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("button_action.pdf") == GdPictureStatus.OK))
{
failedMethod = "";
MessageBox.Show("The PDF document containing the button associated with the URI action has been saved successfully.", "Example: NewActionURI");
}
}
}
}
}
}
if (failedMethod != "")
MessageBox.Show("The " + failedMethod + " method has failed. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionURI");
gdpicturePDF.Dispose();
Dim caption As String = "Example: NewActionURI"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) Then
Dim rootBookmark As Integer = gdpicturePDF.NewBookmark(0, "Links Navigation")
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim bookMarkID1 As Integer = gdpicturePDF.NewBookmark(rootBookmark, "Visit GdPicture website!")
status = gdpicturePDF.GetStat()
Dim bookMarkID2 As Integer = 0
If status = GdPictureStatus.OK Then
bookMarkID2 = gdpicturePDF.NewBookmark(rootBookmark, "Read GdPicture.NET documentation online!")
status = gdpicturePDF.GetStat()
End If
If status = GdPictureStatus.OK Then
Dim actionID1 As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The NewActionURI() method has failed with the status: " + status.ToString(), caption)
End If
Dim actionID2 As Integer = -1
If status = GdPictureStatus.OK Then
actionID2 = gdpicturePDF.NewActionURI("http://www.guides.gdpicture.com", False)
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The NewActionURI() method has failed with the status: " + status.ToString(), caption)
End If
End If
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetBookmarkAction(bookMarkID1, actionID1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetBookmarkAction(bookMarkID2, actionID2)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("actions_NewActionURI.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The new file has been saved successfully.", caption)
Else
MessageBox.Show("The new file can't be saved. Status: " + status.ToString(), caption)
End If
End If
End If
End If
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example has NOT been followed successfully.", caption)
End If
Else
MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NewActionURI";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK))
{
int rootBookmark = gdpicturePDF.NewBookmark(0, "Links Navigation");
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int bookMarkID1 = gdpicturePDF.NewBookmark(rootBookmark, "Visit GdPicture website!");
status = gdpicturePDF.GetStat();
int bookMarkID2 = 0;
if (status == GdPictureStatus.OK)
{
bookMarkID2 = gdpicturePDF.NewBookmark(rootBookmark, "Read GdPicture.NET documentation online!");
status = gdpicturePDF.GetStat();
}
if (status == GdPictureStatus.OK)
{
int actionID1 = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
MessageBox.Show("The NewActionURI() method has failed with the status: " + status.ToString(), caption);
int actionID2 = -1;
if (status == GdPictureStatus.OK)
{
actionID2 = gdpicturePDF.NewActionURI("http://www.guides.gdpicture.com", false);
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
MessageBox.Show("The NewActionURI() method has failed with the status: " + status.ToString(), caption);
}
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetBookmarkAction(bookMarkID1, actionID1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetBookmarkAction(bookMarkID2, actionID2);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("actions_NewActionURI.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The new file has been saved successfully.", caption);
else
MessageBox.Show("The new file can't be saved. Status: " + status.ToString(), caption);
}
}
}
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example has NOT been followed successfully.", caption);
}
else
{
MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
gdpicturePDF.Dispose();
Creates a new action of the type Named. A named action is a simple action defined by its name that PDF viewer applications are expected to support.
See the PdfActionNamed enumeration for the predefined named actions.
A member of the PdfActionNamed enumeration. Sets the destination of the action specified by its name.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The unique action identifier of the newly created action of the type Named. The method can be subsequently used to determine if this method has been successful.
You can subsequently apply this identifier when creating actions using these methods: , , or .
How to create a PDF document of 5 pages with 4 links on each page, while these links are associated with the predefined named actions.
Dim failure As Boolean = True
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionFirstPageID As Integer = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedFirstPage)
status = gdpicturePDF.GetStat()
Dim actionPrevPageID As Integer = -1
If status = GdPictureStatus.OK Then
actionPrevPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedPrevPage)
status = gdpicturePDF.GetStat()
End If
Dim actionNextPageID As Integer = -1
If status = GdPictureStatus.OK Then
actionNextPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedNextPage)
status = gdpicturePDF.GetStat()
End If
Dim actionLastPageID As Integer = -1
If status = GdPictureStatus.OK Then
actionLastPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedLastPage)
status = gdpicturePDF.GetStat()
End If
If status = GdPictureStatus.OK Then
Dim i As Integer = 0, annotID As Integer = -1
Do
i += 1
failure = True
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 0.5F, "This is the page " + i.ToString()) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, 4, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "First page") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 4, 1, 7, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Prev. page") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 7, 1, 10, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Next page") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 10, 1, 13, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Last page") = GdPictureStatus.OK) Then
annotID = gdpicturePDF.AddLinkAnnotation(1, 1, 3, 1, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionFirstPageID) = GdPictureStatus.OK) Then
annotID = gdpicturePDF.AddLinkAnnotation(4, 1, 3, 1, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionPrevPageID) = GdPictureStatus.OK) Then
annotID = gdpicturePDF.AddLinkAnnotation(7, 1, 3, 1, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionNextPageID) = GdPictureStatus.OK) Then
annotID = gdpicturePDF.AddLinkAnnotation(10, 1, 3, 1, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetAnnotationAction(annotID, actionLastPageID)
failure = (status <> GdPictureStatus.OK)
End If
End If
End If
End If
End If
Loop While (Not failure) AndAlso (i < 5)
If Not failure Then
failure = (gdpicturePDF.SaveToFile("NamedActions.pdf") <> GdPictureStatus.OK)
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been followed successfully. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionNamed")
Else
MessageBox.Show("The example HAS been followed successfully." + vbCrLf + "The PDF document with the named actions has been created.", "Example: NewActionNamed")
End If
gdpicturePDF.Dispose()
bool failure = true;
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionFirstPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedFirstPage);
status = gdpicturePDF.GetStat();
int actionPrevPageID = -1;
if (status == GdPictureStatus.OK)
{
actionPrevPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedPrevPage);
status = gdpicturePDF.GetStat();
}
int actionNextPageID = -1;
if (status == GdPictureStatus.OK)
{
actionNextPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedNextPage);
status = gdpicturePDF.GetStat();
}
int actionLastPageID = -1;
if (status == GdPictureStatus.OK)
{
actionLastPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedLastPage);
status = gdpicturePDF.GetStat();
}
if (status == GdPictureStatus.OK)
{
int i = 0, annotID = -1;
do
{
i++; failure = true;
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 0.5f, "This is the page " + i.ToString()) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, 4, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "First page") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 4, 1, 7, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Prev. page") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 7, 1, 10, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Next page") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 10, 1, 13, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Last page") == GdPictureStatus.OK))
{
annotID = gdpicturePDF.AddLinkAnnotation(1, 1, 3, 1, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionFirstPageID) == GdPictureStatus.OK))
{
annotID = gdpicturePDF.AddLinkAnnotation(4, 1, 3, 1, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionPrevPageID) == GdPictureStatus.OK))
{
annotID = gdpicturePDF.AddLinkAnnotation(7, 1, 3, 1, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionNextPageID) == GdPictureStatus.OK))
{
annotID = gdpicturePDF.AddLinkAnnotation(10, 1, 3, 1, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetAnnotationAction(annotID, actionLastPageID);
failure = (status != GdPictureStatus.OK);
}
}
}
}
}
} while ((!failure) && (i < 5));
if (!failure)
failure = (gdpicturePDF.SaveToFile("NamedActions.pdf") != GdPictureStatus.OK);
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been followed successfully. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: NewActionNamed");
else
MessageBox.Show("The example HAS been followed successfully.\nThe PDF document with the named actions has been created.", "Example: NewActionNamed");
gdpicturePDF.Dispose();
Sets the specified action in the OpenAction entry in the PDF document's catalog. This property defines a destination to be displayed or an action to be
carried out when the document is opened. If this entry is absent, the document should be opened to the top of the first page at the default magnification factor.
A unique action identifier specifying a required action object. You can obtain this identifier when creating an action,
for example, using the method.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the OpenAction action of a PDF to open it at the 10th page, with a zoom level of 300% and a default offset set to 1 centimeter from the left and 5 centimeters from the top.
Dim caption As String = "Example: SetViewerOpenAction"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("testPDF.pdf", False)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim actionID As Integer = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, 10, 1, 0, 0, 5, 3)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetViewerOpenAction(actionID)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("open_action.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The PDF document with the specified OpenAction has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
Else
MessageBox.Show("The SetViewerOpenAction() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewActionGoTo() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetViewerOpenAction";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("testPDF.pdf", false);
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
int actionID = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, 10, 1, 0, 0, 5, 3);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetViewerOpenAction(actionID);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("open_action.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The PDF document with the specified OpenAction has been saved successfully.", caption);
}
else
{
MessageBox.Show("The file can't be saved.", caption);
}
}
else
{
MessageBox.Show("The SetViewerOpenAction() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The NewActionGoTo() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Gets the unique action identifier of the action defined in the OpenAction entry in the PDF document's catalog. If this action is set, it defines a destination
to be displayed or an action to be carried out when the document is opened. If it is absent, the document should be opened to the top of the first page at the default magnification factor.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any. For example, if the OpenAction entry is not
available in the PDF document's catalog, the reason for the method's failure is GdPictureStatus.PropertyNotFound.
A unique action identifier of the action known as OpenAction. The method can be subsequently used to determine if this method has been successful.
You can use the method to determine the type of this action as it is shown in the example below.
How to find out if the OpenAction action is defined in the PDF document. If this action is specified, the example also shows you how to determine the type of this action.
Dim caption As String = "Example: GetViewerOpenActionID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("actions.pdf", False)
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.GetViewerOpenActionID()
status = gdpicturePDF.GetStat()
Select Case status
Case GdPictureStatus.OK
Dim actionType As PdfActionType = gdpicturePDF.GetActionType(actionID)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
If status1 = GdPictureStatus.OK Then
MessageBox.Show("The OpenAction action of the type " + actionType.ToString() + " is defined for this document.", caption)
Else
MessageBox.Show("The OpenAction action is defined for this document, but the GetActionType() method has failed with the status: " + status1.ToString(), caption)
End If
Exit Select
Case GdPictureStatus.PropertyNotFound
MessageBox.Show("The OpenAction action is not defined for this document.", caption)
Exit Select
Case Else
MessageBox.Show("The GetViewerOpenActionID() method has failed with the status: " + status.ToString(), caption)
Exit Select
End Select
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetViewerOpenActionID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("actions.pdf", false);
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.GetViewerOpenActionID();
status = gdpicturePDF.GetStat();
switch (status)
{
case GdPictureStatus.OK:
PdfActionType actionType = gdpicturePDF.GetActionType(actionID);
GdPictureStatus status1 = gdpicturePDF.GetStat();
if (status1 == GdPictureStatus.OK)
MessageBox.Show("The OpenAction action of the type " + actionType.ToString() + " is defined for this document.", caption);
else
MessageBox.Show("The OpenAction action is defined for this document, but the GetActionType() method has failed with the status: " + status1.ToString(), caption);
break;
case GdPictureStatus.PropertyNotFound:
MessageBox.Show("The OpenAction action is not defined for this document.", caption);
break;
default:
MessageBox.Show("The GetViewerOpenActionID() method has failed with the status: " + status.ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the action type of a specified PDF action object in the currently loaded PDF document.
A PDF action object defines the characteristics and behavior of an action. Actions can be assigned to links, bookmarks, pages, media clips,
and form fields in the PDF document. Please see the PdfActionType enumeration for more details about all supported PDF actions.
A unique action identifier specifying a required action object. This identifier is the only one you need to exactly determine the required action.
No other action object needs to be used.All available methods for obtaining this identifier are listed in the See Also section below.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfActionType enumeration. The method can be subsequently used to determine if this method has been successful.
The first example shows you how to find out the current action types of all actions associated with all links stored in the PDF document. The second example shows you the same but for the form fields.
Dim caption As String = "Example: GetActionType"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("links.pdf", False)
If status = GdPictureStatus.OK Then
Dim pagesCount As Integer = gdpicturePDF.GetPageCount()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (pagesCount > 0) Then
Dim linksActionTypes As String = ""
For i As Integer = 1 To pagesCount
linksActionTypes = linksActionTypes + "Page Nr." + i.ToString()
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
Dim linksCount As Integer = gdpicturePDF.GetPageLinksCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If linksCount = 0 Then
linksActionTypes = linksActionTypes + " has no links." + vbCrLf
Else
linksActionTypes = linksActionTypes + " has " + linksCount.ToString() + " links." + vbCrLf
Dim err As Boolean = True
For x As Integer = 0 To linksCount - 1
err = True
linksActionTypes = linksActionTypes + " Link Nr." + x.ToString()
Dim linkId As Integer = gdpicturePDF.GetPageLinkAnnotationIdx(x)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim actionId As Integer = gdpicturePDF.GetAnnotationActionID(linkId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim actionType As PdfActionType = gdpicturePDF.GetActionType(actionId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
linksActionTypes = linksActionTypes + " is associated with this action: " + actionType.ToString() + vbCrLf
err = False
End If
Else
If gdpicturePDF.GetStat() = GdPictureStatus.PropertyNotFound Then
linksActionTypes = linksActionTypes + " has no associated action." + vbCrLf
err = False
End If
End If
End If
If err Then
linksActionTypes = linksActionTypes + " has failed to find an action." + vbCrLf
End If
Next
End If
Else
linksActionTypes = linksActionTypes + " has failed to find links." + vbCrLf
End If
Else
linksActionTypes = linksActionTypes + " has failed to select." + vbCrLf
End If
Next
MessageBox.Show(linksActionTypes, caption)
Else
MessageBox.Show("The file has failed to load pages.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionType";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("links.pdf", false);
if (status == GdPictureStatus.OK)
{
int pagesCount = gdpicturePDF.GetPageCount();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) && (pagesCount > 0))
{
string linksActionTypes = "";
for (int i = 1; i <= pagesCount; i++)
{
linksActionTypes = linksActionTypes + "Page Nr." + i.ToString();
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
int linksCount = gdpicturePDF.GetPageLinksCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (linksCount == 0)
linksActionTypes = linksActionTypes + " has no links.\n";
else
{
linksActionTypes = linksActionTypes + " has " + linksCount.ToString() + " links.\n";
bool err = true;
for (int x = 0; x <= linksCount - 1; x++)
{
err = true;
linksActionTypes = linksActionTypes + " Link Nr." + x.ToString();
int linkId = gdpicturePDF.GetPageLinkAnnotationIdx(x);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int actionId = gdpicturePDF.GetAnnotationActionID(linkId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfActionType actionType = gdpicturePDF.GetActionType(actionId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
linksActionTypes = linksActionTypes + " is associated with this action: " + actionType.ToString() + "\n";
err = false;
}
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.PropertyNotFound)
{
linksActionTypes = linksActionTypes + " has no associated action.\n";
err = false;
}
}
}
if (err)
linksActionTypes = linksActionTypes + " has failed to find an action.\n";
}
}
}
else
{
linksActionTypes = linksActionTypes + " has failed to find links.\n";
}
}
else
{
linksActionTypes = linksActionTypes + " has failed to select.\n";
}
}
MessageBox.Show(linksActionTypes, caption);
}
else
{
MessageBox.Show("The file has failed to load pages.", caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Dim caption As String = "Example: GetActionType"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms_actions.pdf", False) = GdPictureStatus.OK Then
Dim FormsCount As Integer = gdpicturePDF.GetFormFieldsCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK OrElse FormsCount = 0 Then
MessageBox.Show("The GetFormFieldsCount() method has failed or " + vbCrLf + " this PDF document doesn't include any form fields.", caption)
Else
Dim FormsActionTypes As String = ""
For x As Integer = 0 To FormsCount - 1
FormsActionTypes = FormsActionTypes + "Form Field Nr." + (x + 1).ToString()
Dim FFId As Integer = gdpicturePDF.GetFormFieldId(x)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim FFType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(FFId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
FormsActionTypes = FormsActionTypes + " is " + FFType.ToString()
Dim ActionId As Integer = gdpicturePDF.GetFormFieldActionID(FFId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim ActionType As PdfActionType = gdpicturePDF.GetActionType(ActionId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
FormsActionTypes = FormsActionTypes + " and has associated action: " + ActionType.ToString() + vbCrLf
Else
FormsActionTypes = FormsActionTypes + ",but the GetActionType() method has failed with the status: " + status.ToString() + vbCrLf
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
FormsActionTypes = FormsActionTypes + " and has no associated action." + vbCrLf
Else
FormsActionTypes = FormsActionTypes + ",but the GetFormFieldActionID() method has failed with the status: " + status.ToString() + vbCrLf
End If
End If
Else
FormsActionTypes = FormsActionTypes + ": The GetFormFieldType() method has failed with the status: " + status.ToString() + vbCrLf
End If
Else
FormsActionTypes = FormsActionTypes + ": The GetFormFieldId() method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(FormsActionTypes, caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionType";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms_actions.pdf", false) == GdPictureStatus.OK)
{
int FormsCount = gdpicturePDF.GetFormFieldsCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK || FormsCount == 0)
{
MessageBox.Show("The GetFormFieldsCount() method has failed or \n this PDF document doesn't include any form fields.", caption);
}
else
{
string FormsActionTypes = "";
for (int x = 0; x <= FormsCount - 1; x++)
{
FormsActionTypes = FormsActionTypes + "Form Field Nr." + (x + 1).ToString();
int FFId = gdpicturePDF.GetFormFieldId(x);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
PdfFormFieldType FFType = gdpicturePDF.GetFormFieldType(FFId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
FormsActionTypes = FormsActionTypes + " is " + FFType.ToString();
int ActionId = gdpicturePDF.GetFormFieldActionID(FFId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
PdfActionType ActionType = gdpicturePDF.GetActionType(ActionId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
FormsActionTypes = FormsActionTypes + " and has associated action: " + ActionType.ToString() + "\n";
}
else
{
FormsActionTypes = FormsActionTypes + ",but the GetActionType() method has failed with the status: " + status.ToString() + "\n";
}
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
{
FormsActionTypes = FormsActionTypes + " and has no associated action.\n";
}
else
{
FormsActionTypes = FormsActionTypes + ",but the GetFormFieldActionID() method has failed with the status: " + status.ToString() + "\n";
}
}
}
else
{
FormsActionTypes = FormsActionTypes + ": The GetFormFieldType() method has failed with the status: " + status.ToString() + "\n";
}
}
else
{
FormsActionTypes = FormsActionTypes + ": The GetFormFieldId() method has failed with the status: " + status.ToString() + "\n";
}
}
MessageBox.Show(FormsActionTypes, caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the target (destination) of the specified URI action. A URI action causes a URI to be resolved. A uniform resource identifier (URI) is a string that
identifies (resolves to) a resource on the Internet - typically a file that is the destination of a hypertext link. URIs are described in RFC 2396 - Uniform Resource Identifier (URI).
A unique action identifier specifying a required action object. You can obtain this identifier
using these methods: , , , or .
Please ensure that the type of the action object specified by this identifier is exactly the PdfActionType.ActionTypeURI.
You can check the type of the required action object using the method as it is shown in the example below.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any. For example, if the action object specified by
the action identifier is not of the type PdfActionType.ActionTypeURI, the reason for the method's failure is GdPictureStatus.InvalidParameter.
A uniform resource identifier as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the target URI of a URI action associated with the form field in the PDF document.
Dim caption As String = "Example: GetActionURI"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms_actions.pdf", False) = GdPictureStatus.OK Then
Dim FormsCount As Integer = gdpicturePDF.GetFormFieldsCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK OrElse FormsCount = 0 Then
MessageBox.Show("The GetFormFieldsCount() method has failed or " + vbCrLf + " this PDF document doesn't include any form fields.", caption)
Else
Dim ActionsURI As String = ""
For x As Integer = 0 To FormsCount - 1
Dim FFId As Integer = gdpicturePDF.GetFormFieldId(x)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionId As Integer = gdpicturePDF.GetFormFieldActionID(FFId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionType As PdfActionType = gdpicturePDF.GetActionType(ActionId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If ActionType = PdfActionType.ActionTypeURI Then
Dim URI As String = gdpicturePDF.GetActionURI(ActionId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
ActionsURI = ActionsURI + "Form Field Nr." + (x + 1).ToString() + " has associated URI action with URI = " + URI + vbCrLf
Else
ActionsURI = ActionsURI + "Form Field Nr." + (x + 1).ToString() + " has associated URI action, but the GetActionURI() method has failed with the status: " + status.ToString() + vbCrLf
End If
End If
End If
End If
End If
Next
MessageBox.Show(ActionsURI, caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionURI";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms_actions.pdf", false) == GdPictureStatus.OK)
{
int FormsCount = gdpicturePDF.GetFormFieldsCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK || FormsCount == 0)
{
MessageBox.Show("The GetFormFieldsCount() method has failed or \n this PDF document doesn't include any form fields.", caption);
}
else
{
string ActionsURI = "";
for (int x = 0; x <= FormsCount - 1; x++)
{
int FFId = gdpicturePDF.GetFormFieldId(x);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int ActionId = gdpicturePDF.GetFormFieldActionID(FFId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfActionType ActionType = gdpicturePDF.GetActionType(ActionId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (ActionType == PdfActionType.ActionTypeURI)
{
string URI = gdpicturePDF.GetActionURI(ActionId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
ActionsURI = ActionsURI + "Form Field Nr." + (x + 1).ToString() + " has associated URI action with URI = " + URI + "\n";
}
else
{
ActionsURI = ActionsURI + "Form Field Nr." + (x + 1).ToString() + " has associated URI action, but the GetActionURI() method has failed with the status: " + status.ToString() + "\n";
}
}
}
}
}
}
MessageBox.Show(ActionsURI, caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the JavaScript script of the specified JavaScript action. A JavaScript action (introduced in PDF 1.3) causes a script to be compiled and executed
by the JavaScript interpreter. JavaScript implements objects, methods, and properties that enable you to manipulate PDF files, modify the appearance of PDF
files, etc. You can tie JavaScript code to a specific PDF document, a page or a field, and much more.
You can read more about the content and effects of JavaScript scripts in the JavaScript for Acrobat API Reference.
A unique action identifier specifying a required action object. You can obtain this identifier
using these methods: , , , or .
Please ensure that the type of the action object specified by this ActionID is exactly the PdfActionType.ActionTypeJavaScript. You can check the type of
the required action object using the method as it is shown in the example below.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any. For example, if the action object specified by
the action identifier is not of the type PdfActionType.ActionTypeJavaScript, the reason for the method's failure is GdPictureStatus.InvalidParameter.
A string containing the JavaScript script to be executed. The method can be subsequently used to determine if this method has been successful.
How to find out the used script of a JavaScript action associated with the form field in the PDF document.
Dim caption As String = "Example: GetActionJavaScript"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms_actions.pdf", False) = GdPictureStatus.OK Then
Dim FormsCount As Integer = gdpicturePDF.GetFormFieldsCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK OrElse FormsCount = 0 Then
MessageBox.Show("The GetFormFieldsCount() method has failed or " + vbCrLf + " this PDF document doesn't include any form fields.", caption)
Else
Dim ActionsJS As String = ""
For x As Integer = 0 To FormsCount - 1
Dim FFId As Integer = gdpicturePDF.GetFormFieldId(x)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionId As Integer = gdpicturePDF.GetFormFieldActionID(FFId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionType As PdfActionType = gdpicturePDF.GetActionType(ActionId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If ActionType = PdfActionType.ActionTypeJavaScript Then
Dim script As String = gdpicturePDF.GetActionJavaScript(ActionId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
ActionsJS = ActionsJS + "Form Field Nr." + (x + 1).ToString() + " has associated JavaScript action with this script:" + vbCrLf + script + vbCrLf
Else
ActionsJS = ActionsJS + "Form Field Nr." + (x + 1).ToString() + " has associated JavaScript action, but the GetActionJavaScript() method has failed with the status: " + status.ToString() + vbCrLf
End If
End If
End If
End If
End If
Next
MessageBox.Show(ActionsJS, caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionJavaScript";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms_actions.pdf", false) == GdPictureStatus.OK)
{
int FormsCount = gdpicturePDF.GetFormFieldsCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK || FormsCount == 0)
{
MessageBox.Show("The GetFormFieldsCount() method has failed or \n this PDF document doesn't include any form fields.", caption);
}
else
{
string ActionsJS = "";
for (int x = 0; x <= FormsCount - 1; x++)
{
int FFId = gdpicturePDF.GetFormFieldId(x);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int ActionId = gdpicturePDF.GetFormFieldActionID(FFId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfActionType ActionType = gdpicturePDF.GetActionType(ActionId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (ActionType == PdfActionType.ActionTypeJavaScript)
{
string script = gdpicturePDF.GetActionJavaScript(ActionId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
ActionsJS = ActionsJS + "Form Field Nr." + (x + 1).ToString() + " has associated JavaScript action with this script:\n" + script + "\n";
}
else
{
ActionsJS = ActionsJS + "Form Field Nr." + (x + 1).ToString() + " has associated JavaScript action, but the GetActionJavaScript() method has failed with the status: " + status.ToString() + "\n";
}
}
}
}
}
}
MessageBox.Show(ActionsJS, caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the action related information (the application name or the filename and its parameters) of a specified action of the type Launch. A launch
action launches an application or opens or prints a document.
A unique action identifier specifying a required action object. You can obtain this identifier
using these methods: , , , or .
Please ensure that the type of the action object specified by this identifier is exactly the PdfActionType.ActionTypeLaunch, otherwise the method will
fail. You can check the type of the required action object using the method as it is shown in the example below.
Output parameter. The file name of the application to be launched or the document to be opened or printed, in standard Windows pathname format.
Output parameter. The default directory (related to the FileName and the Operation parameters) in standard DOS syntax.
It is a Windows-specific parameter, so if it is not defined in the PDF document, the result is an empty string.
Output parameter. A parameter string to be passed to the application designated by the FileName parameter. It is a Windows-specific parameter,
so if it is not defined in the PDF document, the result is an empty string.
Output parameter. A member of the PdfActionLaunchOperation enumeration. It is a Windows-specific parameter, so if it is not defined in the PDF document, the
result is PdfActionLaunchOperation.ActionLaunchOperationUndefined.
Output parameter. Specifies whether to open the related document (see the FileName parameter) in a new window. If the returned value is false, the
specified document replaces the current document in the same window. This value is ignored if the specified document is not a PDF document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the returned value is GdPictureStatus.OK. We strongly recommend always checking this status first.
If the action object specified by the action identifier is not of the type PdfActionType.ActionTypeLaunch, the reason for the method's failure is GdPictureStatus.InvalidParameter.
How to find out the action related information of all actions of type Launch associated with the form fields in the PDF document.
Dim caption As String = "Example: GetActionLaunchDestination"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms_actions.pdf", False) = GdPictureStatus.OK Then
Dim FormsCount As Integer = gdpicturePDF.GetFormFieldsCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK OrElse FormsCount = 0 Then
MessageBox.Show("The GetFormFieldsCount() method has failed or " + vbCrLf + " this PDF document doesn't include any form fields.", caption)
Else
Dim ActionsL As String = ""
For x As Integer = 0 To FormsCount - 1
Dim FFId As Integer = gdpicturePDF.GetFormFieldId(x)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionId As Integer = gdpicturePDF.GetFormFieldActionID(FFId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionType As PdfActionType = gdpicturePDF.GetActionType(ActionId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If ActionType = PdfActionType.ActionTypeLaunch Then
ActionsL = ActionsL + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + vbCrLf
Dim File As String = "", DefDir As String = "", Params As String = ""
Dim LaunchOp As PdfActionLaunchOperation = PdfActionLaunchOperation.ActionLaunchOperationUndefined
Dim NewWindow As Boolean = False
status = gdpicturePDF.GetActionLaunchDestination(ActionId, File, DefDir, Params, LaunchOp, NewWindow)
If status = GdPictureStatus.OK Then
ActionsL = ActionsL + " File: " + File + " New window:" + NewWindow.ToString() + vbCrLf +
" (Win specific) Directory: " + DefDir + " Parameters: " + Params + " Operation: "
Select Case LaunchOp
Case PdfActionLaunchOperation.ActionLaunchOperationOpen
ActionsL = ActionsL + "open" + vbCrLf
Exit Select
Case PdfActionLaunchOperation.ActionLaunchOperationPrint
ActionsL = ActionsL + "print" + vbCrLf
Exit Select
Case PdfActionLaunchOperation.ActionLaunchOperationUndefined
'This value is optional - if the result is undefined, probably the value is not specified in the PDF document.
'The default value is open by the definition in the PDF Reference.
'You can add your own preferred notes here.
' ActionsL = ActionsL + "undefined - default: open\n"
Exit Select
Case Else
'The default value is open by definition in the PDF Reference.
'You can add your own preferred notes here.
' ActionsL = ActionsL + "undefined - default: open\n"
Exit Select
End Select
Else
ActionsL = ActionsL + " but the GetActionLaunchDestination() method has failed with the status: " + status.ToString() + vbCrLf
End If
Else
ActionsL = ActionsL + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action." + vbCrLf
End If
End If
End If
End If
Next
MessageBox.Show(ActionsL, caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionLaunchDestination";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms_actions.pdf", false) == GdPictureStatus.OK)
{
int FormsCount = gdpicturePDF.GetFormFieldsCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK || FormsCount == 0)
{
MessageBox.Show("The GetFormFieldsCount() method has failed or \n this PDF document doesn't include any form fields.", caption);
}
else
{
string ActionsL = "";
for (int x = 0; x <= FormsCount - 1; x++)
{
int FFId = gdpicturePDF.GetFormFieldId(x);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int ActionId = gdpicturePDF.GetFormFieldActionID(FFId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfActionType ActionType = gdpicturePDF.GetActionType(ActionId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (ActionType == PdfActionType.ActionTypeLaunch)
{
ActionsL = ActionsL + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + "\n";
string File = "", DefDir = "", Params = "";
PdfActionLaunchOperation LaunchOp = PdfActionLaunchOperation.ActionLaunchOperationUndefined;
bool NewWindow = false;
status = gdpicturePDF.GetActionLaunchDestination(ActionId, ref File, ref DefDir, ref Params, ref LaunchOp, ref NewWindow);
if (status == GdPictureStatus.OK)
{
ActionsL = ActionsL + " File: " + File + " New window:" + NewWindow.ToString() + "\n" +
" (Win specific) Directory: " + DefDir + " Parameters: " + Params + " Operation: ";
switch (LaunchOp)
{
case PdfActionLaunchOperation.ActionLaunchOperationOpen:
ActionsL = ActionsL + "open\n";
break;
case PdfActionLaunchOperation.ActionLaunchOperationPrint:
ActionsL = ActionsL + "print\n";
break;
case PdfActionLaunchOperation.ActionLaunchOperationUndefined:
//This value is optional - if the result is undefined, probably the value is not specified in the PDF document.
//The default value is open by the definition in the PDF Reference.
//You can add your own preferred notes here.
// ActionsL = ActionsL + "undefined - default: open\n";
break;
default:
//The default value is open by the definition in the PDF Reference.
//You can add your own preferred notes here.
// ActionsL = ActionsL + "undefined - default: open\n";
break;
}
}
else
{
ActionsL = ActionsL + " but the GetActionLaunchDestinatio() method has failed with the status: " + status.ToString() + "\n";
}
}
else
{
ActionsL = ActionsL + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action.\n";
}
}
}
}
}
MessageBox.Show(ActionsL, caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the information (a page number and a page view with the used coordinates) of the destination page of a specified action of the type GoTo, Named or
ExplicitDestination. These actions change the view of the currently loaded PDF document to a specified destination.
A unique action identifier specifying a required action object. You can obtain this identifier
using these methods: , , , , or .
Please ensure that the type of the action object specified by this identifier is one of the action types PdfActionType.ActionTypeGoTo,
PdfActionType.ActionTypeNamed or PdfActionType.ActionTypeExplicitDestination, otherwise the method will fail. You can check the type of the required action
object using the method as it is shown in the example below.
Output parameter. A member of the PdfDestinationType enumeration. Sets up a particular view of a destination page specified by the used action mentioned above.
Output parameter. The destination page number.
Output parameter. The horizontal (left) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Output parameter. The vertical (bottom) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate
is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Output parameter. The horizontal (right) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Output parameter. The vertical (top) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Output parameter. The zoom factor to use when displaying the destination page according to the DestinationType configuration.
The return value of 1 means 100% zoom, 2 means 200%, 0,5 for 50%, etc. The value of 0 means that the current zoom value should remain unchanged.
This method is only allowed for use with non-encrypted documents.
All values of the coordinates are expressed in the current units defined by the method according to the current coordinate space
defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
If the action object specified by the action identifier is not one of the correct action types mentioned above, the reason for the method's failure is GdPictureStatus.InvalidParameter.
How to find out the destinations of all actions of type GoTo, Named or ExplicitDestination associated with the form fields in the PDF document.
Dim caption As String = "Example: GetActionPageDestination"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms_actions.pdf", False) = GdPictureStatus.OK Then
Dim FormsCount As Integer = gdpicturePDF.GetFormFieldsCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK OrElse FormsCount = 0 Then
MessageBox.Show("The GetFormFieldsCount() method has failed or " + vbCrLf + " this PDF document doesn't include any form fields.", caption)
Else
Dim Actions As String = ""
For x As Integer = 0 To FormsCount - 1
Dim FFId As Integer = gdpicturePDF.GetFormFieldId(x)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionId As Integer = gdpicturePDF.GetFormFieldActionID(FFId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionType As PdfActionType = gdpicturePDF.GetActionType(ActionId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Select Case ActionType
Case PdfActionType.ActionTypeExplicitDestination, PdfActionType.ActionTypeGoTo, PdfActionType.ActionTypeNamed
'The GetActionPageDestination() method should only be used for these action types:
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + vbCrLf
Dim DestType As PdfDestinationType = PdfDestinationType.DestinationTypeUndefined
Dim Page As Integer = -1
Dim Left As Single = 0, Bottom As Single = 0, Right As Single = 0, Top As Single = 0, Zoom As Single = 0
status = gdpicturePDF.GetActionPageDestination(ActionId, DestType, Page, Left, Bottom, Right, Top, Zoom)
If status = GdPictureStatus.OK Then
Actions = Actions + " Destination: " + DestType.ToString() + ", Page Nr." + Page.ToString() +
", Coords = (" + Left.ToString() + "," + Bottom.ToString() + ");(" + Right.ToString() + "," + Top.ToString() + "), Zoom = " + Zoom.ToString() + vbCrLf
Else
Actions = Actions + " but the GetActionPageDestination() method has failed with the status: " + status.ToString() + vbCrLf
End If
Exit Select
Case Else
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action." + vbCrLf
Exit Select
End Select
End If
End If
End If
Next
MessageBox.Show(Actions, caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionPageDestination";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms_actions.pdf", false) == GdPictureStatus.OK)
{
int FormsCount = gdpicturePDF.GetFormFieldsCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK || FormsCount == 0)
{
MessageBox.Show("The GetFormFieldsCount() method has failed or \n this PDF document doesn't include any form fields.", caption);
}
else
{
string Actions = "";
for (int x = 0; x <= FormsCount - 1; x++)
{
int FFId = gdpicturePDF.GetFormFieldId(x);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int ActionId = gdpicturePDF.GetFormFieldActionID(FFId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfActionType ActionType = gdpicturePDF.GetActionType(ActionId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
switch (ActionType)
{
case PdfActionType.ActionTypeExplicitDestination:
case PdfActionType.ActionTypeGoTo:
case PdfActionType.ActionTypeNamed:
//The GetActionPageDestination() method should only be used for these action types:
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + "\n";
PdfDestinationType DestType = PdfDestinationType.DestinationTypeUndefined;
int Page = -1;
float Left = 0, Bottom = 0, Right = 0, Top = 0, Zoom = 0;
status = gdpicturePDF.GetActionPageDestination(ActionId, ref DestType, ref Page, ref Left, ref Bottom, ref Right, ref Top, ref Zoom);
if (status == GdPictureStatus.OK)
{
Actions = Actions + " Destination: " + DestType.ToString() + ", Page Nr." + Page.ToString() +
", Coords = (" + Left.ToString() + "," + Bottom.ToString() + ");(" + Right.ToString() + "," + Top.ToString() + "), Zoom = " + Zoom.ToString() + "\n";
}
else
{
Actions = Actions + " but the GetActionPageDestination() method has failed with the status: " + status.ToString() + "\n";
}
break;
default:
Actions = Actions + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action.\n";
break;
}
}
}
}
}
MessageBox.Show(Actions, caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the remote destination information (a file, a page number and a page view with the used coordinates) of the specified GoToR action. This action jumps
to a destination in another PDF file according to the defined destination parameters.
A unique action identifier specifying a required action object. You can obtain this identifier
using these methods: , , , or .
Please ensure that the type of the action object specified by this identifier is exactly the PdfActionType.ActionTypeGoToR, otherwise the method will fail.
You can check the type of the required action object using the method as it is shown in the example below.
Output parameter. A member of the PdfDestinationType enumeration. Sets up a particular view of a destination to jump specified by the this action.
Output parameter. The file path in which the destination is located.
Output parameter. Specifies whether to open the destination document in a new window. If the returned value is false, the destination document
replaces the current document in the same window.
Output parameter. The destination page number.
Output parameter. The horizontal (left) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Output parameter. The vertical (bottom) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate
is expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Output parameter. The horizontal (right) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Output parameter. The vertical (top) coordinate of the document window's position according to the used DestinationType mentioned above. The value of this coordinate is
expressed in the currently set units according to the currently used coordinate space, see the Remarks section below.
Output parameter. The zoom factor to use when displaying the destination page according to the DestinationType configuration.
The return value of 1 means 100% zoom, 2 means 200%, 0,5 for 50%, etc. The value of 0 means that the current zoom value should remain unchanged.
This method is only allowed for use with non-encrypted documents.
All values of the coordinates are expressed in the current units defined by the method according to the current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
If the action object specified by the action identifier is not of the type PdfActionType.ActionTypeGoToR, the reason for the method's failure is GdPictureStatus.InvalidParameter.
How to find out the destinations of all actions of type GoToR associated with the form fields in the PDF document.
Dim caption As String = "Example: GetActionRemotePageDestination"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms_actions.pdf", False) = GdPictureStatus.OK Then
Dim FormsCount As Integer = gdpicturePDF.GetFormFieldsCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK OrElse FormsCount = 0 Then
MessageBox.Show("The GetFormFieldsCount() method has failed or " + vbCrLf + " this PDF document doesn't include any form fields.", caption)
Else
Dim ActionsR As String = ""
For x As Integer = 0 To FormsCount - 1
Dim FFId As Integer = gdpicturePDF.GetFormFieldId(x)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionId As Integer = gdpicturePDF.GetFormFieldActionID(FFId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim ActionType As PdfActionType = gdpicturePDF.GetActionType(ActionId)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If ActionType = PdfActionType.ActionTypeGoToR Then
ActionsR = ActionsR + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + vbCrLf
Dim DestType As PdfDestinationType = PdfDestinationType.DestinationTypeUndefined
Dim File As String = ""
Dim NewWindow As Boolean = False
Dim Page As Integer = -1
Dim Left As Single = 0, Bottom As Single = 0, Right As Single = 0, Top As Single = 0, Zoom As Single = 0
status = gdpicturePDF.GetActionRemotePageDestination(ActionId, DestType, File, NewWindow, Page, Left,
Bottom, Right, Top, Zoom)
If status = GdPictureStatus.OK Then
ActionsR = ActionsR + " Destination: " + DestType.ToString() + " in file " + File + vbCrLf +
"New window:" + NewWindow.ToString() + ", Page Nr." + Page.ToString() +
", Coords = (" + Left.ToString() + "," + Bottom.ToString() + ");(" + Right.ToString() + "," + Top.ToString() + "), Zoom = " + Zoom.ToString() + vbCrLf
Else
ActionsR = ActionsR + " but the GetActionRemotePageDestination() method has failed with the status: " + status.ToString() + vbCrLf
End If
Else
ActionsR = ActionsR + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action." + vbCrLf
End If
End If
End If
End If
Next
MessageBox.Show(ActionsR, caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetActionRemotePageDestination";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms_actions.pdf", false) == GdPictureStatus.OK)
{
int FormsCount = gdpicturePDF.GetFormFieldsCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK || FormsCount == 0)
{
MessageBox.Show("The GetFormFieldsCount() method has failed or \n this PDF document doesn't include any form fields.", caption);
}
else
{
string ActionsR = "";
for (int x = 0; x <= FormsCount - 1; x++)
{
int FFId = gdpicturePDF.GetFormFieldId(x);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int ActionId = gdpicturePDF.GetFormFieldActionID(FFId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfActionType ActionType = gdpicturePDF.GetActionType(ActionId);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (ActionType == PdfActionType.ActionTypeGoToR)
{
ActionsR = ActionsR + "Form Field Nr." + (x + 1).ToString() + " has associated action of type: " + ActionType.ToString() + "\n";
PdfDestinationType DestType = PdfDestinationType.DestinationTypeUndefined;
string File = "";
bool NewWindow = false;
int Page = -1;
float Left = 0, Bottom = 0, Right = 0, Top = 0, Zoom = 0;
status = gdpicturePDF.GetActionRemotePageDestination(ActionId, ref DestType, ref File, ref NewWindow, ref Page, ref Left, ref Bottom, ref Right, ref Top, ref Zoom);
if (status == GdPictureStatus.OK)
{
ActionsR = ActionsR + " Destination: " + DestType.ToString() + " in file " + File +
"\nNew window:" + NewWindow.ToString() + ", Page Nr." + Page.ToString() +
", Coords = (" + Left.ToString() + "," + Bottom.ToString() + ");(" + Right.ToString() + "," + Top.ToString() + "), Zoom = " + Zoom.ToString() + "\n";
}
else
{
ActionsR = ActionsR + " but the GetActionRemotePageDestination() method has failed with the status: " + status.ToString() + "\n";
}
}
else
{
ActionsR = ActionsR + "Form Field Nr." + (x + 1).ToString() + " has associated another type of action.\n";
}
}
}
}
}
MessageBox.Show(ActionsR, caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Removes all JavaScript scripts from the specified objects, that are included in the currently loaded PDF document. You can identify all required objects using
the Options parameter according to your preference. Please refer to the method for more details.
A bitwise combination of values of the PdfRemoveJavaScriptOptions enumeration.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that if the currently loaded PDF document doesn't contain any JavaScript scripts, the returned value is GdPictureStatus.OK.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove all JavaScript scripts from the PDF document.
Dim caption As String = "Example: RemoveJavaScript"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("javascript.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.RemoveJavaScript(PdfRemoveJavaScriptOptions.RemoveAllJavaScript) = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("javascript_removed.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The RemoveJavaScript() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveJavaScript";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("javascript.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.RemoveJavaScript(PdfRemoveJavaScriptOptions.RemoveAllJavaScript) == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("javascript_removed.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The RemoveJavaScript() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
gdpicturePDF.Dispose();
Removes all bookmark items (whole bookmark's hierarchy) from the currently loaded PDF document. The bookmark's section (known as "Outlines" entry) is also
removed from the document's catalog.
This method is only allowed for use with non-encrypted documents.
The value of GdPictureStatus.OK is returned if the PDF document doesn't contain any bookmarks.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove all bookmarks from the PDF document.
Dim caption As String = "Example: RemoveBookmarks"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("bookmarks.pdf", False) = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.RemoveBookmarks()
MessageBox.Show("The example has been followed with the status: " + status.ToString(), caption)
If gdpicturePDF.SaveToFile("bookmarks_removed.pdf") <> GdPictureStatus.OK Then
MessageBox.Show("The file can't be saved.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveBookmarks";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("bookmarks.pdf", false) == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.RemoveBookmarks();
MessageBox.Show("The example has been followed with the status: " + status.ToString(), caption);
if (gdpicturePDF.SaveToFile("bookmarks_removed.pdf") != GdPictureStatus.OK)
MessageBox.Show("The file can't be saved.", caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Removes a specified bookmark item (with all its descendants) from a bookmark's hierarchy of the currently loaded PDF document.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove all bookmark items located on the same level as is the root bookmark except the root bookmark itself.
Dim caption As String = "Example: RemoveBookmark"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim count As Integer = 0
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim bookmarkID As Integer = 0
Dim status1 As GdPictureStatus = GdPictureStatus.OK
Do
bookmarkID = gdpicturePDF.GetBookmarkNextID(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status1 = gdpicturePDF.RemoveBookmark(bookmarkID)
If status1 <> GdPictureStatus.OK Then
MessageBox.Show("The RemoveBookmark() method has failed with the status: " + status1.ToString(), caption)
Else
count += 1
End If
End If
Loop While (status = GdPictureStatus.OK) AndAlso (status1 = GdPictureStatus.OK)
If status1 = GdPictureStatus.OK Then
If status = GdPictureStatus.PropertyNotFound Then
status = gdpicturePDF.SaveToFile("bookmarks_RemoveLevel.pdf", False)
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully." + vbCrLf + "The number of deleted bookmark items is: " + count.ToString(), caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveBookmark";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int count = 0;
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int bookmarkID = 0;
GdPictureStatus status1 = GdPictureStatus.OK;
do
{
bookmarkID = gdpicturePDF.GetBookmarkNextID(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status1 = gdpicturePDF.RemoveBookmark(bookmarkID);
if (status1 != GdPictureStatus.OK)
MessageBox.Show("The RemoveBookmark() method has failed with the status: " + status1.ToString(), caption);
else
count++;
}
}
while ((status == GdPictureStatus.OK) && (status1 == GdPictureStatus.OK));
if (status1 == GdPictureStatus.OK)
{
if (status == GdPictureStatus.PropertyNotFound)
{
status = gdpicturePDF.SaveToFile("bookmarks_RemoveLevel.pdf", false);
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully.\nThe number of deleted bookmark items is: " + count.ToString(), caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Returns the number of all available bookmark items in the currently loaded PDF document.
Bookmarks (also called outline items in the PDF Reference) are items organized in a tree-structured hierarchy, which serves as a visual
table of contents to display the document’s structure to the user.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of all bookmarks. The method can be subsequently used to determine if this method has been successful.
How to find out the number of all available bookmark items in the PDF document.
Dim caption As String = "Example: GetBookmarkCount"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim bookmarksCount As Integer = gdpicturePDF.GetBookmarkCount()
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The GetBookmarkCount() method has failed with the status: " + status.ToString(), caption)
Else
If bookmarksCount = 0 Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The number of bookmarks in this PDF document is: " + bookmarksCount.ToString(), caption)
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int bookmarksCount = gdpicturePDF.GetBookmarkCount();
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
MessageBox.Show("The GetBookmarkCount() method has failed with the status: " + status.ToString(), caption);
else
{
if (bookmarksCount == 0)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
{
MessageBox.Show("The number of bookmarks in this PDF document is: " + bookmarksCount.ToString(), caption);
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Returns a unique identifier of the root bookmark in the currently loaded PDF document.
Bookmarks (also called outline items in the PDF Reference) are items organized in a tree-structured hierarchy, which serves as a visual
table of contents to display the document’s structure to the user. A root bookmark is the first top-level bookmark item in this hierarchy.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any. For example, if the PDF document doesn't contain
any bookmarks, the method returns GdPictureStatus.PropertyNotFound, as it is shown in the example below.
A unique bookmark identifier of the root bookmark. The method can be subsequently used to determine if this method has been successful.
How to obtain an identifier of the root bookmark. The title of this bookmark item is subsequently displayed in the dialog box.
Dim caption As String = "Example: GetBookmarkRootID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), caption)
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkRootID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), caption);
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Dim caption As String = "Example: GetBookmarkRootID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim bookmarksCount As Integer = gdpicturePDF.GetBookmarkCount()
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The GetBookmarkCount() method has failed with the status: " + status.ToString(), caption)
Else
If bookmarksCount = 0 Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The number of bookmarks in this PDF document is: " + bookmarksCount.ToString(), caption)
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkRootID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int bookmarksCount = gdpicturePDF.GetBookmarkCount();
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
MessageBox.Show("The GetBookmarkCount() method has failed with the status: " + status.ToString(), caption);
else
{
if (bookmarksCount == 0)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
{
MessageBox.Show("The number of bookmarks in this PDF document is: " + bookmarksCount.ToString(), caption);
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Returns the number of child bookmark items (all descendants on lower level only) contained within a specified bookmark item in the bookmark's hierarchy of the currently loaded PDF document.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of all child bookmark items contained within the specified bookmark in the bookmark's hierarchy.
The method can be subsequently used to determine if this method has been successful.
This example shows you titles of all bookmark entries in the PDF document organized by the top level (denoted as level 0).
'The main entry point.
Dim caption As String = "Example: GetBookmarkChildCount"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
'Please see the sub-method below.
ParseOutlines(gdpicturePDF, rootID, 0, message)
MessageBox.Show("The example has been followed successfully.", caption)
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
'The sub-method.
Private Sub ParseOutlines(gdpicturePDF As GdPicturePDF, bookmarkID As Integer, level As Integer, ByRef message As String)
Dim title As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
While True
title = gdpicturePDF.GetBookmarkTitle(bookmarkID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "Title: """ + title + """ Level: " + level.ToString() + vbCrLf
Else
message = message + "Title: this error occurs - " + status.ToString() + " Level: " + level.ToString() + vbCrLf
End If
'Checking the children.
Dim childCount As Integer = gdpicturePDF.GetBookmarkChildCount(bookmarkID)
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
message = message + "This error occurs in GetBookmarkChildCount(): status = " + status.ToString() + vbCrLf
End If
If childCount > 0 Then
Dim childID As Integer = gdpicturePDF.GetBookmarkFirstChildID(bookmarkID)
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
message = message + "This error occurs in GetBookmarkFirstChildID(): status = " + status.ToString() + vbCrLf
Else
ParseOutlines(gdpicturePDF, childID, level + 1, message)
End If
End If
'Checking for subsequent bookmarks if the current bookmark has no children.
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID)
status = gdpicturePDF.GetStat()
If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
message = message + "This error occurs in GetBookmarkNextID(): status = " + status.ToString() + vbCrLf
End If
If level = 0 Then
MessageBox.Show(message, "Example: GetBookmarkChildCount")
message = ""
End If
If bookmarkID = 0 Then
Exit While
End If
End While
Return
End Sub
//The main entry point.
string caption = "Example: GetBookmarkChildCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
//Pleae see the sub-method below.
ParseOutlines(gdpicturePDF, rootID, 0, ref message);
MessageBox.Show("The example has been followed successfully.", caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
//The sub-method.
void ParseOutlines(GdPicturePDF gdpicturePDF, int bookmarkID, int level, ref string message)
{
string title = "";
GdPictureStatus status = GdPictureStatus.OK;
while (true)
{
title = gdpicturePDF.GetBookmarkTitle(bookmarkID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + "Title: \"" + title + "\" Level: " + level.ToString() + "\n";
else
message = message + "Title: this error occurs - " + status.ToString() + " Level: " + level.ToString() + "\n";
//Checking children.
int childCount = gdpicturePDF.GetBookmarkChildCount(bookmarkID);
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
message = message + "This error occurs in GetBookmarkChildCount(): status = " + status.ToString() + "\n";
if (childCount > 0)
{
int childID = gdpicturePDF.GetBookmarkFirstChildID(bookmarkID);
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
message = message + "This error occurs in GetBookmarkFirstChildID(): status = " + status.ToString() + "\n";
else
{
ParseOutlines(gdpicturePDF, childID, level + 1, ref message);
}
}
//Checking for subsequent bookmarks if the current bookmark has no children.
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID);
status = gdpicturePDF.GetStat();
if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
message = message + "This error occurs in GetBookmarkNextID(): status = " + status.ToString() + "\n";
if (level == 0)
{
MessageBox.Show(message, "Example: GetBookmarkChildCount");
message = "";
}
if (bookmarkID == 0)
break;
}
return;
}
Returns a unique identifier of the first child bookmark item (the first descendant on lower level) contained within a specified bookmark item in the
bookmark's hierarchy of the currently loaded PDF document.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any. For example, if the specified bookmark item
doesn't contain any child (descendant) bookmark items, the value of GdPictureStatus.InvalidParameter is returned.
You can also use the method to determine if the specified bookmark item contains child (descendant) bookmark items.
A unique bookmark identifier of the first child bookmark item (first descendant in lower level). The method can be subsequently used to determine if this method has been successful.
How to find out the bookmark identifier of the first child bookmark item (lower level descendant) of the root bookmark, if it exists.
Dim caption As String = "Example: GetBookmarkFirstChildID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim childCount As Integer = gdpicturePDF.GetBookmarkChildCount(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If childCount > 0 Then
Dim childID As Integer = gdpicturePDF.GetBookmarkFirstChildID(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim parentID As Integer = gdpicturePDF.GetBookmarkParentID(childID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF contains bookmarks." + vbCrLf + "Root ID: " + rootID.ToString() + " Root's first child ID: " + childID.ToString() + " Child's parent ID: " + parentID.ToString())
Else
MessageBox.Show("The GetBookmarkParentID() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetBookmarkFirstChildID() method has failed with the status: " + status.ToString(), caption)
End If
Else
If childCount = 0 Then
MessageBox.Show("The root bookmark with ID = " + rootID.ToString() + " doesn't contain any child bookmarks.", caption)
End If
End If
Else
MessageBox.Show("The GetBookmarkChildCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkFirstChildID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int childCount = gdpicturePDF.GetBookmarkChildCount(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (childCount > 0)
{
int childID = gdpicturePDF.GetBookmarkFirstChildID(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int parentID = gdpicturePDF.GetBookmarkParentID(childID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("This PDF contains bookmarks.\nRoot ID: " + rootID.ToString() + " Root's first child ID: " + childID.ToString() + " Child's parent ID: " + parentID.ToString());
else
MessageBox.Show("The GetBookmarkParentID() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The GetBookmarkFirstChildID() method has failed with the status: " + status.ToString(), caption);
}
else
{
if (childCount == 0)
MessageBox.Show("The root bookmark with ID = " + rootID.ToString() + " doesn't contain any child bookmarks.", caption);
}
}
else
MessageBox.Show("The GetBookmarkChildCount() method has failed with the status: " + status.ToString(), caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Returns a unique identifier of the next bookmark item located on the same level as a specified bookmark item in the bookmark's hierarchy of the currently loaded PDF document.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any. For example, if the specified bookmark item has
no other next bookmark items available on the same level in the hierarchy, the value of GdPictureStatus.PropertyNotFound is returned.
A unique bookmark identifier of the next bookmark item located on the same level as the specified bookmark item.
The method can be subsequently used to determine if this method has been successful.
Both examples shows you how to find out the next (sibling) bookmark item of a specified bookmark.
Dim caption As String = "Example: GetBookmarkNextID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim siblingID As Integer = gdpicturePDF.GetBookmarkNextID(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim titles1 As String = gdpicturePDF.GetBookmarkTitle(rootID) + vbCrLf
Dim prevID As Integer = 0
While (status = GdPictureStatus.OK) AndAlso (siblingID > 0)
titles1 = titles1 + gdpicturePDF.GetBookmarkTitle(siblingID) + vbCrLf
prevID = siblingID
siblingID = gdpicturePDF.GetBookmarkNextID(siblingID)
status = gdpicturePDF.GetStat()
End While
If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption)
End If
Dim titles2 As String = ""
siblingID = prevID
If status = GdPictureStatus.PropertyNotFound Then
'No other bookmark is available on the same level as the root bookmark.
status = GdPictureStatus.OK
End If
While (status = GdPictureStatus.OK) AndAlso (siblingID > 0)
titles2 = titles2 + gdpicturePDF.GetBookmarkTitle(siblingID) + vbCrLf
siblingID = gdpicturePDF.GetBookmarkPrevID(siblingID)
status = gdpicturePDF.GetStat()
End While
If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
MessageBox.Show("The GetBookmarkPrevID() method has failed with the status: " + status.ToString(), caption)
End If
If (status = GdPictureStatus.OK) OrElse (status = GdPictureStatus.PropertyNotFound) Then
MessageBox.Show("From top to bottom:" + vbCrLf + titles1 + vbCrLf + "From bottom to top:" + vbCrLf + titles2 + vbCrLf + "The example has been successfully followed.", caption)
Else
MessageBox.Show("The example has NOT been successfully followed. Status: " + status.ToString())
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("The root bookmark doesn't contain any sibling bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkNextID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int siblingID = gdpicturePDF.GetBookmarkNextID(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string titles1 = gdpicturePDF.GetBookmarkTitle(rootID) + "\n";
int prevID = 0;
while ((status == GdPictureStatus.OK) && (siblingID > 0))
{
titles1 = titles1 + gdpicturePDF.GetBookmarkTitle(siblingID) + "\n";
prevID = siblingID;
siblingID = gdpicturePDF.GetBookmarkNextID(siblingID);
status = gdpicturePDF.GetStat();
}
if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption);
string titles2 = "";
siblingID = prevID;
//No other bookmark is available on the same level as the root bookmark.
if (status == GdPictureStatus.PropertyNotFound)
status = GdPictureStatus.OK;
while ((status == GdPictureStatus.OK) && (siblingID > 0))
{
titles2 = titles2 + gdpicturePDF.GetBookmarkTitle(siblingID) + "\n";
siblingID = gdpicturePDF.GetBookmarkPrevID(siblingID);
status = gdpicturePDF.GetStat();
}
if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
MessageBox.Show("The GetBookmarkPrevID() method has failed with the status: " + status.ToString(), caption);
if ((status == GdPictureStatus.OK) || (status == GdPictureStatus.PropertyNotFound))
MessageBox.Show("From top to bottom:\n" + titles1 + "\n" + "From bottom to top:\n" + titles2 + "\nThe example has been successfully followed.", caption);
else
MessageBox.Show("The example has NOT been successfully followed. Status: " + status.ToString());
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("The root bookmark doesn't contain any sibling bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
'The main entry point.
Dim caption As String = "Example: GetBookmarkNextID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
'Please see the sub-method below.
ParseOutlines(gdpicturePDF, rootID, 0, message)
MessageBox.Show("The example has been followed successfully.", caption)
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
'The sub-method.
Private Sub ParseOutlines(gdpicturePDF As GdPicturePDF, bookmarkID As Integer, level As Integer, ByRef message As String)
Dim title As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
While True
title = gdpicturePDF.GetBookmarkTitle(bookmarkID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "Title: """ + title + """ Level: " + level.ToString() + vbCrLf
Else
message = message + "Title: this error occurs - " + status.ToString() + " Level: " + level.ToString() + vbCrLf
End If
'Checking children.
Dim childCount As Integer = gdpicturePDF.GetBookmarkChildCount(bookmarkID)
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
message = message + "This error occurs in GetBookmarkChildCount(): status = " + status.ToString() + vbCrLf
End If
If childCount > 0 Then
Dim childID As Integer = gdpicturePDF.GetBookmarkFirstChildID(bookmarkID)
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
message = message + "This error occurs in GetBookmarkFirstChildID(): status = " + status.ToString() + vbCrLf
Else
ParseOutlines(gdpicturePDF, childID, level + 1, message)
End If
End If
'Checking for subsequent bookmarks if the current bookmark has no children.
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID)
status = gdpicturePDF.GetStat()
If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
message = message + "This error occurs in GetBookmarkNextID(): status = " + status.ToString() + vbCrLf
End If
If level = 0 Then
MessageBox.Show(message, "Example: GetBookmarkNextID")
message = ""
End If
If bookmarkID = 0 Then
Exit While
End If
End While
Return
End Sub
//The main entry point.
string caption = "Example: GetBookmarkNextID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
//Please see the sub-method below.
ParseOutlines(gdpicturePDF, rootID, 0, ref message);
MessageBox.Show("The example has been followed successfully.", caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
//The sub-method.
void ParseOutlines(GdPicturePDF gdpicturePDF, int bookmarkID, int level, ref string message)
{
string title = "";
GdPictureStatus status = GdPictureStatus.OK;
while (true)
{
title = gdpicturePDF.GetBookmarkTitle(bookmarkID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + "Title: \"" + title + "\" Level: " + level.ToString() + "\n";
else
message = message + "Title: this error occurs - " + status.ToString() + " Level: " + level.ToString() + "\n";
//Checking children.
int childCount = gdpicturePDF.GetBookmarkChildCount(bookmarkID);
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
message = message + "This error occurs in GetBookmarkChildCount(): status = " + status.ToString() + "\n";
if (childCount > 0)
{
int childID = gdpicturePDF.GetBookmarkFirstChildID(bookmarkID);
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
message = message + "This error occurs in GetBookmarkFirstChildID(): status = " + status.ToString() + "\n";
else
{
ParseOutlines(gdpicturePDF, childID, level + 1, ref message);
}
}
//Checking for subsequent bookmarks if the current bookmark has no children.
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID);
status = gdpicturePDF.GetStat();
if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
message = message + "This error occurs in GetBookmarkNextID(): status = " + status.ToString() + "\n";
if (level == 0)
{
MessageBox.Show(message, "Example: GetBookmarkNextID");
message = "";
}
if (bookmarkID == 0)
break;
}
return;
}
Returns a unique identifier of the previous bookmark item located on the same level as a specified bookmark item in the bookmark's hierarchy of the currently loaded PDF document.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any. For example, if the specified bookmark item has
no other next bookmark items available on the same level in the hierarchy, the value of GdPictureStatus.PropertyNotFound is returned.
A unique bookmark identifier of the previous bookmark item located on the same level as the specified bookmark item. The method can be subsequently used to determine if this method has been successful.
This example shows you all bookmark items (displaying their titles), which are located on the same level as the root bookmark.
The methods GetBookmarkNextID() and GetBookmarkPrevID() are used to obtain bookmark IDs to display the titles of these bookmarks in the order from top to bottom and vice versa.
Dim caption As String = "Example: GetBookmarkPrevID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim siblingID As Integer = gdpicturePDF.GetBookmarkNextID(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim titles1 As String = gdpicturePDF.GetBookmarkTitle(rootID) + vbCrLf
Dim prevID As Integer = 0
While (status = GdPictureStatus.OK) AndAlso (siblingID > 0)
titles1 = titles1 + gdpicturePDF.GetBookmarkTitle(siblingID) + vbCrLf
prevID = siblingID
siblingID = gdpicturePDF.GetBookmarkNextID(siblingID)
status = gdpicturePDF.GetStat()
End While
If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption)
End If
Dim titles2 As String = ""
siblingID = prevID
If status = GdPictureStatus.PropertyNotFound Then
'No other bookmark is available on the same level as the root bookmark.
status = GdPictureStatus.OK
End If
While (status = GdPictureStatus.OK) AndAlso (siblingID > 0)
titles2 = titles2 + gdpicturePDF.GetBookmarkTitle(siblingID) + vbCrLf
siblingID = gdpicturePDF.GetBookmarkPrevID(siblingID)
status = gdpicturePDF.GetStat()
End While
If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
MessageBox.Show("The GetBookmarkPrevID() method has failed with the status: " + status.ToString(), caption)
End If
If (status = GdPictureStatus.OK) OrElse (status = GdPictureStatus.PropertyNotFound) Then
MessageBox.Show("From top to bottom:" + vbCrLf + titles1 + vbCrLf + "From bottom to top:" + vbCrLf + titles2 + vbCrLf + "The example has been successfully followed.", caption)
Else
MessageBox.Show("The example has NOT been successfully followed. Status: " + status.ToString())
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("The root bookmark doesn't contain any sibling bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkPrevID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int siblingID = gdpicturePDF.GetBookmarkNextID(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string titles1 = gdpicturePDF.GetBookmarkTitle(rootID) + "\n";
int prevID = 0;
while ((status == GdPictureStatus.OK) && (siblingID > 0))
{
titles1 = titles1 + gdpicturePDF.GetBookmarkTitle(siblingID) + "\n";
prevID = siblingID;
siblingID = gdpicturePDF.GetBookmarkNextID(siblingID);
status = gdpicturePDF.GetStat();
}
if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption);
string titles2 = "";
siblingID = prevID;
//No other bookmark is available on the same level as the root bookmark.
if (status == GdPictureStatus.PropertyNotFound)
status = GdPictureStatus.OK;
while ((status == GdPictureStatus.OK) && (siblingID > 0))
{
titles2 = titles2 + gdpicturePDF.GetBookmarkTitle(siblingID) + "\n";
siblingID = gdpicturePDF.GetBookmarkPrevID(siblingID);
status = gdpicturePDF.GetStat();
}
if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
MessageBox.Show("The GetBookmarkPrevID() method has failed with the status: " + status.ToString(), caption);
if ((status == GdPictureStatus.OK) || (status == GdPictureStatus.PropertyNotFound))
MessageBox.Show("From top to bottom:\n" + titles1 + "\n" + "From bottom to top:\n" + titles2 + "\nThe example has been successfully followed.", caption);
else
MessageBox.Show("The example has NOT been successfully followed. Status: " + status.ToString());
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("The root bookmark doesn't contain any sibling bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Returns a unique identifier of the parent bookmark item for the specified bookmark in the bookmark's hierarchy of the currently loaded PDF document.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any. For example, if the specified bookmark item has
no parent bookmark item, the value of GdPictureStatus.InvalidParameter is returned.
A unique bookmark identifier of the parent bookmark item for the specified bookmark. The method can be subsequently used to determine if this method has been successful.
How to find out the parent bookmark identifier of the specified bookmark item.
Dim caption As String = "Example: GetBookmarkParentID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim childCount As Integer = gdpicturePDF.GetBookmarkChildCount(rootID)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (childCount > 0) Then
Dim childID As Integer = gdpicturePDF.GetBookmarkFirstChildID(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim parentID As Integer = gdpicturePDF.GetBookmarkParentID(childID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF contains bookmarks." + vbCrLf + "Root ID: " + rootID.ToString() + " Root's first child ID: " + childID.ToString() + " Child's parent ID: " + parentID.ToString())
Else
MessageBox.Show("The GetBookmarkParentID() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetBookmarkFirstChildID() method has failed with the status: " + status.ToString(), caption)
End If
Else
If (status = GdPictureStatus.OK) AndAlso (childCount = 0) Then
MessageBox.Show("The root bookmark with ID = " + rootID.ToString() + " doesn't contain any child bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkChildCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkParentID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int childCount = gdpicturePDF.GetBookmarkChildCount(rootID);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (childCount > 0))
{
int childID = gdpicturePDF.GetBookmarkFirstChildID(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int parentID = gdpicturePDF.GetBookmarkParentID(childID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("This PDF contains bookmarks.\nRoot ID: " + rootID.ToString() + " Root's first child ID: " + childID.ToString() + " Child's parent ID: " + parentID.ToString());
else
MessageBox.Show("The GetBookmarkParentID() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The GetBookmarkFirstChildID() method has failed with the status: " + status.ToString(), caption);
}
else
{
if ((status == GdPictureStatus.OK) && (childCount == 0))
MessageBox.Show("The root bookmark with ID = " + rootID.ToString() + " doesn't contain any child bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkChildCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Returns the title of a bookmark item specified by its unique identifier.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The title of a specified bookmark item. The method can be subsequently used to determine if this method has been successful.
How to find out the title of the specified bookmark item. The title is subsequently displayed in the dialog box.
Dim caption As String = "Example: GetBookmarkTitle"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim title As String = gdpicturePDF.GetBookmarkTitle(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The title of the root bookmark is: " + title, caption)
Else
MessageBox.Show("The GetBookmarkTitle() method has failed with the status: " + status.ToString(), caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string title = gdpicturePDF.GetBookmarkTitle(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The title of the root bookmark is: " + title, caption);
else
MessageBox.Show("The GetBookmarkTitle() method has failed with the status: " + status.ToString(), caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
'The main entry point.
Dim caption As String = "Example: GetBookmarkTitle"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
'Please see the sub-method below.
ParseOutlines(gdpicturePDF, rootID, 0, message)
MessageBox.Show("The example has been followed successfully.", caption)
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
'The sub-method.
Private Sub ParseOutlines(gdpicturePDF As GdPicturePDF, bookmarkID As Integer, level As Integer, ByRef message As String)
Dim title As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
While True
title = gdpicturePDF.GetBookmarkTitle(bookmarkID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "Title: """ + title + """ Level: " + level.ToString() + vbCrLf
Else
message = message + "Title: this error occurs - " + status.ToString() + " Level: " + level.ToString() + vbCrLf
End If
'Checking children.
Dim childCount As Integer = gdpicturePDF.GetBookmarkChildCount(bookmarkID)
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
message = message + "This error occurs in GetBookmarkChildCount(): status = " + status.ToString() + vbCrLf
End If
If childCount > 0 Then
Dim childID As Integer = gdpicturePDF.GetBookmarkFirstChildID(bookmarkID)
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
message = message + "This error occurs in GetBookmarkFirstChildID(): status = " + status.ToString() + vbCrLf
Else
ParseOutlines(gdpicturePDF, childID, level + 1, message)
End If
End If
'Checking for subsequent bookmarks if the current bookmark has no children.
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID)
status = gdpicturePDF.GetStat()
If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
message = message + "This error occurs in GetBookmarkNextID(): status = " + status.ToString() + vbCrLf
End If
If level = 0 Then
MessageBox.Show(message, "Example: GetBookmarkTitle")
message = ""
End If
If bookmarkID = 0 Then
Exit While
End If
End While
Return
End Sub
//The main entry point.
string caption = "Example: GetBookmarkTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
//Please see the sub-method below.
ParseOutlines(gdpicturePDF, rootID, 0, ref message);
MessageBox.Show("The example has been followed successfully.", caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
//The sub-method.
void ParseOutlines(GdPicturePDF gdpicturePDF, int bookmarkID, int level, ref string message)
{
string title = "";
GdPictureStatus status = GdPictureStatus.OK;
while (true)
{
title = gdpicturePDF.GetBookmarkTitle(bookmarkID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + "Title: \"" + title + "\" Level: " + level.ToString() + "\n";
else
message = message + "Title: this error occurs - " + status.ToString() + " Level: " + level.ToString() + "\n";
//Checking children.
int childCount = gdpicturePDF.GetBookmarkChildCount(bookmarkID);
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
message = message + "This error occurs in GetBookmarkChildCount(): status = " + status.ToString() + "\n";
if (childCount > 0)
{
int childID = gdpicturePDF.GetBookmarkFirstChildID(bookmarkID);
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
message = message + "This error occurs in GetBookmarkFirstChildID(): status = " + status.ToString() + "\n";
else
{
ParseOutlines(gdpicturePDF, childID, level + 1, ref message);
}
}
//Checking for subsequent bookmarks if the current bookmark has no children.
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID);
status = gdpicturePDF.GetStat();
if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
message = message + "This error occurs in GetBookmarkNextID(): status = " + status.ToString() + "\n";
if (level == 0)
{
MessageBox.Show(message, "Example: GetBookmarkTitle");
message = "";
}
if (bookmarkID == 0)
break;
}
return;
}
Moves a specified bookmark item up one item within the current level in the bookmark's hierarchy.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to move a bookmark item located just after the root bookmark item (on the same level) before it (up one bookmark item).
Dim caption As String = "Example: MoveBookmarkUp"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim bookmarkID As Integer = gdpicturePDF.GetBookmarkNextID(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.MoveBookmarkUp(bookmarkID)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("bookmarks_MoveUp.pdf", False)
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The MoveBookmarkUp() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The root bookmark has no next bookmark ready to move up or an error occurs.", caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: MoveBookmarkUp";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int bookmarkID = gdpicturePDF.GetBookmarkNextID(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.MoveBookmarkUp(bookmarkID);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("bookmarks_MoveUp.pdf", false);
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The MoveBookmarkUp() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The root bookmark has no next bookmark ready to move up or an error occurs.", caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Moves a specified bookmark item down one item within the current level in the bookmark's hierarchy.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to move the root bookmark item one item down on the same level. The root bookmark will "change" its position with its nearest sibling item.
Dim caption As String = "Example: MoveBookmarkDown"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.MoveBookmarkDown(rootID)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("bookmarks_MoveDown.pdf", False)
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The MoveBookmarkDown() method has failed with the status: " + status.ToString(), caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: MoveBookmarkDown";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.MoveBookmarkDown(rootID);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("bookmarks_MoveDown.pdf", false);
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The MoveBookmarkDown() method has failed with the status: " + status.ToString(), caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Moves one specified bookmark item just before or just after another specified (destination) bookmark item within the level of the destination bookmark in the bookmark's hierarchy.
A unique bookmark identifier specifying a required bookmark object, which you want to move.
You can obtain this identifier using these methods: , , , , or .
A unique bookmark identifier specifying a destination bookmark object.
You can obtain this identifier using these methods: , , , , or .
Specifies the positioning of the moved bookmark item considering the destination bookmark item.
Set this parameter to true if you want to move the required bookmark item just before the destination bookmark item.
Set this parameter to false if you want to move the required bookmark item just after the destination bookmark item.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to move the last bookmark item, located on the same level as the root bookmark item is, just after the root bookmark.
Dim caption As String = "Example: MoveBookmark"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim bookmarkID As Integer = 0, lastBookmarkID As Integer = rootID
Do
bookmarkID = gdpicturePDF.GetBookmarkNextID(lastBookmarkID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
lastBookmarkID = bookmarkID
ElseIf status <> GdPictureStatus.PropertyNotFound Then
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption)
End If
Loop While status = GdPictureStatus.OK
If lastBookmarkID = rootID Then
MessageBox.Show("The root bookmark can't move within its level - it has no next bookmarks.", caption)
Else
If (status = GdPictureStatus.PropertyNotFound) Then
'The GetBookmarkNextID() method returns this status when no other bookmark is available.
status = gdpicturePDF.MoveBookmark(lastBookmarkID, rootID, False)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("bookmarks_Move.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
Else
MessageBox.Show("The MoveBookmark() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: MoveBookmark";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int bookmarkID = 0, lastBookmarkID = rootID;
do
{
bookmarkID = gdpicturePDF.GetBookmarkNextID(lastBookmarkID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
lastBookmarkID = bookmarkID;
else
if (status != GdPictureStatus.PropertyNotFound)
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption);
}
while (status == GdPictureStatus.OK);
if (lastBookmarkID == rootID)
MessageBox.Show("The root bookmark can't move within its level - it has no next bookmarks.", caption);
else
{
//The GetBookmarkNextID() method returns this status when no other bookmark is available.
if (status == GdPictureStatus.PropertyNotFound)
{
status = gdpicturePDF.MoveBookmark(lastBookmarkID, rootID, false);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("bookmarks_Move.pdf", false) == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully.", caption);
else
MessageBox.Show("The file can't be saved.", caption);
}
else
{
MessageBox.Show("The MoveBookmark() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Sets the title of a bookmark item specified by its unique identifier.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
The new title to be used for a specified bookmark item.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the title of the root bookmark in the PDF document.
Dim caption As String = "Example: SetBookmarkTitle"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetBookmarkTitle(rootID, "GdPicturePDF")
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("bookmarks_SetTitle.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SetBookmarkTitle() method has failed with the status: " + status.ToString(), caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetBookmarkTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetBookmarkTitle(rootID, "GdPicturePDF");
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("bookmarks_SetTitle.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The SetBookmarkTitle() method has failed with the status: " + status.ToString(), caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Returns the style characteristics of the text (used to display the bookmark's title) of a bookmark item specified by its unique identifier. The supported
characteristics are italic, bold and bold&italic.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The style characteristics of the bookmark's text of the specified bookmark item as an integer value.
The values are defined as follows: 1 means Italic text, 2 means Bold text, 3 means Bold&Italic text.
The method can be subsequently used to determine if this method has been successful. The GdPictureStatus.PropertyNotFound denotes that the text is
displayed as normal (plain) text by default.
How to find out the style characteristics of the text used to display the bookmark's title for the root bookmark.
Dim caption As String = "Example: GetBookmarkTextAttribute"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = "The style of the text used for displaying the title of the root bookmark is :" + vbCrLf
Dim textAttr As Integer = gdpicturePDF.GetBookmarkTextAttribute(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Select Case textAttr
Case 1
message = message + "Italic"
Exit Select
Case 2
message = message + "Bold"
Exit Select
Case 3
message = message + "Bold & Italic"
Exit Select
Case Else
message = "An error value is detected. Value: " + textAttr.ToString()
Exit Select
End Select
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.PropertyNotFound Then
message = message + "normal (plain text)"
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetBookmarkTextAttribute() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkTextAttribute";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "The style of the text used for displaying the title of the root bookmark is :\n";
int textAttr = gdpicturePDF.GetBookmarkTextAttribute(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
switch (textAttr)
{
case 1: message = message + "Italic"; break;
case 2: message = message + "Bold"; break;
case 3: message = message + "Bold & Italic"; break;
default: message = "An error value is detected. Value: " + textAttr.ToString(); break;
}
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
{
message = message + "normal (plain text)";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetBookmarkTextAttribute() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Sets the style characteristics of the text to be used for displaying the bookmark's title of a bookmark item specified by its unique identifier.
The supported characteristics are: plain (normal text), italic, bold, bold&italic.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
The style characteristics of the bookmark's text of the specified bookmark item as an integer value.
The values are defined as follows: 1 for Italic text, 2 for Bold text, 3 for Bold&Italic text, 0 means no value is specified (normal text).
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the style characteristics of the text to bold (to be used for displaying the bookmark's title) to all bookmark items on the first level of the
bookmark's hierarchy in the PDF document.
Dim caption As String = "Example: SetBookmarkTextAttribute"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim bookmarkID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
While status = GdPictureStatus.OK
status = gdpicturePDF.SetBookmarkColor(bookmarkID, 2)
If status = GdPictureStatus.OK Then
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID)
status = gdpicturePDF.GetStat()
End If
End While
If status = GdPictureStatus.PropertyNotFound Then
status = gdpicturePDF.SaveToFile("bookmarks_SetTextAttribute.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example HAS NOT been followed successfully." + vbCrLf + "The error status is: " + status, caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetBookmarkTextAttribute";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int bookmarkID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
while (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetBookmarkTextAttribute(bookmarkID, 2);
if (status == GdPictureStatus.OK)
{
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID);
status = gdpicturePDF.GetStat();
}
}
if (status == GdPictureStatus.PropertyNotFound)
{
status = gdpicturePDF.SaveToFile("bookmarks_SetTextAttribute.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example HAS NOT been followed successfully.\nThe error status is: " + status, caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Returns the color (used for the bookmark's text) of a bookmark item specified by its unique identifier.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The color of the bookmark's text of the specified bookmark item. The method can be subsequently used to determine if this method has been successful.
How to find out the color of the text defined for the root bookmark.
Dim caption As String = "Example: GetBookmarkColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim color As Color = gdpicturePDF.GetBookmarkColor(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The color of the root bookmark is: " + color.ToString(), caption)
Else
MessageBox.Show("The GetBookmarkColor() method has failed with the status: " + status.ToString(), caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
Color color = gdpicturePDF.GetBookmarkColor(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The color of the root bookmark is: " + color.ToString(), caption);
else
MessageBox.Show("The GetBookmarkColor() method has failed with the status: " + status.ToString(), caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Sets the color to be used for displaying the bookmark's title of a bookmark item specified by its unique identifier.
This method uses the RGB color space for specifying the required color.
Sets the color to be used for displaying the bookmark's title.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the red color (to be used for displaying the bookmark's title) to all bookmark items on the first level of the bookmark's hierarchy in the PDF document.
Dim caption As String = "Example: SetBookmarkColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim bookmarkID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
While status = GdPictureStatus.OK
status = gdpicturePDF.SetBookmarkColor(bookmarkID, 255, 0, 0)
If status = GdPictureStatus.OK Then
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID)
status = gdpicturePDF.GetStat()
End If
End While
If status = GdPictureStatus.PropertyNotFound Then
status = gdpicturePDF.SaveToFile("bookmarks_SetColor.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example HAS NOT been followed successfully." + vbCrLf + "The error status is: " + status, caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetBookmarkColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int bookmarkID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
while (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetBookmarkColor(bookmarkID, 255, 0, 0);
if (status == GdPictureStatus.OK)
{
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID);
status = gdpicturePDF.GetStat();
}
}
if (status == GdPictureStatus.PropertyNotFound)
{
status = gdpicturePDF.SaveToFile("bookmarks_SetColor.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example HAS NOT been followed successfully.\nThe error status is: " + status, caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Sets the color to be used for displaying the bookmark's title of a bookmark item specified by its unique identifier.
This method uses the CMYK color space for specifying the required color.
Sets the color to be used for displaying the bookmark's title.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the resulting color. Use the value between 0 and 255.
The amount of black (key) color to be used for the resulting color. Use the value between 0 and 255.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the cyan color (to be used for displaying the bookmark's title) to all bookmark items on the first level of the bookmark's hierarchy in the PDF document.
Dim caption As String = "Example: SetBookmarkColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim bookmarkID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
While status = GdPictureStatus.OK
status = gdpicturePDF.SetBookmarkColor(bookmarkID, 255, 0, 0, 0)
If status = GdPictureStatus.OK Then
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID)
status = gdpicturePDF.GetStat()
End If
End While
If status = GdPictureStatus.PropertyNotFound Then
status = gdpicturePDF.SaveToFile("bookmarks_SetColor.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example HAS NOT been followed successfully." + vbCrLf + "The error status is: " + status, caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetBookmarkColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int bookmarkID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
while (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetBookmarkColor(bookmarkID, 255, 0, 0, 0);
if (status == GdPictureStatus.OK)
{
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID);
status = gdpicturePDF.GetStat();
}
}
if (status == GdPictureStatus.PropertyNotFound)
{
status = gdpicturePDF.SaveToFile("bookmarks_SetColor.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example HAS NOT been followed successfully.\nThe error status is: " + status, caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Sets the color to be used for displaying the bookmark's title of a bookmark item specified by its unique identifier.
Sets the color to be used for displaying the bookmark's title.
A color object that defines the new color to be used for a specified bookmark item.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the red color (to be used for displaying the bookmark's title) to all bookmark items on the first level of the bookmark's hierarchy in the PDF document.
Dim caption As String = "Example: SetBookmarkColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim bookmarkID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
While status = GdPictureStatus.OK
status = gdpicturePDF.SetBookmarkColor(bookmarkID, Color.Red)
If status = GdPictureStatus.OK Then
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID)
status = gdpicturePDF.GetStat()
End If
End While
If status = GdPictureStatus.PropertyNotFound Then
status = gdpicturePDF.SaveToFile("bookmarks_SetColor.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example HAS NOT been followed successfully." + vbCrLf + "The error status is: " + status, caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetBookmarkColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int bookmarkID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
while (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetBookmarkColor(bookmarkID, Color.Red);
if (status == GdPictureStatus.OK)
{
bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID);
status = gdpicturePDF.GetStat();
}
}
if (status == GdPictureStatus.PropertyNotFound)
{
status = gdpicturePDF.SaveToFile("bookmarks_SetColor.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example HAS NOT been followed successfully.\nThe error status is: " + status, caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Creates and appends a new bookmark item to the exisiting bookmark's hierarchy of the currently loaded PDF document.
A unique bookmark identifier specifying the parent's bookmark of the newly created bookmark item. Please use the value of 0 if you want to create a root bookmark (the first top-level bookmark item).
You can obtain this identifier using these methods: , , , or .
The title for the newly created bookmark item.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The unique bookmark identifier of the newly created bookmark item. The method can be subsequently used to determine if this method has been successful.
How to create a root bookmark item with some child (descendant) bookmark items.
This example creates a bookmark hierarchy with the root bookmark and 10 child bookmark items, each bookmark points to one page in the PDF document. Also a
hierarchy with two child bookmark items is created, both child bookmarks open a website link.
Dim caption As String = "Example: NewBookmark"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim failure As Boolean = True
Dim rootBookmark As Integer = gdpicturePDF.NewBookmark(0, "Pages Navigation")
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The NewBookmark() method (root bookmark for pages) has failed with the status: " + status.ToString(), caption)
Else
Dim i As Integer = 0
Do
i += 1
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim bookMarkID As Integer = gdpicturePDF.NewBookmark(rootBookmark, "Move to the page " + i.ToString())
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failure = (gdpicturePDF.SetBookmarkAction(bookMarkID, actionID) <> GdPictureStatus.OK)
End If
End If
End If
If failure Then
MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Loop While Not failure AndAlso i < 10
End If
If Not failure Then
failure = True
rootBookmark = gdpicturePDF.NewBookmark(0, "Links Navigation")
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The NewBookmark() method (root bookmark for links) has failed with the status: " + status.ToString(), caption)
Else
Dim bookMarkID1 As Integer = gdpicturePDF.NewBookmark(rootBookmark, "Visit GdPicture website!")
status = gdpicturePDF.GetStat()
Dim bookMarkID2 As Integer = 0
If status = GdPictureStatus.OK Then
bookMarkID2 = gdpicturePDF.NewBookmark(rootBookmark, "Read GdPicture.NET documentation online!")
status = gdpicturePDF.GetStat()
End If
If status = GdPictureStatus.OK Then
Dim actionID1 As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
status = gdpicturePDF.GetStat()
Dim actionID2 As Integer = -1
If status = GdPictureStatus.OK Then
actionID2 = gdpicturePDF.NewActionURI("http://www.guides.gdpicture.com", False)
status = gdpicturePDF.GetStat()
End If
If status = GdPictureStatus.OK Then
failure = ((gdpicturePDF.SetBookmarkAction(bookMarkID1, actionID1) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetBookmarkAction(bookMarkID2, actionID2) <> GdPictureStatus.OK))
If failure Then
MessageBox.Show("This error occurs in creating the link navigation bookmark hierarchy: " + status.ToString(), caption)
End If
End If
End If
End If
End If
If Not failure Then
status = gdpicturePDF.SaveToFile("bookmarks_NewBookmark.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The new file has been saved successfully.", caption)
Else
MessageBox.Show("The new file can't be saved. Status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The new file can't be created. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NewBookmark";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool failure = true;
int rootBookmark = gdpicturePDF.NewBookmark(0, "Pages Navigation");
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
MessageBox.Show("The NewBookmark() method (root bookmark for pages) has failed with the status: " + status.ToString(), caption);
else
{
int i = 0;
do
{
i++;
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int bookMarkID = gdpicturePDF.NewBookmark(rootBookmark, "Move to the page " + i.ToString());
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failure = (gdpicturePDF.SetBookmarkAction(bookMarkID, actionID) != GdPictureStatus.OK);
}
}
}
if (failure)
MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption);
} while (!failure && i < 10);
}
if (!failure)
{
failure = true;
rootBookmark = gdpicturePDF.NewBookmark(0, "Links Navigation");
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
MessageBox.Show("The NewBookmark() method (root bookmark for links) has failed with the status: " + status.ToString(), caption);
else
{
int bookMarkID1 = gdpicturePDF.NewBookmark(rootBookmark, "Visit GdPicture website!");
status = gdpicturePDF.GetStat();
int bookMarkID2 = 0;
if (status == GdPictureStatus.OK)
{
bookMarkID2 = gdpicturePDF.NewBookmark(rootBookmark, "Read GdPicture.NET documentation online!");
status = gdpicturePDF.GetStat();
}
if (status == GdPictureStatus.OK)
{
int actionID1 = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
status = gdpicturePDF.GetStat();
int actionID2 = -1;
if (status == GdPictureStatus.OK)
{
actionID2 = gdpicturePDF.NewActionURI("http://www.guides.gdpicture.com", false);
status = gdpicturePDF.GetStat();
}
if (status == GdPictureStatus.OK)
{
failure = ((gdpicturePDF.SetBookmarkAction(bookMarkID1, actionID1) != GdPictureStatus.OK) ||
(gdpicturePDF.SetBookmarkAction(bookMarkID2, actionID2) != GdPictureStatus.OK));
if (failure)
MessageBox.Show("This error occurs in creating the link navigation bookmark hierarchy: " + status.ToString(), caption);
}
}
}
}
if (!failure)
{
status = gdpicturePDF.SaveToFile("bookmarks_NewBookmark.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The new file has been saved successfully.", caption);
else
MessageBox.Show("The new file can't be saved. Status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The new file can't be created. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Returns the action's unique identifier of the action associated with a bookmark item specified by its unique identifier.
You can subsequently use the method to determine the kind of this action.
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A unique action identifier of the action associated with a specified bookmark. The method can be subsequently used to determine if this method has been successful.
You can use the method to obtain the type of this action, as it is shown in the example below.
How to find out if the root bookmark in the PDF document is associated with an action. The example shows you, how to determine the type of the associated action.
Dim caption As String = "Example: GetBookmarkActionID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.GetBookmarkActionID(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionType As PdfActionType = gdpicturePDF.GetActionType(actionID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The action associated with a root bookmark is of the type: " + actionType.ToString(), caption)
Else
MessageBox.Show("The GetActionType() method has failed with the status: " + status.ToString(), caption)
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("No action is associated with a root bookmark.", caption)
Else
MessageBox.Show("The GetBookmarkActionID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkActionID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.GetBookmarkActionID(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
PdfActionType actionType = gdpicturePDF.GetActionType(actionID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The action associated with a root bookmark is of the type: " + actionType.ToString(), caption);
else
MessageBox.Show("The GetActionType() method has failed with the status: " + status.ToString(), caption);
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("No action is associated with a root bookmark.", caption);
else
MessageBox.Show("The GetBookmarkActionID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Associates a specified action (identified with a unique action identifier) with a specified bookmark item (identified with a unique bookmark identifier).
A unique bookmark identifier specifying a required bookmark object.
You can obtain this identifier using these methods: , , , , or .
A unique action identifier specifying a required action object.
You can obtain this identifier when creating an action, for example, using
the , , , , or methods.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to assign an action to a bookmark item. This example creates a bookmark hierarchy with 10 bookmark items, each bookmark points to one page in the PDF document.
Dim caption As String = "Example: SetBookmarkAction"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
Else
Dim rootBookmark As Integer = gdpicturePDF.NewBookmark(0, "Pages Navigation")
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The NewBookmark() method (root bookmark) has failed with the status: " + status.ToString(), caption)
Else
Dim failure As Boolean = True
Dim i As Integer = 0
Do
i += 1
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim bookMarkID As Integer = gdpicturePDF.NewBookmark(rootBookmark, "Move to the page " + i.ToString())
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
failure = (gdpicturePDF.SetBookmarkAction(bookMarkID, actionID) <> GdPictureStatus.OK)
End If
End If
End If
If failure Then
MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Loop While Not failure AndAlso i < 10
If Not failure AndAlso (gdpicturePDF.SaveToFile("bookmarks_Actions.pdf") = GdPictureStatus.OK) Then
MessageBox.Show("The new file has been saved successfully.", caption)
Else
MessageBox.Show("The new file can't be saved.", caption)
End If
End If
End If
Else
MessageBox.Show("The new file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetBookmarkAction";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
else
{
int rootBookmark = gdpicturePDF.NewBookmark(0, "Pages Navigation");
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
MessageBox.Show("The NewBookmark() method (root bookmark) has failed with the status: " + status.ToString(), caption);
else
{
bool failure = true;
int i = 0;
do
{
i++;
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "This is the page " + i.ToString()) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionGoTo(PdfDestinationType.DestinationTypeXYZ, i, 0, 0, 0, 0, 1);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int bookMarkID = gdpicturePDF.NewBookmark(rootBookmark, "Move to the page " + i.ToString());
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
failure = (gdpicturePDF.SetBookmarkAction(bookMarkID, actionID) != GdPictureStatus.OK);
}
}
}
if (failure)
MessageBox.Show("The error occurs when creating a page nr." + i.ToString() + " or an action or a bookmark on this page. Status: " + gdpicturePDF.GetStat().ToString(), caption);
} while (!failure && i < 10);
if (!failure && (gdpicturePDF.SaveToFile("bookmarks_Actions.pdf") == GdPictureStatus.OK))
MessageBox.Show("The new file has been saved successfully.", caption);
else
MessageBox.Show("The new file can't be saved.", caption);
}
}
}
else
{
MessageBox.Show("The new file can't be created.", caption);
}
gdpicturePDF.Dispose();
Returns the encryption algorithm which has been used to encrypt the currently loaded PDF document.
The PDF specification defines different algorithms to be used to encrypt and/or decrypt a PDF document's content: RC4 40 bits, RC4 128 bits, AES 128 bits, AES 256 bits.
You should apply this method on a decrypted PDF document only (see the example below).
You need to decrypt the PDF document at first using the method with specifyting either the correct user password or the owner password.
A member of the PdfEncryption enumeration. The method can be subsequently used to determine if this method has been successful.
How to correctly find out the encryption algorithm that has been used to encrypt the PDF document.
Dim caption As String = "Example: GetEncryptionScheme"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example in the SetPassword method for creating this file.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("encrypted.pdf", False)
If status = GdPictureStatus.OK Then
Dim encryption As PdfEncryption = PdfEncryption.PdfEncryptionUnknown
Dim encrypted As Boolean = gdpicturePDF.IsEncrypted()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If encrypted Then
'This is incorrect usage.
encryption = gdpicturePDF.GetEncryptionScheme()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("This PDF document is encrypted, the encryption scheme is: " + encryption.ToString() + vbCrLf + "Please use SetPassword to decrypt your document.", caption)
End If
'You need to provide the correct password here.
status = gdpicturePDF.SetPassword("user")
If status = GdPictureStatus.OK Then
'The correct usage.
encryption = gdpicturePDF.GetEncryptionScheme() ' correct use
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("This PDF document is decrypted, the encryption scheme is: " + encryption.ToString(), caption)
End If
Else
MessageBox.Show("The SetPassword() method has failed with the status: " + status.ToString(), caption)
End If
Else
encryption = gdpicturePDF.GetEncryptionScheme()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The PDF document is not encrypted, the encryption scheme is: " + encryption.ToString(), caption)
End If
End If
Else
MessageBox.Show("The IsEncrypted() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEncryptionScheme";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example in the SetPassword method for creating this file.
GdPictureStatus status = gdpicturePDF.LoadFromFile("encrypted.pdf", false);
if (status == GdPictureStatus.OK)
{
PdfEncryption encryption = PdfEncryption.PdfEncryptionUnknown;
bool encrypted = gdpicturePDF.IsEncrypted();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (encrypted)
{
//This is incorrect usage.
encryption = gdpicturePDF.GetEncryptionScheme();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("This PDF document is encrypted, the encryption scheme is: " + encryption.ToString() + "\nPlease use SetPassword to decrypt your document.", caption);
//You need to provide the correct password here.
status = gdpicturePDF.SetPassword("user");
if (status == GdPictureStatus.OK)
{
//The correct usage.
encryption = gdpicturePDF.GetEncryptionScheme();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("This PDF document is decrypted, the encryption scheme is: " + encryption.ToString(), caption);
}
else
{
MessageBox.Show("The SetPassword() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
encryption = gdpicturePDF.GetEncryptionScheme();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The PDF document is not encrypted, the encryption scheme is: " + encryption.ToString(), caption);
}
}
else
{
MessageBox.Show("The IsEncrypted() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns if the currently loaded PDF document is encrypted or not using the standard security handler encryption mechanism. This approach allows you to define
access permissions and up to two passwords - an user password and an owner password. You can use the method to decrypt the PDF documents. Once
this method has been applied, the currently loaded document remains decrypted for subsequent use.
Please read more about providing the passwords in the method.
A PDF document can be encrypted to protect its content from unauthorized access.
An user (or open) password allows users to open the document with respect to the defined access permissions. The document cannot be opened at all without providing this password if one is set.
An owner (or permission or master) password will give users full access to the document.
This access restriction password does not affect user's ability to open and view the PDF document, but prevents user from editing, changing, printing and more according to which access rights has been set.
true if the currently loaded PDF document is encrypted using the standard security handler, otherwise false.
Once the loaded PDF document is decrypted, the return value will be always false.
How to correctly find out if the PDF document is encrypted, decrypted or unencrypted.
Dim caption As String = "Example: IsEncrypted"
Dim gdpicturePDF As New GdPicturePDF()
'We assume the test.pdf is unencrypted PDF document.
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim encrypted As Boolean = gdpicturePDF.IsEncrypted()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If encrypted Then
'This is an incorrect option.
MessageBox.Show("This PDF document is encrypted.", caption)
Else
'This is a correct option.
MessageBox.Show("This PDF document is unencrypted.", caption)
End If
Else
MessageBox.Show("The IsEncrypted() method has failed.", caption)
End If
If gdpicturePDF.CloseDocument() <> GdPictureStatus.OK Then
Return
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
'Please see the example in the SetPassword method for creating this file.
If gdpicturePDF.LoadFromFile("encrypted.pdf", False) = GdPictureStatus.OK Then
Dim encrypted As Boolean = gdpicturePDF.IsEncrypted()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If encrypted Then
'This is a correct option, you can provide a password here.
MessageBox.Show("This PDF document is encrypted.", caption)
'Providing an user password.
Dim status As GdPictureStatus = gdpicturePDF.SetPassword("user")
If status = GdPictureStatus.OK Then
encrypted = gdpicturePDF.IsEncrypted()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If encrypted Then
'This is an incorrect option.
MessageBox.Show("This PDF document is still encrypted.", caption)
Else
'This is a correct option.
MessageBox.Show("This PDF document is decrypted now.", caption)
End If
Else
MessageBox.Show("The IsEncrypted() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SetPassword() method has failed with the status: " + status.ToString(), caption)
End If
Else
'This is an incorrect option.
MessageBox.Show("This PDF is unencrypted.", caption)
End If
Else
MessageBox.Show("The IsEncrypted() method has failed.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: IsEncrypted";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//We assume the test.pdf is unencrypted PDF document.
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
bool encrypted = gdpicturePDF.IsEncrypted();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (encrypted)
//This is an incorrect option.
MessageBox.Show("This PDF document is encrypted.", caption);
else
//This is a correct option.
MessageBox.Show("This PDF document is unencrypted.", caption);
}
else
MessageBox.Show("The IsEncrypted() method has failed.", caption);
if (gdpicturePDF.CloseDocument() != GdPictureStatus.OK) return;
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
//Please see the example in the SetPassword method for creating this file.
if (gdpicturePDF.LoadFromFile("encrypted.pdf", false) == GdPictureStatus.OK)
{
bool encrypted = gdpicturePDF.IsEncrypted();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (encrypted)
{
//This is a correct option, you can provide a password here.
MessageBox.Show("This PDF document is encrypted.", caption);
//Providing an user password.
GdPictureStatus status = gdpicturePDF.SetPassword("user");
if (status == GdPictureStatus.OK)
{
encrypted = gdpicturePDF.IsEncrypted();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (encrypted)
//This is an incorrect option.
MessageBox.Show("This PDF document is still encrypted.", caption);
else
//This is a correct option.
MessageBox.Show("This PDF document is decrypted now.", caption);
}
else
MessageBox.Show("The IsEncrypted() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The SetPassword() method has failed with the status: " + status.ToString(), caption);
}
else
//This is an incorrect option.
MessageBox.Show("This PDF is unencrypted.", caption);
}
else
MessageBox.Show("The IsEncrypted() method has failed.", caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Decrypts the currently loaded PDF document with entering the password (an user password or an owner password) you have specified.
Once the correct password is provided (it does not matter if an user password or an owner password), the PDF document becomes decrypted for subsequent use and any other attempt to set a password will fail.
Please read more about the password and permissions security in the method.
The user password or the owner password to be used to decrypt the currently loaded PDF document.
The basic rules for applying the user and the owner passwords are:
1. A PDF document was encrypted using the user (open) password only. By the definition this means that the owner password is the same as the user password.
Providing the correct user password on opening allows you to fully access the document content.
2. A PDF document was encrypted using the owner (permission, master) password only. You are allowed to open and view the document content without providing the
password, but you need to respect the access rights which has been set. To change these rights to be able to control the access to the document content you
need to provide the owner password.3. A PDF document was encrypted using both passwords, the user and the owner as well, assuming they are not the same. Providing the user password on opening
leads to the point 2. Providing the owner password on opening allows you to fully access the document content directly.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to correctly decrypt the PDF document providing an user or an owner password.
Dim caption As String = "Example: SetPassword"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
'We are going to create an encrypted PDF document here.
If gdpicturePDF.SaveToFile("encrypted.pdf", PdfEncryption.PdfEncryption128BitRC4, "user", "owner", False, False,
False, False, False, False, False, False) = GdPictureStatus.OK Then
If gdpicturePDF.CloseDocument() <> GdPictureStatus.OK Then
Return
End If
If gdpicturePDF.LoadFromFile("encrypted.pdf", False) <> GdPictureStatus.OK Then
Return
End If
'The new encrypted PDF document has been successfully loaded.
Dim isEncrypted As Boolean = gdpicturePDF.IsEncrypted()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If isEncrypted Then
'Providing an user password.
status = gdpicturePDF.SetPassword("user")
MessageBox.Show("The PDF document was encrypted and now it is decrypted with the status: " + status.ToString(), caption)
'You can work with the PDF document according to the specified access rights (see above).
'Closing and reloading the document to make it encrypted again.
If gdpicturePDF.CloseDocument() <> GdPictureStatus.OK Then
Return
End If
If gdpicturePDF.LoadFromFile("encrypted.pdf", False) <> GdPictureStatus.OK Then
Return
End If
'Providing an owner password.
status = gdpicturePDF.SetPassword("owner")
'You have full access to the document content now.
MessageBox.Show("The PDF document was encrypted and now it is decrypted with the status: " + status.ToString(), caption)
Else
MessageBox.Show("The PDF document is unencrypted.", caption)
End If
End If
Else
MessageBox.Show("The encrypted file has failed to save.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetPassword";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
//We are going to create an encrypted PDF document here.
if (gdpicturePDF.SaveToFile("encrypted.pdf", PdfEncryption.PdfEncryption128BitRC4, "user", "owner", false, false, false, false, false, false, false, false) == GdPictureStatus.OK)
{
if (gdpicturePDF.CloseDocument() != GdPictureStatus.OK) return;
if (gdpicturePDF.LoadFromFile("encrypted.pdf", false) != GdPictureStatus.OK) return;
//The new encrypted PDF document has been successfully loaded.
bool isEncrypted = gdpicturePDF.IsEncrypted();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (isEncrypted)
{
//Providing an user password.
status = gdpicturePDF.SetPassword("user");
MessageBox.Show("The PDF document was encrypted and now it is decrypted with the status: " + status.ToString(), caption);
//You can work with the PDF document according to the specified access rights (see above).
//Closing and reloading the document to make it encrypted again.
if (gdpicturePDF.CloseDocument() != GdPictureStatus.OK) return;
if (gdpicturePDF.LoadFromFile("encrypted.pdf", false) != GdPictureStatus.OK) return;
//Providing an owner password.
status = gdpicturePDF.SetPassword("owner");
MessageBox.Show("The PDF document was encrypted and now it is decrypted with the status: " + status.ToString(), caption);
//You have full access to the document content now.
}
else
{
MessageBox.Show("The PDF document is unencrypted.", caption);
}
}
}
else
{
MessageBox.Show("The encrypted file has failed to save.", caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the certificate (the associated public key), contained in the digital ID stored in the specified external PKCS#12 file with the filename extension
".p12" or ".pfx". The method works with the file specified by its file path as a string.
This method applies the concept of the public key security. It is assumed, that the currently loaded PDF document is encrypted using the provided digital
ID. The document is subsequently decrypted using the associated public key.
Sets the certificate contained in the digital ID file and decrypts the currently loaded PDF document using the associated public key.
The file path to the digital ID file. This file contains the certificate given to decrypt the currently loaded PDF document.
The password to open the digital ID file specified above.
The public key security handler applies the authentication with a pair of a public key (a certificate) and a private key. In comparison to the standard
security handler, this allows you to define individual rights and unique access permissions for different recipients. Only specified recipients will be able to
open the encrypted PDF document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set a certificate from a file to decrypt the document.
Dim caption As String = "SetCertificate"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("your_encrypted_document.pdf", False) = GdPictureStatus.OK Then
'Specify your digitalID filename here.
Dim digitalID_filename As String = "your_digitalID_filename.pfx"
'Specify the corresponding password here.
Dim password As String = "password"
Dim status As GdPictureStatus = gdpicturePDF.SetCertificate(digitalID_filename, password)
MessageBox.Show("The SetCertificate() method has terminated with the status: " + status.ToString(), caption)
'You can do your stuff with the PDF document here.
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "SetCertificate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("your_encrypted_document.pdf", false) == GdPictureStatus.OK)
{
//Specify your digitalID filename here.
string digitalID_filename = "your_digitalID_filename.pfx";
//Specify the corresponding password here.
string password = "password";
GdPictureStatus status = gdpicturePDF.SetCertificate(digitalID_filename, password);
MessageBox.Show("The SetCertificate() method has terminated with the status: " + status.ToString(),caption);
//You can do your stuff with the PDF document here.
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the certificate (the associated public key), contained in the digital ID stored in the specified external PKCS#12 file with the filename extension ".p12"
or ".pfx". The method works with the instantiated stream object containing the corresponding file.
This method applies the concept of the public key security. It is assumed, that the currently loaded PDF document is encrypted using the provided digital
ID. The document is subsequently decrypted using the associated public key.
Sets the certificate contained in the digital ID file and decrypts the currently loaded PDF document using the associated public key.
A Stream object specifying the digital ID file. This file contains the certificate given to decrypt the currently loaded PDF document.
This Stream object must be initialized and opened for reading before it can be sent into this method and it should remain open for subsequent use.
The password to open the digital ID file specified above.
The public key security handler applies the authentication with a pair of a public key (a certificate) and a private key. In comparison to the standard
security handler, this allows you to define individual rights and unique access permissions for different recipients. Only specified recipients will be able to
open the encrypted PDF document.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set a certificate from an instantiated stream object to decrypt the document.
Dim caption As String = "SetCertificate"
Dim gdpicturePDF As New GdPicturePDF()
'Specify your digitalID filename here.
Dim digitalID_filename As String = "your_digitalID_filename.pfx"
'Specify the corresponding password here.
Dim password As String = "password"
Dim digitalID_stream As System.IO.FileStream = New system.IO.FileStream(digitalID_filename, FileMode.Open, FileAccess.Read)
If gdpicturePDF.LoadFromFile("your_encrypted_document.pdf", False) = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.SetCertificate(digitalID_stream, password)
MessageBox.Show("The SetCertificate() method has terminated with the status: " + status.ToString(), caption)
'You can do your stuff with the PDF document here.
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
digitalID_stream.Dispose()
string caption = "SetCertificate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Specify your digitalID filename here.
string digitalID_filename = "your_digitalID_filename.pfx";
//Specify the corresponding password here.
string password = "password";
System.IO.FileStream digitalID_stream = new system.IO.FileStream(digitalID_filename, FileMode.Open, FileAccess.Read);
if (gdpicturePDF.LoadFromFile("your_encrypted_document.pdf", false) == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.SetCertificate(digitalID_stream, password);
MessageBox.Show("The SetCertificate() method has terminated with the status: " + status.ToString(),caption);
//You can do your stuff with the PDF document here.
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
digitalID_stream.Dispose();
Returns if the provided access permission is granted within the currently loaded PDF document.
A member of the PdfRight enumeration. You need to specify the permisson you want to find out if it is allowed or not.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
You should apply this method on a decrypted PDF document only. If your document is still encrypted, the method returns false
and the method returns GdPictureStatus.PdfDocumentMustBeUnencrypted.
You need to decrypt the PDF document at first using the method with specifyting either the correct user password or the owner password.
true if the access permission you have specified is allowed, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to correctly find out the access permissions of the PDF document.
Dim caption As String = "Example: GetRight"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example in the SetPassword method for creating this file.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("encrypted.pdf", False)
If status = GdPictureStatus.OK Then
Dim encrypted As Boolean = gdpicturePDF.IsEncrypted()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If encrypted Then
'Setting the user password.
status = gdpicturePDF.SetPassword("user")
'Try the same with providing the owner password.
'status = gdpicturePDF.SetPassword("owner");
If status = GdPictureStatus.OK Then
encrypted = gdpicturePDF.IsEncrypted()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso Not encrypted Then
Dim encryptScheme As PdfEncryption = gdpicturePDF.GetEncryptionScheme()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim permList As String = ""
If gdpicturePDF.GetRight(PdfRight.PdfRightCanView) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanView.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanPrint) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanPrint.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanModify) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanModify.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanCopy) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanCopy.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanAddNotes) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanAddNotes.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanFillFields) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanFillFields.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanCopyAccess) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanCopyAccess.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanAssemble) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanAssemble.ToString() + vbCrLf
End If
If gdpicturePDF.GetRight(PdfRight.PdfRightCanPrintFull) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
permList = permList + PdfRight.PdfRightCanPrintFull.ToString() + vbCrLf
End If
MessageBox.Show("PDF encryption is " + encryptScheme.ToString() + "." + vbCrLf + "Access permissions are: " + vbCrLf + permList.ToString(), caption)
Else
MessageBox.Show("The GetEncryptionScheme() method has failed with the status: " + status.ToString())
End If
End If
Else
MessageBox.Show("You have probably provided a bad password.", caption)
End If
Else
MessageBox.Show("The file is unencrypted.", caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetRight";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("encrypted.pdf", false);
//Please see the example in the SetPassword method for creating this file.
if (status == GdPictureStatus.OK)
{
bool encrypted = gdpicturePDF.IsEncrypted();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (encrypted)
{
//Setting the user password.
status = gdpicturePDF.SetPassword("user");
//Try the same with providing the owner password.
//status = gdpicturePDF.SetPassword("owner");
if (status == GdPictureStatus.OK)
{
encrypted = gdpicturePDF.IsEncrypted();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) && !encrypted)
{
PdfEncryption encryptScheme = gdpicturePDF.GetEncryptionScheme();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string permList = "";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanView) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanView.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanPrint) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanPrint.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanModify) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanModify.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanCopy) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanCopy.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanAddNotes) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanAddNotes.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanFillFields) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanFillFields.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanCopyAccess) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanCopyAccess.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanAssemble) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanAssemble.ToString() + "\n";
if (gdpicturePDF.GetRight(PdfRight.PdfRightCanPrintFull) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
permList = permList + PdfRight.PdfRightCanPrintFull.ToString() + "\n";
MessageBox.Show("PDF encryption is " + encryptScheme.ToString() + ".\nAccess permissions are: \n" + permList.ToString(), caption);
}
else
{
MessageBox.Show("The GetEncryptionScheme() method has failed with the status: " + status.ToString());
}
}
}
else
{
MessageBox.Show("You have probably provided a bad password.", caption);
}
}
else
{
MessageBox.Show("The file is unencrypted.", caption);
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the security handler which has been used to encrypt the currently loaded PDF document.
The file's security handler provides a mechanism that not only implements encryption in PDF documents, but also stores all data related to this process. The
PDF specification defines two security handlers: Standard Security Handler and Public-Key Security Handler. Other applications may provide security handlers of
their own.
You should apply this method on an encrypted PDF document only (see the example below).
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfEncryptionMode enumeration. The method can be subsequently used to determine if this method has been successful.
How to find out the used security handler for the encrypted PDF document.
Dim caption As String = "Example: GetEncryptionMode"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example in the SetPassword method for creating this file.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("encrypted.pdf", False)
If status = GdPictureStatus.OK Then
Dim emode As PdfEncryptionMode = PdfEncryptionMode.UnKnown
If gdpicturePDF.IsEncrypted() Then
emode = gdpicturePDF.GetEncryptionMode()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF document is encrypted, the security handler is: " + emode.ToString(), caption)
Else
MessageBox.Show("The GetEncryptionMode() method has failed with the status: " + status.ToString(), caption)
End If
'You need to provide the correct password here.
If gdpicturePDF.SetPassword("user") = GdPictureStatus.OK Then
emode = gdpicturePDF.GetEncryptionMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("This PDF document has been decrypted, the security handler is: " + emode.ToString(), caption)
End If
End If
Else
emode = gdpicturePDF.GetEncryptionMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The PDF document is not encrypted. The security handler is: " + emode.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEncryptionMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example in the SetPassword method for creating this file.
GdPictureStatus status = gdpicturePDF.LoadFromFile("encrypted.pdf", false);
if (status == GdPictureStatus.OK)
{
PdfEncryptionMode emode = PdfEncryptionMode.UnKnown;
if (gdpicturePDF.IsEncrypted())
{
emode = gdpicturePDF.GetEncryptionMode();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("This PDF document is encrypted, the security handler is: " + emode.ToString(), caption);
}
else
{
MessageBox.Show("The GetEncryptionMode() method has failed with the status: " + status.ToString(), caption);
}
//You need to provide the correct password here.
if (gdpicturePDF.SetPassword("user") == GdPictureStatus.OK)
{
emode = gdpicturePDF.GetEncryptionMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("This PDF document has been decrypted, the security handler is: " + emode.ToString(), caption);
}
}
}
else
{
emode = gdpicturePDF.GetEncryptionMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The PDF document is not encrypted. The security handler is: " + emode.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns if the password provided with the method was the owner password.
You only need to provide the correct password once when using the method. Any other subsequent attempt to set a password using this method will fail.
Please read more about the password and permissions security in the method and in the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the password provided with the method is the owner password, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to check if you have provided the correct owner password.
Dim caption As String = "Example: IsOwnerPassword"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example in the SetPassword method for creating this file.
If gdpicturePDF.LoadFromFile("encrypted.pdf", False) = GdPictureStatus.OK Then
Dim PassOk As Boolean = False
Dim isEncrypted As Boolean = gdpicturePDF.IsEncrypted()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If isEncrypted Then
If gdpicturePDF.SetPassword("") = GdPictureStatus.OK Then
PassOk = True
Else
'Try this call also with the "owner" password.
If gdpicturePDF.SetPassword("user") = GdPictureStatus.OK Then
PassOk = True
If PassOk = True Then
Dim isOwner As Boolean = gdpicturePDF.IsOwnerPassword()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If isOwner Then
MessageBox.Show("The password you have provided is the owner password.", caption)
Else
MessageBox.Show("The password you have provided is the user password.", caption)
End If
End If
End If
End If
End If
If PassOk = False Then
MessageBox.Show("You have provided a wrong password.", caption)
End If
Else
MessageBox.Show("This PDF is not encrypted.", caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: IsOwnerPassword";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example in the SetPassword method for creating this file.
if (gdpicturePDF.LoadFromFile("encrypted.pdf", false) == GdPictureStatus.OK)
{
bool PassOk = false;
bool isEncrypted = gdpicturePDF.IsEncrypted();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (isEncrypted)
{
if (gdpicturePDF.SetPassword("") == GdPictureStatus.OK)
{
PassOk = true;
}
else
{
//Try this call also with the "owner" password.
if (gdpicturePDF.SetPassword("user") == GdPictureStatus.OK)
{
PassOk = true;
if (PassOk == true)
{
bool isOwner = gdpicturePDF.IsOwnerPassword();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (isOwner)
{
MessageBox.Show("The password you have provided is the owner password.", caption);
}
else
{
MessageBox.Show("The password you have provided is the user password.", caption);
}
}
}
}
}
if (PassOk == false)
{
MessageBox.Show("You have provided a wrong password.", caption);
}
}
else
{
MessageBox.Show("This PDF is not encrypted.", caption);
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the PDF or PDF/A conformance of the currently loaded PDF document.
PDF/A is an ISO-standardized version of the PDF specialized for the digital preservation of electronic documents. It is a subset of the PDF standard which
excludes those PDF features that give rise to concerns about security and the ability to archive documents long term.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
When a PDF/A file is created, the toolkit ensures that the fonts are embedded. If the fonts are not embedded, you don't have a valid PDF/A file. PDF/A
validation tools will inform you if fonts have or have not been embedded.
Just to inform you that the method returns the value of the PdfConformance.PDF for common PDF document.
A member of the PdfConformance enumeration. Returns standard PDF/A conformance levels and versions for the PDF/A compliant document.
The method can be subsequently used to determine if this method has been successful.
How to determine the conformance to the PDF/A standard of the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("your_test_pdfa.pdf", False)
If status = GdPictureStatus.OK Then
Dim oConformance As PdfConformance = gdpicturePDF.GetPDFAConformance()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF conforms to " + oConformance.ToString() + " standard.", "Example: GetPDFAConformance")
Else
MessageBox.Show("The GetPDFAConformance() method has failed with the status: " + status.ToString(), "Example: GetPDFAConformance")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetPDFAConformance")
End If
If gdpicturePDF.CloseDocument() <> GdPictureStatus.OK Then
Return
End If
If gdpicturePDF.NewPDF(PdfConformance.PDF_A_1b) = GdPictureStatus.OK Then
Dim oConformance As PdfConformance = gdpicturePDF.GetPDFAConformance()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF conforms to " + oConformance.ToString() + " standard.", "Example: GetPDFAConformance") 'Should be PDF_A_1b.
Else
MessageBox.Show("The GetPDFAConformance() method has failed with the status: " + status.ToString(), "Example: GetPDFAConformance")
End If
Else
MessageBox.Show("The new file can't be created.", "Example: GetPDFAConformance")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("your_test_pdfa.pdf", false);
if (status == GdPictureStatus.OK)
{
PdfConformance oConformance = gdpicturePDF.GetPDFAConformance();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("This PDF conforms to " + oConformance.ToString() + " standard.", "Example: GetPDFAConformance");
else
MessageBox.Show("The GetPDFAConformance() method has failed with the status: " + status.ToString(), "Example: GetPDFAConformance");
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetPDFAConformance");
}
if (gdpicturePDF.CloseDocument() != GdPictureStatus.OK)
return;
if (gdpicturePDF.NewPDF(PdfConformance.PDF_A_1b) == GdPictureStatus.OK)
{
PdfConformance oConformance = gdpicturePDF.GetPDFAConformance();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("This PDF conforms to " + oConformance.ToString() + " standard.", "Example: GetPDFAConformance"); //Should be PDF_A_1b.
else
MessageBox.Show("The GetPDFAConformance() method has failed with the status: " + status.ToString(), "Example: GetPDFAConformance");
}
else
{
MessageBox.Show("The new file can't be created.", "Example: GetPDFAConformance");
}
gdpicturePDF.Dispose();
Checks whether the currently loaded PDF document is a valid linearized PDF file.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A Linearized PDF file is a file that has been organized in a special way to enable efficient incremental access in a network environment.
Enhanced viewer applications can recognize that a PDF file has been linearized and can take advantage of that organization
(as well as added hint information) to enhance viewing performance (see PDF Reference, Section "Linearized PDF").
true if the current PDF is linearized, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to determine if the PDF document is a valid linearized PDF file.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim isLinearized As Boolean = gdpicturePDF.IsLinearized()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If isLinearized Then
MessageBox.Show("Your PDF document is linearized.", "Example: IsLinearized")
Else
MessageBox.Show("Your PDF document is not linearized.", "Example: IsLinearized")
End If
Else
MessageBox.Show("The IsLinearized() method has failed with the status: " + status.ToString(), "Example: IsLinearized")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: IsLinearized")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
bool isLinearized = gdpicturePDF.IsLinearized();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (isLinearized)
{
MessageBox.Show("Your PDF document is linearized.", "Example: IsLinearized");
}
else
{
MessageBox.Show("Your PDF document is not linearized.", "Example: IsLinearized");
}
}
else
{
MessageBox.Show("The IsLinearized() method has failed with the status: " + status.ToString(), "Example: IsLinearized");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: IsLinearized");
}
gdpicturePDF.Dispose();
Returns the author of the currently loaded PDF document, if any is set in the document information dictionary.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the document's Author property as a string. The method can be subsequently used to determine if this method has been successful.
How to find out who is the author of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim author As String = gdpicturePDF.GetAuthor()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The author of this PDF is: " + author, "Example: GetAuthor")
Else
MessageBox.Show("The GetAuthor() method has failed with the status: " + status.ToString(), "Example: GetAuthor")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetAuthor")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string author = gdpicturePDF.GetAuthor();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The author of this PDF is: " + author, "Example: GetAuthor");
}
else
{
MessageBox.Show("The GetAuthor() method has failed with the status: " + status.ToString(), "Example: GetAuthor");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetAuthor");
}
}
Returns the title of the currently loaded PDF document, if any is set in the document information dictionary.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the document's Title property as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the title of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim title As String = gdpicturePDF.GetTitle()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The title of this PDF is: " + title, "Example: GetTitle")
Else
MessageBox.Show("The GetTitle() method has failed with the status: " + status.ToString(), "Example: GetTitle")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetTitle")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string title = gdpicturePDF.GetTitle();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The title of this PDF is: " + title, "Example: GetTitle");
}
else
{
MessageBox.Show("The GetTitle() method has failed with the status: " + status.ToString(), "Example: GetTitle");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetTitle");
}
}
Returns the subject of the currently loaded PDF document, if any is set in the document information dictionary.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the document's Subject property as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the subject of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim subject As String = gdpicturePDF.GetSubject()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The subject of this PDF is: " + subject, "Example: GetSubject")
Else
MessageBox.Show("The GetSubject() method has failed with the status: " + status.ToString(), "Example: GetSubject")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetSubject")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string subject = gdpicturePDF.GetSubject();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The subject of this PDF is: " + subject, "Example: GetSubject");
}
else
{
MessageBox.Show("The GetSubject() method has failed with the status: " + status.ToString(), "Example: GetSubject");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetSubject");
}
}
Returns the keywords associated with the currently loaded PDF document, if any are set in the document information dictionary.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the document's Keywords property as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the keywords associated with the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim keywords As String = gdpicturePDF.GetKeywords()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The associated keywords are: " + keywords, "Example: GetKeywords")
Else
MessageBox.Show("The GetKeywords() method has failed with the status: " + status.ToString(), "Example: GetKeywords")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetKeywords")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string keywords = gdpicturePDF.GetKeywords();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The associated keywords are: " + keywords, "Example: GetKeywords");
}
else
{
MessageBox.Show("The GetKeywords() method has failed with the status: " + status.ToString(), "Example: GetKeywords");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetKeywords");
}
}
Returns the creator of the currently loaded PDF document, if any is set in the document information dictionary.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the document's Creator property as a string.The method can be subsequently used to determine if this method has been successful.
How to find out who is the creator of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim creator As String = gdpicturePDF.GetCreator()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The creator of this PDF is: " + creator, "Example: GetCreator")
Else
MessageBox.Show("The GetCreator() method has failed with the status: " + status.ToString(), "Example: GetCreator")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetCreator")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string creator = gdpicturePDF.GetCreator();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The creator of this PDF is: " + creator, "Example: GetCreator");
}
else
{
MessageBox.Show("The GetCreator() method has failed with the status: " + status.ToString(), "Example: GetCreator");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetCreator");
}
}
Returns the producer of the currently loaded PDF document, if any is set in the document information dictionary.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the document's Producer property as a string. The method can be subsequently used to determine if this method has been successful.
How to find out who is the producer of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim producer As String = gdpicturePDF.GetProducer()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The producer of this PDF is: " + producer, "Example: GetProducer")
Else
MessageBox.Show("The GetProducer() method has failed with the status: " + status.ToString(), "Example: GetProducer")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetProducer")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string producer = gdpicturePDF.GetProducer();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The producer of this PDF is: " + producer, "Example: GetProducer");
}
else
{
MessageBox.Show("The GetProducer() method has failed with the status: " + status.ToString(), "Example: GetProducer");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetProducer");
}
}
Returns the date and time the currently loaded PDF document was created, as it is set in the document information dictionary.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the document's CreationDate property as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the date and time the PDF document was created.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim creationDate As String = gdpicturePDF.GetCreationDate()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The date and time this PDF was created: " + creationDate, "Example: GetCreationDate")
Else
MessageBox.Show("The GetCreationDate() method has failed with the status: " + status.ToString(), "Example: GetCreationDate")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetCreationDate")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string creationDate = gdpicturePDF.GetCreationDate();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The date and time this PDF was created: " + creationDate, "Example: GetCreationDate");
}
else
{
MessageBox.Show("The GetCreationDate() method has failed with the status: " + status.ToString(), "Example: GetCreationDate");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetCreationDate");
}
}
Returns the date and time the currently loaded PDF document was most recently modified, as it is set in the document information dictionary.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the document's ModDate property as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the date and time the PDF document was last modified.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim modificationDate As String = gdpicturePDF.GetModificationDate()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The date and time this PDF was last modified: " + modificationDate, "Example: GetModificationDate")
Else
MessageBox.Show("The GetModificationDate() method has failed with the status: " + status.ToString(), "Example: GetModificationDate")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetModificationDate")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string modificationDate = gdpicturePDF.GetModificationDate();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The date and time this PDF was last modified: " + modificationDate, "Example: GetModificationDate");
}
else
{
MessageBox.Show("The GetModificationDate() method has failed with the status: " + status.ToString(), "Example: GetModificationDate");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetModificationDate");
}
}
Adds the pair - the custom information key name and its value - to already defined custom metadata fields of the currently loaded PDF document.
The name of the custom information key (the custom metadata field).
The value of the specified custom information key.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add a new custom metadata pair key-value to the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetCustomPDFInformation("NewKey", "NewValue")
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_SetMetaData_func.pdf")
If status = GdPictureStatus.OK Then
'You can use the GetCustomPDFInformationKeys and GetCustomPDFInformation methods to check your custom metadata fields.
MessageBox.Show("Your custom metadata has been added successfully.", "Example: SetCustomPDFInformation")
End If
Else
MessageBox.Show("The SetCustomPDFInformation() method has failed with the status: " + status.ToString(), "Example: SetCustomPDFInformation")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetCustomPDFInformation")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetCustomPDFInformation("NewKey", "NewValue");
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_SetMetaData_func.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("Your custom metadata has been added successfully.", "Example: SetCustomPDFInformation");
//You can use the GetCustomPDFInformationKeys and GetCustomPDFInformation methods to check your custom metadata fields.
}
}
else
{
MessageBox.Show("The SetCustomPDFInformation() method has failed with the status: " + status.ToString(), "Example: SetCustomPDFInformation");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetCustomPDFInformation");
}
gdpicturePDF.Dispose();
Removes the pair - the custom information key name and its value - from the custom metadata fields of the currently loaded PDF document according to the specified key name.
The name of the custom information key (the custom metadata field) to remove.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to delete a custom metadata field specified by its key name from the PDF document.
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim keys As String = gdpicturePDF.GetCustomPDFInformationKeys("~")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If keys.Equals("") Then
MessageBox.Show("Your PDF document does not contain any custom keys.", "Example: DeleteCustomPDFInformation")
Else
If keys.Contains("gdpicture") Then
status = gdpicturePDF.DeleteCustomPDFInformation("gdpicture")
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_DeleteMetaData.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", "Example: DeleteCustomPDFInformation")
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), "Example: DeleteCustomPDFInformation")
End If
Else
MessageBox.Show("The DeleteCustomPDFInformation() method has failed with the status: " + status.ToString(), "Example: DeleteCustomPDFInformation")
End If
Else
MessageBox.Show("Your PDF document does not contain custom key gdpicture.", "Example: DeleteCustomPDFInformation")
End If
End If
Else
MessageBox.Show("The GetCustomPDFInformationKeys() method has failed with the status: " + status.ToString(), "Example: DeleteCustomPDFInformation")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: DeleteCustomPDFInformation")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string keys = gdpicturePDF.GetCustomPDFInformationKeys("~");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (keys.Equals(""))
{
MessageBox.Show("Your PDF document does not contain any custom keys.", "Example: DeleteCustomPDFInformation");
}
else
{
if (keys.Contains("gdpicture"))
{
status = gdpicturePDF.DeleteCustomPDFInformation("gdpicture");
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_DeleteMetaData.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", "Example: DeleteCustomPDFInformation");
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), "Example: DeleteCustomPDFInformation");
}
else
MessageBox.Show("The DeleteCustomPDFInformation() method has failed with the status: " + status.ToString(), "Example: DeleteCustomPDFInformation");
}
else
MessageBox.Show("Your PDF document does not contain custom key gdpicture.", "Example: DeleteCustomPDFInformation");
}
}
else
{
MessageBox.Show("The GetCustomPDFInformationKeys() method has failed with the status: " + status.ToString(), "Example: DeleteCustomPDFInformation");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: DeleteCustomPDFInformation");
}
gdpicturePDF.Dispose();
Returns a string containing the value of the specified custom information key (the custom metadata field) in the currently loaded PDF document.
The name of the required custom information key.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the specified custom information key as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the names of the custom metadata fields and their values if they are specified in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim keys As String = gdpicturePDF.GetCustomPDFInformationKeys(vbCrLf)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If keys.Equals("") Then
MessageBox.Show("Your PDF document does not contain any custom keys.", "Example: GetCustomPDFInformation")
Else
MessageBox.Show("All custom keys are:" + vbCrLf + keys, "Example: GetCustomPDFInformation")
Dim value As String = ""
Dim outPut As String = ""
Dim keyTable As String() = Split(keys, vbCrLf)
For x As Integer = 0 To keyTable.Length - 1
value = gdpicturePDF.GetCustomPDFInformation(keyTable(x))
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
outPut = outPut + keyTable(x) + " = " + value + vbCrLf
Else
MessageBox.Show("The GetCustomPDFInformation() method has failed with the status: " + status.ToString(), "Example: GetCustomPDFInformation")
End If
Next
MessageBox.Show("Custom keys and values are:" + vbCrLf + outPut, "Example: GetCustomPDFInformation")
End If
Else
MessageBox.Show("The GetCustomPDFInformationKeys() method has failed with the status: " + status.ToString(), "Example: GetCustomPDFInformation")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetCustomPDFInformation")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string keys = gdpicturePDF.GetCustomPDFInformationKeys("\n");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (keys.Equals(""))
{
MessageBox.Show("Your PDF document does not contain any custom keys.", "Example: GetCustomPDFInformation");
}
else
{
MessageBox.Show("All custom keys are:\n" + keys, "Example: GetCustomPDFInformation");
string[] names = keys.Split('\n');
string value = "";
string output = "";
foreach (var name in names)
{
value = gdpicturePDF.GetCustomPDFInformation(name);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = output + name + " = " + value + "\n";
}
else
{
MessageBox.Show("The GetCustomPDFInformation() method has failed with the status: " + status.ToString(), "Example: GetCustomPDFInformation");
}
}
MessageBox.Show("Custom keys and values are:\n" + output, "Example: GetCustomPDFInformation");
}
}
else
{
MessageBox.Show("The GetCustomPDFInformationKeys() method has failed with the status: " + status.ToString(), "Example: GetCustomPDFInformation");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetCustomPDFInformation");
}
gdpicturePDF.Dispose();
Returns a string composed from the names of the custom information keys (custom metadata fields) of the currently loaded PDF document.
The included names of the custom information keys are separated with the specified separator.
The string used to separate all the names of the custom information keys in the resulting string.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The names of the custom information keys separated with the specified separator as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the names of the custom metadata fields if they are specified in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim keys As String = gdpicturePDF.GetCustomPDFInformationKeys(vbCrLf)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If keys.Equals("") Then
MessageBox.Show("Your PDF document does not contain any custom keys.", "Example: GetCustomPDFInformationKeys")
Else
MessageBox.Show("All custom keys are:" + vbCrLf + keys, "Example: GetCustomPDFInformationKeys")
End If
Else
MessageBox.Show("The GetCustomPDFInformationKeys() method has failed with the status: " + status.ToString(), "Example: GetCustomPDFInformationKeys")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetCustomPDFInformationKeys")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string keys = gdpicturePDF.GetCustomPDFInformationKeys("\n");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (keys.Equals(""))
{
MessageBox.Show("Your PDF document does not contain any custom keys.", "Example: GetCustomPDFInformationKeys");
}
else
{
MessageBox.Show("All custom keys are:\n" + keys, "Example: GetCustomPDFInformationKeys");
}
}
else
{
MessageBox.Show("The GetCustomPDFInformationKeys() method has failed with the status: " + status.ToString(), "Example: GetCustomPDFInformationKeys");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetCustomPDFInformationKeys");
}
gdpicturePDF.Dispose();
Returns the version of the PDF specification to which the currently loaded PDF document conforms.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the PDF version conformity as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the PDF version of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim version As String = gdpicturePDF.GetVersion()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF version of this document is: " + version, "Example: GetVersion")
Else
MessageBox.Show("The GetVersion() method has failed with the status: " + status.ToString(), "Example: GetVersion")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetVersion")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string version = gdpicturePDF.GetVersion();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The PDF version of this document is: " + version, "Example: GetVersion");
}
else
{
MessageBox.Show("The GetVersion() method has failed with the status: " + status.ToString(), "Example: GetVersion");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetVersion");
}
}
Increases the full PDF version number of the currently loaded PDF document to the version number you have specified.
The PDF version number uses a form M.m, where M is the major version number and m is the minor version number.
This version is stated in the PDF header, which is the first line in the PDF file.
Please note that you have to specify the full version number using this method. For example, for increasing to the version 1.6, you have to set the Version parameter to 1.6,
or for increasing to 2.0 you have to set the Version parameter to 2.0.
The new full PDF version number you want to increase to. You have to set the full version number here, for example, 1.6 or 2.0.
This method is only allowed for use with non-encrypted documents.
Be aware that if the required version you specify is not supported by the toolkit, this method will fail.
Just to inform you, that this method can be useful to convert your input PDF/A 1.4 compliant document to be PDF 1.6 compliant in order to decrease its resulting file size.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to increase the PDF version of your document to be compliant with PDF 1.6 version.
Dim caption As String = "Example: IncreaseVersion"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim version As String = gdpicturePDF.GetVersion()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The original version of this PDF is: " + version, caption)
If version.Equals("1.4", StringComparison.Ordinal) OrElse version.Equals("1.5", StringComparison.Ordinal) Then
status = gdpicturePDF.IncreaseVersion(1.6F)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_IncreaseVersion.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The version has been increased successfully.", caption)
Else
MessageBox.Show("The new file can't be saved.", caption)
End If
Else
MessageBox.Show("The IncreaseVersion() method has failed with the status: " + status.ToString(), caption)
End If
Else
If version.Equals("1.6", StringComparison.Ordinal) Then
MessageBox.Show("This PDF file already conforms to PDF version 1.6.", caption)
End If
End If
Else
MessageBox.Show("The GetVersion() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
End Using
string caption = "Example: IncreaseVersion";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string version = gdpicturePDF.GetVersion();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The original version of this PDF is: " + version, caption);
if (version.Equals("1.4", StringComparison.Ordinal) || version.Equals("1.5", StringComparison.Ordinal))
{
status = gdpicturePDF.IncreaseVersion(1.6f);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_IncreaseVersion.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The version has been increased successfully.", caption);
}
else
{
MessageBox.Show("The new file can't be saved.", caption);
}
}
else
{
MessageBox.Show("The IncreaseVersion() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (version.Equals("1.6", StringComparison.Ordinal))
{
MessageBox.Show("This PDF file already conforms to PDF version 1.6.", caption);
}
}
}
else
{
MessageBox.Show("The GetVersion() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
}
Returns the metadata of the currently loaded PDF document, if any are stored in the PDF.
The toolkit supports XMP format of metadata, which is the standard for embedding metadata in files.
For further assistance, please refer to the core XMP specification published as ISO standard 16684-1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the document's metadata as a string in the XMP standardized format. The method can be subsequently used to determine if this method has been successful.
How to find out the metadata of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim metadata As String = gdpicturePDF.GetMetadata()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The metadata of this PDF are:" + vbCrLf + metadata, "Example: GetMetadata")
Else
MessageBox.Show("The GetMetadata() method has failed with the status: " + status.ToString(), "Example: GetMetadata")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetMetadata")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string metadata = gdpicturePDF.GetMetadata();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The metadata of this PDF are:\n" + metadata, "Example: GetMetadata");
}
else
{
MessageBox.Show("The GetMetadata() method has failed with the status: " + status.ToString(), "Example: GetMetadata");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetMetadata");
}
}
Sets up a new title of the currently loaded PDF document into the document information dictionary and into the document catalog's metadata as well.
If the loaded PDF document contains metadata stored in the Metadata entry in the document catalog, the newly specified Title property is synchronized
with those metadata. That means, you will be able to see the changed value of this property using the Acrobat's Document Properties dialogue box.
A new value of the Title property as a string.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that the newly specified Title property is synchronized with existing metadata, if any are included in the loaded PDF document.
How to set up a new title of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim title As String = gdpicturePDF.GetTitle()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The original title of this PDF is: " + title, "Example: SetTitle")
gdpicturePDF.SetTitle("This is a new title.")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
title = gdpicturePDF.GetTitle()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The new title of this PDF is: " + title, "Example: SetTitle")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetTitle")
End If
Else
MessageBox.Show("The SetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle")
End If
Else
MessageBox.Show("The GetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetTitle")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string title = gdpicturePDF.GetTitle();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The original title of this PDF is: " + title, "Example: SetTitle");
gdpicturePDF.SetTitle("This is a new title.");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
title = gdpicturePDF.GetTitle();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The new title of this PDF is: " + title, "Example: SetTitle");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetTitle");
}
}
else
{
MessageBox.Show("The SetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle");
}
}
else
{
MessageBox.Show("The GetTitle() method has failed with the status: " + status.ToString(), "Example: SetTitle");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetTitle");
}
}
Sets up a new author of the currently loaded PDF document into the document information dictionary and in the document catalog's metadata as well.
If the loaded PDF document contains metadata stored in the Metadata entry in the document catalog, the newly specified Author property is synchronized
with those metadata. That means, you will be able to see the changed value of this property using the Acrobat's Document Properties dialogue box.
A new value of the Author property as a string.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that the newly specified Author property is synchronized with existing metadata, if any are included in the loaded PDF document.
How to set up who is the author of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim author As String = gdpicturePDF.GetAuthor()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The author of this PDF is: " + author, "Example: SetAuthor")
gdpicturePDF.SetAuthor(author + " Victor Hugo")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
author = gdpicturePDF.GetAuthor()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The author of this PDF was set properly." + vbCrLf + "The new author is: " + author, "Example: SetAuthor")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetAuthor")
End If
Else
MessageBox.Show("The SetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor")
End If
Else
MessageBox.Show("The GetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetAuthor")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string author = gdpicturePDF.GetAuthor();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The author of this PDF is: " + author, "Example: SetAuthor");
gdpicturePDF.SetAuthor(author + " Victor Hugo");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
author = gdpicturePDF.GetAuthor();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The author of this PDF was set properly.\nThe new author is: " + author, "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The SetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The GetAuthor() method has failed with the status: " + status.ToString(), "Example: SetAuthor");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetAuthor");
}
}
Sets up a new producer of the currently loaded PDF document into the document information dictionary and in the document catalog's metadata as well.
If the loaded PDF document contains metadata stored in the Metadata entry in the document catalog, the newly specified Producer property is synchronized
with those metadata. That means, you will be able to see the changed value of this property using the Acrobat's Document Properties dialogue box.
A new value of the Producer property as a string.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that the newly specified Producer property is synchronized with existing metadata, if any are included in the loaded PDF document.
How to set up a new producer of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim producer As String = gdpicturePDF.GetProducer()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The original producer of this PDF is: " + producer, "Example: SetProducer")
gdpicturePDF.SetProducer("GdPicture.Net")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
producer = gdpicturePDF.GetProducer()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The new producer of this PDF is: " + producer, "Example: SetProducer")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetProducer")
End If
Else
MessageBox.Show("The SetProducer() method has failed with the status: " + status.ToString(), "Example: SetProducer")
End If
Else
MessageBox.Show("The GetProducer() method has failed with the status: " + status.ToString(), "Example: SetProducer")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetProducer")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string producer = gdpicturePDF.GetProducer();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The original producer of this PDF is: " + producer, "Example: SetProducer");
gdpicturePDF.SetProducer("GdPicture.Net");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
producer = gdpicturePDF.GetProducer();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The new producer of this PDF is: " + producer, "Example: SetProducer");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetProducer");
}
}
else
{
MessageBox.Show("The SetProducer() method has failed with the status: " + status.ToString(), "Example: SetProducer");
}
}
else
{
MessageBox.Show("The GetProducer() method has failed with the status: " + status.ToString(), "Example: SetProducer");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetProducer");
}
}
Sets up a new creator of the currently loaded PDF document into the document information dictionary and in the document catalog's metadata as well.
If the loaded PDF document contains metadata stored in the Metadata entry in the document catalog, the newly specified Creator property is synchronized
with those metadata. That means, you will be able to see the changed value of this property using the Acrobat's Document Properties dialogue box.
A new value of the Creator property as a string.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that the newly specified Creator property is synchronized with existing metadata, if any are included in the loaded PDF document.
How to set up a new creator of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim creator As String = gdpicturePDF.GetCreator()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The original creator of this PDF is: " + creator, "Example: SetCreator")
gdpicturePDF.SetCreator("GdPicture")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
creator = gdpicturePDF.GetCreator()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The new creator of this PDF is: " + creator, "Example: SetCreator")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetCreator")
End If
Else
MessageBox.Show("The SetCreator() method has failed with the status: " + status.ToString(), "Example: SetCreator")
End If
Else
MessageBox.Show("The GetCreator() method has failed with the status: " + status.ToString(), "Example: SetCreator")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetCreator")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string creator = gdpicturePDF.GetCreator();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The original creator of this PDF is: " + creator, "Example: SetCreator");
gdpicturePDF.SetCreator("GdPicture");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
creator = gdpicturePDF.GetCreator();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The new creator of this PDF is: " + creator, "Example: SetCreator");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetCreator");
}
}
else
{
MessageBox.Show("The SetCreator() method has failed with the status: " + status.ToString(), "Example: SetCreator");
}
}
else
{
MessageBox.Show("The GetCreator() method has failed with the status: " + status.ToString(), "Example: SetCreator");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetCreator");
}
}
Sets up a new subject of the currently loaded PDF document into the document information dictionary and in the document catalog's metadata as well.
If the loaded PDF document contains metadata stored in the Metadata entry in the document catalog, the newly specified Subject property is synchronized
with those metadata. That means, you will be able to see the changed value of this property using the Acrobat's Document Properties dialogue box.
A new value of the Subject property as a string.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that the newly specified Subject property is synchronized with existing metadata, if any are included in the loaded PDF document.
How to set up a new subject of the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim subject As String = gdpicturePDF.GetSubject()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The original subject of this PDF is: " + subject, "Example: SetSubject")
gdpicturePDF.SetSubject("Test GdPicture working on PDFs.")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
subject = gdpicturePDF.GetSubject()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The new subject of this PDF is: " + subject, "Example: SetSubject")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetSubject")
End If
Else
MessageBox.Show("The SetSubject() method has failed with the status: " + status.ToString(), "Example: SetSubject")
End If
Else
MessageBox.Show("The GetSubject() method has failed with the status: " + status.ToString(), "Example: SetSubject")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetSubject")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string subject = gdpicturePDF.GetSubject();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The original subject of this PDF is: " + subject, "Example: SetSubject");
gdpicturePDF.SetSubject("Test GdPicture working on PDFs.");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
subject = gdpicturePDF.GetSubject();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The new subject of this PDF is: " + subject, "Example: SetSubject");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetSubject");
}
}
else
{
MessageBox.Show("The SetSubject() method has failed with the status: " + status.ToString(), "Example: SetSubject");
}
}
else
{
MessageBox.Show("The GetSubject() method has failed with the status: " + status.ToString(), "Example: SetSubject");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetSubject");
}
}
Sets up new keywords associated with the currently loaded PDF document into the document information dictionary and in the document catalog's metadata as well.
If the loaded PDF document contains metadata stored in the Metadata entry in the document catalog, the newly specified Keywords are synchronized
with those metadata. That means, you will be able to see the changed value of this property using the Acrobat's Document Properties dialogue box.
At the same, if you need to add and store any kind of structured information into your existing document, you can also use the method instead.
Please use comma or semi-colon as word separators in the specified Keywords parameter for single keywords.
A new value of the Keywords property as a string.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that the newly specified Keywords are fully synchronized with existing metadata, if any are included in the loaded PDF document.
Likewise, you can also use the method to store any kind of structured information there.
How to set up new keywords associated with your already existing or newly created PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim keywords As String = gdpicturePDF.GetKeywords()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The original keywords of this PDF are: " + keywords, "Example: SetKeywords")
'These keywords are stored in the document information dictionary.
gdpicturePDF.SetKeywords("For Whom the Bell Tolls,Indian Camp,The Sun Also Rises,A Farewell to Arms,The Old Man and the Sea")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
keywords = gdpicturePDF.GetKeywords()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The new keywords of this PDF are: " + keywords, "Example: SetKeywords")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetKeywords")
End If
Else
MessageBox.Show("The SetKeywords() method has failed with the status: " + status.ToString(), "Example: SetKeywords")
End If
Else
MessageBox.Show("The GetKeywords() method has failed with the status: " + status.ToString(), "Example: SetKeywords")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetKeywords")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string keywords = gdpicturePDF.GetKeywords();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The original keywords of this PDF are: " + keywords, "Example: SetKeywords");
//These keywords are stored in the document information dictionary.
gdpicturePDF.SetKeywords("For Whom the Bell Tolls,Indian Camp,The Sun Also Rises,A Farewell to Arms,The Old Man and the Sea");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
keywords = gdpicturePDF.GetKeywords();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The new keywords of this PDF are: " + keywords, "Example: SetKeywords");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetKeywords");
}
}
else
{
MessageBox.Show("The SetKeywords() method has failed with the status: " + status.ToString(), "Example: SetKeywords");
}
}
else
{
MessageBox.Show("The GetKeywords() method has failed with the status: " + status.ToString(), "Example: SetKeywords");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetKeywords");
}
}
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF(PdfConformance.PDF_A_1b) = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
If status = GdPictureStatus.OK Then
'Create your own PDF content here.
'...
'These keywords are stored in the document catalog dictionary as the structured metadata.
gdpicturePDF.SetKeywords("For Whom the Bell Tolls,Indian Camp,The Sun Also Rises,A Farewell to Arms,The Old Man and the Sea")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
Dim keywords As String = gdpicturePDF.GetKeywords()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The new keywords of this PDF are: " + keywords, "Example: SetKeywords")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetKeywords")
End If
Else
MessageBox.Show("The SetKeywords() method has failed with the status: " + status.ToString(), "Example: SetKeywords")
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), "Example: SetKeywords")
End If
Else
MessageBox.Show("The file can't be created.", "Example: SetKeywords")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.NewPDF(PdfConformance.PDF_A_1b) == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
if (status == GdPictureStatus.OK)
{
//Create your own PDF content here.
//...
//These keywords are stored in the document catalog dictionary as the structured metadata.
gdpicturePDF.SetKeywords("For Whom the Bell Tolls,Indian Camp,The Sun Also Rises,A Farewell to Arms,The Old Man and the Sea");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
string keywords = gdpicturePDF.GetKeywords();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The new keywords of this PDF are: " + keywords, "Example: SetKeywords");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetKeywords");
}
}
else
{
MessageBox.Show("The SetKeywords() method has failed with the status: " + status.ToString(), "Example: SetKeywords");
}
}
else
{
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), "Example: SetKeywords");
}
}
else
{
MessageBox.Show("The file can't be created.", "Example: SetKeywords");
}
}
Sets up a metadata of the currently loaded PDF document according to what you have specified.
The toolkit supports XMP format of metadata, which is the standard for embedding metadata in files.
For further assistance, please refer to the core XMP specification published as ISO standard 16684-1.
A new value of the metadata as a string in the XMP standardized format.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that the currently stored metadata entries will be overwritten according to the values you have specified.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add or replace the specified metadata of the PDF document.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
'Let's say that metadata.xmp are your required metadata you want to add/replace.
Dim metadataFile As System.IO.StreamReader = New System.IO.StreamReader("metadata.xmp")
Dim xmp As String = metadataFile.ReadToEnd()
metadataFile.Close()
'Now you can change the metadata here.
If gdpicturePDF.SetMetadata(xmp) = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test.pdf") = GdPictureStatus.OK Then
xmp = gdpicturePDF.GetMetadata()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The changed metadata are:" + vbCrLf + xmp, "Example: SetMetadata")
End If
Else
MessageBox.Show("The file can't be saved.", "Example: SetMetadata")
End If
Else
MessageBox.Show("The SetMetadata() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), "Example: SetMetadata")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetMetadata")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
//Let's say that metadata.xmp are your required metadata you want to add/replace.
System.IO.StreamReader metadataFile = new System.IO.StreamReader("metadata.xmp");
string xmp = metadataFile.ReadToEnd();
metadataFile.Close();
//Now you can change the metadata here.
if (gdpicturePDF.SetMetadata(xmp) == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test.pdf") == GdPictureStatus.OK)
{
xmp = gdpicturePDF.GetMetadata();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The changed metadata are:\n" + xmp, "Example: SetMetadata");
}
}
else
{
MessageBox.Show("The file can't be saved.", "Example: SetMetadata");
}
}
else
{
MessageBox.Show("The SetMetadata() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), "Example: SetMetadata");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetMetadata");
}
}
Removes PDF/A conformance claim from currrently loaded PDF document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Sets up different viewer preference settings. These preferences, if defined, control the way the document is to be presented on the screen in Adobe Reader or Acrobat viewer.
A member of the PdfViewerPreference enumeration. You have to specify the name of the preference you want to enable or disable.
Set this parameter to true if you want to enable the specified preference setting. If you set this parameter to false, the specified preference setting will be disabled.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to enable or disable required viewer preference settings.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
'The specified preference will be enabled.
status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceFitWindow, True)
If status = GdPictureStatus.OK Then
'The specified preference will be enabled.
status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceHideWindowUI, True)
If status = GdPictureStatus.OK Then
'The specified preference will be disabled.
status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceDisplayDocTitle, False)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_SetViewerPreference_func.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("Your specified preference settings have been set successfully.", "Example: SetViewerPreference")
End If
Else
MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference")
End If
Else
MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference")
End If
Else
MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetViewerPreference")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
'The specified preference will be enabled.
status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceFitWindow, true);
if (status == GdPictureStatus.OK)
{
'The specified preference will be enabled.
status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceHideWindowUI, true);
if (status == GdPictureStatus.OK)
{
'The specified preference will be disabled.
status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceDisplayDocTitle, false);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_SetViewerPreference_func.pdf", false) == GdPictureStatus.OK)
MessageBox.Show("Your specified preference settings have been set successfully.", "Example: SetViewerPreference");
}
else
{
MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference");
}
}
else
{
MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference");
}
}
else
{
MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetViewerPreference");
}
gdpicturePDF.Dispose();
Finds out if the specified viewer preference setting is enabled or not. These preferences, if defined, control the way the document is to be presented on the screen in Adobe Reader or Acrobat viewer.
A member of the PdfViewerPreference enumeration. You have to specify the name of the preference you want to find out if it is enabled or not.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the specified preference is enabled, otherwise false. The default value is false.
The method can be subsequently used to determine if this method has been successful.
How to find out which viewer preference settings are enabled and which are disabled.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim PreferenceFound As Boolean
PreferenceFound = gdpicturePDF.GetViewerPreference(PdfViewerPreference.PdfViewerPreferenceCenterWindow)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The required preference is defined for the currently loaded PDF document.
If PreferenceFound = True Then
'The preference is enabled.
MessageBox.Show("The position of the document's window is set to be in the center of the screen.", "Example: GetViewerPreference")
Else
'The preference is disabled.
MessageBox.Show("The position of the document's window is set not to be in the center of the screen.", "Example: GetViewerPreference")
End If
Else
MessageBox.Show("The GetViewerPreference() method has failed with the status: " + status.ToString(), "Example: GetViewerPreference")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetViewerPreference")
End If
gdpicturePDF.Dispose()
'You can do the same for other viewer preferences:
'PdfViewerPreference.PdfViewerPreferenceHideToolbar specifies that the viewer application's tool bars will be hidden when the document is active.
'PdfViewerPreference.PdfViewerPreferenceHideMenubar specifies that the viewer application's menu bar will be hidden when the document is active.
'PdfViewerPreference.PdfViewerPreferenceHideWindowUI specifies that the user interface elements in the document's window (such as scroll bars and navigation controls) will be hidden, leaving only the document's content displayed.
'PdfViewerPreference.PdfViewerPreferenceFitWindow specifies that the document's window will be resized to fit the size of the first displayed page.
'PdfViewerPreference.PdfViewerPreferenceDisplayDocTitle specifies that the window's title bar should display the document title taken from the document information dictionary.
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
bool PreferenceFound = gdpicturePDF.GetViewerPreference(PdfViewerPreference.PdfViewerPreferenceCenterWindow);
status = gdpicturePDF.GetStat();
//The required preference is defined for the currently loaded PDF document.
if (status == GdPictureStatus.OK)
{
if (PreferenceFound)
{
//The preference is enabled.
MessageBox.Show("The position of the document's window is set to be in the center of the screen.", "Example: GetViewerPreference");
}
else
{
//The preference is disabled.
MessageBox.Show("The position of the document's window is set not to be in the center of the screen.", "Example: GetViewerPreference");
}
}
else
{
MessageBox.Show("The GetViewerPreference() method has failed with the status: " + status.ToString(), "Example: GetViewerPreference");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetViewerPreference");
}
gdpicturePDF.Dispose();
//You can do the same for other viewer preferences:
//PdfViewerPreference.PdfViewerPreferenceHideToolbar specifies that the viewer application's tool bars will be hidden when the document is active.
//PdfViewerPreference.PdfViewerPreferenceHideMenubar specifies that the viewer application's menu bar will be hidden when the document is active.
//PdfViewerPreference.PdfViewerPreferenceHideWindowUI specifies that the user interface elements in the document's window (such as scroll bars and navigation controls) will be hidden, leaving only the document's content displayed.
//PdfViewerPreference.PdfViewerPreferenceFitWindow specifies that the document's window will be resized to fit the size of the first displayed page.
//PdfViewerPreference.PdfViewerPreferenceDisplayDocTitle specifies that the window's title bar should display the document title taken from the document information dictionary.
Sets the document's page mode setting, specifying how the document should be displayed when opened in Adobe Reader or Acrobat viewer.
A member of the PdfViewerPageMode enumeration. Set this parameter according to your preference.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the viewer page mode to display the PDF document in full-screen mode on opening.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetViewerPageMode(PdfViewerPageMode.PdfViewerPageModeFullScreen)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_SetViewerPageMode_func.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("The viewer page mode has been set successfully.", "Example: SetViewerPageMode")
End If
Else
MessageBox.Show("The SetViewerPageMode() method has failed with the status: " + status.ToString(), "Example: SetViewerPageMode")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetViewerPageMode")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetViewerPageMode(PdfViewerPageMode.PdfViewerPageModeFullScreen);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_SetViewerPageMode_func.pdf", false) == GdPictureStatus.OK)
MessageBox.Show("The viewer page mode has been set successfully.", "Example: SetViewerPageMode");
}
else
{
MessageBox.Show("The SetViewerPageMode() method has failed with the status: " + status.ToString(), "Example: SetViewerPageMode");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetViewerPageMode");
}
gdpicturePDF.Dispose();
Returns the document's page mode setting, specifying how the document should be displayed when opened in Adobe Reader or Acrobat viewer.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfViewerPageMode enumeration. The default value is PdfViewerPageMode.PdfViewerPageModeUseNone.
The method can be subsequently used to determine if this method has been successful.
How to find out the way your document will display on opening.
Dim caption As String = "Example: GetViewerPageMode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim oPdfViewerPageMode As PdfViewerPageMode = gdpicturePDF.GetViewerPageMode()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Select Case oPdfViewerPageMode
Case PdfViewerPageMode.PdfViewerPageModeUseNone
MessageBox.Show("Neither document outline nor thumbnail images are visible.", caption)
Case PdfViewerPageMode.PdfViewerPageModeUseOutlines
MessageBox.Show("Document outline is visible.", caption)
Case PdfViewerPageMode.PdfViewerPageModeUseThumbs
MessageBox.Show("Thumbnail images are visible.", caption)
Case PdfViewerPageMode.PdfViewerPageModeFullScreen
MessageBox.Show("Full-screen mode, with no menu bar, window controls, or any other window is visible.", caption)
Case PdfViewerPageMode.PdfViewerPageModeUseOC
MessageBox.Show("(PDF 1.5) Optional content group panel is visible.", caption)
Case PdfViewerPageMode.PdfViewerPageModeUseAttachments
MessageBox.Show("(PDF 1.6) Attachments panel is visible.", caption)
Case Else
MessageBox.Show("Invalid value has been returned.", caption)
End Select
Else
MessageBox.Show("The GetViewerPageMode() method has failed.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetViewerPageMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
PdfViewerPageMode oPdfViewerPageMode = gdpicturePDF.GetViewerPageMode();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
switch (oPdfViewerPageMode)
{
case PdfViewerPageMode.PdfViewerPageModeUseNone:
MessageBox.Show("Neither document outline nor thumbnail images are visible.", caption);
break;
case PdfViewerPageMode.PdfViewerPageModeUseOutlines:
MessageBox.Show("Document outline is visible.", caption);
break;
case PdfViewerPageMode.PdfViewerPageModeUseThumbs:
MessageBox.Show("Thumbnail images are visible.", caption);
break;
case PdfViewerPageMode.PdfViewerPageModeFullScreen:
MessageBox.Show("Full-screen mode, with no menu bar, window controls, or any other window is visible.", caption);
break;
case PdfViewerPageMode.PdfViewerPageModeUseOC:
MessageBox.Show("(PDF 1.5) Optional content group panel is visible.", caption);
break;
case PdfViewerPageMode.PdfViewerPageModeUseAttachments:
MessageBox.Show("(PDF 1.6) Attachments panel is visible.", caption);
break;
default:
MessageBox.Show("Invalid value has been returned.", caption);
break;
}
}
else
{
MessageBox.Show("The GetViewerPageMode() method has failed.", caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the document's page mode setting, specifying how to display the document on exiting full-screen mode when viewing the document in Adobe Reader or Acrobat viewer.
This setting is only meaningful if the value returned by the method is PdfViewerPageMode.PdfViewerPageModeFullScreen. It is ignored otherwise.
A member of the PdfViewerNonFullScreenPageMode enumeration. Set this parameter according to your preference.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set thumbnail images to be visible when exiting the full-screen page mode.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetViewerPageMode(PdfViewerPageMode.PdfViewerPageModeFullScreen)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetViewerNonFullScreenPageMode(PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseThumbs)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_SetViewerNonFullScreenPageMode_func.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("The page mode has been set successfully.", "Example: SetViewerNonFullScreenPageMode")
End If
Else
MessageBox.Show("The SetViewerNonFullScreenPageMode() method has failed with the status: " + status.ToString(), "Example: SetViewerNonFullScreenPageMode")
End If
Else
MessageBox.Show("The SetViewerPageMode() method has failed with the status: " + status.ToString(), "Example: SetViewerNonFullScreenPageMode")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetViewerNonFullScreenPageMode")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetViewerPageMode(PdfViewerPageMode.PdfViewerPageModeFullScreen);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetViewerNonFullScreenPageMode(PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseThumbs);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_SetViewerNonFullScreenPageMode_func.pdf", false) == GdPictureStatus.OK)
MessageBox.Show("The page mode has been set successfully.", "Example: SetViewerNonFullScreenPageMode");
}
else
{
MessageBox.Show("The SetViewerNonFullScreenPageMode() method has failed with the status: " + status.ToString(), "Example: SetViewerNonFullScreenPageMode");
}
}
else
{
MessageBox.Show("The SetViewerPageMode() method has failed with the status: " + status.ToString(), "Example: SetViewerNonFullScreenPageMode");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetViewerNonFullScreenPageMode");
}
gdpicturePDF.Dispose();
Returns the document's page mode setting, specifying how to display the document on exiting full-screen mode when viewing the document in Adobe Reader or Acrobat viewer.
This setting is only meaningful if the value returned by the method is PdfViewerPageMode.PdfViewerPageModeFullScreen. It is ignored otherwise.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfViewerNonFullScreenPageMode enumeration. The default value is PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseNone.
The method can be subsequently used to determine if this method has been successful.
How to find out the way your document will display on exiting full-screen mode.
Dim caption As String = "Example: GetViewerNonFullScreenPageMode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim oNonFullScreenPageMode As PdfViewerNonFullScreenPageMode = gdpicturePDF.GetViewerNonFullScreenPageMode()
status = gdpicturePDF.GetStat()
if status= GdPictureStatus.OK Then
Select Case oNonFullScreenPageMode
Case PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseNone
MessageBox.Show("Neither document outline nor thumbnail images are visible.", caption)
Case PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseOutlines
MessageBox.Show("Document outline is visible.", caption)
Case PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseThumbs
MessageBox.Show("Thumbnail images are visible.", caption)
Case PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseOC
MessageBox.Show("Optional content group panel is visible.", caption)
Case Else
MessageBox.Show("An invalid value has been returned.", caption)
End Select
Else
MessageBox.Show("The GetViewerNonFullScreenPageMode() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetViewerNonFullScreenPageMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
PdfViewerNonFullScreenPageMode oNonFullScreenPageMode = gdpicturePDF.GetViewerNonFullScreenPageMode();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
switch (oNonFullScreenPageMode)
{
case PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseNone:
MessageBox.Show("Neither document outline nor thumbnail images are visible.", caption);
break;
case PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseOutlines:
MessageBox.Show("Document outline is visible.", caption);
break;
case PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseThumbs:
MessageBox.Show("Thumbnail images are visible.", caption);
break;
case PdfViewerNonFullScreenPageMode.PdfViewerNonFullScreenPageModeUseOC:
MessageBox.Show("Optional content group panel is visible.", caption);
break;
default:
MessageBox.Show("An invalid value has been returned.", caption);
break;
}
}
else
{
MessageBox.Show("The GetViewerNonFullScreenPageMode() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the document's layout mode setting, specifying the page layout to be used when the document is opened in Adobe Reader or Acrobat viewer.
A member of the PdfViewerLayoutMode enumeration. Set this parameter according to your preference.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the PDF document's page layout mode to display a single page at a time.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetViewerLayoutMode(PdfViewerLayoutMode.PdfViewerLayoutModeSinglePage)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_SetViewerLayoutMode_func.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("The page layout mode has been set successfully.", "Example: SetViewerLayoutMode")
End If
Else
MessageBox.Show("The SetViewerLayoutMode() method has failed with the status: " + status.ToString(), "Example: SetViewerLayoutMode")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetViewerLayoutMode")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetViewerLayoutMode(PdfViewerLayoutMode.PdfViewerLayoutModeSinglePage);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_SetViewerLayoutMode_func.pdf", false) == GdPictureStatus.OK)
MessageBox.Show("The page layout mode has been set successfully.", "Example: SetViewerLayoutMode");
}
else
{
MessageBox.Show("The SetViewerLayoutMode() method has failed with the status: " + status.ToString(), "Example: SetViewerLayoutMode");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetViewerLayoutMode");
}
gdpicturePDF.Dispose();
Returns the document's layout mode setting, specifying the page layout to be used when the document is opened in Adobe Reader or Acrobat viewer.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfViewerLayoutMode enumeration. The default value is PdfViewerLayoutMode.PdfViewerLayoutModeSinglePage.
The method can be subsequently used to determine if this method has been successful.
How to find out the current page layout mode of the PDF document.
Dim caption As String = "Example: GetViewerLayoutMode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim oLayoutMode As PdfViewerLayoutMode = gdpicturePDF.GetViewerLayoutMode()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Select Case oLayoutMode
Case PdfViewerLayoutMode.PdfViewerLayoutModeSinglePage
MessageBox.Show("This PDF displays one page at a time.", caption)
Case PdfViewerLayoutMode.PdfViewerLayoutModeOneColumn
MessageBox.Show("This PDF displays the pages in one column.", caption)
Case PdfViewerLayoutMode.PdfViewerLayoutModeTwoColumnLeft
MessageBox.Show("This PDF displays the pages in two columns, with odd-numbered pages on the left.", caption)
Case PdfViewerLayoutMode.PdfViewerLayoutModeTwoColumnRight
MessageBox.Show("This PDF displays the pages in two columns, with odd-numbered pages on the right.", caption)
Case PdfViewerLayoutMode.PdfViewerLayoutModeTwoPageLeft
MessageBox.Show("This PDF displays the pages two at a time, with odd-numbered pages on the left.", caption)
Case PdfViewerLayoutMode.PdfViewerLayoutModeTwoPageRight
MessageBox.Show("This PDF displays the pages two at a time, with odd-numbered pages on the right.", caption)
Case Else
MessageBox.Show("An invalid value has been returned.", caption)
End Select
Else
MessageBox.Show("The GetViewerLayoutMode() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetViewerLayoutMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
PdfViewerLayoutMode oLayoutMode = gdpicturePDF.GetViewerLayoutMode();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
switch (oLayoutMode)
{
case PdfViewerLayoutMode.PdfViewerLayoutModeSinglePage:
MessageBox.Show("This PDF displays one page at a time.", caption);
break;
case PdfViewerLayoutMode.PdfViewerLayoutModeOneColumn:
MessageBox.Show("This PDF displays the pages in one column.", caption);
break;
case PdfViewerLayoutMode.PdfViewerLayoutModeTwoColumnLeft:
MessageBox.Show("This PDF displays the pages in two columns, with odd-numbered pages on the left.", caption);
break;
case PdfViewerLayoutMode.PdfViewerLayoutModeTwoColumnRight:
MessageBox.Show("This PDF displays the pages in two columns, with odd-numbered pages on the right.", caption);
break;
case PdfViewerLayoutMode.PdfViewerLayoutModeTwoPageLeft:
MessageBox.Show("This PDF displays the pages two at a time, with odd-numbered pages on the left.", caption);
break;
case PdfViewerLayoutMode.PdfViewerLayoutModeTwoPageRight:
MessageBox.Show("This PDF displays the pages two at a time, with odd-numbered pages on the right.", caption);
break;
default:
MessageBox.Show("An invalid value has been returned.", caption);
break;
}
}
else
{
MessageBox.Show("The GetViewerLayoutMode() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns if the currently loaded PDF document contains any executable JavaScript actions.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the currently loaded PDF document contains any JavaScript actions, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to find out if the PDF document contains JavaScript actions.
Dim caption As String = "Example: HasJavaScript"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("sample.pdf", False) = GdPictureStatus.OK Then
Dim hasJS As Boolean = gdpicturePDF.HasJavaScript()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If hasJS Then
MessageBox.Show("This PDF document contains JavaScript.", caption)
Else
MessageBox.Show("This PDF document contains NO JavaScript.", caption)
End If
Else
MessageBox.Show("The HasJavaScript() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: HasJavaScript";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("sample.pdf", false) == GdPictureStatus.OK)
{
bool hasJS = gdpicturePDF.HasJavaScript();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (hasJS)
MessageBox.Show("This PDF document contains JavaScript.", caption);
else
MessageBox.Show("This PDF document contains NO JavaScript.", caption);
}
else
MessageBox.Show("The HasJavaScript() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Embeds (attaches) a file specified by its file path into the currently loaded PDF document. You can also add a verbal description of
this attachment. The specified file is embedded (attached) into the source PDF file and can be displayed in a special viewer panel in most PDF viewers.
The file path of the file to embed. Any kind of file, and any numbers of files, can be embedded into a PDF file.
The verbal description of this attachment, for example, a purpose of embedding this file.
This method is only allowed for use with non-encrypted documents.
The file title for the embedded file is set to the file name of this embedded file without the file extension.
You also need to be aware that embedded files are forbidden in PDF/A-1. But PDF/A-2 allows embedding of PDF/A files, facilitating the archiving of sets
of PDF/A documents in a single file. PDF/A-3 allows embedding of any file format such as XML, CAD and others into PDF/A documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Embedding a text file into the PDF document.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
{
gdpicturePDF.LoadFromFile("document.pdf", True)
gdpicturePDF.EmbedFile("textfile.txt", "Text Attachment")
gdpicturePDF.SaveToFile("document.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("document.pdf", true);
gdpicturePDF.EmbedFile("textfile.txt", "Text Attachment");
gdpicturePDF.SaveToFile("document.pdf");
}
Embeds (attaches) a file data from a previously instantiated Stream object into the currently loaded PDF document under the provided file title.
You can also add a verbal description of this attachment. The file data is embedded (attached) into the source PDF file and can be displayed in a special viewer panel in most PDF viewers.
Embeds (attaches) a specified file or a file data into the currently loaded PDF document. The embedded file or file data can be displayed in a special viewer panel in most PDF viewers.
The stream that contains file data to embed. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Any kind of file data, and any numbers of files, can be embedded into a PDF file.
The file title to use for the embedded file data.
The verbal description of this attachment, for example, a purpose of embedding this file.
This method is only allowed for use with non-encrypted documents.
Also be aware that the provided stream should remain open and can only be closed/disposed of by the user.
You also need to be aware that embedded files are forbidden in PDF/A-1. But PDF/A-2 allows embedding of PDF/A files, facilitating the archiving of sets
of PDF/A documents in a single file. PDF/A-3 allows embedding of any file format such as XML, CAD and others into PDF/A documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Embedding a text file into the PDF document using stream.
Using (gdpicturePDF As GdPicturePDF = New GdPicturePDF())
gdpicturePDF.LoadFromFile("document.pdf", True)
FileStream attachment = new FileStream("textfile.txt", FileMode.Open)
gdpicturePDF.EmbedFile(attachment, "textfile.txt", "Text Attachment")
gdpicturePDF.SaveToFile("document.pdf")
attachment.Close()
attachment.Dispose()
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("document.pdf", true);
FileStream attachment = new FileStream("textfile.txt", FileMode.Open);
gdpicturePDF.EmbedFile(attachment, "textfile.txt", "Text Attachment");
gdpicturePDF.SaveToFile("document.pdf");
attachment.Close();
attachment.Dispose();
}
Embeds (attaches) a invoice data from file specified by the file path into the currently loaded PDF document.
The file path of the file to embed. Any kind of file, and any numbers of files, can be embedded into a PDF file.
A member of the PdfInvoiceDataFormat enumeration, specifying the embedded xml invoice data format.
This method is only allowed for use with non-encrypted documents.
This method is only usable for PDF/A-3 documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Embedding a text file into the PDF document.
Using gdpicturePDF = New GdPicturePDF()
{
gdpicturePDF.LoadFromFile("pdfa3.pdf", True)
gdpicturePDF.EmbedInvoiceData("factur-x.xml", PdfInvoiceDataFormat.FacturX_1_0)
gdpicturePDF.SaveToFile("facturx_document.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("pdfa3.pdf", true);
gdpicturePDF.EmbedInvoiceData("factur-x.xml", PdfInvoiceDataFormat.FacturX_1_0);
gdpicturePDF.SaveToFile("facturx_document.pdf");
}
Embeds (attaches) a invoice data from a previously instantiated Stream object into the currently loaded PDF document.
The stream that contains invoice data to embed.
A member of the PdfInvoiceDataFormat enumeration, specifying the embedded xml invoice data format.
This method is only allowed for use with non-encrypted documents.
This method is only usable for PDF/A-3 documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Embedding a text file into the PDF document using stream.
Using gdpicturePDF = New GdPicturePDF()
gdpicturePDF.LoadFromFile("pdfa3.pdf", True)
FileStream fs = new FileStream("factur-x.xml", FileMode.Open)
gdpicturePDF.EmbedInvoiceData(fs, "Text Attachment")
gdpicturePDF.SaveToFile("facturx_document.pdf")
fs.Close()
fs.Dispose()
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("pdfa3.pdf", true);
FileStream fs = new FileStream("factur-x.xml", FileMode.Open);
gdpicturePDF.EmbedInvoiceData(fs, PdfInvoiceDataFormat.FacturX_1_0);
gdpicturePDF.SaveToFile("facturx_document.pdf");
fs.Close();
fs.Dispose();
}
Gets the number of all embedded (attached) files in your currently loaded PDF document.
Embedded files, so called File Attachments, can be included as a whole directly to a PDF document. Be aware that PDF documents can also contain
attached files as part of the file attachment annotations. You can refer
to our examples
how to extract embedded files in both ways.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of all embedded files. The method can be subsequently used to determine if this method has been successful.
How to find out the number of all embedded files within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileCount"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF document contains " + embeddedFileCount.ToString() + " embedded files.", caption)
Else
MessageBox.Show("The GetEmbeddedFileCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEmbeddedFileCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("This PDF document contains " + embeddedFileCount.ToString() + " embedded files.", caption);
}
else
{
MessageBox.Show("The GetEmbeddedFileCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Gets the file size of an embedded file (the size of an attached file) within the currently loaded PDF document, in bytes. You need to specify this attachment by its 0-based index.
The 0-based index of the embedded file. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The size of the embedded file, in bytes. It is the current size in bytes of the attached file.
The method can be subsequently used to determine if this method has been successful.
How to find out the file size of the first embedded file within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileSize"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If embeddedFileCount = 0 Then
MessageBox.Show("This PDF file does not contain embedded files.", caption)
Else
Dim fsize As Integer = gdpicturePDF.GetEmbeddedFileSize(0)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The file size of the first embedded file is: " + fsize.ToString(), caption)
Else
MessageBox.Show("The GetEmbeddedFileSize() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEmbeddedFileSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (embeddedFileCount == 0)
{
MessageBox.Show("This PDF file does not contain embedded files.", caption);
}
else
{
int fsize = gdpicturePDF.GetEmbeddedFileSize(0);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file size of the first embedded file is: " + fsize.ToString(), caption);
}
else
{
MessageBox.Show("The GetEmbeddedFileSize() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Gets the file name of an embedded file (the attachment's file name) within the currently loaded PDF document.
You need to specify this attachment by its 0-based index.
The 0-based index of the embedded file. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The file name of the embedded file. It is the attachment's current file name with its file extension.
The method can be subsequently used to determine if this method has been successful.
How to find out the file name of the first embedded file within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileName"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If embeddedFileCount = 0 Then
MessageBox.Show("This PDF file does not contain embedded files.", caption)
Else
Dim fname As String = gdpicturePDF.GetEmbeddedFileName(0)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The file name of the first embedded file is: " + fname, caption)
Else
MessageBox.Show("The GetEmbeddedFileName() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEmbeddedFileName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (embeddedFileCount == 0)
{
MessageBox.Show("This PDF file does not contain embedded files.", caption);
}
else
{
string fname = gdpicturePDF.GetEmbeddedFileName(0);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The file name of the first embedded file is: " + fname, caption);
}
else
{
MessageBox.Show("The GetEmbeddedFileName() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Gets the title of an embedded file (the title of an attached file) within the currently loaded PDF document.
You need to specify this attachment by its 0-based index.
The 0-based index of the embedded file. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The title of the embedded file. The method can be subsequently used to determine if this method has been successful.
Mostly it is the whole file name of the embedded file with the file extension. If your files have been embedded using the method,
the return value is only the file name of the embedded file without the file extension.
How to find out the title of the first embedded file within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileTitle"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If embeddedFileCount = 0 Then
MessageBox.Show("This PDF file does not contain embedded files.", caption)
Else
Dim title As String = gdpicturePDF.GetEmbeddedFileTitle(0)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The file title of the first embedded file is: " + title, caption)
Else
MessageBox.Show("The GetEmbeddedFileTitle() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEmbeddedFileTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (embeddedFileCount == 0)
{
MessageBox.Show("This PDF file does not contain embedded files.", caption);
}
else
{
string title = gdpicturePDF.GetEmbeddedFileTitle(0);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The title of the first embedded file is: " + title, caption);
}
else
{
MessageBox.Show("The GetEmbeddedFileTitle() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Gets the description of an embedded file (the attachment's description) within the currently loaded PDF document. You need to specify this attachment by its 0-based index.
The 0-based index of the embedded file. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The description of the embedded file. It is the description you have specified with embedding the file.
The method can be subsequently used to determine if this method has been successful.
How to find out the description of the first embedded file within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileDescription"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If embeddedFileCount = 0 Then
MessageBox.Show("This PDF file does not contain embedded files.", caption)
Else
Dim description As String = gdpicturePDF.GetEmbeddedFileDescription(0)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The description of the first embedded file is: " + description, caption)
Else
MessageBox.Show("The GetEmbeddedFileDescription() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEmbeddedFileDescription";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (embeddedFileCount == 0)
{
MessageBox.Show("This PDF file does not contain embedded files.", caption);
}
else
{
string description = gdpicturePDF.GetEmbeddedFileDescription(0);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The description of the first embedded file is: " + description, caption);
}
else
{
MessageBox.Show("The GetEmbeddedFileDescription() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Gets the creation date of an embedded file (the attachment's creation date) within the currently loaded PDF document. You need to specify this attachment by its 0-based index.
The 0-based index of the embedded file. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The creation date of the embedded file. It is the date when you have embedded this file into the PDF document (you have created this attachment).
The method can be subsequently used to determine if this method has been successful.
How to find out the creation date of the first embedded file within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileCreationDate"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If embeddedFileCount = 0 Then
MessageBox.Show("This PDF file does not contain embedded files.", caption)
Else
Dim creationDate As String = gdpicturePDF.GetEmbeddedFileCreationDate(0)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The creation date of the first embedded file is: " + creationDate, caption)
Else
MessageBox.Show("The GetEmbeddedFileCreationDate() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEmbeddedFileCreationDate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (embeddedFileCount == 0)
{
MessageBox.Show("This PDF file does not contain embedded files.", caption);
}
else
{
string creationDate = gdpicturePDF.GetEmbeddedFileCreationDate(0);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The creation date of the first embedded file is: " + creationDate, caption);
}
else
{
MessageBox.Show("The GetEmbeddedFileCreationDate() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Gets the modification date of an embedded file (the attachment's modification date) within the currently loaded PDF document. You need to specify this attachment by its 0-based index.
The 0-based index of the embedded file. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The modification date of the embedded file. It is the date when you have last modified this embedded file.
The method can be subsequently used to determine if this method has been successful.
How to find out the modification date of the first embedded file within the PDF document.
Dim caption As String = "Example: GetEmbeddedFileModificationDate"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If embeddedFileCount = 0 Then
MessageBox.Show("This PDF file does not contain embedded files.", caption)
Else
Dim modDate As String = gdpicturePDF.GetEmbeddedFileModificationDate(0)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The modification date of the first embedded file is: " + modDate, caption)
Else
MessageBox.Show("The GetEmbeddedFileModificationDate() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetEmbeddedFileModificationDate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (embeddedFileCount == 0)
{
MessageBox.Show("This PDF file does not contain embedded files.", caption);
}
else
{
string modDate = gdpicturePDF.GetEmbeddedFileModificationDate(0);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The modification date of the first embedded file is: " + modDate, caption);
}
else
{
MessageBox.Show("The GetEmbeddedFileModificationDate() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Gets the uncompressed content of an embedded file (the content of an attached file) within the currently loaded PDF document, in bytes. You need to specify this attachment by its 0-based index.
The 0-based index of the embedded file. It must be a value from 0 to -1.
Output parameter. An array of bytes containing the uncompressed content (data) of the embedded file.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to extract and save the content of the first embedded file within the PDF document.
Dim caption As String = "Example: ExtractEmbeddedFile"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If embeddedFileCount = 0 Then
MessageBox.Show("This PDF file does not contain embedded files.", caption)
Else
Dim FileName As String = gdpicturePDF.GetEmbeddedFileName(0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim FileSize As Integer = gdpicturePDF.GetEmbeddedFileSize(0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim FileData As Byte() = New Byte(FileSize) {}
Dim status As GdPictureStatus = gdpicturePDF.ExtractEmbeddedFile(0, FileData)
If status = GdPictureStatus.OK Then
MessageBox.Show("The content of the first embedded file has been extracted successfully.", caption)
Dim oFileStream As System.IO.FileStream = Nothing
oFileStream = New System.IO.FileStream(FileName + "_content.dat", System.IO.FileMode.Create)
oFileStream.Write(FileData, 0, FileData.Length)
oFileStream.Close()
MessageBox.Show("The content has been saved successfully.", caption)
Else
MessageBox.Show("The ExtractEmbeddedFile() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ExtractEmbeddedFile";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (embeddedFileCount == 0)
{
MessageBox.Show("This PDF file does not contain embedded files.", caption);
}
else
{
string FileName = gdpicturePDF.GetEmbeddedFileName(0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int FileSize = gdpicturePDF.GetEmbeddedFileSize(0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
byte[] FileData = new byte[FileSize + 1];
GdPictureStatus status = gdpicturePDF.ExtractEmbeddedFile(0, ref FileData);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The content of the first embedded file has been extracted successfully.", caption);
System.IO.FileStream oFileStream = default(System.IO.FileStream);
oFileStream = new System.IO.FileStream(FileName + "_content.dat", System.IO.FileMode.Create);
oFileStream.Write(FileData, 0, FileData.Length);
oFileStream.Close();
MessageBox.Show("The content has been saved successfully.", caption);
}
else
{
MessageBox.Show("The ExtractEmbeddedFile() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Removes an embedded (attached) file from your currently loaded PDF document. You need to specify this attachment by its 0-based index.
The 0-based index of the embedded file you want to remove. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove the first embedded file from the PDF document.
Dim caption As String = "Example: DeleteEmbeddedFile"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", False) = GdPictureStatus.OK Then
Dim embeddedFileCount As Integer = gdpicturePDF.GetEmbeddedFileCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If embeddedFileCount = 0 Then
MessageBox.Show("This PDF file does not contain embedded files.", caption)
Else
Dim status As GdPictureStatus = gdpicturePDF.DeleteEmbeddedFile(0)
If status = GdPictureStatus.OK Then
MessageBox.Show("The attachment has been successfully removed.", caption)
If gdpicturePDF.SaveToFile("test_DeleteEmbeddedFile_func.pdf", False) <> GdPictureStatus.OK Then
MessageBox.Show("The file can't be saved.", caption)
End If
Else
MessageBox.Show("The DeleteEmbeddedFile() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DeleteEmbeddedFile";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("TestPDFWithAttachment.pdf", false) == GdPictureStatus.OK)
{
int embeddedFileCount = gdpicturePDF.GetEmbeddedFileCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (embeddedFileCount == 0)
{
MessageBox.Show("This PDF file does not contain embedded files.", caption);
}
else
{
GdPictureStatus status = gdpicturePDF.DeleteEmbeddedFile(0);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The attachment has been successfully removed.", caption);
if (gdpicturePDF.SaveToFile("test_DeleteEmbeddedFile_func.pdf", false) != GdPictureStatus.OK)
{
MessageBox.Show("The file can't be saved.", caption);
}
}
else
{
MessageBox.Show("The DeleteEmbeddedFile() method has failed with the status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Converts a common PDF document into a PDF Portfolio file. You need to specify the file name of that embedded file you want to display on opening the PDF Portfolio and the view mode users can view the component files in.
Please note that your source PDF document must contain at least one embedded (attached) file, otherwise this method will fail.
It is also not allowed to create a PDF Portfolio file if your source PDF document is PDF/A compliant.
These methods convert a common PDF document into a PDF Portfolio file, so called portable collection. You can easily specify the way your PDF Portfolio file will display on opening.
The file name of that embedded file, which is initially presented in the user interface on opening the PDF Portfolio.
A member of the PdfPortFolioType enumeration. Sets the view mode users can view the component files in.
This method is only allowed for use with non-encrypted documents.
The PDF version of the newly created PDF Portfolio is 1.7.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to create a PDF Portfolio containing a collection of three files.
Dim caption As String = "Example: PortFolioCreate"
Dim gdpicturePDF As New GdPicturePDF()
'Creating a new common PDF file.
If (gdpicturePDF.NewPDF() <> GdPictureStatus.OK) OrElse (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter) <> GdPictureStatus.OK) Then
MessageBox.Show("The new PDF document can't be created.", caption)
Else
'Embedding the files into the created PDF file.
If (gdpicturePDF.EmbedFile("textfile.txt", "1st attachmment") <> GdPictureStatus.OK) OrElse (gdpicturePDF.EmbedFile("docfile.docx", "2nd attachment") <> GdPictureStatus.OK) OrElse (gdpicturePDF.EmbedFile("pdffile.pdf", "3rd attachment") <> GdPictureStatus.OK) Then
MessageBox.Show("The files can't be attached.", caption)
Else
'Creating a PDF Portfolio.
Dim status As GdPictureStatus = gdpicturePDF.PortFolioCreate("textfile.txt", PdfPortFolioType.Detail)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("gdpicturepdf_portfolio.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The PDF Portfolio file has been created and saved successfully.", caption)
End If
Else
MessageBox.Show("The PortFolioCreate() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
gdpicturePDF.Dispose()
string caption = "Example: PortFolioCreate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Creating a new common PDF file.
if ((gdpicturePDF.NewPDF() != GdPictureStatus.OK) ||
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter) != GdPictureStatus.OK))
{
MessageBox.Show("The new PDF document can't be created.", caption);
}
else
{
//Embedding the files into the created PDF file.
if ((gdpicturePDF.EmbedFile("textfile.txt", "1st attachmment") != GdPictureStatus.OK) ||
(gdpicturePDF.EmbedFile("docfile.docx", "2nd attachment") != GdPictureStatus.OK) ||
(gdpicturePDF.EmbedFile("pdffile.pdf", "3rd attachment") != GdPictureStatus.OK))
{
MessageBox.Show("The files can't be attached.", caption);
}
else
{
//Creating a PDF Portfolio.
GdPictureStatus status = gdpicturePDF.PortFolioCreate("textfile.txt", PdfPortFolioType.Detail);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("gdpicturepdf_portfolio.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The PDF Portfolio file has been created and saved successfully.", caption);
}
}
else
{
MessageBox.Show("The PortFolioCreate() method has failed with the status: " + status.ToString(), caption);
}
}
}
gdpicturePDF.Dispose();
Converts a common PDF document into a PDF Portfolio file. You need to specify the index of that embedded file you want to display on opening the PDF Portfolio and the view mode users can view the component files in.
Please note that your source PDF document must contain at least one embedded (attached) file, otherwise this method will fail.
It is also not allowed to create a PDF Portfolio file if your source PDF document is PDF/A compliant.
The PDF version of the newly created PDF Portfolio will be 1.7.
These methods convert a common PDF document into a PDF Portfolio file, so called portable collection. You can easily specify the way your PDF Portfolio file will display on opening.
The 0-based index of that embedded file, which is initially presented in the user interface on opening the PDF Portfolio.
It must be a value from 0 to -1.
A member of the PdfPortFolioType enumeration. Sets the view mode users can view the component files in.
This method is only allowed for use with non-encrypted documents.
The PDF version of the newly created PDF Portfolio is 1.7.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to create a PDF Portfolio containing a collection of three files.
Dim caption As String = "Example: PortFolioCreate"
Dim gdpicturePDF As New GdPicturePDF()
'Creating a new common PDF file.
If (gdpicturePDF.NewPDF() <> GdPictureStatus.OK) OrElse (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter) <> GdPictureStatus.OK) Then
MessageBox.Show("The new PDF document can't be created.", caption)
Else
'Embedding the files into the created PDF file.
If (gdpicturePDF.EmbedFile("textfile.txt", "1st attachmment") <> GdPictureStatus.OK) OrElse (gdpicturePDF.EmbedFile("docfile.docx", "2nd attachment") <> GdPictureStatus.OK) OrElse (gdpicturePDF.EmbedFile("pdffile.pdf", "3rd attachment") <> GdPictureStatus.OK) Then
MessageBox.Show("The files can't be attached.", caption)
Else
'Creating a PDF Portfolio.
Dim status As GdPictureStatus = gdpicturePDF.PortFolioCreate(0, PdfPortFolioType.Detail)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("gdpicturepdf_portfolio.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The PDF Portfolio file has been created and saved successfully.", caption)
End If
Else
MessageBox.Show("The PortFolioCreate() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
gdpicturePDF.Dispose()
string caption = "Example: PortFolioCreate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Creating a new common PDF file.
if ((gdpicturePDF.NewPDF() != GdPictureStatus.OK) ||
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter) != GdPictureStatus.OK))
{
MessageBox.Show("The new PDF document can't be created.", caption);
}
else
{
//Embedding the files into the created PDF file.
if ((gdpicturePDF.EmbedFile("textfile.txt", "1st attachmment") != GdPictureStatus.OK) ||
(gdpicturePDF.EmbedFile("docfile.docx", "2nd attachment") != GdPictureStatus.OK) ||
(gdpicturePDF.EmbedFile("pdffile.pdf", "3rd attachment") != GdPictureStatus.OK))
{
MessageBox.Show("The files can't be attached.", caption);
}
else
{
//Creating a PDF Portfolio.
GdPictureStatus status = gdpicturePDF.PortFolioCreate(0, PdfPortFolioType.Detail);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("gdpicturepdf_portfolio.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The PDF Portfolio file has been created and saved successfully.", caption);
}
}
else
{
MessageBox.Show("The PortFolioCreate() method has failed with the status: " + status.ToString(), caption);
}
}
}
gdpicturePDF.Dispose();
Removes all information related to a PDF Portfolio from the currently loaded PDF Portfolio document and converts this file to a common
PDF document. The collected files are embedded one by one into the source document. You can use the method to check the number of embedded files.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert your PDF Portfolio document into a common PDF document with embedded files.
Dim caption As String = "Example: PortFolioDelete"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("gdpicturepdf_portfolio.pdf", False) = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.PortFolioDelete()
If status = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetEmbeddedFileCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF Portfolio has been successfully deteted." + vbCrLf + "This common PDF document contains " + count.ToString() + " embedded files.", caption)
gdpicturePDF.SaveToFile("gdpicturepdf_commonpdf.pdf")
Else
MessageBox.Show("The PDF Portfolio has been successfully deteted." + vbCrLf + "This error occurs when finding the number of embedded files: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The PortFolioDelete() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: PortFolioDelete";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("gdpicturepdf_portfolio.pdf", false) == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.PortFolioDelete();
if (status == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetEmbeddedFileCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The PDF Portfolio has been successfully deteted.\nThis common PDF document contains " + count.ToString() + " embedded files.", caption);
gdpicturePDF.SaveToFile("gdpicturepdf_commonpdf.pdf");
}
else
{
MessageBox.Show("The PDF Portfolio has been successfully deteted.\nThis error occurs when finding the number of embedded files: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The PortFolioDelete() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Checks whether the currently loaded PDF document is a portable collection, so called PDF Portfolio.
A PDF Portfolio contains multiple files put together into a single PDF file. The files in a PDF Portfolio can be in a wide range of file types created in different applications, but the original files hold their individual identities.
You can open, read, edit, and format each component file independently of the other component files in the PDF Portfolio.
Output parameter. true if the current PDF file is a PDF Portfolio, otherwise false.
Output parameter. The index of that embedded file, which is initially presented in the user interface on opening the PDF Portfolio.
The return value is -1 if the initial document is the one that contains the collection (the source document),
otherwise the return value is between 0 and -1.
Output parameter. A member of the PdfPortFolioType enumeration. The view mode you can view the component files in.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to find out if the PDF document is a portable collection (PDF Portfolio).
Dim caption As String = "Example: IsPortFolio"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("portfolio.pdf", False) = GdPictureStatus.OK Then
Dim isPortfolio As Boolean 'out variable
Dim firstIndex As Integer 'out variable
Dim type As PdfPortFolioType 'out variable
Dim status As GdPictureStatus = gdpicturePDF.IsPortFolio(isPortfolio, firstIndex, type)
If status = GdPictureStatus.OK Then
If isPortfolio Then
Dim count As Integer = gdpicturePDF.GetEmbeddedFileCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF document is a portable collection containing " + count.ToString() + " files.", caption)
Else
MessageBox.Show("This PDF document is a portable collection." + vbCrLf + "This error occurs when finding the number of files: " + status.ToString(), caption)
End If
Else
MessageBox.Show("This PDF document is not a portable collection.", caption)
End If
Else
MessageBox.Show("The IsPortFolio() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: IsPortFolio";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("portfolio.pdf", false) == GdPictureStatus.OK)
{
bool isPortfolio = false; //out variable
int firstIndex = -1; //out variable
PdfPortFolioType type = PdfPortFolioType.Detail; //out variable
GdPictureStatus status = gdpicturePDF.IsPortFolio(ref isPortfolio, ref firstIndex, ref type);
if (status == GdPictureStatus.OK)
{
if (isPortfolio)
{
int count = gdpicturePDF.GetEmbeddedFileCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("This PDF document is a portable collection containing " + count.ToString() + " files.", caption);
}
else
{
MessageBox.Show("This PDF document is a portable collection.\nThis error occurs when finding the number of files: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("This PDF document is not a portable collection.", caption);
}
}
else
{
MessageBox.Show("The IsPortFolio() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Saves the currently loaded PDF document to a file according to a file path you have specified.
Please note that you can highly reduce the file size of the PDF document by enabling the use of the standard compression mechanism during saving.
These methods save your currently loaded PDF document to a file in several ways according to your preference.
The file path where the currently loaded PDF document will be saved. If the specified file already exists, it will be overwritten.
You are allowed to overwrite the currently opened PDF document only if the document has been loaded into memory setting the LoadInMemory parameter
to true in the previously called method.
You have to specify a full file path with the correct file extension, which is "pdf".
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.NewPage(500, 500)
If status = GdPictureStatus.OK Then
'If such a file exists, it will be overwritten.
status = gdpicturePDF.SaveToFile("new_file.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been saved successfully.", "Example: SaveToFile")
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: SaveToFile")
End If
End If
gdpicturePDF.CloseDocument()
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.NewPage(500, 500);
if (status == GdPictureStatus.OK)
{
//If such a file exists, it will be overwritten.
status = gdpicturePDF.SaveToFile("new_file.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The PDF file has been saved successfully.", "Example: SaveToFile");
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: SaveToFile");
}
}
gdpicturePDF.CloseDocument();
}
}
Using gdpicturePDF As New GdPicturePDF()
'The file will load into memory.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", True)
If status = GdPictureStatus.OK Then
If gdpicturePDF.ClonePage(1) = GdPictureStatus.OK Then
'The file will be overwritten.
status = gdpicturePDF.SaveToFile("test.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been overwritten and saved successfully.", "Example: SaveToFile")
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: SaveToFile")
End If
gdpicturePDF.CloseDocument()
'The file will not load into memory.
status = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
If gdpicturePDF.DeletePage(1) = GdPictureStatus.OK Then
'The file will not be overwritten.
status = gdpicturePDF.SaveToFile("test.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been overwritten and saved successfully.", "Example: SaveToFile")
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: SaveToFile")
End If
gdpicturePDF.CloseDocument()
End If
Else
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Example: SaveToFile")
End If
End If
Else
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Example: SaveToFile")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
//The file will load into memory.
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", true);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.ClonePage(1) == GdPictureStatus.OK)
{
//The file will be overwritten.
status = gdpicturePDF.SaveToFile("test.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The PDF file has been overwritten and saved successfully.", "Example: SaveToFile");
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: SaveToFile");
}
gdpicturePDF.CloseDocument();
//The file will not load into memory.
status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.DeletePage(1) == GdPictureStatus.OK)
{
//The file will not be overwritten.
status = gdpicturePDF.SaveToFile("test.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The PDF file has been overwritten and saved successfully.", "Example: SaveToFile");
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), "Example: SaveToFile");
}
gdpicturePDF.CloseDocument();
}
}
else
{
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Example: SaveToFile");
}
}
}
else
{
MessageBox.Show("The file can't be opened. Status: " + status.ToString(), "Example: SaveToFile");
}
}
Packs and saves the currently loaded PDF document to a file according to a file path you have specified.
Please note that you can highly reduce the file size of the PDF document by enabling the use of the standard compression mechanism during saving.
These methods save your currently loaded PDF document to a file in several ways according to your preference.
The file path where the currently loaded PDF document will be saved. If the specified file already exists, it will be overwritten.
You are allowed to overwrite the currently opened PDF document only if the document has been loaded into memory setting the LoadInMemory parameter
to true in the previously called method.
Specifies if the toolkit has to pack the current document before the save process to reduce its size.
Set this parameter to true if you want to pack the PDF document before saving. Please note that the whole saving process can be as a result slower with some documents.
If you set this parameter to false, the PDF document will remain unpacked after the save process.
The pack mode is an option allowing the toolkit the removal of any unused PDF objects and to better compress some other objects before saving the PDF document.
Using this option leads to recreation of a brand new PDF document by cloning all existing pages of the current document onto a brand new document.
You can also combine this parameter with the standard compression mechanism as well as you can benefit from using the method
to eliminate all unused resources from your saved PDF document.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the PDF document with enabled pack mode.
Dim caption As String = "Example: SaveToFile"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("Input.pdf", False) = GdPictureStatus.OK Then
'The file will save without being compressed.
gdpicturePDF.EnableCompression(False)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If gdpicturePDF.SaveToFile("uncompressed.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("Saving file without compression and without packing has been successful.", caption)
End If
If gdpicturePDF.SaveToFile("uncompressed_pack.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("Saving file without compression and with packing has been successful.", caption)
End If
'The file will save using the compression mechanism.
gdpicturePDF.EnableCompression(True)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If gdpicturePDF.SaveToFile("compressed.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("Saving file without compression and without packing has been successful.", caption)
End If
If gdpicturePDF.SaveToFile("compressed_pack.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("Saving file without compression and without packing has been successful.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: SaveToFile";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("Input.pdf", false) == GdPictureStatus.OK)
{
//The file will save without being compressed.
gdpicturePDF.EnableCompression(false);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if (gdpicturePDF.SaveToFile("uncompressed.pdf", false) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file without compression and without packing has been successful.", caption);
}
if (gdpicturePDF.SaveToFile("uncompressed_pack.pdf", true) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file without compression and with packing has been successful.", caption);
}
//The file will save using the compression mechanism.
gdpicturePDF.EnableCompression(true);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if (gdpicturePDF.SaveToFile("compressed.pdf", false) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file without compression and without packing has been successful.", caption);
}
if (gdpicturePDF.SaveToFile("compressed_pack.pdf", true) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file without compression and without packing has been successful.", caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
error:
gdpicturePDF.Dispose();
Packs, linearizes and saves the currently loaded PDF document to a file according to a file path you have specified.
Please note that you can highly reduce the file size of the PDF document by enabling the use of the standard compression mechanism during saving.
These methods save your currently loaded PDF document to a file in several ways according to your preference.
The file path where the currently loaded PDF document will be saved. If the specified file already exists, it will be overwritten.
You are allowed to overwrite the currently opened PDF document only if the document has been loaded into memory setting the LoadInMemory parameter
to true in the previously called method.
Specifies if the toolkit has to pack the current document before the save process to reduce its size.
Set this parameter to true if you want to pack the PDF document before saving. Please note that the whole saving process can be as a result slower with some documents.
If you set this parameter to false, the PDF document will remain unpacked after the save process.
Specifies if the PDF document should be linearized when saving, that means if the PDF document should enable Fast Web View mode.
Set this parameter to true to enable optimized save for Fast Web View mode.If you set this parameter to false, the PDF will not be optimized for Fast Web View mode when saving.
The pack mode is an option allowing the toolkit the removal of any unused PDF objects and to better compress some other objects before saving the PDF document.
Using this option leads to the recreation of a brand new PDF document by cloning all existing pages of the current document onto a brand new document.
You can also combine this parameter with the standard compression mechanism as well as you can benefit from using the method
to eliminate all unused resources from your saved PDF document.
Fast Web View restructures a PDF document for page-at-a-time downloading from web. With Fast Web View, the web server only sends the requested page,
rather than the entire PDF. This is especially important with large documents that can take a long time to download.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to linearize and save the PDF document.
Dim caption As String = "Example: SaveToFile"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
gdpicturePDF.EnableCompression(True)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If gdpicturePDF.SaveToFile("compressed_pack_unlinearize.pdf", True, False) = GdPictureStatus.OK Then
MessageBox.Show("Saving file with compression, with packing but without linearization has been successful.", caption)
End If
If gdpicturePDF.SaveToFile("compressed_pack_linearize.pdf", True, True) = GdPictureStatus.OK Then
MessageBox.Show("Saving file with compression, with packing and with linearization has been successful.", caption)
End If
gdpicturePDF.CloseDocument()
If gdpicturePDF.LoadFromFile("compressed_pack_unlinearize.pdf", False) = GdPictureStatus.OK Then
Dim isLinearized As Boolean = gdpicturePDF.IsLinearized()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If isLinearized Then
MessageBox.Show("This file is linearized.", caption)
Else
'This should be the correct case.
MessageBox.Show("This file is not linearized.", caption)
End If
End If
gdpicturePDF.CloseDocument()
If gdpicturePDF.LoadFromFile("compressed_pack_linearize.pdf", False) = GdPictureStatus.OK Then
Dim isLinearized As Boolean = gdpicturePDF.IsLinearized()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If isLinearized Then
'This should be the correct case.
MessageBox.Show("This file is linearized.", caption)
Else
MessageBox.Show("This file is not linearized.", caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: SaveToFile";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
gdpicturePDF.EnableCompression(true);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if (gdpicturePDF.SaveToFile("compressed_pack_unlinearize.pdf", true, false) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file with compression, with packing but without linearization has been successful.", caption);
}
if (gdpicturePDF.SaveToFile("compressed_pack_linearize.pdf", true, true) == GdPictureStatus.OK)
{
MessageBox.Show("Saving file with compression, with packing and with linearization has been successful.", caption);
}
gdpicturePDF.CloseDocument();
if (gdpicturePDF.LoadFromFile("compressed_pack_unlinearize.pdf", false) == GdPictureStatus.OK)
{
bool isLinearized = gdpicturePDF.IsLinearized();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if (isLinearized)
{
MessageBox.Show("This file is linearized.", caption);
}
else
{
//This should be the correct case.
MessageBox.Show("This file is not linearized.", caption);
}
}
gdpicturePDF.CloseDocument();
if (gdpicturePDF.LoadFromFile("compressed_pack_linearize.pdf", false) == GdPictureStatus.OK)
{
bool isLinearized = gdpicturePDF.IsLinearized();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if (isLinearized)
{
//This should be the correct case.
MessageBox.Show("This file is linearized.", caption);
}
else
{
MessageBox.Show("This file is not linearized.", caption);
}
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
error:
gdpicturePDF.Dispose();
Encrypts the currently loaded PDF document according to a specified encryption algorithm and saves it to a file according to a file path you have specified. Encryption process is not allowed for PDF/A compliant documents.
Please note that encrypted PDF files are always saved without using the packing mechanism. You can however use the standard compression process.
Please read more about the password and permissions security in the method.
These methods save your currently loaded PDF document to a file in several ways according to your preference.
The file path where the currently loaded PDF document will be saved. If the specified file already exists, it will be overwritten.
You are allowed to overwrite the currently opened PDF document only if the document has been loaded into memory setting the LoadInMemory parameter
to true in the previously called method.
A member of the PdfEncryption enumeration. The encryption algorithm you have to specify. This algorithm will be used to encrypt the PDF document according to other specified parameters.
The user (open) password as a string. You can set null value here or an empty string as well. The null value will alway be converted to an empty string.
Please read more about passwords in the Remarks section.
The owner (permission, master) password as a string. You can set null value here or an empty string as well. The null value will always be converted
to an empty string. Please read more about passwords in the Remarks section.
Allows the user to print the document, but possibly not at the highest quality level, see also PdfRightCanPrintFull. It is ignored if the EncryptionScheme
parameter is set to PdfEncryption.PdfEncryptionNone.
Allows the user to copy or extract text and graphics from the document. It is ignored if the EncryptionScheme parameter is set to PdfEncryption.PdfEncryptionNone.
Allows the user to modify the document. It is ignored if the EncryptionScheme parameter is set to PdfEncryption.PdfEncryptionNone.
Allows the user to add annotations. It is ignored if the EncryptionScheme parameter is set to PdfEncryption.PdfEncryptionNone.
Allows the user to fill-in form fields. It works only with 128-bit encryption.
Enables copying or extracting for use with accessibility features. It works only with 128-bit encryption.
Allows the user to assemble the document. It works only with 128-bit encryption.
Allows high resolution printing of the document. It works only with 128-bit encryption.
Some basic rules for better understanding the use of the user and the owner passwords are:
1. A null password (or a password, that is not set) will always be converted to an empty string password.
2. If both the user password and the owner password are empty (or they are not set), the PDF document is unencrypted and you have full access to the
document content. This is defined by the PDF specification.3. If the user password is set (assuming not null or empty) and the owner password is not set, the PDF document in encrypted. You will have full access
to the document content right after the decrypting your document with the correct user password. The owner password is set to the user password by default, see
the PDF specification.4. If the owner password is set (assuming not null or empty) and the user password is not set, the toolkit tells you that the PDF document is unencrypted.
You can use the GetEncryptionScheme and the GetRight methods to correctly operate with the PDF document respecting the defined access permissions.
5. Both passwords can be different of course. The IsOwnerPassword method tells you, if the password you have set by the method is the owner
password or not.6. If both the user password and the owner password are set (assuming not null or empty) and they are the same, we consider that the PDF document does not
have the owner password. Your PDF document in encrypted and you will have full access to the document content after the decrypting it with the correct user (or the owner) password.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to encrypt and save the PDF document.
Dim caption As String = "Example: SaveToFile"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("encrypted.pdf", PdfEncryption.PdfEncryption40BitRC4, "user", "owner", False, False, False, False, False, False, False, False) = GdPictureStatus.OK Then
MessageBox.Show("The encrypted file has been saved successfully.", caption)
'Closing the current document.
gdpicturePDF.CloseDocument()
'Loading the encrypted file.
If gdpicturePDF.LoadFromFile("encrypted.pdf", False) = GdPictureStatus.OK Then
'Checking if the file is encrypted.
Dim encrypted As Boolean = gdpicturePDF.IsEncrypted()
MessageBox.Show("The encrypted file has been loaded successfully." + vbCrLf + " The IsEncrypted method returns: " + encrypted.ToString() + " status: " + gdpicturePDF.GetStat().ToString(), caption)
Else
MessageBox.Show("The encrypted file has failed to load.", caption)
End If
Else
MessageBox.Show("The encrypted file has failed to save.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SaveToFile";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("encrypted.pdf", PdfEncryption.PdfEncryption40BitRC4, "user", "owner", false, false, false, false, false, false, false, false) == GdPictureStatus.OK)
{
MessageBox.Show("The encrypted file has been saved successfully.", caption);
//Closing the current document.
gdpicturePDF.CloseDocument();
//Loading the encrypted file.
if (gdpicturePDF.LoadFromFile("encrypted.pdf", false) == GdPictureStatus.OK)
{
//Checking if the file is encrypted.
bool encrypted = gdpicturePDF.IsEncrypted();
MessageBox.Show("The encrypted file has been loaded successfully.\n The IsEncrypted method returns: " + encrypted.ToString() + " status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The encrypted file has failed to load.", caption);
}
}
else
{
MessageBox.Show("The encrypted file has failed to save.", caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Saves the currently loaded PDF document to a specified file using incremental updates. This incremental saving feature (see PDF Reference for Incremental
updates) executes very quick save and ensures the document content persistence, but it also produces bigger file than the standard save process.
We suggest to use this method only if you perform small modifications on large documents.
The content of a PDF file can be updated incrementally without rewriting the entire file. Changes are appended to the end of the file, leaving its original content intact.
The main advantage to updating a file in this way is that small changes to a large document can be saved quickly (see PDF Reference, Section "Incremental updates").
The file path where the currently loaded PDF document will be saved. If the specified file already exists, it will be overwritten.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that you can overwrite the handled PDF document only if the document has been loaded into memory or with specifying the read/write access mode using the method.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to merge two PDF documents using incremental saving feature. Incremental updates (see also PDF Reference) help to reduce memory usage and dramatically increase performance during the merging process.
Dim caption As String = "Example: SaveToFileInc"
Dim oSrcPDF As New GdPicturePDF()
Dim oDstPDF As New GdPicturePDF()
'The file access mode will be read/write.
Dim status As GdPictureStatus = oDstPDF.LoadFromFileEx("doc1.pdf", True)
If status = GdPictureStatus.OK Then
' The file will not load into memory.
status = oSrcPDF.LoadFromFile("doc2.pdf", False)
If status = GdPictureStatus.OK Then
Dim srcPageCount As Integer = oSrcPDF.GetPageCount()
If oSrcPDF.GetStat() = GdPictureStatus.OK Then
For i As Integer = 1 To srcPageCount
status = oDstPDF.ClonePage(oSrcPDF, i)
If status <> GdPictureStatus.OK Then
Exit For
End If
Next
If status = GdPictureStatus.OK Then
status = oDstPDF.SaveToFileInc("doc1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been successfully saved.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The source file can't be opened. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The destination file can't be opened. Status: " + status.ToString(), caption)
End If
oDstPDF.Dispose()
oSrcPDF.Dispose()
string caption = "Example: SaveToFileInc";
GdPicturePDF oSrcPDF = new GdPicturePDF();
GdPicturePDF oDstPDF = new GdPicturePDF();
//The file access mode will be read/write.
GdPictureStatus status = oDstPDF.LoadFromFileEx("doc1.pdf", true);
if (status == GdPictureStatus.OK)
{
//The file will not load into memory.
status = oSrcPDF.LoadFromFile("doc2.pdf", false);
if (status == GdPictureStatus.OK)
{
int srcPageCount = oSrcPDF.GetPageCount();
if (oSrcPDF.GetStat() == GdPictureStatus.OK)
{
for (int i = 1; i <= srcPageCount; i++)
{
status = oDstPDF.ClonePage(oSrcPDF, i);
if (status != GdPictureStatus.OK) break;
}
if (status == GdPictureStatus.OK)
{
status = oDstPDF.SaveToFileInc("doc1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The file has been successfully saved.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
{
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The source file can't be opened. Status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The destination file can't be opened. Status: " + status.ToString(), caption);
}
oDstPDF.Dispose();
oSrcPDF.Dispose();
Saves the currently loaded PDF document to an instantiated Stream object using incremental updates. This incremental saving feature (see PDF Reference for Incremental
updates) executes very quick save and ensures the document content persistence, but it also produces bigger file than the standard save
process. We suggest to use this method only if you perform small modifications on large documents.
The content of a PDF file can be updated incrementally without rewriting the entire file. Changes are appended to the end of the file, leaving its original content intact.
The main advantage to updating a file in this way is that small changes to a large document can be saved quickly (see PDF Reference, Section "Incremental updates").
A Stream object where the currently loaded PDF document will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
This method is only allowed for use with non-encrypted documents.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add a cloned page to the PDF document and save the file to a stream using incremental saving feature. Incremental updates (see also
PDF Reference) help to reduce memory usage and dramatically increase performance during the merging process.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SelectPage(1) <> GdPictureStatus.OK Then
GoTo [error]
End If
If gdpicturePDF.DuplicatePage(1) <> GdPictureStatus.OK Then
GoTo [error]
End If
Dim oFileStream As New System.IO.FileStream("test_SaveIncToStream.pdf", System.IO.FileMode.Create)
status = gdpicturePDF.SaveToStreamInc(oFileStream)
oFileStream.Close()
MessageBox.Show("The SaveToStreamInc() method has failed with the status: " + status.ToString(), "Example: SaveToStreamInc")
End If
[error]:
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SelectPage(1) != GdPictureStatus.OK) goto error;
if (gdpicturePDF.DuplicatePage(1) != GdPictureStatus.OK) goto error;
System.IO.FileStream oFileStream = new System.IO.FileStream("test_SaveIncToStream.pdf", System.IO.FileMode.Create);
status = gdpicturePDF.SaveToStreamInc(oFileStream);
oFileStream.Close();
MessageBox.Show("The SaveToStreamInc() method has failed with the status: " + status.ToString(), "Example: SaveToStreamInc");
}
error:
gdpicturePDF.Dispose();
Saves the currently loaded PDF document to an instantiated Stream object according to what you have specified.
These methods save your currently loaded PDF document to a Stream object in several ways according to your preference.
A Stream object where the currently loaded PDF document will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
The output stream should be open for writing and should be closed/disposed of by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the PDF document to a stream with enabled content compression.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim oFileStream As New System.IO.FileStream("test_SaveToStream.pdf", System.IO.FileMode.Create)
gdpicturePDF.EnableCompression(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToStream(oFileStream)
MessageBox.Show("The SaveToStream() method has followed with the status: " + status.ToString(), "Example: SaveToStream")
End If
oFileStream.Dispose()
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = new System.IO.FileStream("test_SaveToStream.pdf", System.IO.FileMode.Create);
gdpicturePDF.EnableCompression(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToStream(oFileStream);
MessageBox.Show("The SaveToStream() method has followed with the status: " + status.ToString(), "Example: SaveToStream");
}
oFileStream.Dispose();
}
gdpicturePDF.Dispose();
Packs and saves the currently loaded PDF document to an instantiated Stream object according to what you have specified.
These methods save your currently loaded PDF document to a Stream object in several ways according to your preference.
A Stream object where the currently loaded PDF document will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Specifies if the toolkit has to pack the current document before the save process to reduce its size.
Set this parameter to true if you want to pack the PDF document before saving. Please note that the whole saving process can be as a result slower with some documents.
If you set this parameter to false, the PDF document will remain unpacked after the save process.
The output stream should be open for writing and should be closed/disposed of by the user as well.
The pack mode is an option allowing the removal of any unused PDF objects and to better compress some other objects before saving the PDF document. Using this
option leads to recreation of a brand new PDF document by cloning all existing pages of the current document onto a brand new document.
You can also combine this parameter with the standard compression mechanism as well as you can benefit from using the method
to eliminate all unused resources from your saved PDF document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to save the PDF document to a stream with enabled compression and packing.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim oFileStream As New System.IO.FileStream("test_SaveToStream.pdf", System.IO.FileMode.Create)
gdpicturePDF.EnableCompression(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToStream(oFileStream, True)
MessageBox.Show("The SaveToStream() method has followed with the status: " + status.ToString(), "Example: SaveToStream")
End If
oFileStream.Dispose()
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = new System.IO.FileStream("test_SaveToStream.pdf", System.IO.FileMode.Create);
gdpicturePDF.EnableCompression(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToStream(oFileStream, true);
MessageBox.Show("The SaveToStream() method has followed with the status: " + status.ToString(), "Example: SaveToStream");
}
oFileStream.Dispose();
}
gdpicturePDF.Dispose();
Packs, linearizes and saves the currently loaded PDF document to an instantiated Stream object according to what you have specified.
These methods save your currently loaded PDF document to a Stream object in several ways according to your preference.
A Stream object where the currently loaded PDF document will be saved to.
This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Specifies if the toolkit has to pack the current document before the save process to reduce its size.
Set this parameter to true if you want to pack the PDF document before saving. Please note that the whole saving process can be as a result slower with some documents.
If you set this parameter to false, the PDF document will remain unpacked after the save process.
Specifies if the PDF document should be linearized when saving, that means if the PDF document should enable Fast Web View mode.
Set this parameter to true to enable optimized save for Fast Web View mode.If you set this parameter to false, your PDF will not be optimized for Fast Web View mode when saving.
The output stream should be open for writing and should be closed/disposed of by the user as well.
The pack mode is an option allowing the removal of any unused PDF objects and to better compress some other objects before saving the PDF document. Using this
option leads to recreation of a brand new PDF document by cloning all existing pages of the current document onto a brand new document. You can also combine this parameter
with the standard compression mechanism as well as you can benefit from using the method to eliminate all unused resources from your saved PDF document.
Fast Web View restructures a PDF document for page-at-a-time downloading from web. With Fast Web View, the web server only sends the requested page,
rather than the entire PDF. This is especially important with large documents that can take a long time to download.
This method requires the Linearization & PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to linearize and save the PDF document using a stream.
Dim caption As String = "Example: SaveToStream"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
gdpicturePDF.EnableCompression(True)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
Dim oFileStream As New System.IO.FileStream("test_Stream_compressed_pack_unlinearize.pdf", System.IO.FileMode.Create)
If gdpicturePDF.SaveToStream(oFileStream, True, False) = GdPictureStatus.OK Then
MessageBox.Show("Saving the file to a stream with compression, with packing but without linearization has been successful.", caption)
End If
oFileStream.Dispose()
oFileStream = New System.IO.FileStream("test_Stream_compressed_pack_linearize.pdf", System.IO.FileMode.Create)
If gdpicturePDF.SaveToStream(oFileStream, True, True) = GdPictureStatus.OK Then
MessageBox.Show("Saving the file to a stream with compression, with packing and with linearization has been successful.", caption)
End If
oFileStream.Dispose()
gdpicturePDF.CloseDocument()
oFileStream = New System.IO.FileStream("test_Stream_compressed_pack_unlinearize.pdf", System.IO.FileMode.Open)
If gdpicturePDF.LoadFromStream(oFileStream, False) = GdPictureStatus.OK Then
Dim isLinearized As Boolean = gdpicturePDF.IsLinearized()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If isLinearized Then
MessageBox.Show("This file is linearized.", caption)
Else
'This should be the correct case.
MessageBox.Show("This file is not linearized.", caption)
End If
End If
End If
oFileStream.Dispose()
gdpicturePDF.CloseDocument()
oFileStream = New System.IO.FileStream("test_Stream_compressed_pack_linearize.pdf", System.IO.FileMode.Open)
If gdpicturePDF.LoadFromStream(oFileStream, False) = GdPictureStatus.OK Then
Dim isLinearized As Boolean = gdpicturePDF.IsLinearized()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If isLinearized Then
'This should be the correct case.
MessageBox.Show("This file is linearized.", caption)
Else
MessageBox.Show("This file is not linearized.", caption)
End If
End If
End If
oFileStream.Dispose()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: SaveToStream";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
gdpicturePDF.EnableCompression(true);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
System.IO.FileStream oFileStream = new System.IO.FileStream("test_Stream_compressed_pack_unlinearize.pdf", System.IO.FileMode.Create);
if (gdpicturePDF.SaveToStream(oFileStream, true, false) == GdPictureStatus.OK)
{
MessageBox.Show("Saving the file to a stream with compression, with packing but without linearization has been successful.", caption);
}
oFileStream.Dispose();
oFileStream = new System.IO.FileStream("test_Stream_compressed_pack_linearize.pdf", System.IO.FileMode.Create);
if (gdpicturePDF.SaveToStream(oFileStream, true, true) == GdPictureStatus.OK)
{
MessageBox.Show("Saving the file to a stream with compression, with packing and with linearization has been successful.", caption);
}
oFileStream.Dispose();
gdpicturePDF.CloseDocument();
oFileStream = new System.IO.FileStream("test_Stream_compressed_pack_unlinearize.pdf", System.IO.FileMode.Open);
if (gdpicturePDF.LoadFromStream(oFileStream, false) == GdPictureStatus.OK)
{
bool isLinearized = gdpicturePDF.IsLinearized();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (isLinearized)
{
MessageBox.Show("This file is linearized.", caption);
}
else
{
//This should be the correct case.
MessageBox.Show("This file is not linearized.", caption);
}
}
}
oFileStream.Dispose();
gdpicturePDF.CloseDocument();
oFileStream = new System.IO.FileStream("test_Stream_compressed_pack_linearize.pdf", System.IO.FileMode.Open);
if (gdpicturePDF.LoadFromStream(oFileStream, false) == GdPictureStatus.OK)
{
bool isLinearized = gdpicturePDF.IsLinearized();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (isLinearized)
{
//This should be the correct case.
MessageBox.Show("This file is linearized.", caption);
}
else
{
MessageBox.Show("This file is not linearized.", caption);
}
}
}
oFileStream.Dispose();
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
error:
gdpicturePDF.Dispose();
Encrypts the currently loaded PDF document according to the specified encryption algorithm and saves it to an instantiated Stream object according to
what you have specified. Encryption process is not allowed for PDF/A compliant documents.
Please read more about the password and permissions security in the method.
This method requires the PDF Processing component to run.
These methods save your currently loaded PDF document to a Stream object in several ways according to your preference.
A Stream object where the currently loaded PDF document will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
A member of the PdfEncryption enumeration. The encryption algorithm you have to specify. This algorithm will be used to encrypt your PDF
document according to other specified parameters.
The user (open) password as a string. You can set null value here or an empty string as well. The null value will alway be converted to an empty string. Please
read more about passwords in the Remarks section.
The owner (permission, master) password as a string. You can set null value here or an empty string as well. The null value will always be converted to an
empty string. Please read more about passwords in the Remarks section.
Allows the user to print the document, but possibly not at the highest quality level, see also PdfRightCanPrintFull. It is ignored if the EncryptionScheme
parameter is set to PdfEncryption.PdfEncryptionNone.
Allows the user to copy or extract text and graphics from the document. It is ignored if the EncryptionScheme parameter is set to PdfEncryption.PdfEncryptionNone.
Allows the user to modify the document. It is ignored if the EncryptionScheme parameter is set to PdfEncryption.PdfEncryptionNone.
Allows the user to add annotations. It is ignored if the EncryptionScheme parameter is set to PdfEncryption.PdfEncryptionNone.
Allows the user to fill-in form fields. It works only with 128-bit encryption.
Enables copying or extracting for use with accessibility features. It works only with 128-bit encryption.
Allows the user to assemble the document. It works only with 128-bit encryption.
Allows high resolution printing of the document. It works only with 128-bit encryption.
Some basic rules for better understanding the use of the user and the owner passwords are described in details
within the method.
This method requires the PDF Processing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to encrypt and save the PDF document to a stream.
Dim caption As String = "Example: SaveToStream"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = GdPictureStatus.OK
If gdpicturePDF.LoadFromFile("testPDF.pdf", False) = GdPictureStatus.OK Then
Dim oFileStream As New System.IO.FileStream("encryptedStream.pdf", System.IO.FileMode.Create)
'Encrypting and saving the document to a stream.
status = gdpicturePDF.SaveToStream(oFileStream, PdfEncryption.PdfEncryption256BitAES, "user", "owner", False, False, False, False, False, False, False, False)
If status = GdPictureStatus.OK Then
MessageBox.Show("The encrypted file has been saved successfully.", caption)
'Closing the current file.
gdpicturePDF.CloseDocument()
oFileStream.Dispose()
oFileStream = New System.IO.FileStream("encryptedStream.pdf", System.IO.FileMode.Open)
'Loading the encrypted document.
status = gdpicturePDF.LoadFromStream(oFileStream)
If status = GdPictureStatus.OK Then
Dim encrypted As Boolean = gdpicturePDF.IsEncrypted()
status = gdpicturePDF.GetStat()
MessageBox.Show("The encrypted file has been loaded successfully." + vbCrLf + "The IsEncrypted method returns: " + encrypted.ToString() + " status: " + status.ToString(), caption)
Else
MessageBox.Show("The encrypted file has failed to load.", caption)
End If
oFileStream.Dispose()
Else
MessageBox.Show("The encrypted file has failed to save.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SaveToStream";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = GdPictureStatus.OK;
if (gdpicturePDF.LoadFromFile("testPDF.pdf", false) == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = new System.IO.FileStream("encryptedStream.pdf", System.IO.FileMode.Create);
//Encrypting and saving the document to a stream.
status = gdpicturePDF.SaveToStream(oFileStream, PdfEncryption.PdfEncryption256BitAES, "user", "owner", false, false, false, false, false, false, false, false);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The encrypted file has been saved successfully.", caption);
//Closing the current file.
gdpicturePDF.CloseDocument();
oFileStream.Dispose();
oFileStream = new System.IO.FileStream("encryptedStream.pdf", System.IO.FileMode.Open);
//Loading the encrypted document.
status = gdpicturePDF.LoadFromStream(oFileStream);
if (status == GdPictureStatus.OK)
{
bool encrypted = gdpicturePDF.IsEncrypted();
status = gdpicturePDF.GetStat();
MessageBox.Show("The encrypted file has been loaded successfully.\nThe IsEncrypted method returns: " + encrypted.ToString() + " status: " + status.ToString(), caption);
}
else
{
MessageBox.Show("The encrypted file has failed to load.", caption);
}
oFileStream.Dispose();
}
else
{
MessageBox.Show("The encrypted file has failed to save.", caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the parameter for the current GdPicturePDF object that specifies if PDF documents will be compressed during the save process.
The result of this compression is a smaller file size. The compression is enabled by default for each newly created GdPicturePDF object.
Heavy text and image content can considerably increase the size of the PDF document. During the compression process, the toolkit will remove unused objects and elements.
This leads to a significantly reduced file size. Therefore the compression is particularly valuable for large images.
This drastic reduction however does not affect any of the file's content but it will make your PDF files compact and easy to open.
The list of compression algorithms is extensive, for example, JPEG, JPEG2000 or JBIG2 for images, Flate or LZW for text as well as images, etc.
The toolkit offers the Deflate compression algorithm.
Set this parameter to true if you want to compress the PDF document during each save process.
Enabling the compression will allow the toolkit to compress the content of your currently loaded PDF document using the Deflate Algorithm.
If you set this parameter to false, the PDF document will remain uncompressed after the save process.
The method can be subsequently used to determine if this method has been successful.
The deflate data compression algorithm, which we support, is a lossless type of compression, that can reduce files without a loss of information in the process. The original file can be then recreated exactly when uncompressed.
On the other hand, the opposite approach is lossy compression, that reduces the file size by permanently deleting any unnecessary data. However, the original file can't be retained.
How to enable and disable PDF compression.
Dim caption As String = "Example: EnableCompression"
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
gdpicturePDF.EnableCompression(True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_EnableCompression.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The file has been successfully compressed and saved.", caption)
End If
Else
MessageBox.Show("The EnableCompression() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.EnableCompression(False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_DisableCompression.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The file has been successfully saved without compression.", caption)
End If
Else
MessageBox.Show("The EnableCompression() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
End Using
string caption = "Example: EnableCompression";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
gdpicturePDF.EnableCompression(true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_EnableCompression.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The file has been successfully compressed and saved.", caption);
}
}
else
{
MessageBox.Show("The EnableCompression() method has failed with the status: " + status.ToString(), caption);
}
gdpicturePDF.EnableCompression(false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_DisableCompression.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The file has been successfully saved without compression.", caption);
}
}
else
{
MessageBox.Show("The EnableCompression() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
}
Returns the number of applied digital signatures to the currently loaded PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
This method requires the Digital Signatures component to run.
The number of applied digital signatures. The method can be subsequently used to determine if this method has been successful.
How to determine the number of applied digital signatures to the current document.
Dim caption As String = "GetSignatureCount"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim signatureCount As Integer = gdpicturePDF.GetSignatureCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF document contains " + signatureCount.ToString() + " digital signature/s.", caption)
Else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "GetSignatureCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int signatureCount = gdpicturePDF.GetSignatureCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("This PDF document contains " + signatureCount.ToString() + " digital signature/s.", caption);
else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Retrieves available information about the applied digital signature specified by its index in the currently loaded PDF document, as well as about the used certificate (digital ID).
This method also checks the certificate validity and if the document has been altered or corrupted since it was signed.
The signature index. It must be a value from 0 to -1.
Output parameter. The name of the person or authority signing the document. Since it is an optional information, the returned value can be an empty string.
Output parameter. The reason for the signing the document. Since it is an optional information, the returned value can be an empty string.
Output parameter. The CPU host name or physical location of the signing. Since it is an optional information, the returned value can be an empty string.
Output parameter. Information provided by the signer to enable a recipient to contact the signer to verify the signature,
for example a phone number. Since it is an optional information, the returned value can be an empty string.
Output parameter. The time of signing as a string. Depending on the signature handler, this may be a normal unverified computer time or a time
generated in a verifiable way from a secure time server.
Output parameter. The horizontal (X) coordinate of the closest point to the currently defined origin, where the signature is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the page, where the signature is situated.
Output parameter. The vertical (Y) coordinate of the closest point to the currently defined origin, where the signature is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the page, where the signature is situated.
Output parameter. The width of the signature's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
If the returned value is 0, the signature is invisible.
Output parameter. The height of the signature's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
If the returned value is 0, the signature is invisible.
Output parameter. The number of the page, on which the signature is placed.
Output parameter. true, if the document has been altered or corrupted since it was signed, otherwise false.
Output parameter. true, if the used certificate (digital ID) has been successfully verified, otherwise false.
Output parameter. The associated alias of the used certificate, that means the name of the certificate's owner.
Output parameter. The name of the authority that issued the used certificate.
Output parameter. The earliest time and date on which the used certificate is valid.
Output parameter. The time and date past which the used certificate is no longer valid.
Output parameter. The entity the used certificate belongs to, for example an individual or an organization.
Output parameter. The version of the used certificate.
Output parameter. The date and time when the document has been signed. This value should be used only when the time of signing is not available in the signature.
Output parameter. A member of the PdfSignatureCertificationLevel enumeration. The used level of the signature certification.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of the coordinates and dimensions are expressed in the current units defined by the method according to the
current coordinate space defined by the method.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve and show properties of the first signature of the PDF document.
Dim caption As String = "GetSignatureProperties"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test_signed.pdf", False)
If status = GdPictureStatus.OK Then
Dim signatureCount As Integer = gdpicturePDF.GetSignatureCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If signatureCount > 0 Then
Dim sigName As String = "", sigReason As String = "", sigLocation As String = "", sigInfo As String = "", sigDate As String = "",
certFriendName As String = "", certIssuer As String = "", certSubject As String = ""
Dim stampLeft As Single = 0, stampTop As Single = 0, stampWidth As Single = 0, stampHeight As Single = 0
Dim stampPage As Integer = 0, certVersion As Integer = 0
Dim docValid As Boolean = False, certValid As Boolean = False
Dim certNotBefore As New DateTime(), certNotAfter As New DateTime(), sigTime As New DateTime()
Dim sigLevel As PdfSignatureCertificationLevel = PdfSignatureCertificationLevel.NotCertified
status = gdpicturePDF.GetSignatureProperties(0, sigName, sigReason, sigLocation, sigInfo, sigDate,
stampLeft, stampTop, stampWidth, stampHeight, stampPage,
docValid, certValid, certFriendName, certIssuer, certNotBefore, certNotAfter, certSubject, certVersion, sigTime, sigLevel)
If status = GdPictureStatus.OK Then
Dim message As String = "The 1. signature is located on the page " + stampPage.ToString() + " at the coordinates " + stampLeft.ToString() + ", " + stampTop.ToString()
If (stampWidth = 0) OrElse (stampHeight = 0) Then
message = message + ", the signature is invisible,"
Else
message = message + " with the width of " + stampWidth.ToString() + " and the height of " + stampHeight.ToString()
End If
message = message + " and the certificate level is set to " + sigLevel.ToString() + ". The next properties are:" + vbCrLf
If docValid Then
message = message + "The document has not been changed after signing." + vbCrLf
Else
message = message + "The document has been changed after signing." + vbCrLf
End If
If certValid Then
message = message + "The signature is valid." + vbCrLf
Else
message = message + "The signature is not valid." + vbCrLf
End If
message = message + "Signature Info:" + vbCrLf + " Name: " + sigName + vbCrLf + " Reason: " + sigReason + vbCrLf + " Location: " + sigLocation + vbCrLf + " Contact info: " + sigInfo + vbCrLf + " Date: " + sigDate + vbCrLf +
"Certificate Info:" + vbCrLf + " Name: " + certFriendName + vbCrLf + " Issuer: " + certIssuer + vbCrLf + " Subject: " + certSubject + vbCrLf + " Version: " + certVersion + vbCrLf + " Time: " + sigTime.ToString() + vbCrLf +
"Certificate validity - not before " + certNotBefore.ToString() + " and not after " + certNotAfter.ToString() + "."
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetSignatureProperties() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("This PDF document doesn't contain any digital signature.", caption)
End If
Else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "GetSignatureProperties";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test_signed.pdf", false);
if (status == GdPictureStatus.OK)
{
int signatureCount = gdpicturePDF.GetSignatureCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (signatureCount > 0)
{
string sigName = "", sigReason = "", sigLocation = "", sigInfo = "", sigDate = "", certFriendName = "", certIssuer = "", certSubject = "";
float stampLeft = 0, stampTop = 0, stampWidth = 0, stampHeight = 0;
int stampPage = 0, certVersion = 0;
bool docValid = false, certValid = false;
DateTime certNotBefore = new DateTime(), certNotAfter = new DateTime(), sigTime = new DateTime();
PdfSignatureCertificationLevel sigLevel = PdfSignatureCertificationLevel.NotCertified;
status = gdpicturePDF.GetSignatureProperties(0, ref sigName, ref sigReason, ref sigLocation, ref sigInfo, ref sigDate,
ref stampLeft, ref stampTop, ref stampWidth, ref stampHeight, ref stampPage,
ref docValid, ref certValid, ref certFriendName, ref certIssuer,
ref certNotBefore, ref certNotAfter, ref certSubject, ref certVersion, ref sigTime, ref sigLevel);
if (status == GdPictureStatus.OK)
{
string message = "The 1. signature is located on the page " + stampPage.ToString() + " at the coordinates " + stampLeft.ToString() + ", " + stampTop.ToString();
if ((stampWidth == 0) || (stampHeight == 0))
message = message + ", the signature is invisible,";
else
message = message + " with the width of " + stampWidth.ToString() + " and the height of " + stampHeight.ToString();
message = message + " and the certificate level is set to " + sigLevel.ToString() + ". The next properties are:\n";
if (docValid)
message = message + "The document has not been changed after signing.\n";
else
message = message + "The document has been changed after signing.\n";
if (certValid)
message = message + "The signature is valid.\n";
else
message = message + "The signature is not valid.\n";
message = message + "Signature Info:\n Name: " + sigName + "\n Reason: " + sigReason + "\n Location: " + sigLocation + "\n Contact info: " + sigInfo + "\n Date: " + sigDate +
"\nCertificate Info:\n Name: " + certFriendName + "\n Issuer: " + certIssuer + "\n Subject: " + certSubject + "\n Version: " + certVersion + "\n Time: " + sigTime.ToString() +
"\nCertificate validity - not before " + certNotBefore.ToString() + " and not after " + certNotAfter.ToString() + ".";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetSignatureProperties() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("This PDF document doesn't contain any digital signature.", caption);
}
else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Checks if signature field specified by its index in the currently loaded PDF document contains digital signature information.
The signature index. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the signature field contains digital signature information, otherwise false.
Removes a digital signature specified by its index from the currently loaded PDF document.
The 0-based signature index within the current document. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove the specified digital signature from the current document.
Dim caption As String = "RemoveSignature"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim signatureCount As Integer = gdpicturePDF.GetSignatureCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If signatureCount > 0 Then
status = gdpicturePDF.RemoveSignature(signatureCount - 1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_RemoveSignature.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The signature has been removed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The signature has been removed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The RemoveSignature() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("This PDF document doesn't contain any digital signature.", caption)
End If
Else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "RemoveSignature";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int signatureCount = gdpicturePDF.GetSignatureCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (signatureCount > 0)
{
status = gdpicturePDF.RemoveSignature(signatureCount - 1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_RemoveSignature.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The signature has been removed successfully and the file has been saved.", caption);
else
MessageBox.Show("The signature has been removed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The RemoveSignature() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("This PDF document doesn't contain any digital signature.", caption);
}
else
MessageBox.Show("The GetSignatureCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Specifies the level of the signature certification to be used for subsequent signing of the currently loaded PDF document.
A value of PdfSignatureCertificationLevel.NotCertified defines the standard (ordinary) recipient digital signature, while other values introduce an author
or certifying signatures (modification detection and prevention). Hence PDF files can be certified only once, but if permissions allow, can be digitally signed many times.
Regarding certifying signatures, the level means the author’s specification of which changes to the document will invalidate the signature. A value of
PdfSignatureCertificationLevel.NoChanges indicates that the document is intended to be final; that is, any changes invalidate the signature. The values
PdfSignatureCertificationLevel.FormFilling and PdfSignatureCertificationLevel.FormFillingAndAnnotations permit modifications that are appropriate for form
field or comment workflow.
A member of the PdfSignatureCertificationLevel enumeration. The required certification level to be used in the subsequent signing process.
This method is only allowed for use with non-encrypted documents.
Be aware that you need to set up the required certification level before you start the signing process.
A PDF document can contain only one certifying signature and it must be the first added signature in this document.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify a required certification level of the subsequent signing. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureCertificationLevel"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'Please set the signature certification level.
'If this step is omitted, the value of PdfSignatureCertificationLevel.NotCertified is used.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureCertificationLevel(PdfSignatureCertificationLevel.NotCertified)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificationLevel() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureCertificationLevel";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//Please set the signature certification level.
//If this step is omitted, the value of PdfSignatureCertificationLevel.NotCertified is used.
GdPictureStatus status = gdpicturePDF.SetSignatureCertificationLevel(PdfSignatureCertificationLevel.NotCertified);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificationLevel() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the certificate, contained in the digital ID stored in the specified external PKCS#12 file with the filename extension ".p12" or ".pfx". This
certificate is later used for the subsequent signing of the currently loaded PDF document. The method works with the file specified by its file path as a string.
Sets the certificate contained in the digital ID file for the subsequent signing of the currently loaded PDF document.
The file path to the digital ID file. This file contains the certificate to be used for the subsequent signing.
The password to open the digital ID file specified above.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that setting up the valid certificate is the mandatory step to be able to digitally sign the PDF document. Please select the
appropriate method for carrying out this requirement according to your preference before you start the signing process.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the certificate (digital ID) from the external file for the subsequent signing.
You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureCertificateFromP12"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureCertificateFromP12("your-digitalID-file.pfx", "your-password")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificateFromP12() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureCertificateFromP12";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
GdPictureStatus status = gdpicturePDF.SetSignatureCertificateFromP12("your-digitalID-file.pfx", "your-password");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificateFromP12() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets the certificate, contained in the digital ID stored in the specified external PKCS#12 file with the filename extension ".p12" or ".pfx". This certificate
is later used for the subsequent signing of the currently loaded PDF document. The method works with the instantiated stream object containing the corresponding file.
Sets the certificate contained in the digital ID file for the subsequent signing of the currently loaded PDF document.
A Stream object specifying the digital ID file. This file contains the certificate to be used for the subsequent signing. This Stream object must be
initialized and opened for reading before it can be sent into this method and it should remain open for subsequent use.
The password to open the digital ID file specified above.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that setting up the valid certificate is the mandatory step to be able to digitally sign the PDF document. Please select the
appropriate method for carrying out this requirement according to your preference before you start the signing process.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the certificate (digital ID) from the external file using the stream for the subsequent signing.
You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureCertificateFromP12"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
Dim certificate As New System.IO.FileStream("your-digitalID-file.pfx", System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureCertificateFromP12(certificate, "your-password")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificateFromP12() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
certificate.Dispose()
gdpicturePDF.Dispose()
string caption = "SetSignatureCertificateFromP12";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
System.IO.FileStream certificate = new System.IO.FileStream("your-digitalID-file.pfx", System.IO.FileMode.Open, System.IO.FileAccess.Read);
GdPictureStatus status = gdpicturePDF.SetSignatureCertificateFromP12(certificate, "your-password");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificateFromP12() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
certificate.Dispose();
gdpicturePDF.Dispose();
Sets up the certificate, contained in the digital ID stored in the Windows Certificate Store (the current user's store or the local machine's store),
specified by its serial number. This certificate is later used for the subsequent signing of the currently loaded PDF document.
The serial number of the certificate to be used for the subsequent signing. Use the empty string to allow the application to give you the list of
available certificates. Be aware that the serial number string is not case sensitive.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that setting up the valid certificate is the mandatory step to be able to digitally sign the PDF document. Please select the
appropriate method for carrying out this requirement according to your preference before you start the signing process.
Just to remind you that you can use the empty string if you are not sure about the correct serial number of your certificate. The application pops up a
window to allow you to select a correct one from the current user's store or the local machine's store.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the certificate (digital ID) from the Windows Certificate Store for the subsequent signing.
You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureCertificateFromStore"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureCertificateFromStore("serial-number-of-your-certificate")
'Or you can use the empty string instead to allow the application to give you a list of certificates in the current user's store.
'GdPictureStatus status = gdpicturePDF.SetSignatureCertificateFromStore("");
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificateFromStore() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureCertificateFromStore";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
GdPictureStatus status = gdpicturePDF.SetSignatureCertificateFromStore("serial-number-of-your-certificate");
//Or you can use the empty string instead to allow the application to give you a list of certificates in the current user's store.
//GdPictureStatus status = gdpicturePDF.SetSignatureCertificateFromStore("");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificateFromStore() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the certificate, contained in the digital ID, from a Smart Card reader.
This certificate is later used for the subsequent signing of the currently loaded PDF document.
The smart card provider name, for example "Microsoft Base Smart Card Crypto Provider".
The key container name.
The pin code of the smart card. Use the empty string to allow the application to ask for the correct pin code at the signing time.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that setting up the valid certificate is the mandatory step to be able to digitally sign the PDF document. Please select the
appropriate method for carrying out this requirement according to your preference before you start the signing process.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the certificate (digital ID) from a Smart Card reader for the subsequent signing.
You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureCertificateFromSmartCard"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureCertificateFromSmartCard("Smart-Card-Provider", "Key-Container-Name", "")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificateFromSmartCard() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureCertificateFromSmartCard";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
GdPictureStatus status = gdpicturePDF.SetSignatureCertificateFromSmartCard("Smart-Card-Provider", "Key-Container-Name", "");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificateFromSmartCard() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the certificate, contained in the digital ID, from a Smart Card reader, specified by its serial number.
This certificate is later used for the subsequent signing of the currently loaded PDF document.
The serial number of the certificate to be used for the subsequent signing. Use the empty string to allow the application to give you the list of
available certificates. Be aware that the serial number string is not case sensitive.
The pin code of the smart card. Use the empty string to allow the application to ask for the correct pin code at the signing time.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that setting up the valid certificate is the mandatory step to be able to digitally sign the PDF document. Please select the
appropriate method for carrying out this requirement according to your preference before you start the signing process.
Just to remind you that you can use the empty string if you are not sure about the correct serial number of your certificate as well as for the pin code.
The application pops up a window to allow you to select a correct certificate and also the application asks for the correct pin code at the signing time.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the certificate (digital ID) from a Smart Card reader for the subsequent signing.
You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureCertificateFromSmartCardBySerialNumber"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureCertificateFromSmartCardBySerialNumber("", "")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificateFromSmartCardBySerialNumber() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureCertificateFromSmartCardBySerialNumber";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//This is the first step in the signing process. It is the mandatory step. Select the method according to your preference.
GdPictureStatus status = gdpicturePDF.SetSignatureCertificateFromSmartCardBySerialNumber("", "");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificateFromSmartCardBySerialNumber() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the coordinates and dimensions of the signature's bounding box within the current page of the loaded PDF document. This is the location,
where the signature is placed after the successful signing of the current document. If you omit this method in the signing process, or you set the width
or the height to 0, the signature will not be drawn, that means it becomes invisible on the current page.
The horizontal (X) coordinate of the bottom left point of the signature's bounding box,
expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin, related to the current page.
The vertical (Y) coordinate of the bottom left point of the signature's bounding box,
expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin, related to the current page.
The width of the signature's bounding box, expressed in the current units specified by the SetMeasurementUnit method. If you set the width to 0, the signature becomes invisible.
The height of the signature's bounding box, expressed in the current units specified by the SetMeasurementUnit method. If you set the height to 0, the signature becomes invisible.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined settings during the signing, you need to set up the required parameters before you start the
signing process. But using this method in the whole process is optional.
Be aware that the values of the coordinates and dimensions are expressed in the current units defined by the method according to the
current coordinate space defined by the method. The signature is not drawn, if the width or the height of the specified bounding box are set to 0
or if this method is omitted in the signing process.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the signature's location on the current page. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignaturePos"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'Setting the origin for easier positioning the signature on the page.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'Set the signature's location on the current page. This step is optional.
'If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePos(200, 500, 200, 100)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignaturePos() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignaturePos";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//Setting the origin for easier positioning the signature on the page.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//Set the signature's location on the current page. This step is optional.
//If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePos(200, 500, 200, 100);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignaturePos() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the coordinates and dimensions of the signature's bounding box within the current page of the loaded PDF document. This is the location, where the
signature is placed after the successful signing of the current document. This method uses an empty signature form field specified by its index, so called
signature placeholder, previously added by method, to inherit its coordinates and dimensions. If you omit this method in the signing
process, or the width or the height of a placeholder are set to 0, the signature will not be drawn, that means it becomes invisible on the current page.
Sets up the coordinates and dimensions of the signature's bounding box within the current page of the loaded PDF document using the signature placeholder, in
other words previously added empty signature form field.
The index of the signature form field (placeholder). It must be a value from 0 to -1 related to the document,
where the placeholder is located. Be aware that this index doesn't correspond to the form field unique identifier.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined settings during the signing, you need to set up the required parameters before you start the
signing process. But using this method in the whole process is optional.This method can be used instead of the method.
A signature place holder can be created with the method.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the signature's location on the current page using an empty signature form field.
You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignaturePosFromPlaceHolder"
Dim gdpicturePDF As New GdPicturePDF()
'Please take a PDF document created in the example for the AddSignatureFormField() method.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test_AddSignatureFormField.pdf", False)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The file can't be loaded.", caption)
GoTo [error]
End If
'Please set the corresponding certificate - this is a mandatory step.
'Set the signature information. At least one parameter must be defined for the successful signing.
status = gdpicturePDF.SetSignatureInfo("Orpalis", "GdPicturePDF", "Toulouse (France)", "")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureInfo() has failed with the status " + status.ToString(), caption)
GoTo [error]
End If
'Find a placeholder for a signature.
Dim signatureCount As Integer = gdpicturePDF.GetSignatureCount()
'This step is strongly bound to the file "test_AddSignatureFormField.pdf".
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (signatureCount = 1) Then
'Set the signature's location on the current page. This step is optional.
'If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePosFromPlaceHolder(signatureCount - 1)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignaturePosFromPlaceHolder() has failed with the status: " + status.ToString(), caption)
GoTo [error]
End If
Else
MessageBox.Show("Can't find a signature placeholder field." + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignaturePosFromPlaceHolder";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please take a PDF document created in the example for the AddSignatureFormField() method.
GdPictureStatus status = gdpicturePDF.LoadFromFile("test_AddSignatureFormField.pdf", false);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The file can't be loaded.", caption);
goto error;
}
//Please set the corresponding certificate - this is a mandatory step.
//Set the signature information. At least one parameter must be defined for the successful signing.
status = gdpicturePDF.SetSignatureInfo("Orpalis", "GdPicturePDF", "Toulouse (France)", "");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureInfo() has failed with the status " + status.ToString(), caption);
goto error;
}
//Find a placeholder for a signature.
int signatureCount = gdpicturePDF.GetSignatureCount();
//This step is strongly bound to the file "test_AddSignatureFormField.pdf".
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) && (signatureCount == 1))
{
//Set the signature's location on the current page. This step is optional.
//If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePosFromPlaceHolder(signatureCount - 1);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignaturePosFromPlaceHolder() has failed with the status: " + status.ToString(), caption);
goto error;
}
}
else
{
MessageBox.Show("Can't find a signature placeholder field." + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow
error:
gdpicturePDF.Dispose();
Sets up the coordinates and dimensions of the signature's bounding box within the current page of the loaded PDF document. This is the location, where the
signature is placed after the successful signing of the current document. This method uses an empty signature form field specified by its name, so called
signature placeholder, previously added by method, to inherit its coordinates and dimensions. If you omit this method in the signing
process, or the width or the height of a placeholder are set to 0, the signature will not be drawn, that means it becomes invisible on the current page.
Sets up the coordinates and dimensions of the signature's bounding box within the current page of the loaded PDF document using the signature placeholder, in
other words previously added empty signature form field.
The name of the signature form field (placeholder). It is the FieldName parameter from the method or
you can obtain this name using the method.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined settings during the signing, you need to set up the required parameters before you start the
signing process. But using this method in the whole process is optional.
This method can be used instead of the method. A signature place holder can be created with the method.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the signature's location on the current page using an empty signature form field.
You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignaturePosFromPlaceHolder"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please take a PDF document created in the example for the AddSignatureFormField() method.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test_AddSignatureFormField.pdf", False)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The file can't be loaded.", caption)
Goto [Error]
End If
'Please set the corresponding certificate - this is a mandatory step.
'Set the signature information. At least one parameter must be defined for the successful signing.
status = gdpicturePDF.SetSignatureInfo("Orpalis", "GdPicturePDF", "Toulouse (France)", "")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureInfo() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
'Find a placeholder for a signature.
Dim formID As Integer = 0
Dim formType As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim signatureName As String = ""
'Here we demonstrate how to find out the signature's name (the name of the signature form field (placeholder)).
Dim formsCount As Integer = gdpicturePDF.GetFormFieldsCount()
status = gdpicturePDF.GetStat()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If formsCount = 0 Then
MessageBox.Show("This document does not include form fields.", caption)
Goto [Error]
End If
'This step is strongly bound to the file "test_AddSignatureFormField.pdf".
For i As Integer = 0 To formsCount - 1 - 1
formID = gdpicturePDF.GetFormFieldId(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
formType = gdpicturePDF.GetFormFieldType(formID)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (formType = PdfFormFieldType.PdfFormFieldTypeSignature) Then
signatureName = gdpicturePDF.GetFormFieldTitle(formID)
status = gdpicturePDF.GetStat()
'Only one signature form field is expected here - see the "test_AddSignatureFormField.pdf" file.
Exit For
End If
End If
Next
If status <> GdPictureStatus.OK Then
MessageBox.Show("Can't find a signature placeholder field. Status: " + status.ToString(), caption)
Goto [Error]
End If
Else
MessageBox.Show("The method GetFormFieldsCount() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
'Set the signature's location on the current page. This step is optional.
'If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePosFromPlaceHolder(signatureName)
'If you know the form field's name, you can use it directly like this (see the file "test_AddSignatureFormField.pdf"):
'status = gdpicturePDF.SetSignaturePosFromPlaceHolder("Signature1")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignaturePosFromPlaceHolder() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignaturePosFromPlaceHolder";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please take a PDF document created in the example for the AddSignatureFormField() method.
GdPictureStatus status = gdpicturePDF.LoadFromFile("test_AddSignatureFormField.pdf", false);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The file can't be loaded.", caption);
goto error;
}
//Please set the corresponding certificate - this is a mandatory step.
//Set the signature information. At least one parameter must be defined for the successful signing.
status = gdpicturePDF.SetSignatureInfo("Orpalis", "GdPicturePDF", "Toulouse (France)", "");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureInfo() has failed with the status " + status.ToString(), caption);
goto error;
}
//Find a placeholder for a signature.
int formID = 0;
PdfFormFieldType formType = PdfFormFieldType.PdfFormFieldTypeUnknown;
string signatureName = "";
//Here we demonstrate how to find out the signature's name (the name of the signature form field (placeholder)).
int formsCount = gdpicturePDF.GetFormFieldsCount();
status = gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (formsCount == 0)
{
MessageBox.Show("This document does not include form fields.", caption);
goto error;
}
//This step is strongly bound to the file "test_AddSignatureFormField.pdf".
for (int i = 0; i < formsCount-1; i++ )
{
formID = gdpicturePDF.GetFormFieldId(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
formType = gdpicturePDF.GetFormFieldType(formID);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) &&
(formType == PdfFormFieldType.PdfFormFieldTypeSignature))
{
signatureName = gdpicturePDF.GetFormFieldTitle(formID);
status = gdpicturePDF.GetStat();
//Only one signature form field is expected here - see the "test_AddSignatureFormField.pdf" file.
break;
}
}
}
if (status != GdPictureStatus.OK)
{
MessageBox.Show("Can't find a signature placeholder field. Status: " + status.ToString(), caption);
goto error;
}
}
else
{
MessageBox.Show("The method GetFormFieldsCount() has failed with the status " + status.ToString(), caption);
goto error;
}
//Set the signature's location on the current page. This step is optional.
//If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePosFromPlaceHolder(signatureName);
//If you know the form field's name, you can use it directly like this (see the file "test_AddSignatureFormField.pdf"):
//status = gdpicturePDF.SetSignaturePosFromPlaceHolder("Signature1");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignaturePosFromPlaceHolder() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the required image to be drawn within the signature's bounding box. The specified resource will be applied during the subsequent signing process. If
the applied signature is invisible, the image will not be drawn. If you also set the text using the method,
the image will be situated at the right side within the signature's bounding box.
The resource name of the image you want to drawn within the signature's bounding box. The image will not be drawn if the signature is invisible.
For further assistance, please see the Images section of the GdPicturePDF class in the Reference Guide.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined settings during the signing, you need to set up the required parameters before you start the
signing process. But using this method in the whole process is optional.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the image to be displayed within the signature. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureStampImage"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'Set the image to be displayed within the signature's bounding box. This step is optional.
Dim imageResName As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method AddJpegImageFromFile() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
status = gdpicturePDF.SetSignatureStampImage(imageResName)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureStampImage() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureStampImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//Set the image to be displayed within the signature's bounding box. This step is optional.
string imageResName = gdpicturePDF.AddJpegImageFromFile("image.jpg");
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method AddJpegImageFromFile() has failed with the status " + status.ToString(), caption);
goto error;
}
status = gdpicturePDF.SetSignatureStampImage(imageResName);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureStampImage() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the additional signature information.
The name of the person or authority signing the document.
The reason for the signing the document.
The (physical) location of the signing.
Information provided by the signer to enable a recipient to contact the signer to verify the signature, for example a phone number.
This method is only allowed for use with non-encrypted documents.
This step is optional. In case the additional information is not provided the signing process will extract necessary information from the certificate.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up additional information for the subsequent signing. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureInfo"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureInfo("Orpalis", "Important PDF", "Toulouse (France)", "contact@orpalis.com")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureInfo() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureInfo";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
GdPictureStatus status = gdpicturePDF.SetSignatureInfo("Orpalis", "Important PDF", "Toulouse (France)", "contact@orpalis.com");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureInfo() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the defined text to be displayed within the signature's bounding box according to the parameters you have specified. The required settings will be
applied during the subsequent signing process. If you also set the image using the method, the text will be situated on the left side
within the signature's bounding box. If the applied signature is invisible, the text will not be drawn.
Sets up the text to be displayed within the signature's bounding box.
The required text to draw. If you leave this parameter empty and the ShowText parameter is set to true, the drawn text will be built automatically using
the additional information previously defined by the method. The text will not be drawn if the signature is invisible.
The resource name of the font you prefer for drawing the text. If you leave this parameter empty, the predefined standard font is used.
For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points. Please note that 1 point = 1/72 inch.
A color object that defines the color of the required text.
The required horizontal alignment of the text within the signature's bounding box.
The required vertical alignment of the text within the signature's bounding box.
Set this parameter to true, if you want to draw the text, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined settings during the signing, you need to set up the required parameters before you start the
signing process. But using this method in the whole process is optional.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the additional text to be displayed within the signature. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureText"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'Set the text to be displayed within the signature's bounding box. This step is optional.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureText("", "", 12, Color.Navy, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureText() has failed with the status " + status.ToString(), caption)
GoTo [error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//Set the text to be displayed within the signature's bounding box. This step is optional.
GdPictureStatus status = gdpicturePDF.SetSignatureText("", "", 12, Color.Navy, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureText() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the defined text to be displayed within the signature's bounding box according to the parameters you have specified. The required settings will be
applied during the subsequent signing process. If you also set the image using the method, the text will be situated on the left side
within the signature's bounding box. If the applied signature is invisible, the text will not be drawn.
Sets up the text to be displayed within the signature's bounding box.
The required text to draw. If you leave this parameter empty and the ShowText parameter is set to true, the drawn text will be built automatically using
the additional information previously defined by the method. The text will not be drawn if the signature is invisible.
The resource name of the font you prefer for drawing the text. If you leave this parameter empty, the predefined standard font is used.
For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points. Please note that 1 point = 1/72 inch.
A color object that defines the color of the required text.
The required horizontal alignment of the text within the signature's bounding box.
The required vertical alignment of the text within the signature's bounding box.
A member of the PDFTextDecorationStyle enumeration.
Set this parameter to true, if you want to draw the text, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined settings during the signing, you need to set up the required parameters before you start the
signing process. But using this method in the whole process is optional.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the additional text to be displayed within the signature. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureText"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'Set the text to be displayed within the signature's bounding box. This step is optional.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureText("", "", 12, Color.Navy, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, PdfTextDecorationStyle.Underline, True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureText() has failed with the status " + status.ToString(), caption)
GoTo [error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//Set the text to be displayed within the signature's bounding box. This step is optional.
GdPictureStatus status = gdpicturePDF.SetSignatureText("", "", 12, Color.Navy, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, PdfTextDecorationStyle.Underline, true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureText() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the defined text to be displayed within the signature's bounding box according to the parameters you have specified. The required settings will be
applied during the subsequent signing process. If you also set the image using the method, the text will be situated on the left side
within the signature's bounding box. If the applied signature is invisible, the image will not be drawn.
This method uses the CMYK color space for specifying the required color.
Sets up the text to be displayed within the signature's bounding box.
The required text to draw. If you leave this parameter empty and the ShowText parameter is set to true, the drawn text will be built automatically using
the additional information previously defined by the method. The text will not be drawn if the signature is invisible.
The resource name of the font you prefer for drawing the text. If you leave this parameter empty, the predefined standard font is used.
For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points. Please note that 1 point = 1/72 inch.
The amount of cyan color to be used for the resulting text color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting text color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting text color. Use the value between 0 and 255.
The amount of black color to be used for the resulting text color. Use the value between 0 and 255.
The required horizontal alignment of the text within the signature's bounding box.
The required vertical alignment of the text within the signature's bounding box.
Set this parameter to true, if you want to draw the text, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined settings during the signing, you need to set up the required parameters before you start the
signing process. But using this method in the whole process is optional.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the additional text to be displayed within the signature. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureText"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'Set the text to be displayed within the signature's bounding box. This step is optional.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureText("", "", 12, 255, 255, 128, 128, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureText() has failed with the status " + status.ToString(), caption)
GoTo [error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//Set the text to be displayed within the signature's bounding box. This step is optional.
GdPictureStatus status = gdpicturePDF.SetSignatureText("", "", 12, 255, 255, 128, 128, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureText() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Sets up the defined text to be displayed within the signature's bounding box according to the parameters you have specified. The required settings will be
applied during the subsequent signing process. If you also set the image using the method, the text will be situated on the left side
within the signature's bounding box. If the applied signature is invisible, the image will not be drawn.
This method uses the CMYK color space for specifying the required color.
Sets up the text to be displayed within the signature's bounding box.
The required text to draw. If you leave this parameter empty and the ShowText parameter is set to true, the drawn text will be built automatically using
the additional information previously defined by the method. The text will not be drawn if the signature is invisible.
The resource name of the font you prefer for drawing the text. If you leave this parameter empty, the predefined standard font is used.
For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points. Please note that 1 point = 1/72 inch.
The amount of cyan color to be used for the resulting text color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting text color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting text color. Use the value between 0 and 255.
The amount of black color to be used for the resulting text color. Use the value between 0 and 255.
The required horizontal alignment of the text within the signature's bounding box.
The required vertical alignment of the text within the signature's bounding box.
A member of the PDFTextDecorationStyle enumeration.
Set this parameter to true, if you want to draw the text, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined settings during the signing, you need to set up the required parameters before you start the
signing process. But using this method in the whole process is optional.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the additional text to be displayed within the signature. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureText"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'Set the text to be displayed within the signature's bounding box. This step is optional.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureText("", "", 12, 255, 255, 128, 128, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, PdfTextDecorationStyle.Underline, True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureText() has failed with the status " + status.ToString(), caption)
GoTo [error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//Set the text to be displayed within the signature's bounding box. This step is optional.
GdPictureStatus status = gdpicturePDF.SetSignatureText("", "", 12, 255, 255, 128, 128, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, PdfTextDecorationStyle.Underline, true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureText() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Specifies whether the validity of the signature will be displayed using the corresponding graphic icon (validation mark) after the signing of the currently loaded
PDF document. The predefined icon, that represents the current validity of the signature, is subsequently drawn within the signature's bounding box after
the successful signing.
Set this parameter to true if you want to display the signature's validity icon along with displaying the signature itself. Otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined setting during the signing, you need to set up the required parameter before you start the signing
process. But using this method in the whole process is optional.Prior to Acrobat 6.0, signature appearances were manipulated at run-time in order to display the validity of the signature. The validity was shown as a
graphic icon and with an additional, optional text message. Beginning with version 6, Acrobat does not maintain support for signature appearances that can be
manipulated, though legacy signatures with these appearances may continue to display correctly. Use of the validity mark in the signature is not recommended.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up displaying the signature's validity after the successful signing. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureValidationMark"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'The icon that represents the validity will display along with the signature. This step is optional.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureValidationMark(True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureValidationMark() has failed with the status " + status.ToString(), caption)
GoTo [error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureValidationMark";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//The icon that represents the validity will display along with the signature. This step is optional.
GdPictureStatus status = gdpicturePDF.SetSignatureValidationMark(true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureValidationMark() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Specifies the Time Stamp Server and the corresponding credentials, if you want to use timestamping for the subsequent signing of the
currently loaded PDF document.
The required Time Stamp Server's URL to be used when signing. Supported are TCP and HTTP/HTTPS formatted URLs.
The username corresponding with the account created on the specified server, if available. You can use an empty string if you are uncertain.
The parameter is not used when the server's URL is in TCP format.
The password for the corresponding account, if available. You can use an empty string if you are uncertain.
The parameter is not used when the server's URL is in TCP format.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if you want to apply the defined settings during the signing, you need to set up the required parameters before you start the
signing process. But using this method in the whole process is optional.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up timestamp information for the subsequent signing. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureTimestampInfo"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'Set the timestamp information. This step is optional.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureTimestampInfo("your_time_stamp_server_url", "your_username", "your_password")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureTimestampInfo() has failed with the status " + status.ToString(), caption)
GoTo [error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureTimestampInfo";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//Set the timestamp information. This step is optional.
GdPictureStatus status = gdpicturePDF.SetSignatureTimestampInfo("your_time_stamp_server_url", "your_username", "your_password");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureTimestampInfo() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Specifies the hash algorithm to be used for the subsequent signing of the currently loaded PDF document.
Now the SHA-256 algorithm is used as the standard, although with some old certificates you will still need to use SHA-1.
You can find more details about the SHA algorithms in RFC 6234 US Secure Hash Algorithms (SHA And SHA-based HMAC And HKDF).
A member of the PdfSignatureHash enumeration. The required hash algorithm to be used in the subsequent signing process.
Please check the returned status to find out if the specified hash is supported by your certificate.
This method is only allowed for use with non-encrypted documents.
Be aware that you need to set up the required hash algorithm before you start the signing process.
At the same, always check if your certificate supports the specified hash using the returned status.
Furthermore, from 2016 onward the SHA-1 algorithm is deprecated, the SHA-256 or stronger should be used instead if possible.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify a required hash algorithm for the subsequent signing. You can find the complete sample within the ApplySignature() method's example.
Dim caption As String = "SetSignatureHash"
Dim gdpicturePDF As New GdPicturePDF()
'Please load the PDF document you want to sign.
'Please set the corresponding certificate - this is a mandatory step.
'Set the hash algorithm.
'If this step is omitted, the value of PdfSignatureHash.SHA256 is used.
'If your certificate does not support this hash, the old PdfSignatureHash.SHA1 is used as default.
Dim status As GdPictureStatus = gdpicturePDF.SetSignatureHash(PdfSignatureHash.SHA512)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureHash() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
'Please see the complete sample in the ApplySignature() method for next steps to follow.
[error]:
gdpicturePDF.Dispose()
string caption = "SetSignatureHash";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please load the PDF document you want to sign.
//Please set the corresponding certificate - this is a mandatory step.
//Set the hash algorithm.
//If this step is omitted, the value of PdfSignatureHash.SHA256 is used.
//If your certificate does not support this hash, the old PdfSignatureHash.SHA1 is used as default.
GdPictureStatus status = gdpicturePDF.SetSignatureHash(PdfSignatureHash.SHA512);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureHash() has failed with the status " + status.ToString(), caption);
goto error;
}
//Please see the complete sample in the ApplySignature() method for next steps to follow.
error:
gdpicturePDF.Dispose();
Set the alternate title property for the Signature field.
The value to set as alternate title.
This method is only allowed for use with non-encrypted documents.
This step is optional. The alternate title is usually used to set tooltip content.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Applies the digital signature or the certificate on the current page of the loaded PDF document according to all settings you have provided. This method uses
the output filename as a string parameter.
Please follow the example below to find out the correct steps for setting up the particular parameters you need. Some of these steps are mandatory, some of
them are optional. The method is always the last one you need to call.
Be aware that all settings are applied to the currently loaded PDF document.
You are also allowed to successfully apply more than one digital signature to the PDF document in a time. You only need to reload the currently signed PDF document
after every single signing. This way you will not invalidate the previously applied signature.
Applies the digital signature or the certificate on the current page of the loaded PDF document.
The file path, where the currently loaded PDF document will be saved to after the successful signing. If the specified file already exists, it will be
overwritten. You have to specify a full file path with the correct file extension, which is "pdf".
A member of the PdfSignatureMode enumeration. Specifies the electronic signature technology (security handler) to be used during the signing process.
Specifies if the output PDF document should be linearized when saving.
This method is only allowed for use with non-encrypted documents.
Just to remind you that PPKLite is the old technology, prefer PPKMS. If you need to meet EU requirements, choose CAdES. PPKLite uses PKCS#1 standard and
PPKMS uses PKCS#7 standard.
Likewise, be aware that from 2016 onward the SHA-1 algorithm is deprecated, therefore the SHA-256 algorithm is used as default.
You can change it using the method.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to sign a PDF document. The example shows you all steps you need to follow for successful signing.
Dim caption As String = "Digital Signature"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("file_to_sign.pdf", False)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The file can't be loaded.", caption)
Goto [Error]
End If
'Mandatory steps are step #1 and step #2 and the last step #5.
'Step 1 : Set the certificate, your digital ID file.
status = gdpicturePDF.SetSignatureCertificateFromP12("your_digital_ID.pfx", "your_password")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificateFromP12() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 2 : Set the signature information. At least one parameter must be set, others may stay empty.
status = gdpicturePDF.SetSignatureInfo("Orpalis", "Important PDF", "Toulouse (France)", "contact@orpalis.com")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureInfo() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Optional steps.
'Step 3a : Set the signature's location on the current page. If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePos(300, 100, 200, 100)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignaturePos() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 3b : Set the text to be displayed within the signature's bounding box. The text will not be drawn if the signature is invisible.
status = gdpicturePDF.SetSignatureText("", "", 12, Color.Navy, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureText() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 3c : Set the image to be displayed within the signature's bounding box. The image will not be drawn if the signature is invisible.
Dim imageName As String = gdpicturePDF.AddJpegImageFromFile("your_image.jpg")
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method AddJpegImageFromFile() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
status = gdpicturePDF.SetSignatureStampImage(imageName)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureStampImage() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 3d : Set the icon that represents the validity of the signature.
status = gdpicturePDF.SetSignatureValidationMark(True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureValidationMark() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 4a : Set the signature certification level.
status = gdpicturePDF.SetSignatureCertificationLevel(PdfSignatureCertificationLevel.NotCertified)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificationLevel() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 4b : Set the hash algorithm.
status = gdpicturePDF.SetSignatureHash(PdfSignatureHash.SHA256)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureHash() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
'Step 4c : Set the timestamp information.
status = gdpicturePDF.SetSignatureTimestampInfo("your_time_stamp_server_url", "your_username", "your_password")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureTimestampInfo() has failed with the status " + status.ToString(), caption)
GoTo [error]
End If
'Step 5 : The last step - sign. This step must be the last one. All other optional steps may be done in any order.
status = gdpicturePDF.ApplySignature("signed.pdf", PdfSignatureMode.PdfSignatureModeAdobePPKMS, True)
If status = GdPictureStatus.OK Then
MessageBox.Show("The document has been signed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The method ApplySignature() has failed with the status: " + status.ToString(), caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Digital Signature";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("file_to_sign.pdf", false);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The file can't be loaded.", caption);
goto error;
}
//Mandatory steps are step #1 and step #2 and the last step #5.
//Step 1 : Set the certificate, your digital ID file.
status = gdpicturePDF.SetSignatureCertificateFromP12("your_digital_ID.pfx", "your_password");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificateFromP12() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 2 : Set the signature information. At least one parameter must be set, others may stay empty.
status = gdpicturePDF.SetSignatureInfo("Orpalis", "Important PDF", "Toulouse (France)", "contact@orpalis.com");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureInfo() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Optional steps.
//Step 3a : Set the signature's location on the current page. If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePos(300, 100, 200, 100);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignaturePos() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 3b : Set the text to be displayed within the signature's bounding box. The text will not be drawn if the signature is invisible.
status = gdpicturePDF.SetSignatureText("", "", 12, Color.Navy, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureText() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 3c : Set the image to be displayed within the signature's bounding box. The image will not be drawn if the signature is invisible.
string imageName = gdpicturePDF.AddJpegImageFromFile("your_image.jpg");
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method AddJpegImageFromFile() has failed with the status: " + status.ToString(), caption);
goto error;
}
status = gdpicturePDF.SetSignatureStampImage(imageName);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureStampImage() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 3d : Set the icon that represents the validity of the signature.
status = gdpicturePDF.SetSignatureValidationMark(true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureValidationMark() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 4a : Set the signature certification level.
status = gdpicturePDF.SetSignatureCertificationLevel(PdfSignatureCertificationLevel.NotCertified);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificationLevel() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 4b : Set the hash algorithm.
status = gdpicturePDF.SetSignatureHash(PdfSignatureHash.SHA256);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureHash() has failed with the status " + status.ToString(), caption);
goto error;
}
//Step 4c : Set the timestamp information.
status = gdpicturePDF.SetSignatureTimestampInfo("your_time_stamp_server_url", "your_username", "your_password");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureTimestampInfo() has failed with the status " + status.ToString(), caption);
goto error;
}
//Step 5 : The last step - sign. This step must be the last one. All other optional steps may be done in any order.
status = gdpicturePDF.ApplySignature("signed.pdf", PdfSignatureMode.PdfSignatureModeAdobePPKMS, true);
if (status == GdPictureStatus.OK)
MessageBox.Show("The document has been signed successfully and the file has been saved.", caption);
else
MessageBox.Show("The method ApplySignature() has failed with the status: " + status.ToString(), caption);
error:
gdpicturePDF.Dispose();
Applies the digital signature or the certificate on the current page of the loaded PDF document according to all settings you have provided. This method uses
the output filename as a Stream parameter.
Please follow the example below to find out the correct steps for setting up the particular parameters you need. Some of these steps are mandatory, some of
them are optional. The method is always the last one you need to call.
Be aware that all settings are applied to the currently loaded PDF document.
You are also allowed to successfully apply more than one digital signature to the PDF document in a time. You only need to reload the currently signed PDF document
after every single signing. This way you will not invalidate the previously applied signature.
Applies the digital signature or the certificate on the current page of the loaded PDF document.
A Stream object, where the currently loaded PDF document will be saved to after the successful signing.
A member of the PdfSignatureMode enumeration. Specifies the electronic signature technology (security handler) to be used during the signing process.
Specifies if the output PDF document should be linearized when saving.
This method is only allowed for use with non-encrypted documents.
Just to remind you that PPKLite is the old technology, prefer PPKMS. If you need to meet EU requirements, choose CAdES. PPKLite uses PKCS#1 standard and PPKMS uses PKCS#7 standard.
Likewise, be aware that from 2016 onward the SHA-1 algorithm is deprecated, therefore the SHA-256 algorithm is used as default.
You can change it using the method.
This method requires the Digital Signatures component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to sign a PDF document. The example shows you all steps you need to follow for successful signing.
Dim caption As String = "Digital Signature"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("file_to_sign.pdf", False)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The file can't be loaded.", caption)
Goto [Error]
End If
'Mandatory steps are step #1 and step #2 and the last step #5.
'Step 1 : Set the certificate, your digital ID file.
status = gdpicturePDF.SetSignatureCertificateFromP12("your_digital_ID.pfx", "your_password")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificateFromP12() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 2 : Set the signature information. At least one parameter must be set, others may stay empty.
status = gdpicturePDF.SetSignatureInfo("Orpalis", "Important PDF", "Toulouse (France)", "contact@orpalis.com")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureInfo() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Optional steps.
'Step 3a : Set the signature's location on the current page. If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePos(300, 100, 200, 100)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignaturePos() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 3b : Set the text to be displayed within the signature's bounding box. The text will not be drawn if the signature is invisible.
status = gdpicturePDF.SetSignatureText("", "", 12, Color.Navy, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureText() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 3c : Set the image to be displayed within the signature's bounding box. The image will not be drawn if the signature is invisible.
Dim imageName As String = gdpicturePDF.AddJpegImageFromFile("your_image.jpg")
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method AddJpegImageFromFile() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
status = gdpicturePDF.SetSignatureStampImage(imageName)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureStampImage() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 3d : Set the icon that represents the validity of the signature.
status = gdpicturePDF.SetSignatureValidationMark(True)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureValidationMark() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 4a : Set the signature certification level.
status = gdpicturePDF.SetSignatureCertificationLevel(PdfSignatureCertificationLevel.NotCertified)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureCertificationLevel() has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
'Step 4b : Set the hash algorithm.
status = gdpicturePDF.SetSignatureHash(PdfSignatureHash.SHA256)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureHash() has failed with the status " + status.ToString(), caption)
Goto [Error]
End If
'Step 4c : Set the timestamp information.
status = gdpicturePDF.SetSignatureTimestampInfo("your_time_stamp_server_url", "your_username", "your_password")
If status <> GdPictureStatus.OK Then
MessageBox.Show("The method SetSignatureTimestampInfo() has failed with the status " + status.ToString(), caption)
GoTo [error]
End If
'Step 5 : The last step - sign. This step must be the last one. All other optional steps may be done in any order.
Dim streamSigned As New System.IO.FileStream("signed.pdf", System.IO.FileMode.Create)
status = gdpicturePDF.ApplySignature("signed.pdf", PdfSignatureMode.PdfSignatureModeAdobePPKMS, True)
If status = GdPictureStatus.OK Then
MessageBox.Show("The document has been signed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The method ApplySignature() has failed with the status: " + status.ToString(), caption)
End If
streamSigned.Dispose()
[error]:
gdpicturePDF.Dispose()
string caption = "Digital Signature";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("file_to_sign.pdf", false);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The file can't be loaded.", caption);
goto error;
}
//Mandatory steps are step #1 and step #2 and the last step #5.
//Step 1 : Set the certificate, your digital ID file.
status = gdpicturePDF.SetSignatureCertificateFromP12("your_digital_ID.pfx", "your_password");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificateFromP12() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 2 : Set the signature information. At least one parameter must be set, others may stay empty.
status = gdpicturePDF.SetSignatureInfo("Orpalis", "Important PDF", "Toulouse (France)", "contact@orpalis.com");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureInfo() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Optional steps.
//Step 3a : Set the signature's location on the current page. If this step is omitted, the signature will be invisible.
status = gdpicturePDF.SetSignaturePos(300, 100, 200, 100);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignaturePos() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 3b : Set the text to be displayed within the signature's bounding box. The text will not be drawn if the signature is invisible.
status = gdpicturePDF.SetSignatureText("", "", 12, Color.Navy, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureText() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 3c : Set the image to be displayed within the signature's bounding box. The image will not be drawn if the signature is invisible.
string imageName = gdpicturePDF.AddJpegImageFromFile("your_image.jpg");
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method AddJpegImageFromFile() has failed with the status: " + status.ToString(), caption);
goto error;
}
status = gdpicturePDF.SetSignatureStampImage(imageName);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureStampImage() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 3d : Set the icon that represents the validity of the signature.
status = gdpicturePDF.SetSignatureValidationMark(true);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureValidationMark() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 4a : Set the signature certification level.
status = gdpicturePDF.SetSignatureCertificationLevel(PdfSignatureCertificationLevel.NotCertified);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureCertificationLevel() has failed with the status: " + status.ToString(), caption);
goto error;
}
//Step 4b : Set the hash algorithm.
status = gdpicturePDF.SetSignatureHash(PdfSignatureHash.SHA256);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureHash() has failed with the status " + status.ToString(), caption);
goto error;
}
//Step 4c : Set the timestamp information.
status = gdpicturePDF.SetSignatureTimestampInfo("your_time_stamp_server_url", "your_username", "your_password");
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The method SetSignatureTimestampInfo() has failed with the status " + status.ToString(), caption);
goto error;
}
//Step 5 : The last step - sign. This step must be the last one. All other optional steps may be done in any order.
System.IO.FileStream streamSigned = new System.IO.FileStream("signed.pdf", System.IO.FileMode.Create);
status = gdpicturePDF.ApplySignature(streamSigned, PdfSignatureMode.PdfSignatureModeAdobePPKMS, true);
if (status == GdPictureStatus.OK)
MessageBox.Show("The document has been signed successfully and the file has been saved.", caption);
else
MessageBox.Show("The method ApplySignature() has failed with the status: " + status.ToString(), caption);
streamSigned.Dispose();
error:
gdpicturePDF.Dispose();
Returns the number of fonts used in the currently loaded PDF document.
A font for use with a PDF consumer application is prepared in the form of a program.
Such a font program is written in a special-purpose language, that is understood by a specialized font interpreter.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of fonts used in the document. The method can be subsequently used to determine if this method has been successful.
How to find out the number of all fonts and their properties used in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim fontCount As Integer = gdpicturePDF.GetFontCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim output As String = "The number of fonts used in this document is " + fontCount.ToString() + "." + vbCrLf + vbCrLf
For i As Integer = 1 To fontCount
output = output + i.ToString() + ". Font: "
Dim fontName As String = "", fontType As String = "", fontEncoding As String = ""
'Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " Name = " + fontName
Else
output = output + " Name = Error (" + status.ToString() + ")"
End If
'Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Type = " + fontType
Else
output = output + "; Type = Error (" + status.ToString() + ")"
End If
'Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Encoding = " + fontEncoding
Else
output = output + "; Encoding = Error (" + status.ToString() + ")"
End If
'Finding out if the used font is embedded.
Dim fontEmbedded As Boolean = gdpicturePDF.IsFontEmbedded(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Embedded = " + fontEmbedded.ToString() + vbCrLf
Else
output = output + "; Embedded = Error (" + status.ToString() + ")" + vbCrLf
End If
Next
MessageBox.Show(output, "Example: GetFontCount")
Else
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontCount")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetFontCount")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int fontCount = gdpicturePDF.GetFontCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string output = "The number of fonts used in this document is " + fontCount.ToString() + ".\n\n";
for (int i = 1; i <= fontCount; i++)
{
output = output + i.ToString() + ". Font: ";
string fontName = "", fontType = "", fontEncoding = "";
//Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " Name = " + fontName;
else
output = output + " Name = Error (" + status.ToString() + ")";
//Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Type = " + fontType;
else
output = output + "; Type = Error (" + status.ToString() + ")";
//Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Encoding = " + fontEncoding;
else
output = output + "; Encoding = Error (" + status.ToString() + ")";
//Finding out if the used font is embedded.
bool fontEmbedded = gdpicturePDF.IsFontEmbedded(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Embedded = " + fontEmbedded.ToString() + "\n";
else
output = output + "; Embedded = Error (" + status.ToString() + ")\n";
}
MessageBox.Show(output, "Example: GetFontCount");
}
else
{
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontCount");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetFontCount");
}
gdpicturePDF.Dispose();
Returns the name of the font used in the currently loaded PDF document according to the font index you have specified.
You can use the method to determine the number of all used fonts in the PDF document. The font index is simply an integer value from 1 to .
This name of the font can be used to find the font's definition in the consumer application or its environment. It is also the name that is used when printing to a PostScript output device.
The font index. It must be a value from 1 to .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The font name (the PostScript name of the font). The method can be subsequently used to determine if this method has been successful.
How to find out the number of all fonts and their properties used in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim fontCount As Integer = gdpicturePDF.GetFontCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim output As String = "The number of fonts used in this document is " + fontCount.ToString() + "." + vbCrLf + vbCrLf
For i As Integer = 1 To fontCount
output = output + i.ToString() + ". Font: "
Dim fontName As String = "", fontType As String = "", fontEncoding As String = ""
'Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " Name = " + fontName
Else
output = output + " Name = Error (" + status.ToString() + ")"
End If
'Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Type = " + fontType
Else
output = output + "; Type = Error (" + status.ToString() + ")"
End If
'Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Encoding = " + fontEncoding
Else
output = output + "; Encoding = Error (" + status.ToString() + ")"
End If
'Finding out if the used font is embedded.
Dim fontEmbedded As Boolean = gdpicturePDF.IsFontEmbedded(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Embedded = " + fontEmbedded.ToString() + vbCrLf
Else
output = output + "; Embedded = Error (" + status.ToString() + ")" + vbCrLf
End If
Next
MessageBox.Show(output, "Example: GetFontName")
Else
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontName")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetFontName")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int fontCount = gdpicturePDF.GetFontCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string output = "The number of fonts used in this document is " + fontCount.ToString() + ".\n\n";
for (int i = 1; i <= fontCount; i++)
{
output = output + i.ToString() + ". Font: ";
string fontName = "", fontType = "", fontEncoding = "";
//Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " Name = " + fontName;
else
output = output + " Name = Error (" + status.ToString() + ")";
//Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Type = " + fontType;
else
output = output + "; Type = Error (" + status.ToString() + ")";
//Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Encoding = " + fontEncoding;
else
output = output + "; Encoding = Error (" + status.ToString() + ")";
//Finding out if the used font is embedded.
bool fontEmbedded = gdpicturePDF.IsFontEmbedded(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Embedded = " + fontEmbedded.ToString() + "\n";
else
output = output + "; Embedded = Error (" + status.ToString() + ")\n";
}
MessageBox.Show(output, "Example: GetFontName");
}
else
{
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontName");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetFontName");
}
gdpicturePDF.Dispose();
Returns the type of the font used in the currently loaded PDF document according to the font index you have specified. You can use the method
to determine the number of all used fonts in the PDF document. The font index is simply an integer value from 1 to .
For example, the most popular font types are TrueType and Adobe's Type 1, another are Type 3, Composite fonts and OpenType.
The font index. It must be a value from 1 to .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The font type. The method can be subsequently used to determine if this method has been successful.
How to find out the number of all fonts and their properties used in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim fontCount As Integer = gdpicturePDF.GetFontCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim output As String = "The number of fonts used in this document is " + fontCount.ToString() + "." + vbCrLf + vbCrLf
For i As Integer = 1 To fontCount
output = output + i.ToString() + ". Font: "
Dim fontName As String = "", fontType As String = "", fontEncoding As String = ""
'Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " Name = " + fontName
Else
output = output + " Name = Error (" + status.ToString() + ")"
End If
'Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Type = " + fontType
Else
output = output + "; Type = Error (" + status.ToString() + ")"
End If
'Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Encoding = " + fontEncoding
Else
output = output + "; Encoding = Error (" + status.ToString() + ")"
End If
'Finding out if the used font is embedded.
Dim fontEmbedded As Boolean = gdpicturePDF.IsFontEmbedded(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Embedded = " + fontEmbedded.ToString() + vbCrLf
Else
output = output + "; Embedded = Error (" + status.ToString() + ")" + vbCrLf
End If
Next
MessageBox.Show(output, "Example: GetFontType")
Else
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontType")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetFontType")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int fontCount = gdpicturePDF.GetFontCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string output = "The number of fonts used in this document is " + fontCount.ToString() + ".\n\n";
for (int i = 1; i <= fontCount; i++)
{
output = output + i.ToString() + ". Font: ";
string fontName = "", fontType = "", fontEncoding = "";
//Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " Name = " + fontName;
else
output = output + " Name = Error (" + status.ToString() + ")";
//Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Type = " + fontType;
else
output = output + "; Type = Error (" + status.ToString() + ")";
//Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Encoding = " + fontEncoding;
else
output = output + "; Encoding = Error (" + status.ToString() + ")";
//Finding out if the used font is embedded.
bool fontEmbedded = gdpicturePDF.IsFontEmbedded(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Embedded = " + fontEmbedded.ToString() + "\n";
else
output = output + "; Embedded = Error (" + status.ToString() + ")\n";
}
MessageBox.Show(output, "Example: GetFontType");
}
else
{
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontType");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetFontType");
}
gdpicturePDF.Dispose();
Returns the encoding scheme (the base font encoding) of the font used in the currently loaded PDF document according to the font index
you have specified. You can use the method to determine the number of all used fonts in the PDF document. The font index is simply an integer value from 1 to .
The font encoding refers to the mapping of a character code to a particular glyph (character shape) description. Each font in a PDF uses a specific type of
encoding, either a standard or a custom one. The following types of encoding are supported by the PDF file format: StandardEncoding, WinAnsiEncoding,
MacRomanEncoding, MacExpertEncoding, and PDFDocEncoding. For a font that is embedded in the PDF file, the implicit base encoding is the font program's built-in encoding.
The font index. It must be a value from 1 to .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The encoding scheme. The method can be subsequently used to determine if this method has been successful.
How to find out the number of all fonts and their properties used in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim fontCount As Integer = gdpicturePDF.GetFontCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim output As String = "The number of fonts used in this document is " + fontCount.ToString() + "." + vbCrLf + vbCrLf
For i As Integer = 1 To fontCount
output = output + i.ToString() + ". Font: "
Dim fontName As String = "", fontType As String = "", fontEncoding As String = ""
'Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " Name = " + fontName
Else
output = output + " Name = Error (" + status.ToString() + ")"
End If
'Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Type = " + fontType
Else
output = output + "; Type = Error (" + status.ToString() + ")"
End If
'Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Encoding = " + fontEncoding
Else
output = output + "; Encoding = Error (" + status.ToString() + ")"
End If
'Finding out if the used font is embedded.
Dim fontEmbedded As Boolean = gdpicturePDF.IsFontEmbedded(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Embedded = " + fontEmbedded.ToString() + vbCrLf
Else
output = output + "; Embedded = Error (" + status.ToString() + ")" + vbCrLf
End If
Next
MessageBox.Show(output, "Example: GetFontEncoding")
Else
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontEncoding")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetFontEncoding")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int fontCount = gdpicturePDF.GetFontCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string output = "The number of fonts used in this document is " + fontCount.ToString() + ".\n\n";
for (int i = 1; i <= fontCount; i++)
{
output = output + i.ToString() + ". Font: ";
string fontName = "", fontType = "", fontEncoding = "";
//Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " Name = " + fontName;
else
output = output + " Name = Error (" + status.ToString() + ")";
//Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Type = " + fontType;
else
output = output + "; Type = Error (" + status.ToString() + ")";
//Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Encoding = " + fontEncoding;
else
output = output + "; Encoding = Error (" + status.ToString() + ")";
//Finding out if the used font is embedded.
bool fontEmbedded = gdpicturePDF.IsFontEmbedded(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Embedded = " + fontEmbedded.ToString() + "\n";
else
output = output + "; Embedded = Error (" + status.ToString() + ")\n";
}
MessageBox.Show(output, "Example: GetFontEncoding");
}
else
{
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontEncoding");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetFontEncoding");
}
gdpicturePDF.Dispose();
Returns if the font, used in the currently loaded PDF document, according to the font index you have specified, is embedded. You can use the method
to determine the number of all used fonts in the PDF document. The font index is simply an integer value from 1 to .
Font embedding means that a full copy of the entire character set of a font is stored in the PDF. A font program can be embedded in a PDF file as data contained in a PDF stream object (also called a font file).
Such font programs are subject to copyright, and the copyright owner may impose conditions under which a font program can be used.
The font index. It must be a value from 1 to .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if a font data (a font file) is embedded in the PDF document, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to find out the number of all fonts and their properties used in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim fontCount As Integer = gdpicturePDF.GetFontCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim output As String = "The number of fonts used in this document is " + fontCount.ToString() + "." + vbCrLf + vbCrLf
For i As Integer = 1 To fontCount
output = output + i.ToString() + ". Font: "
Dim fontName As String = "", fontType As String = "", fontEncoding As String = ""
'Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " Name = " + fontName
Else
output = output + " Name = Error (" + status.ToString() + ")"
End If
'Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Type = " + fontType
Else
output = output + "; Type = Error (" + status.ToString() + ")"
End If
'Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Encoding = " + fontEncoding
Else
output = output + "; Encoding = Error (" + status.ToString() + ")"
End If
'Finding out if the used font is embedded.
Dim fontEmbedded As Boolean = gdpicturePDF.IsFontEmbedded(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Embedded = " + fontEmbedded.ToString() + vbCrLf
Else
output = output + "; Embedded = Error (" + status.ToString() + ")" + vbCrLf
End If
Next
MessageBox.Show(output, "Example: IsFontEmbedded")
Else
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: IsFontEmbedded")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: IsFontEmbedded")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int fontCount = gdpicturePDF.GetFontCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string output = "The number of fonts used in this document is " + fontCount.ToString() + ".\n\n";
for (int i = 1; i <= fontCount; i++)
{
output = output + i.ToString() + ". Font: ";
string fontName = "", fontType = "", fontEncoding = "";
//Finding out the name of the used font.
fontName = gdpicturePDF.GetFontName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " Name = " + fontName;
else
output = output + " Name = Error (" + status.ToString() + ")";
//Finding out the type of the used font.
fontType = gdpicturePDF.GetFontType(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Type = " + fontType;
else
output = output + "; Type = Error (" + status.ToString() + ")";
//Finding out the font encoding of the used font.
fontEncoding = gdpicturePDF.GetFontEncoding(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Encoding = " + fontEncoding;
else
output = output + "; Encoding = Error (" + status.ToString() + ")";
//Finding out if the used font is embedded.
bool fontEmbedded = gdpicturePDF.IsFontEmbedded(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "; Embedded = " + fontEmbedded.ToString() + "\n";
else
output = output + "; Embedded = Error (" + status.ToString() + ")\n";
}
MessageBox.Show(output, "Example: IsFontEmbedded");
}
else
{
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: IsFontEmbedded");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: IsFontEmbedded");
}
gdpicturePDF.Dispose();
Tries to remove the embedded font program data of font, used in the currently loaded PDF document, according to the font index you have specified, if the font is embedded. You can use the method
to determine the number of all used fonts in the PDF document. The font index is simply an integer value from 1 to .
Font embedding means that a full copy of the entire character set of a font is stored in the PDF. A font program can be embedded in a PDF file as data contained in a PDF stream object (also called a font file).
Embedded fonts ensure that all of the font information needed to correctly visualize the document are always present. Removing this information might lead to decrease of the document quality and in rare cases to loss of information.
Certain types of fonts like font subsets or fonts with custom character mapping can not be unembedded using this method.
The font index. It must be a value from 1 to .
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. If the method was unable to unembedd the font because of the font properties, then the return value is GdPictreStatus.Aborted.
How to unembed all fonts from the PDF document
Using pdf = New GdPicturePDF()
pdf.LoadFromFile("input.pdf")
Dim fontCount = pdf.GetFontCount()
For i = 1 To fontCount
Dim status = pdf.UnembedFont(i)
If status = GdPictureStatus.Aborted Then
'unable to remove embedded font data
GdPictureStatus.OK Then]]>
'unexpected error
End If
Next
End Using
using(GdPicturePDF pdf = new GdPicturePDF())
{
pdf.LoadFromFile("input.pdf");
int fontCount = pdf.GetFontCount();
for(int i = 1; i <= fontCount; i++)
{
GdPictureStatus status = pdf.UnembedFont(i);
if (status == GdPictureStatus.Aborted)
{
//unable to remove embedded font data
}
else if(status != GdPictureStatus.OK)
{
//unexpected error
}
}
pdf.SaveToFile("output.pdf");
}
Returns, in other words extracts, the embedded font program of the font used in the currently loaded PDF document according to the font index you
have specified. You can use the method to determine the number of all used fonts in the PDF document. The font index is simply an integer value from 1 to .
A font program can be embedded in a PDF file as data contained in a PDF stream object. Such a stream object is also called a font file by analogy with font
programs that are available from sources external to the consumer application.
The font index. It must be a value from 1 to .
Output parameter. An array of bytes containing the uncompressed content (data) of the embedded font program.
This method is only allowed for use with non-encrypted documents.
Be aware that the font program, which you are going to extract, needs to be embedded in the PDF document.
Using this method you are allowed to extract a font program, that is embedded as subset as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
How to extract the font program for all embedded fonts used in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim fontCount As Integer = gdpicturePDF.GetFontCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim output As String = "The number of fonts used in this document is " + fontCount.ToString() + "." + vbCrLf + vbCrLf
For i As Integer = 1 To fontCount
output = output + i.ToString() + ". Font: "
Dim fontName As String = gdpicturePDF.GetFontName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " Name = " + fontName
Else
output = output + " Name = Error (" + status.ToString() + ")"
End If
Dim fontEmbedded As Boolean = gdpicturePDF.IsFontEmbedded(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "; Embedded = " + fontEmbedded.ToString() + vbCrLf
If fontEmbedded Then
Dim fontData As Byte() = Nothing
Dim fontFileData As String = fontName + "_fontData.dat"
status = gdpicturePDF.GetFontData(i, fontData)
If status = GdPictureStatus.OK Then
Dim oFileStream As System.IO.FileStream = Nothing
oFileStream = New System.IO.FileStream(fontFileData, System.IO.FileMode.Create)
oFileStream.Write(fontData, 0, fontData.Length)
oFileStream.Close()
output = output + "; Font data have been saved." + vbCrLf
Else
output = output + "; Font data have NOT been saved. Error (" + status.ToString() + ")" + vbCrLf
End If
End If
Else
output = output + "; Embedded = Error (" + status.ToString() + ")" + vbCrLf
End If
Next
MessageBox.Show(output, "Example: GetFontData")
Else
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontData")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetFontData")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int fontCount = gdpicturePDF.GetFontCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string output = "The number of fonts used in this document is " + fontCount.ToString() + ".\n\n";
for (int i = 1; i <= fontCount; i++)
{
output = output + i.ToString() + ". Font: ";
string fontName = gdpicturePDF.GetFontName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " Name = " + fontName;
else
output = output + " Name = Error (" + status.ToString() + ")";
bool fontEmbedded = gdpicturePDF.IsFontEmbedded(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = output + "; Embedded = " + fontEmbedded.ToString() + "\n";
if (fontEmbedded)
{
byte[] fontData = null;
string fontFileData = fontName + "_fontData.dat";
status = gdpicturePDF.GetFontData(i, ref fontData);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream oFileStream = default(System.IO.FileStream);
oFileStream = new System.IO.FileStream(fontFileData, System.IO.FileMode.Create);
oFileStream.Write(fontData, 0, fontData.Length);
oFileStream.Close();
output = output + "; Font data have been saved.\n";
}
else
output = output + "; Font data have NOT been saved. Error (" + status.ToString() + ")\n";
}
}
else
output = output + "; Embedded = Error (" + status.ToString() + ")\n";
}
MessageBox.Show(output, "Example: GetFontData");
}
else
{
MessageBox.Show("The GetFontCount() method has failed with the status: " + status.ToString(), "Example: GetFontData");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetFontData");
}
gdpicturePDF.Dispose();
Adds a TrueType or OpenType system font to the currently loaded PDF document according to a font name and other parameters you have specified.
Please note that only ANSI characters are supported when using this font to display some text.
The TrueType font format has been adopted as a standard font format for the Microsoft Windows operating system. A TrueType font program can be embedded
directly in a PDF file as a stream object.
The name of the required system font to add for use in the PDF document.
Set this parameter to true if you want to add the font in the bold style, otherwise set it to false.
Set this parameter to true if you want to add the font in the italic style, otherwise set it to false.
Set this parameter to true if you want to embed the font in the PDF document, otherwise set it to false.
Please note that embedding the font in the file significantly increases the filesize.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Returns a resource name of the specified font required for the next usage within the PDF document. The method can be subsequently used to determine if this method has been successful.
This resource name you can subsequently pass, for example, to the method, as well as to all methods, which have a font resource name as a parameter.
How to add a True Type system font to the newly created PDF document. The font resource name is subsequently used to draw some text on the newly created page.
Dim caption As String = "Example: AddTrueTypeFont"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim fontResNameBold As String = gdpicturePDF.AddTrueTypeFont("TimesNewRoman", True, False, False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim fontResNameBoldItalic As String = gdpicturePDF.AddTrueTypeFont("TimesNewRoman", True, True, False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResNameBold, 10, 50, "Here is some bold text") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResNameBoldItalic, 10, 100, "Here is some bold italic text") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFont.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully. Both fonts have been added to the newly created document.", caption)
End If
Else
status = gdpicturePDF.GetStat()
End If
Else
MessageBox.Show("The AddTrueTypeFont() method for bold italic font has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
Else
MessageBox.Show("The AddTrueTypeFont() method for bold font has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTrueTypeFont";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
string fontResNameBold = gdpicturePDF.AddTrueTypeFont("TimesNewRoman", true, false, false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string fontResNameBoldItalic = gdpicturePDF.AddTrueTypeFont("TimesNewRoman", true, true, false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResNameBold, 10, 50, "Here is some bold text") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResNameBoldItalic, 10, 100, "Here is some bold italic text") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFont.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully. Both fonts have been added to the newly created document.", caption);
}
else
status = gdpicturePDF.GetStat();
}
else
{
MessageBox.Show("The AddTrueTypeFont() method for bold italic font has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
else
{
MessageBox.Show("The AddTrueTypeFont() method for bold font has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption);
gdpicturePDF.Dispose();
Adds a TrueType or OpenType system font to the currently loaded PDF document according to a font name and other parameters you have specified. The displaying of Unicode
characters is supported when using the font added by this method.
Be aware that the specified font is always subset using this method. You can disable font subsetting by using the overloaded method with the EnableSubset parameter.
Adds a TrueType or OpenType system font with Unicode support to the currently loaded PDF document according to your preference.
The name of the required system font to add for use in the PDF document.
Since version 14 this parameter is obsolete, that means the value you set here is no longer used.
Set this parameter to true if you want to add the font in the bold style, otherwise set it to false.
Set this parameter to true if you want to add the font in the italic style, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Returns a resource name of the specified font required for the next usage within the PDF document. The method can be subsequently used to determine if this method has been successful.
This resource name you can subsequently pass, for example, to the method, as well as to all methods, which have a font resource name as a parameter.
How to add a True Type system font with Unicode support to the newly created PDF document.
The font resource name is subsequently used to draw some unicode text on the newly created page.
Dim caption As String = "Example: AddTrueTypeFontU"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim fontResNameBold As String = gdpicturePDF.AddTrueTypeFontU("MingLiu", 0, False, False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResNameBold, 10, 50, ChrW(20320)) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontU.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", caption)
End If
Else
status = gdpicturePDF.GetStat()
End If
Else
MessageBox.Show("The AddTrueTypeFontU() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTrueTypeFontU";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
string fontResName = gdpicturePDF.AddTrueTypeFontU("MingLiu", 0, false, false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 10, 50, ((char)(20320)).ToString()) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontU.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", caption);
}
else
status = gdpicturePDF.GetStat();
}
else
{
MessageBox.Show("The AddTrueTypeFontU() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption);
gdpicturePDF.Dispose();
Adds a TrueType or OpenType system font to the currently loaded PDF document according to a font name and other parameters you have specified. The displaying of Unicode
characters is supported when using the font added by this method.
Adds a TrueType or OpenType system font with Unicode support to the currently loaded PDF document according to your preference.
The name of the required system font to add for use in the PDF document.
Set this parameter to true if you want to add the font in the bold style, otherwise set it to false.
Set this parameter to true if you want to add the font in the italic style, otherwise set it to false.
Set this parameter to true if you want to subset the font, otherwise set it to false.
Subsetting a font allows you to keep a file smaller, but note that the font subset is gradually updated with each use of the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Returns a resource name of the specified font required for the next usage within the PDF document. The method can be subsequently used to determine if this method has been successful.
This resource name you can subsequently pass, for example, to the method, as well as to all methods, which have a font resource name as a parameter.
How to add a True Type system font with Unicode support to the newly created PDF document. The font resource name is subsequently used to draw some unicode text on the newly created page.
Dim caption As String = "Example: AddTrueTypeFontU"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim fontResNameBold As String = gdpicturePDF.AddTrueTypeFontU("MingLiu", False, False, False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResNameBold, 10, 50, ChrW(20320) + " " + ChrW(22909)) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontU.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", caption)
End If
Else
status = gdpicturePDF.GetStat()
End If
Else
MessageBox.Show("The AddTrueTypeFontU() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTrueTypeFontU";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
string fontResName = gdpicturePDF.AddTrueTypeFontU("MingLiu", false, false, false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string text = ((char)(20320)).ToString() + " " + ((char)(22909)).ToString();
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 10, 50, text) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontU.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", caption);
}
else
status = gdpicturePDF.GetStat();
}
else
{
MessageBox.Show("The AddTrueTypeFontU() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption);
gdpicturePDF.Dispose();
Adds an embedded TrueType or OpenType font from a file to the currently loaded PDF document according to a font file path and other parameters you have specified.
The displaying of Unicode characters is supported when using the font added by this method.
The file path of the resource font file.
The name of the required font to add for use in the PDF document.
Set this parameter to true if you want to add the font in the bold style, otherwise set it to false.
Set this parameter to true if you want to add the font in the italic style, otherwise set it to false.
Set this parameter to true if you want to subset the font, otherwise set it to false.
Subsetting a font allows you to keep a file smaller, but note that the font subset is gradually updated with each use of the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Returns a resource name of the specified font required for the next usage within the PDF document. The method can be subsequently used to determine if this method has been successful.
This resource name you can subsequently pass, for example, to the method, as well as to all methods, which have a font resource name as a parameter.
How to add a TrueType font from the specified file to the newly created PDF document. The font resource name is subsequently used to draw some unicode text on the newly created page.
Dim caption As String = "Example: AddTrueTypeFontFromFileU"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
'You need to set the correct path to your resource font file here.
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontFromFileU("\Windows\Fonts\SimSun.ttc", "SimSun", False, False, True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 10, 50, ChrW(20320) + " " + ChrW(22909)) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontFromFileU.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", caption)
End If
Else
status = gdpicturePDF.GetStat()
End If
Else
MessageBox.Show("The AddTrueTypeFontFromFileU() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTrueTypeFontFromFileU";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
//You need to set the correct path to your resource font file here.
string fontResName = gdpicturePDF.AddTrueTypeFontFromFileU("\\Windows\\Fonts\\SimSun.ttc", "SimSun", false, false, true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string utext = ((char)(20320)).ToString() + " " + ((char)(22909)).ToString();
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 10, 50, utext) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontFromFileU.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", caption);
}
else
status = gdpicturePDF.GetStat();
}
else
{
MessageBox.Show("The AddTrueTypeFontFromFileU() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption);
gdpicturePDF.Dispose();
Adds a TrueType or OpenType font from a file to the currently loaded PDF document according to a font file path and other parameters you have specified.
Please note that only ANSI characters are supported when using this font to display some text.
The file path of the resource font file.
Set this parameter to true if you want to add the font in the bold style, otherwise set it to false.
Set this parameter to true if you want to add the font in the italic style, otherwise set it to false.
Set this parameter to true if you want to embed the font in the PDF document, otherwise set it to false.
Please note that embedding the font in the file significantly increases the filesize.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Returns a resource name of the specified font required for the next usage within the PDF document. The method can be subsequently used to determine if this method has been successful.
This resource name you can subsequently pass, for example, to the method, as well as to all methods, which have a font resource name as a parameter.
How to add a TrueType font from the specified file to the newly created PDF document. The font resource name is subsequently used to draw some text on the newly created page.
Dim caption As String = "Example: AddTrueTypeFontFromFile"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
'You need to set the correct path to your resource font file here.
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontFromFile("\WINDOWS\Fonts\webdings.ttf", False, False, True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 10, 50, "Here is some text") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontFromFile.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", caption)
End If
Else
status = gdpicturePDF.GetStat()
End If
Else
MessageBox.Show("The AddTrueTypeFontFromFile() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTrueTypeFontFromFile";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
//You need to set the correct path to your resource font file here.
string fontResName = gdpicturePDF.AddTrueTypeFontFromFile("\\WINDOWS\\Fonts\\webdings.ttf", false, false, true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 10, 50, "Here is some text") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddTrueTypeFontFromFile.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", caption);
}
else
status = gdpicturePDF.GetStat();
}
else
{
MessageBox.Show("The AddTrueTypeFontFromFile() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption);
gdpicturePDF.Dispose();
Adds a font from a file to the currently loaded PDF document according to a font file path and other parameters you have specified. The displaying of Unicode
characters is supported when using the font added by this method.
Supported font file formats are:* .fon - Font resource file* .fnt - Raw bitmap font file* .ttf - Raw TrueType file* .ttc - East Asian Windows: TrueType font collection* .fot - TrueType resource file* .otf - PostScript OpenType font
The file path of the resource font file.Please note that adding a font, that consists from several resource font files, is currently not supported.
The name of the required font to add for use in the PDF document.
A member of the FontCharSet enumeration. Defines the character encoding system (character set) used by the specified font.
Set this parameter to true if you want to add the font in the bold style, otherwise set it to false.
Set this parameter to true if you want to add the font in the italic style, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Returns a resource name of the specified font required for the next usage within the PDF document. The method can be subsequently used to determine if this method has been successful.
This resource name you can subsequently pass, for example, to the method, as well as to all methods, which have a font resource name as a parameter.
How to add a font from the specified file to the newly created PDF document. The font resource name is subsequently used to draw some unicode text on the newly created page.
Dim caption As String = "Example: AddFontFromFileU"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
'You need to set the correct path to your resource font file here.
Dim fontResName As String = gdpicturePDF.AddFontFromFileU("\WINDOWS\Fonts\mingliu.ttc", "MingLiu", FontCharSet.ANSI_CHARSET, False, False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 10, 50, ChrW(20320) + " " + ChrW(22909)) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddFontFromFileU.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", caption)
End If
Else
status = gdpicturePDF.GetStat()
End If
Else
MessageBox.Show("The AddFontFromFileU() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddFontFromFileU";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
//You need to set the correct path to your resource font file here.
string fontResName = gdpicturePDF.AddFontFromFileU("\\WINDOWS\\Fonts\\mingliu.ttc", "MingLiu", FontCharSet.ANSI_CHARSET, false, false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string utext = ((char)(20320)).ToString() + " " + ((char)(22909)).ToString();
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 10, 50, utext) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddFontFromFileU.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", caption);
}
else
status = gdpicturePDF.GetStat();
}
else
{
MessageBox.Show("The AddFontFromFileU() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), caption);
gdpicturePDF.Dispose();
Adds a standard font, one of the standard 14 fonts (Standard Type 1 Fonts), to the currently loaded PDF document.
You need to specify the name of the font according to your preference.
PDF prescribes a set of 14 standard fonts that can be used without prior definition. These include four faces each of three Latin text typefaces (Courier,
Helvetica, And Times), as well as two symbolic fonts (Symbol And ITC ZapfDingbats®). These fonts, or suitable substitute fonts with the same metrics, are
required to be available in all PDF consumer applications.
The predefined name of the required standard font. A member of the PdfStandardFont enumeration.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Returns a resource name of the specified font required for the next usage within the PDF document. The method can be subsequently used to determine if this method has been successful.
This resource name you can subsequently pass, for example, to the method, as well as to all methods, which have a font resource name as a parameter.
How to add one of the standard fonts to the newly created PDF document. The font resource name is subsequently used to draw some text on the newly created page.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 10, 50, "Here is some text") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddStandardFont.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your prefered standard font has been successfully added and used in the newly created document.", "Example: AddStandardFont")
End If
Else
status = gdpicturePDF.GetStat()
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), "Example: AddStandardFont")
status = GdPictureStatus.OK
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), "Example: AddStandardFont")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 10, 50, "Here is some text") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddStandardFont.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your prefered standard font has been successfully added and used in the newly created document.", "Example: AddStandardFont");
}
else
status = gdpicturePDF.GetStat();
}
else
{
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), "Example: AddStandardFont");
status = GdPictureStatus.OK;
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is = " + status.ToString(), "Example: AddStandardFont");
gdpicturePDF.Dispose();
Deskews the current page in the loaded PDF document and returns the calculated skew angle, in degrees.
The page is subsequently rotated using this angle to correct the possible skewing if present.
Deskewing a page can help a lot to do OCR, OMR, barcode detection or just improve the reliability of the page itself.
You can benefit from using this method especially for documents mixing vector and raster content.
Maximum skew angle set for providing the subsequent research.
For example, use the value of 10 to achieve deskiewing the page with a skew angle ±10 degrees. It is recommended to use a value lower than 15.
Determines if the engine must be optimistic in the skew detection.
Set this parameter to true if you are sure that the current page has a skew. Otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that the resulting skew angle can be between -MaxAngleOfResearch and +MaxAngleOfResearch,
where negative values indicate counterclockwise and positive values indicate a clockwise rotation.
The skew angle of the currently selected page, in degrees, between -MaxAngleOfResearch and +MaxAngleOfResearch.
The method can be subsequently used to determine if this method has been successful.
How to autodeskew the pages in the PDF document.
Dim caption As String = "Example: AutoDeskew"
Using pdf As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
Dim status As GdPictureStatus = pdf.LoadFromFile("source.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = pdf.GetPageCount()
status = pdf.GetStat()
Dim pageNo As Integer = 1
While (pageNo <= pageCount) AndAlso (status = GdPictureStatus.OK)
status = pdf.SelectPage(pageNo)
If status = GdPictureStatus.OK Then
Dim angle As Single = pdf.AutoDeskew(15, False)
status = pdf.GetStat()
If status = GdPictureStatus.OK Then
message += "PageNo " + pageNo.ToString() + ". - skew angle = " + angle.ToString() + vbCrLf
Else
message += "PageNo " + pageNo.ToString() + ". - status: " + status.ToString() + vbCrLf
End If
End If
pageNo += 1
End While
If status = GdPictureStatus.OK Then
status = pdf.SaveToFile("dest.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show(message + vbCrLf + "The file has been saved.", caption)
Else
MessageBox.Show(message + vbCrLf + "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has NOT been followed successfully. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: AutoDeskew";
using (GdPicturePDF pdf = new GdPicturePDF())
{
string message = "";
GdPictureStatus status = pdf.LoadFromFile("source.pdf", false);
if (status == GdPictureStatus.OK)
{
int pageCount = pdf.GetPageCount();
status = pdf.GetStat();
for (int pageNo = 1; (pageNo <= pageCount) && (status == GdPictureStatus.OK); pageNo++)
{
status = pdf.SelectPage(pageNo);
if (status == GdPictureStatus.OK)
{
float angle = pdf.AutoDeskew(15, false);
status = pdf.GetStat();
if (status == GdPictureStatus.OK)
message += "PageNo " + pageNo.ToString() + ". - skew angle = " + angle.ToString() + "\n";
else
message += "PageNo " + pageNo.ToString() + ". - status: " + status.ToString() + "\n";
}
}
if (status == GdPictureStatus.OK)
{
status = pdf.SaveToFile("dest.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show(message + "\nThe file has been saved.", caption);
else
MessageBox.Show(message + "\nThe example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has NOT been followed successfully. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
Returns the whole content (in the form of postscript data) of the current page in the loaded PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The postscript content of the currently selected page. The method can be subsequently used to determine if this method has been successful.
How to obtain the postscript content of all pages in the PDF document. The content of each page is subsequently saved into a separate file.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim data As String = "", filename As String = "", message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
data = gdpicturePDF.GetPageContent()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = "content_page" + i.ToString() + ".txt"
System.IO.File.WriteAllText(filename, data)
message = message + "Content of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The GetPageContent() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, "Example: GetPageContent")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPageContent")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetPageContent")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string data = "", filename = "", message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
data = gdpicturePDF.GetPageContent();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = "content_page" + i.ToString() + ".txt";
System.IO.File.WriteAllText(filename, data);
message = message + "Content of the page nr." + i.ToString() + " has been successfully saved.\n";
}
else
message = message + "The GetPageContent() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, "Example: GetPageContent");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPageContent");
}
else
MessageBox.Show("The file can't be loaded.", "Example: GetPageContent");
gdpicturePDF.Dispose();
Sets the content in the form of postscript data of the current page in the loaded PDF document.
The postscript content to reset the actual content of the currently selected page.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the postscript content of all pages in the PDF document. The content of each page is read from the separate file.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim data As String = "", filename As String = "", message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
filename = "content_page" + i.ToString() + ".txt"
data = System.IO.File.ReadAllText(filename)
status = gdpicturePDF.SetPageContent(data)
If status = GdPictureStatus.OK Then
message = message + "The page content for the page nr." + i.ToString() + " has been set successfully." + vbCrLf
Else
message = message + "The SetPageContent() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_SetPageContent.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, "Example: SetPageContent")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageContent")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetPageContent")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string data = "", filename = "", message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
filename = "content_page" + i.ToString() + ".txt";
data = System.IO.File.ReadAllText(filename);
status = gdpicturePDF.SetPageContent(data);
if (status == GdPictureStatus.OK)
message = message + "The page content for the page nr." + i.ToString() + " has been set successfully.\n";
else
message = message + "The SetPageContent() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_SetPageContent.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, "Example: SetPageContent");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageContent");
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetPageContent");
gdpicturePDF.Dispose();
Returns the page label associated with a page specified by its page number within the currently loaded PDF document. If no page labeling range is defined
using the method, the value of the current page number as string is returned by default.
The required page number. This parameter is without any restrictions in this moment.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The page label, if any is defined, or the current page number as a string. The method can be subsequently used to determine if this method has been successful.
How to find out the current page label for each page in the PDF document.
Dim caption As String = "Example: GetPageLabel"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim message As String = ""
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + rangesCount.ToString() + " page labeling ranges are defined in this PDF document." + vbCrLf
Else
message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString() + vbCrLf
End If
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim pageLabel As String = ""
For i As Integer = 1 To pageCount
pageLabel = gdpicturePDF.GetPageLabel(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "The page number " + i.ToString() + " contains this page label = """ + pageLabel + """." + vbCrLf
Else
message = message + "The GetPageLabel() method has failed for the " + i.ToString() + ". page with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageLabel";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string message = "";
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + rangesCount.ToString() + " page labeling ranges are defined in this PDF document.\n";
else
message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString() + "\n";
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string pageLabel = "";
for (int i = 1; i <= pageCount; i++)
{
pageLabel = gdpicturePDF.GetPageLabel(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "The page number " + i.ToString() + " contains this page label = \"" + pageLabel + "\".\n";
}
else
message = message + "The GetPageLabel() method has failed for the " + i.ToString() + ". page with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the number of all page labeling ranges, previously defined by the method, in the currently loaded PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of the currently defined labeling ranges in the document. The method can be subsequently used to determine if this method has been successful.
How to find out the actual number of the defined page labeling ranges in the PDF document.
Dim caption As String = "Example: GetPageLabelsRangeCount"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If rangesCount > 0 Then
Dim message As String = "This PDF document contains " + rangesCount.ToString() + " labeling ranges." + vbCrLf
For i As Integer = 0 To rangesCount - 1
Dim startPage As Integer = 0, num As Integer = 0
Dim style As PdfPageLabelStyle = PdfPageLabelStyle.PdfPageLabelStyleUndefined
Dim prefix As String = ""
status = gdpicturePDF.GetPageLabelsRange(i, startPage, style, prefix, num)
If status = GdPictureStatus.OK Then
message = message + "The labeling range with the index " + i.ToString() + " starts at the page number " + startPage.ToString() + " and has these attributes:" + vbCrLf + "style = " + style.ToString() + " prefix = """ + prefix.ToString() + """ num.portion = " + num.ToString() + vbCrLf
Else
message = message + "The GetPageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("This PDF document doesn't contain any page labeling ranges.", caption)
End If
Else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageLabelsRangeCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (rangesCount > 0)
{
string message = "This PDF document contains " + rangesCount.ToString() + " labeling ranges.\n";
for (int i = 0; i < rangesCount; i++)
{
int startPage = 0, num = 0;
PdfPageLabelStyle style = PdfPageLabelStyle.PdfPageLabelStyleUndefined;
string prefix = "";
status = gdpicturePDF.GetPageLabelsRange(i, ref startPage, ref style, ref prefix, ref num);
if (status == GdPictureStatus.OK)
{
message = message + "The labeling range with the index " + i.ToString() + " starts at the page number " + startPage.ToString() + " and has these attributes:\n" +
"style = " + style.ToString() + " prefix = \"" + prefix.ToString() + "\" num.portion = " + num.ToString() + "\n";
}
else
message = message + "The GetPageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("This PDF document doesn't contain any page labeling ranges.", caption);
}
else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Adds a new page labeling range into the currently loaded PDF document according to what you have specified.
A page labeling range is a series of consecutive pages using the same numbering system. The purpose of page labels is to identify each page visually on
the screen or in print. Pages, that are included in the specific labeling range, are defined by the interval starting at the first page specified by the
StartPage parameter and always ending at the last page of the document.
All labeling ranges are simply indexed by an integer value from 0 to -1.
The page number of the starting page in the labeling range. It must be a value from 1 to .
A member of the PdfPageLabelStyle enumeration. It defines the page labeling style.
The label prefix for page labels in this range. It can be an empty string.
The value of the numeric portion for the first page label in the range.
Subsequent pages are numbered sequentially from this value, which must be greater than or equal to 1. The default value is 1.
This method is only allowed for use with non-encrypted documents.
Pages within a labeling range are numbered sequentially in ascending order, starting at the first page specified by the StartPage parameter and always ending
at the last page of the document. You also need to be aware that if you add a page range, which begins at the page other than the first page of the document,
the supplementary labeling range is created for the pages outside your required interval (starting at the first page and ending at the page before your StartPage).
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to define the roman page labels, which begin at number 10, starting from the first page within the PDF document
Dim caption As String = "Example: AddPageLabelsRange"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
GoTo [error]
End If
If count = 0 Then
MessageBox.Show("This PDF document contains no pages.", caption)
GoTo [error]
End If
'Removing current labeling ranges, if any are defined.
status = gdpicturePDF.DeletePageLabels()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The DeletePageLabels() method has failed with the status: " + status.ToString(), caption)
Goto [Error]
End If
status = gdpicturePDF.AddPageLabelsRange(1, PdfPageLabelStyle.PdfPageLabelStyleUppercaseRomanNumerals, "A-", 10)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_AddPageLabelsRange.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been labeled successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been labeled successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("The AddPageLabelsRange() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: AddPageLabelsRange";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
goto error;
}
if (count == 0)
{
MessageBox.Show("This PDF document contains no pages.", caption);
goto error;
}
//Removing current labeling ranges, if any are defined.
status = gdpicturePDF.DeletePageLabels();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The DeletePageLabels() method has failed with the status: " + status.ToString(), caption);
goto error;
}
status = gdpicturePDF.AddPageLabelsRange(1, PdfPageLabelStyle.PdfPageLabelStyleUppercaseRomanNumerals, "A-", 10);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_AddPageLabelsRange.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been labeled successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been labeled successfully, but the file can't be saved.", caption);
}
else
MessageBox.Show("The AddPageLabelsRange() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
error:
gdpicturePDF.Dispose();
Returns the properties of a specific page labeling range of the currently loaded PDF document.
The index of the required labeling range. It must be a value from 0 to -1.
Output parameter. The page number of the starting page of the specified labeling range.
Output parameter. The page labeling style of the specified labeling range. A member of the PdfPageLabelStyle enumeration.
Output parameter. The label prefix, if any is defined, for page labels of the specified labeling range.
Output parameter. The value of the numeric portion for the first page label of the specified labeling range.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve properties of all defined page labeling ranges in the PDF document.
Dim caption As String = "Example: GetPageLabelsRangeCount"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If rangesCount > 0 Then
Dim message As String = "This PDF document contains " + rangesCount.ToString() + " labeling ranges." + vbCrLf
For i As Integer = 0 To rangesCount - 1
Dim startPage As Integer = 0, num As Integer = 0
Dim style As PdfPageLabelStyle = PdfPageLabelStyle.PdfPageLabelStyleUndefined
Dim prefix As String = ""
status = gdpicturePDF.GetPageLabelsRange(i, startPage, style, prefix, num)
If status = GdPictureStatus.OK Then
message = message + "The labeling range with the index " + i.ToString() + " starts at the page number " + startPage.ToString() + " and has these attributes:" + vbCrLf + "style = " + style.ToString() + " prefix = """ + prefix.ToString() + """ num.portion = " + num.ToString() + vbCrLf
Else
message = message + "The GetPageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("This PDF document doesn't contain any page labeling ranges.", caption)
End If
Else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageLabelsRangeCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (rangesCount > 0)
{
string message = "This PDF document contains " + rangesCount.ToString() + " labeling ranges.\n";
for (int i = 0; i < rangesCount; i++)
{
int startPage = 0, num = 0;
PdfPageLabelStyle style = PdfPageLabelStyle.PdfPageLabelStyleUndefined;
string prefix = "";
status = gdpicturePDF.GetPageLabelsRange(i, ref startPage, ref style, ref prefix, ref num);
if (status == GdPictureStatus.OK)
{
message = message + "The labeling range with the index " + i.ToString() + " starts at the page number " + startPage.ToString() + " and has these attributes:\n" +
"style = " + style.ToString() + " prefix = \"" + prefix.ToString() + "\" num.portion = " + num.ToString() + "\n";
}
else
message = message + "The GetPageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("This PDF document doesn't contain any page labeling ranges.", caption);
}
else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Removes all page labels previously defined by the method within the currently loaded PDF document. This actually means that all
defined page labeling ranges are completely removed from the document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove all page labels (means all page labeling ranges) within the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim message As String = ""
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = rangesCount.ToString() + " page labeling ranges are defined in this PDF document." + vbCrLf
status = gdpicturePDF.DeletePageLabels()
If status = GdPictureStatus.OK Then
message = message + "The page labeling ranges has been successfully deleted." + vbCrLf
rangesCount = gdpicturePDF.GetPageLabelsRangeCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = rangesCount.ToString() + " page labeling ranges are defined in this PDF document." + vbCrLf
If gdpicturePDF.SaveToFile("test_DeletePageLabels.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
Else
message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString()
End If
Else
message = message + "The DeletePageLabels() method has failed with the status: " + status.ToString()
End If
Else
message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString()
End If
MessageBox.Show(message, "Example: DeletePageLabels")
Else
MessageBox.Show("The file can't be loaded.", "Example: DeletePageLabels")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string message = "";
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = rangesCount.ToString() + " page labeling ranges are defined in this PDF document.\n";
status = gdpicturePDF.DeletePageLabels();
if (status == GdPictureStatus.OK)
{
message = message + "The page labeling ranges has been successfully deleted.\n";
rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = rangesCount.ToString() + " page labeling ranges are defined in this PDF document.\n";
if (gdpicturePDF.SaveToFile("test_DeletePageLabels.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
}
else
message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString();
}
else
message = message + "The DeletePageLabels() method has failed with the status: " + status.ToString();
}
else
message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString();
MessageBox.Show(message, "Example: DeletePageLabels");
}
else
MessageBox.Show("The file can't be loaded.", "Example: DeletePageLabels");
gdpicturePDF.Dispose();
Removes a page labeling range specified by its index, previously defined by the method, within the currently loaded PDF document.
It is not allowed (see PDF Reference, Section "Page Labels") to delete the page labeling range with the index 0, if more than one labeling range is defined in the PDF document.
The index of the required labeling range to remove. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
If you want to delete all page labeling ranges at once, you can simply use the method instead of removing them one by one. Be aware that
the removal of the labeling range with the index 0 makes nothing if more than one labeling range is defined in your document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove actual page labeling ranges, one by one, if any are defined, in the PDF document.
As it is mentioned above, the range with the index 0 is only allowed to delete if it is the only one labeling range defined in the document.
Because of this in the example below we start to remove ranges from the last one to the first one.
Dim caption As String = "Example: DeletePageLabelsRange"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If rangesCount > 0 Then
Dim message As String = ""
For i As Integer = rangesCount - 1 To 0 Step -1
status = gdpicturePDF.DeletePageLabelsRange(i)
If status = GdPictureStatus.OK Then
message = message + "The page labeling range with the index " + i.ToString() + " has been successfully deleted." + vbCrLf
Else
message = message + "The DeletePageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_DeletePageLabelsRange.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("This PDF document contains no page labeling ranges.", caption)
End If
Else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DeletePageLabelsRange";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (rangesCount > 0)
{
string message = "";
for (int i = rangesCount-1; i >= 0; i--)
{
status = gdpicturePDF.DeletePageLabelsRange(i);
if (status == GdPictureStatus.OK)
message = message + "The page labeling range with the index " + i.ToString() + " has been successfully deleted.\n";
else
message = message + "The DeletePageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_DeletePageLabelsRange.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("This PDF document contains no page labeling ranges.", caption);
}
else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Modifies the starting page of the labeling range, specified by its index, of the currently loaded PDF document.
The index of the required labeling range. It must be a value from 0 to -1.
Defined the new starting page of the required labeling range. It must be a value from 1 to .
This method is only allowed for use with non-encrypted documents.
Be aware that if you modify the StartPage parameter of the required labeling range, which has been previously set to the number 1, to be the new greater
value, the supplementary labeling range is created for the pages outside the newly defined interval, that means the new page labeling range with the index 0 is added
to the document, starting at the first page and ending at the page before your newly specified StartPage.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the starting page of the specified page labeling range.
Dim caption As String = "Example: SetPageLabelsRangeStartPage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If rangesCount > 0 Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetPageLabelsRangeStartPage(0, pageCount)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_SetPageLabelsRangeStartPage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The starting page for the first labeling range has been reset successfully and the file has been saved.", caption)
Else
MessageBox.Show("The starting page for the first labeling range has been reset successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("The SetPageLabelsRangeStartPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("No page labeling ranges are defined in this PDF document.", caption)
End If
Else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetPageLabelsRangeStartPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (rangesCount > 0)
{
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetPageLabelsRangeStartPage(0, pageCount);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_SetPageLabelsRangeStartPage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The starting page for the first labeling range has been reset successfully and the file has been saved.", caption);
else
MessageBox.Show("The starting page for the first labeling range has been reset successfully, but the file can't be saved.", caption);
}
else
MessageBox.Show("The SetPageLabelsRangeStartPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("No page labeling ranges are defined in this PDF document.", caption);
}
else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Modifies the style of the labeling range, specified by its index, of the currently loaded PDF document.
The index of the required labeling range. It must be a value from 0 to -1.
A member of the PdfPageLabelStyle enumeration. Defines the new page labeling style of the required labeling range.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the current page labeling range attributes to the new ones according to your preference.
Dim caption As String = "Example: SetPageLabelsRangeStyle"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If rangesCount > 0 Then
Dim message As String = ""
Dim startPage As Integer = 0, num As Integer = 0
Dim style As PdfPageLabelStyle = PdfPageLabelStyle.PdfPageLabelStyleUndefined
Dim prefix As String = ""
status = gdpicturePDF.GetPageLabelsRange(0, startPage, style, prefix, num)
If status = GdPictureStatus.OK Then
message = message + "The previously defined attributes for the first labeling range are:" + vbCrLf + "style = " + style.ToString() + vbCrLf + "prefix = """ + prefix.ToString() + """" + vbCrLf + "num.portion = " + num.ToString() + vbCrLf
Else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.SetPageLabelsRangeNumPortion(0, 5)
If status <> GdPictureStatus.OK Then
message = message + "The SetPageLabelsRangeNumPortion() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.SetPageLabelsRangePrefix(0, "Prefix:")
If status <> GdPictureStatus.OK Then
message = message + "The SetPageLabelsRangePrefix() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.SetPageLabelsRangeStyle(0, PdfPageLabelStyle.PdfPageLabelStyleLowercaseRomanNumerals)
If status <> GdPictureStatus.OK Then
message = message + "The SetPageLabelsRangeStyle() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.GetPageLabelsRange(0, startPage, style, prefix, num)
If status = GdPictureStatus.OK Then
message = message + "The newly defined attributes for the first labeling range are:" + vbCrLf + "style = " + style.ToString() + vbCrLf + "prefix = """ + prefix.ToString() + """" + vbCrLf + "num.portion = " + num.ToString() + vbCrLf
Else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + vbCrLf
End If
If gdpicturePDF.SaveToFile("test_SetPageLabelsRangeAttributes.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("No page labeling ranges are defined in this PDF document.", caption)
End If
Else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetPageLabelsRangeStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (rangesCount > 0)
{
string message = "";
int startPage = 0, num = 0;
PdfPageLabelStyle style = PdfPageLabelStyle.PdfPageLabelStyleUndefined;
string prefix = "";
status = gdpicturePDF.GetPageLabelsRange(0, ref startPage, ref style, ref prefix, ref num);
if (status == GdPictureStatus.OK)
{
message = message + "The previously defined attributes for the first labeling range are:\n" +
"style = " + style.ToString() + "\nprefix = \"" + prefix.ToString() + "\"\nnum.portion = " + num.ToString() + "\n";
}
else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.SetPageLabelsRangeNumPortion(0, 5);
if (status != GdPictureStatus.OK)
message = message + "The SetPageLabelsRangeNumPortion() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.SetPageLabelsRangePrefix(0, "Prefix:");
if (status != GdPictureStatus.OK)
message = message + "The SetPageLabelsRangePrefix() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.SetPageLabelsRangeStyle(0, PdfPageLabelStyle.PdfPageLabelStyleLowercaseRomanNumerals);
if (status != GdPictureStatus.OK)
message = message + "The SetPageLabelsRangeStyle() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.GetPageLabelsRange(0, ref startPage, ref style, ref prefix, ref num);
if (status == GdPictureStatus.OK)
{
message = message + "The newly defined attributes for the first labeling range are:\n" +
"style = " + style.ToString() + "\nprefix = \"" + prefix.ToString() + "\"\nnum.portion = " + num.ToString() + "\n";
}
else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + "\n";
if (gdpicturePDF.SaveToFile("test_SetPageLabelsRangeAttributes.pdf") == GdPictureStatus.OK)
MessageBox.Show("The file has been saved successfully.", caption);
else
MessageBox.Show("The file can't be saved.", caption);
MessageBox.Show(message, caption);
}
else
MessageBox.Show("No page labeling ranges are defined in this PDF document.", caption);
}
else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Modifies the label prefix of the labeling range, specified by its index, of the currently loaded PDF document.
The index of the required labeling range. It must be a value from 0 to -1.
Defines the new label prefix of the required labeling range.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the current page labeling range attributes to the new ones according to your preference.
Dim caption As String = "Example: SetPageLabelsRangePrefix"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If rangesCount > 0 Then
Dim message As String = ""
Dim startPage As Integer = 0, num As Integer = 0
Dim style As PdfPageLabelStyle = PdfPageLabelStyle.PdfPageLabelStyleUndefined
Dim prefix As String = ""
status = gdpicturePDF.GetPageLabelsRange(0, startPage, style, prefix, num)
If status = GdPictureStatus.OK Then
message = message + "The previously defined attributes for the first labeling range are:" + vbCrLf + "style = " + style.ToString() + vbCrLf + "prefix = """ + prefix.ToString() + """" + vbCrLf + "num.portion = " + num.ToString() + vbCrLf
Else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.SetPageLabelsRangeNumPortion(0, 5)
If status <> GdPictureStatus.OK Then
message = message + "The SetPageLabelsRangeNumPortion() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.SetPageLabelsRangePrefix(0, "Prefix:")
If status <> GdPictureStatus.OK Then
message = message + "The SetPageLabelsRangePrefix() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.SetPageLabelsRangeStyle(0, PdfPageLabelStyle.PdfPageLabelStyleLowercaseRomanNumerals)
If status <> GdPictureStatus.OK Then
message = message + "The SetPageLabelsRangeStyle() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.GetPageLabelsRange(0, startPage, style, prefix, num)
If status = GdPictureStatus.OK Then
message = message + "The newly defined attributes for the first labeling range are:" + vbCrLf + "style = " + style.ToString() + vbCrLf + "prefix = """ + prefix.ToString() + """" + vbCrLf + "num.portion = " + num.ToString() + vbCrLf
Else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + vbCrLf
End If
If gdpicturePDF.SaveToFile("test_SetPageLabelsRangeAttributes.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("No page labeling ranges are defined in this PDF document.", caption)
End If
Else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetPageLabelsRangePrefix";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (rangesCount > 0)
{
string message = "";
int startPage = 0, num = 0;
PdfPageLabelStyle style = PdfPageLabelStyle.PdfPageLabelStyleUndefined;
string prefix = "";
status = gdpicturePDF.GetPageLabelsRange(0, ref startPage, ref style, ref prefix, ref num);
if (status == GdPictureStatus.OK)
{
message = message + "The previously defined attributes for the first labeling range are:\n" +
"style = " + style.ToString() + "\nprefix = \"" + prefix.ToString() + "\"\nnum.portion = " + num.ToString() + "\n";
}
else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.SetPageLabelsRangeNumPortion(0, 5);
if (status != GdPictureStatus.OK)
message = message + "The SetPageLabelsRangeNumPortion() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.SetPageLabelsRangePrefix(0, "Prefix:");
if (status != GdPictureStatus.OK)
message = message + "The SetPageLabelsRangePrefix() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.SetPageLabelsRangeStyle(0, PdfPageLabelStyle.PdfPageLabelStyleLowercaseRomanNumerals);
if (status != GdPictureStatus.OK)
message = message + "The SetPageLabelsRangeStyle() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.GetPageLabelsRange(0, ref startPage, ref style, ref prefix, ref num);
if (status == GdPictureStatus.OK)
{
message = message + "The newly defined attributes for the first labeling range are:\n" +
"style = " + style.ToString() + "\nprefix = \"" + prefix.ToString() + "\"\nnum.portion = " + num.ToString() + "\n";
}
else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + "\n";
if (gdpicturePDF.SaveToFile("test_SetPageLabelsRangeAttributes.pdf") == GdPictureStatus.OK)
MessageBox.Show("The file has been saved successfully.", caption);
else
MessageBox.Show("The file can't be saved.", caption);
MessageBox.Show(message, caption);
}
else
MessageBox.Show("No page labeling ranges are defined in this PDF document.", caption);
}
else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Modifies the numeric portion value of the first page label of the labeling range, specified by its index, of the currently loaded PDF document.
The index of the required labeling range. It must be a value from 0 to -1.
Defines the new value of the numeric portion for the first page label of the required labeling range.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the current page labeling range attributes to the new ones according to your preference.
Dim caption As String = "Example: SetPageLabelsRangeNumPortion"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If rangesCount > 0 Then
Dim message As String = ""
Dim startPage As Integer = 0, num As Integer = 0
Dim style As PdfPageLabelStyle = PdfPageLabelStyle.PdfPageLabelStyleUndefined
Dim prefix As String = ""
status = gdpicturePDF.GetPageLabelsRange(0, startPage, style, prefix, num)
If status = GdPictureStatus.OK Then
message = message + "The previously defined attributes for the first labeling range are:" + vbCrLf + "style = " + style.ToString() + vbCrLf + "prefix = """ + prefix.ToString() + """" + vbCrLf + "num.portion = " + num.ToString() + vbCrLf
Else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.SetPageLabelsRangeNumPortion(0, 5)
If status <> GdPictureStatus.OK Then
message = message + "The SetPageLabelsRangeNumPortion() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.SetPageLabelsRangePrefix(0, "Prefix:")
If status <> GdPictureStatus.OK Then
message = message + "The SetPageLabelsRangePrefix() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.SetPageLabelsRangeStyle(0, PdfPageLabelStyle.PdfPageLabelStyleLowercaseRomanNumerals)
If status <> GdPictureStatus.OK Then
message = message + "The SetPageLabelsRangeStyle() method has failed with the status: " + status.ToString() + vbCrLf
End If
status = gdpicturePDF.GetPageLabelsRange(0, startPage, style, prefix, num)
If status = GdPictureStatus.OK Then
message = message + "The newly defined attributes for the first labeling range are:" + vbCrLf + "style = " + style.ToString() + vbCrLf + "prefix = """ + prefix.ToString() + """" + vbCrLf + "num.portion = " + num.ToString() + vbCrLf
Else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + vbCrLf
End If
If gdpicturePDF.SaveToFile("test_SetPageLabelsRangeAttributes.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("No page labeling ranges are defined in this PDF document.", caption)
End If
Else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetPageLabelsRangeNumPortion";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (rangesCount > 0)
{
string message = "";
int startPage = 0, num = 0;
PdfPageLabelStyle style = PdfPageLabelStyle.PdfPageLabelStyleUndefined;
string prefix = "";
status = gdpicturePDF.GetPageLabelsRange(0, ref startPage, ref style, ref prefix, ref num);
if (status == GdPictureStatus.OK)
{
message = message + "The previously defined attributes for the first labeling range are:\n" +
"style = " + style.ToString() + "\nprefix = \"" + prefix.ToString() + "\"\nnum.portion = " + num.ToString() + "\n";
}
else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.SetPageLabelsRangeNumPortion(0, 5);
if (status != GdPictureStatus.OK)
message = message + "The SetPageLabelsRangeNumPortion() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.SetPageLabelsRangePrefix(0, "Prefix:");
if (status != GdPictureStatus.OK)
message = message + "The SetPageLabelsRangePrefix() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.SetPageLabelsRangeStyle(0, PdfPageLabelStyle.PdfPageLabelStyleLowercaseRomanNumerals);
if (status != GdPictureStatus.OK)
message = message + "The SetPageLabelsRangeStyle() method has failed with the status: " + status.ToString() + "\n";
status = gdpicturePDF.GetPageLabelsRange(0, ref startPage, ref style, ref prefix, ref num);
if (status == GdPictureStatus.OK)
{
message = message + "The newly defined attributes for the first labeling range are:\n" +
"style = " + style.ToString() + "\nprefix = \"" + prefix.ToString() + "\"\nnum.portion = " + num.ToString() + "\n";
}
else
message = message + "The GetPageLabelsRange() method has failed with the status: " + status.ToString() + "\n";
if (gdpicturePDF.SaveToFile("test_SetPageLabelsRangeAttributes.pdf") == GdPictureStatus.OK)
MessageBox.Show("The file has been saved successfully.", caption);
else
MessageBox.Show("The file can't be saved.", caption);
MessageBox.Show(message, caption);
}
else
MessageBox.Show("No page labeling ranges are defined in this PDF document.", caption);
}
else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Empties, that means completely removes, the whole content of the currently selected page in the loaded PDF document. The selected page becomes blank,
but it retains its properties, for example, page dimensions or the rotation.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove the whole content of the first page in the PDF document.
Dim caption As String = "Example: ClearPageContent"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If count > 0 Then
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.ClearPageContent()
If status = GdPictureStatus.OK Then
Dim message As String = "The pages have been cleared successfully"
If gdpicturePDF.SaveToFile("test_ClearPageContent.pdf") = GdPictureStatus.OK Then
message = message + " and the file has been saved."
Else
message = message + ", but the file can't be saved."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The ClearPageContent() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The page can't be selected.", caption)
End If
Else
MessageBox.Show("This document contains no pages.", caption)
End If
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ClearPageContent";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (count > 0)
{
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.ClearPageContent();
if (status == GdPictureStatus.OK)
{
string message = "The pages have been cleared successfully";
if (gdpicturePDF.SaveToFile("test_ClearPageContent.pdf") == GdPictureStatus.OK)
message = message + " and the file has been saved.";
else
message = message + ", but the file can't be saved.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The ClearPageContent() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The page can't be selected.", caption);
}
else
MessageBox.Show("This document contains no pages.", caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Adds a new page according to the specified page size, expressed in the current units, into the currently loaded PDF document.
The new empty page is added at the end of the document as the last page and it is automatically selected as the current page.
Adds a new page specified by its size into the currently loaded PDF document as the last page.
The page width, expressed in the current units specified by the SetMeasurementUnit method.
You can simply use the method to determine the currently defined units and you can easily use the method
to reset the units according to your preference.
The page height, expressed in the current units specified by the SetMeasurementUnit method.
You can simply use the method to determine the currently defined units and you can easily use the method
to reset the units according to your preference.
This method is only allowed for use with non-encrypted documents.
The newly created page is automatically set as the current page after successful adding.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add a new page (standard size of A4) specified in millimeters to the newly created document.
Dim caption As String = "Example: NewPage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim status As GdPictureStatus = gdpicturePDF.NewPage(210, 297) 'A4 page size in millimeters
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_NewPage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NewPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
GdPictureStatus status = gdpicturePDF.NewPage(210, 297); //A4 page size in millimeters
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_NewPage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The file has been saved successfully.", caption);
else
MessageBox.Show("The file can't be saved.", caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a new page according to the required predefined page size into the currently loaded PDF document. The new empty page is added at the end of the document
as the last page and it is automatically selected as the current page.
Adds a new page specified by its size into the currently loaded PDF document as the last page.
A member of the PdfPageSizes enumeration. The predefined page size.
This method is only allowed for use with non-encrypted documents.
The newly created page is automatically set as the current page after successful adding.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add a new page with the standard size of A4 to the newly created document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_NewPage.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", "Example: NewPage")
Else
MessageBox.Show("The file can't be saved.", "Example: NewPage")
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), "Example: NewPage")
End If
Else
MessageBox.Show("The file can't be created.", "Example: NewPage")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_NewPage.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The file has been saved successfully.", "Example: NewPage");
else
MessageBox.Show("The file can't be saved.", "Example: NewPage");
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), "Example: NewPage");
}
else
MessageBox.Show("The file can't be created.", "Example: NewPage");
gdpicturePDF.Dispose();
Resizes the currently selected page in the loaded PDF document according to the newly specified page width and page height.
The new required page width expressed in the current units specified by the SetMeasurementUnit method.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
The new required page height expressed in the current units specified by the SetMeasurementUnit method.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
This method is only allowed for use with non-encrypted documents.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to resize the first page in the PDF document.
Dim caption As String = "Example: ResizePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("testPDF.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If count > 0 Then
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
Dim height As Single = gdpicturePDF.GetPageHeight()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim width As Single = gdpicturePDF.GetPageWidth()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.ResizePage(width / 2, height / 2)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_ResizePage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The page has been resized successfully and the file has been saved.", caption)
Else
MessageBox.Show("The page has been resized successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("The ResizePage() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
End If
End If
Else
status = GdPictureStatus.InvalidParameter
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ResizePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("testPDF.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (count > 0)
{
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
float height = gdpicturePDF.GetPageHeight();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
float width = gdpicturePDF.GetPageWidth();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.ResizePage(width/2, height/2);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_ResizePage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The page has been resized successfully and the file has been saved.", caption);
else
MessageBox.Show("The page has been resized successfully, but the file can't be saved.", caption);
}
else
{
MessageBox.Show("The ResizePage() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
}
}
}
else
status = GdPictureStatus.InvalidParameter;
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Scales (multiplies) the currently selected page in the loaded PDF document according to the specified scale factors for both page width and page height.
The horizontal scale factor, it corresponds to the page width.
For example, if this parameter is set to 2.0, it multiplies the page width of the currently selected page by 2, and if it is set to 0.5, it
divides the page width by 2.
The vertical scale factor, it corresponds to the page height.
For example, if this parameter is set to 2.0, it multiplies the page height of the currently selected page by 2, and if it is set to 0.5, it
divides the page height by 2.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to scale the first page in the PDF document.
Dim caption As String = "Example: ScalePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If count > 0 Then
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.ScalePage(0.5, 0.5)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_ScalePage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The page has been scaled successfully and the file has been saved.", caption)
Else
MessageBox.Show("The page has been scaled successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("The ScalePage() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
Else
status = GdPictureStatus.InvalidParameter
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ScalePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (count > 0)
{
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.ScalePage((float)0.5, (float)0.5);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_ScalePage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The page has been scaled successfully and the file has been saved.", caption);
else
MessageBox.Show("The page has been scaled successfully, but the file can't be saved.", caption);
}
else
{
MessageBox.Show("The ScalePage() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
}
else
status = GdPictureStatus.InvalidParameter;
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Inserts a new blank page according to the specified page size, expressed in the current units, and the page position into the currently loaded PDF document.
The newly inserted page is automatically selected as the current page.
Inserts a blank page specified by its size and its position into the currently loaded PDF document.
The page width expressed in the current units specified by the SetMeasurementUnit method.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
The page height expressed in the current units specified by the SetMeasurementUnit method.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
The required position of the page to insert, that means the page number for the newly inserted page. It must be a value greater than 0.
If the specified value is greater than the number of all pages in the loaded document, the new page is automatically inserted as the last page, as it is shown in the example below.
This method is only allowed for use with non-encrypted documents.
The newly inserted page is automatically set as the current page after the successful insertion.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to insert a blank page with the same page size as the first page to be the new first page and also to be the new last page of your document.
Dim caption As String = "Example: InsertPage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If count > 0 Then
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
Dim pageHeight As Single = gdpicturePDF.GetPageHeight()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim pageWidth As Single = gdpicturePDF.GetPageWidth()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.InsertPage(pageWidth, pageHeight, 1)
If status = GdPictureStatus.OK Then
count = count + 1
Dim current As Integer = gdpicturePDF.GetCurrentPage()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The page has been inserted successfully." + vbCrLf + "The currently selected page is page nr. " + current.ToString(), caption)
Else
MessageBox.Show("The page has been inserted successfully, but the GetCurrentPage() method has failed.")
End If
status = gdpicturePDF.InsertPage(pageWidth, pageHeight, count + 1)
If status = GdPictureStatus.OK Then
current = gdpicturePDF.GetCurrentPage()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The page has been inserted successfully." + vbCrLf + "The currently selected page is page nr. " + current.ToString(), caption)
Else
MessageBox.Show("The page has been inserted successfully, but the GetCurrentPage() method has failed.")
End If
If gdpicturePDF.SaveToFile("test_InsertPage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been inserted successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been inserted successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("The InsertPage() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
Else
MessageBox.Show("The InsertPage() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
End If
End If
Else
status = GdPictureStatus.InvalidParameter
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: InsertPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (count > 0)
{
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
float pageHeight = gdpicturePDF.GetPageHeight();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
float pageWidth = gdpicturePDF.GetPageWidth();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.InsertPage(pageWidth, pageHeight, 1);
if (status == GdPictureStatus.OK)
{
count = count + 1;
int current = gdpicturePDF.GetCurrentPage();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The page has been inserted successfully.\nThe currently selected page is page nr. " + current.ToString(), caption);
else
MessageBox.Show("The page has been inserted successfully, but the GetCurrentPage() method has failed.");
status = gdpicturePDF.InsertPage(pageWidth, pageHeight, count + 1);
if (status == GdPictureStatus.OK)
{
current = gdpicturePDF.GetCurrentPage();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The page has been inserted successfully.\nThe currently selected page is page nr. " + current.ToString(), caption);
else
MessageBox.Show("The page has been inserted successfully, but the GetCurrentPage() method has failed.");
if (gdpicturePDF.SaveToFile("test_InsertPage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been inserted successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been inserted successfully, but the file can't be saved.", caption);
}
else
{
MessageBox.Show("The InsertPage() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
else
{
MessageBox.Show("The InsertPage() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
}
}
}
else
status = GdPictureStatus.InvalidParameter;
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Inserts a new blank page according to the required predefined page size and the page position into the currently loaded PDF document. The newly
inserted page is automatically selected as the current page.
Inserts a blank page specified by its size and its position into the currently loaded PDF document.
A member of the PdfPageSizes enumeration. The predefined page size.
The required position of the page to insert, that means the page number for the newly inserted page. It must be a value greater than 0.
If the specified value is greater than the number of all pages in the loaded document, the new page is automatically inserted as the last page.
This method is only allowed for use with non-encrypted documents.
The newly inserted page is automatically set as the current page after the successful insertion.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to insert a standard A4 page into the newly created document.
Dim caption As String = "Example: InsertPage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.InsertPage(PdfPageSizes.PdfPageSizeA4, 1)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_InsertPage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The page has been inserted successfully and the file has been saved.", caption)
Else
MessageBox.Show("The page has been inserted successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("The InsertPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: InsertPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.InsertPage(PdfPageSizes.PdfPageSizeA4, 1);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_InsertPage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The page has been inserted successfully and the file has been saved.", caption);
else
MessageBox.Show("The page has been inserted successfully, but the file can't be saved.", caption);
}
else
MessageBox.Show("The InsertPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Clones a page specified by its page number, that means creates exactly the same copy of the specified page, in the currently loaded PDF document.
The newly created page is added at the end of the document as the last page and it is automatically selected as the current page.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while cloning large documents.
The feature is available in both 32-bit and 64-bit mode by default.
Clones a specific page within the current document or from another source document into the current one.
The page number of a page you want to clone. It must be a value from 1 to .
This method is only allowed for use with non-encrypted documents.
The newly created page is automatically set as the current page after successful cloning.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to clone all pages of the PDF document.
Dim caption As String = "Example: ClonePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
For i As Integer = 1 To count
status = gdpicturePDF.ClonePage(i)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Next
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_ClonePage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been cloned successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been cloned successfully, but the file can't be saved.", caption)
End If
End If
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ClonePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.ClonePage(i);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_ClonePage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been cloned successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been cloned successfully, but the file can't be saved.", caption);
}
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Clones a page specified by its page number located in the specified source PDF document into the currently loaded PDF document. The newly created page is added
at the end of the current document as the last page and it is automatically selected as the current page.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while cloning large documents.
The feature is available in both 32-bit and 64-bit mode by default.
This method can be useful when you need to merge multiple PDF documents into one destination document, as it is shown in the attached example.
You can also benefit from this method when you need to split a large multipage PDF document into smaller separate PDF documents that will contain the required number of pages,
please refer to this example of
how to quickly achieve it.
Clones a specific page within the current document or from another source document into the current one.
A GdPicturePDF object. The source PDF document, which contains the page you want to clone into the currently loaded PDF document.
The page number of a required page from the source document, which you want to clone into the current document.
It must be a value from 1 to of the source document.
This method is only allowed for use with non-encrypted documents, both source and destination ones.
The newly created page is automatically set as the current page after successful cloning.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to merge two PDF documents into one destination document.
Dim caption As String = "Example: ClonePage"
Dim gdpicturePDF1 As New GdPicturePDF()
Dim gdpicturePDF2 As New GdPicturePDF()
If gdpicturePDF1.LoadFromFile("test1.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF2.LoadFromFile("test2.pdf", False) = GdPictureStatus.OK Then
Dim oGdPictureNewPDF As New GdPicturePDF()
If oGdPictureNewPDF.NewPDF() = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF1.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF1.GetStat()
If status = GdPictureStatus.OK Then
For page As Integer = 1 To pageCount
status = oGdPictureNewPDF.ClonePage(gdpicturePDF1, page)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString() + vbCrLf + "Document: first Page nr. " + page.ToString(), caption)
Exit For
End If
Next
Else
MessageBox.Show("The GetPageCount() method for the first document has failed with the status: " + status.ToString(), caption)
End If
If status = GdPictureStatus.OK Then
pageCount = gdpicturePDF2.GetPageCount()
status = gdpicturePDF2.GetStat()
If status = GdPictureStatus.OK Then
For page As Integer = 1 To pageCount
status = oGdPictureNewPDF.ClonePage(gdpicturePDF2, page)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString() + vbCrLf + "Document: second Page nr. " + page.ToString(), caption)
Exit For
End If
Next
Else
MessageBox.Show("The GetPageCount() method for the second document has failed with the status: " + status.ToString(), caption)
End If
End If
If status = GdPictureStatus.OK Then
Dim message As String = "The pages have been cloned successfully"
If oGdPictureNewPDF.SaveToFile("test_ClonePage.pdf") = GdPictureStatus.OK Then
message = message + " and the file has been saved."
Else
message = message + ", but the file can't be saved."
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The destination file can't be created.", caption)
End If
oGdPictureNewPDF.Dispose()
Else
MessageBox.Show("The second file can't be loaded.", caption)
End If
Else
MessageBox.Show("The first file can't be loaded.", caption)
End If
gdpicturePDF1.Dispose()
gdpicturePDF2.Dispose()
string caption = "Example: ClonePage";
GdPicturePDF gdpicturePDF1 = new GdPicturePDF();
GdPicturePDF gdpicturePDF2 = new GdPicturePDF();
if (gdpicturePDF1.LoadFromFile("test1.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF2.LoadFromFile("test2.pdf", false) == GdPictureStatus.OK)
{
GdPicturePDF oGdPictureNewPDF = new GdPicturePDF();
if (oGdPictureNewPDF.NewPDF() == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF1.GetPageCount();
GdPictureStatus status = gdpicturePDF1.GetStat();
if (status == GdPictureStatus.OK)
{
for (int page = 1; page <= pageCount; page++)
{
status = oGdPictureNewPDF.ClonePage(gdpicturePDF1, page);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString() + "\nDocument: first Page nr. " + page.ToString(), caption);
break;
}
}
}
else
MessageBox.Show("The GetPageCount() method for the first document has failed with the status: " + status.ToString(), caption);
if (status == GdPictureStatus.OK)
{
pageCount = gdpicturePDF2.GetPageCount();
status = gdpicturePDF2.GetStat();
if (status == GdPictureStatus.OK)
{
for (int page = 1; page <= pageCount; page++)
{
status = oGdPictureNewPDF.ClonePage(gdpicturePDF2, page);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString() + "\nDocument: second Page nr. " + page.ToString(), caption);
break;
}
}
}
else
MessageBox.Show("The GetPageCount() method for the second document has failed with the status: " + status.ToString(), caption);
}
if (status == GdPictureStatus.OK)
{
string message = "The pages have been cloned successfully";
if (oGdPictureNewPDF.SaveToFile("test_ClonePage.pdf") == GdPictureStatus.OK)
message = message + " and the file has been saved.";
else
message = message + ", but the file can't be saved.";
MessageBox.Show(message, caption);
}
}
else
MessageBox.Show("The destination file can't be created.", caption);
oGdPictureNewPDF.Dispose();
}
else
MessageBox.Show("The second file can't be loaded.", caption);
}
else
MessageBox.Show("The first file can't be loaded.", caption);
gdpicturePDF1.Dispose();
gdpicturePDF2.Dispose();
Clones a range of pages located in the specified source PDF document into the currently loaded PDF document. The new pages are added
at the end of the current document and the last page is automatically selected as the current page.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while cloning large documents.
The feature is available in both 32-bit and 64-bit mode by default.
This method is a alternative to method in cases where multiple pages need to be cloned together.
A GdPicturePDF object. The source PDF document, which contains the page range you want to clone into the currently loaded PDF document.
The page range to be cloned, for example, "1;4;5" to clone pages 1, 4 and 5 or "1-5;10" to clone pages from 1 to 5 and page 10.
Set this parameter to "*" to clone all pages from the specified document.
This method is only allowed for use with non-encrypted documents, both source and destination ones.
This method will keep internal document link references intact.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to clone range of pages to a new document.
Using sourcePDF As GdPicturePDF = New GdPicturePDF()
sourcePDF.LoadFromFile("test.pdf")
Using destPDF As GdPicturePDF = New GdPicturePDF()
destPDF.NewPDF()
destPDF.ClonePages(sourcePDF, "2-5;8")
destPDF.SaveToFile("test_2-5,8.pdf")
End Using
End Using
using (GdPicturePDF sourcePDF = new GdPicturePDF())
{
sourcePDF.LoadFromFile("test.pdf");
using (GdPicturePDF destPDF = new GdPicturePDF())
{
destPDF.NewPDF();
destPDF.ClonePages(sourcePDF, "2-5;8");
destPDF.SaveToFile("test_2-5,8.pdf");
}
}
Duplicates the currently selected page into the loaded PDF document according to a specified number of copies. All duplicated pages retain its content and the
layer structure. They all are appended at the end of the current document and the last page is automatically selected as the current page.
This method is particularly useful if you want to apply a common page header and footer while keeping the file size as small as possible.
The number of copies of the selected page you want to duplicate.
This method is only allowed for use with non-encrypted documents.
The last added page is automatically selected as the current page after the successful duplication of the required page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to duplicate the first page of your document three times. This example shows you that all three newly created pages are added at the end of the
document and the last page is selected as the current.
Dim caption As String = "Example: DuplicatePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("testPDF.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If count > 0 Then
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.DuplicatePage(3)
If status = GdPictureStatus.OK Then
Dim current As Integer = gdpicturePDF.GetCurrentPage()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_DuplicatePage.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully." + vbCrLf +
"The current page before the page duplication was: 1 " + vbCrLf +
"The current page after the page duplication is: " + current.ToString(), caption)
End If
End If
Else
MessageBox.Show("The DuplicatePage() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DuplicatePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (count > 0)
{
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.DuplicatePage(3);
if (status == GdPictureStatus.OK)
{
int current = gdpicturePDF.GetCurrentPage();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_DuplicatePage.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.\nThe current page before the page duplication was: 1 \n" +
"The current page after the page duplication is: " + current.ToString(), caption);
}
}
else
{
MessageBox.Show("The DuplicatePage() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Deletes a page specified by its page number in the currently loaded PDF document.
The page number of a page you want to delete. It must be a value from 1 to .
This method is only allowed for use with non-encrypted documents.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to delete the first page of your document. The page has been previously cloned.
Dim caption As String = "Example: DeletePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If count > 0 Then
status = gdpicturePDF.ClonePage(1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.DeletePage(1)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_DeletePage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The page has been deleted successfully and the file has been saved.", caption)
Else
MessageBox.Show("The page has been deleted successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("The DeletePage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DeletePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (count > 0)
{
status = gdpicturePDF.ClonePage(1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.DeletePage(1);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_DeletePage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The page has been deleted successfully and the file has been saved.", caption);
else
MessageBox.Show("The page has been deleted successfully, but the file can't be saved.", caption);
}
else
MessageBox.Show("The DeletePage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Swaps two pages specified by their page numbers within the currently loaded PDF document, that means the specified pages change their position with one another in the document.
The page number of the one page you want to swap. It must be a value from 1 to other than Page2 parameter.
The page number of the other page you want to swap. It must be a value from 1 to other than Page1 parameter.
This method is only allowed for use with non-encrypted documents.
It is only allowed to swap the pages with different page numbers, otherwise the method will fail.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to swap the first page and the last page in the PDF document.
Dim caption As String = "Example: SwapPage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If count > 1 Then
status = gdpicturePDF.SwapPages(1, count)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_SwapPage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been swapped successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been swapped successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("The SwapPages() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
Else
MessageBox.Show("The document must contain at least two pages to follow this example.", caption)
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SwapPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (count > 1)
{
status = gdpicturePDF.SwapPages(1, count);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_SwapPage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been swapped successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been swapped successfully, but the file can't be saved.", caption);
}
else
{
MessageBox.Show("The SwapPages() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
else
MessageBox.Show("The document must contain at least two pages to follow this example.", caption);
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Moves a specified page to a destination page within the currently loaded PDF document. Moving a page means that the specified page takes on the page number,
that is equal to the destination page number. Please note that the destination page doesn't change its position in the document. The current page is
automatically set to the moved page after successful moving.
The page number of a page you want to move. It must be a value from 1 to .
The page number of a destination page. It must be a value from 1 to .
The specified page you want to move takes on this page number after the successful move.
This method is only allowed for use with non-encrypted documents.
The moved page is automatically set as the current page after the successful moving.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to move the first page of your document to become the third page.
Dim caption As String = "Example: MovePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If count < 3 Then
status = GdPictureStatus.InvalidParameter
Else
status = gdpicturePDF.MovePage(1, 3)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_MovePage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been moved successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been moved successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("The MovePage() method has failed with the status: " + status.ToString(), caption)
status = GdPictureStatus.OK
End If
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: MovePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (count < 3)
status = GdPictureStatus.InvalidParameter;
else
{
status = gdpicturePDF.MovePage(1,3);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_MovePage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been moved successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been moved successfully, but the file can't be saved.", caption);
}
else
{
MessageBox.Show("The MovePage() method has failed with the status: " + status.ToString(), caption);
status = GdPictureStatus.OK;
}
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the number of pages in the currently loaded PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of pages in the PDF document. The method can be subsequently used to determine if this method has been successful.
How to find out the number of pages in the PDF document.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("This PDF document contains " + count + " pages.", "Example: GetPageCount")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPageCount")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetPageCount")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("This PDF document contains " + count + " pages.", "Example: GetPageCount");
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPageCount");
}
else
MessageBox.Show("The file can't be loaded.", "Example: GetPageCount");
}
Returns the page width of the currently selected page in the loaded PDF document expressed in the current units used in this document.
You can simply use the method to determine the currently defined units or you can easily use the method
to reset the units according to your preference.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The page width expressed in the current units specified by the SetMeasurementUnit method. The method can be subsequently used to determine if this method has been successful.
Be aware that any potential page rotation is not respected. The returned value is always the original page width value, that has been set when adding the page.
How to find out the page width of the currently selected page in the loaded PDF document. This example shows you that the page rotation is not respected when
determining the page width.
Dim caption As String = "Example: GetPageWidth"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) 'A4 = (210mm x 270mm)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim width As Single = gdpicturePDF.GetPageWidth()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The width of the current page is " + width.ToString() + " mm.", caption)
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption)
End If
status = gdpicturePDF.RotatePage(90)
If status = GdPictureStatus.OK Then
width = gdpicturePDF.GetPageWidth()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The width of the current page after the rotation is " + width.ToString() + " mm.", caption)
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageWidth";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4); //A4 = (210mm x 270mm)
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
float width = gdpicturePDF.GetPageWidth();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The width of the current page is " + width.ToString() + " mm." , caption);
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption);
status = gdpicturePDF.RotatePage(90);
if (status == GdPictureStatus.OK)
{
width = gdpicturePDF.GetPageWidth();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The width of the current page after the rotation is " + width.ToString() + " mm.", caption);
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the page height of the currently selected page in the loaded PDF document expressed in the current units used in this document.
You can simply use the method to determine the currently defined units or you can easily use the method
to reset the units according to your preference.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The page height expressed in the current units specified by the SetMeasurementUnit method. The method can be subsequently used to determine if this method has been successful.
Be aware that any potential page rotation is not respected. The returned value is always the original page height value, that has been set when adding the page.
How to find out the page height of the currently selected page in the loaded PDF document.
This example shows you that the page rotation is not respected when determining the page height.
Dim caption As String = "Example: GetPageHeight"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) 'A4 = (210mm x 270mm)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim height As Single = gdpicturePDF.GetPageHeight()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The height of the current page is " + height.ToString() + " mm.", caption)
Else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + status.ToString(), caption)
End If
status = gdpicturePDF.RotatePage(90)
If status = GdPictureStatus.OK Then
height = gdpicturePDF.GetPageHeight()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The height of the current page after the rotation is " + height.ToString() + " mm.", caption)
Else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageHeight";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4); //A4 = (210mm x 270mm)
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
float height = gdpicturePDF.GetPageHeight();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The height of the current page is " + height.ToString() + " mm." , caption);
else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + status.ToString(), caption);
status = gdpicturePDF.RotatePage(90);
if (status == GdPictureStatus.OK)
{
height = gdpicturePDF.GetPageHeight();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The height of the current page after the rotation is " + height.ToString() + " mm.", caption);
else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the boundaries, expressed in the current units used in this document, of the specified page box of the currently selected page of the loaded PDF document.
You can simply use the method to determine the currently defined units or you can easily use the method to reset
the units according to your preference.
The required page (boundary) box. A member of the PdfPageBox enumeration.
Output parameter. The horizontal (X) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The vertical (Y) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The horizontal (X) coordinate of the bottom right point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The vertical (Y) coordinate of the bottom right point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
The output values are always calulated with respect to the default bottom-left origin. SetOrigin method does not affect the results in any way.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to obtain the mediabox and the cropbox boundaries of the first page in your document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
Dim left As Single = 0, top As Single = 0, right As Single = 0, bottom As Single = 0
status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, left, top, right, bottom)
If status = GdPictureStatus.OK Then
message = message + "The mediabox for the first page is defined like this:" + vbCrLf + "( " + left.ToString() + " ; " + top.ToString() +
" ) - ( " + right.ToString() + " ; " + bottom.ToString() + " ) millimeters."
Else
message = message + "The GetPageBox() method for mediabox has failed with the status: " + status.ToString()
End If
status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxCropBox, left, top, right, bottom)
If status = GdPictureStatus.OK Then
message = message + vbCrLf + "The cropbox for the first page is defined like this:" + vbCrLf + "( " + Left.ToString() + " ; " + top.ToString() +
" ) - ( " + right.ToString() + " ; " + bottom.ToString() + " ) millimeters."
Else
message = message + vbCrLf + "The GetPageBox() method for cropbox has failed with the status: " + status.ToString()
End If
Else
message = message + "The SelectPage() method has failed with the status: " + status.ToString()
End If
MessageBox.Show(message, "Example: GetPageBox")
Else
MessageBox.Show("The file can't be loaded.", "Example: GetPageBox")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
float left = 0, top = 0, right = 0, bottom = 0;
status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, ref left, ref top, ref right, ref bottom);
if (status == GdPictureStatus.OK)
{
message = message + "The mediabox for the first page is defined like this:\n( " + left.ToString() + " ; " + top.ToString() +
" ) - ( " + right.ToString() + " ; " + bottom.ToString() + " ) millimeters.";
}
else
message = message + "The GetPageBox() method for mediabox has failed with the status: " + status.ToString();
status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxCropBox, ref left, ref top, ref right, ref bottom);
if (status == GdPictureStatus.OK)
{
message = message + "\nThe cropbox for the first page is defined like this:\n( " + left.ToString() + " ; " + top.ToString() +
" ) - ( " + right.ToString() + " ; " + bottom.ToString() + " ) millimeters.";
}
else
message = message + "\nThe GetPageBox() method for cropbox has failed with the status: " + status.ToString();
}
else
message = message + "The SelectPage() method has failed with the status: " + status.ToString();
MessageBox.Show(message, "Example: GetPageBox");
}
else
MessageBox.Show("The file can't be loaded.", "Example: GetPageBox");
gdpicturePDF.Dispose();
Sets the new boundaries, expressed in the current units used in this document, of the required page box of the currently selected page of the loaded PDF document.
You can simply use the method to determine the currently defined units or you can easily use the method to reset
the units according to your preference.
The required page (boundary) box. A member of the PdfPageBox enumeration.
The newly defined horizontal (X) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
The newly defined vertical (Y) coordinate of the top left point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
The newly defined horizontal (X) coordinate of the bottom right point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
The newly defined vertical (Y) coordinate of the bottom right point of the specified page box expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
The input values should always respect the default bottom-left origin. SetOrigin method does not affect the results of this method in any way.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the cropbox boundaries of the cloned page in your document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
status = gdpicturePDF.ClonePage(1)
If status = GdPictureStatus.OK Then
Dim left As Single = 0, top As Single = 0, right As Single = 0, bottom As Single = 0
status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxCropBox, left, top, right, bottom)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetPageBox(PdfPageBox.PdfPageBoxCropBox, left + 10, top - 10, right - 10, bottom + 10)
If status = GdPictureStatus.OK Then
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_SetPageBox.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and file has been saved."
Else
message = message + "The example has been followed successfully but the file can't be saved."
End If
End If
Else
message = message + "The SetPageBox() method has failed with the status: " + status.ToString()
End If
Else
message = message + "The GetPageBox() method has failed with the status: " + status.ToString()
End If
Else
message = message + "The ClonePage() method has failed with the status: " + status.ToString()
End If
MessageBox.Show(message, "Example: GetPageBox")
Else
MessageBox.Show("The file can't be loaded.", "Example: SetPageBox")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
status = gdpicturePDF.ClonePage(1);
if (status == GdPictureStatus.OK)
{
float left = 0, top = 0, right = 0, bottom = 0;
status = gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxCropBox, ref left, ref top, ref right, ref bottom);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetPageBox(PdfPageBox.PdfPageBoxCropBox, left + 10, top - 10, right - 10, bottom + 10);
if (status == GdPictureStatus.OK)
{
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_SetPageBox.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and file has been saved.";
else
message = message + "The example has been followed successfully but the file can't be saved.";
}
}
else
message = message + "The SetPageBox() method has failed with the status: " + status.ToString();
}
else
message = message + "The GetPageBox() method has failed with the status: " + status.ToString();
}
else
message = message + "The ClonePage() method has failed with the status: " + status.ToString();
MessageBox.Show(message, "Example: GetPageBox");
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetPageBox");
gdpicturePDF.Dispose();
Removes the specified page box of the currently selected page of the loaded PDF document.
The required page (boundary) box. A member of the PdfPageBox enumeration.
This method is only allowed for use with non-encrypted documents.
Since MediaBox is a mandatory entry for each page object it is not possible to remove this type of page box using this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove the cropbox boundaries of the page in your document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
gdpicturePDF.SelectPage(1)
gdpicturePDF.RemovePageBox(PdfPageBox.PdfPageBoxCropBox)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
gdpicturePDF.SelectPage(1);
gdpicturePDF.RemovePageBox(PdfPageBox.PdfPageBoxCropBox);
gdpicturePDF.SaveToFile("output.pdf");
}
Selects a specified page (means sets as the current page) in the currently loaded PDF document.
The required page number. This parameter is without any restrictions.
If the specified value is out of the expected range from 1 to , the next-lower or the next-greater value in this range is automatically used.
It means that for values lower than 1 the first page is selected and for values greater than the last page is selected, as it is shown in the example below.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to select a specified page in the PDF document.
Dim caption As String = "Example: SelectPage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim current As Integer = 0
status = gdpicturePDF.SelectPage(0)
If status = GdPictureStatus.OK Then
current = gdpicturePDF.GetCurrentPage()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption)
Else
MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption)
End If
status = gdpicturePDF.SelectPage(count + 1)
If status = GdPictureStatus.OK Then
current = gdpicturePDF.GetCurrentPage()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption)
Else
MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption)
End If
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
current = gdpicturePDF.GetCurrentPage()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption)
Else
MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage(1) method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage(count + 1) method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage(0) method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SelectPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int current = 0;
status = gdpicturePDF.SelectPage(0);
if (status == GdPictureStatus.OK)
{
current = gdpicturePDF.GetCurrentPage();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption);
else
MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption);
status = gdpicturePDF.SelectPage(count + 1);
if (status == GdPictureStatus.OK)
{
current = gdpicturePDF.GetCurrentPage();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption);
else
MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption);
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
current = gdpicturePDF.GetCurrentPage();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption);
else
MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The SelectPage(1) method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The SelectPage(count + 1) method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The SelectPage(0) method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the page number of the currently selected page within the loaded PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The page number of the currently selected page. It is a value from 1 to .
The method can be subsequently used to determine if this method has been successful.
How to find out the actual page (currently selected) in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
'You can replace the previous line of code with this one and try the example again.
'Dim status As GdPictureStatus = gdpicturePDF.NewPDF();
If status = GdPictureStatus.OK Then
Dim pageNr As Integer = gdpicturePDF.GetCurrentPage()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The currently selected page in this PDF document is the page nr." + pageNr.ToString(), "Example: GetCurrentPage")
Else
MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), "Example: GetCurrentPage")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetCurrentPage")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
//You can replace the previous line of code with this one and try the example again.
//GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
int pageNr = gdpicturePDF.GetCurrentPage();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The currently selected page in this PDF document is the page nr." + pageNr.ToString(), "Example: GetCurrentPage");
}
else
{
MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), "Example: GetCurrentPage");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetCurrentPage");
}
gdpicturePDF.Dispose();
Returns the actual page rotation in the clockwise direction, in degrees, of the currently selected page in the loaded PDF document.
This value expresses the number of degrees by which the current page should be rotated clockwise when displayed or printed.
It must always be a multiple of 90.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to warn you that in spite of the methods GetPageRotation() and AddPageRotation() are named similarly, they work with different data.
Please see the method for more details about the differences.
The clockwise rotation of the currently selected page in degrees. The returned value can only be 0, 90, 180 or 270.
The method can be subsequently used to determine if this method has been successful.
How to determine the actual page rotation in degrees. In this example each page of the currently loaded PDF document has been rotated step by step by its page number multiple of 90 degrees.
Dim caption As String = "Example: GetPageRotation"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.RotatePage(i * 90)
If status = GdPictureStatus.OK Then
Dim rotation As Integer = gdpicturePDF.GetPageRotation()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The rotation angle of the page nr." + i.ToString() + " is " + rotation.ToString() + " degrees.", caption)
Else
MessageBox.Show("The GetPageRotation() method has failed with the status: " + status.ToString(), caption)
End If
If i = count Then
If gdpicturePDF.SaveToFile("test_GetPageRotation.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been rotated successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been rotated successfully but the file can't be saved.", caption)
End If
End If
Else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Next
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageRotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.RotatePage(i*90);
if (status == GdPictureStatus.OK)
{
int rotation = gdpicturePDF.GetPageRotation();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The rotation angle of the page nr." + i.ToString() + " is " + rotation.ToString() + " degrees.", caption);
else
MessageBox.Show("The GetPageRotation() method has failed with the status: " + status.ToString(), caption);
if (i == count)
{
if (gdpicturePDF.SaveToFile("test_GetPageRotation.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been rotated successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been rotated successfully but the file can't be saved.", caption);
}
}
else
{
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Rotates clockwise the currently selected page of the loaded PDF document. The rotation angle can be set to 90, 180 or 270 degrees.
The rotation angle, in degrees, determining the clockwise rotation. This parameter can be set to 90, -90, 180, -180, 270, -270 or any multiple of 90.
This method is only allowed for use with non-encrypted documents.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to rotate all pages of your document step by step by multiple of 90 degrees, that means each page is rotated by next (means page number) multiple of 90. You can subsequently determine the actual page rotation.
Dim caption As String = "Example: RotatePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.RotatePage(i * 90)
If status = GdPictureStatus.OK Then
Dim rotation As Integer = gdpicturePDF.GetPageRotation()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The rotation angle of the page nr." + i.ToString() + " is " + rotation.ToString() + " degrees.", caption)
Else
MessageBox.Show("The GetPageRotation() method has failed with the status: " + status.ToString(), caption)
End If
If i = count Then
If gdpicturePDF.SaveToFile("test_RotatePage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been rotated successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been rotated successfully but the file can't be saved.", caption)
End If
End If
Else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Next
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RotatePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.RotatePage(i*90);
if (status == GdPictureStatus.OK)
{
int rotation = gdpicturePDF.GetPageRotation();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The rotation angle of the page nr." + i.ToString() + " is " + rotation.ToString() + " degrees.", caption);
else
MessageBox.Show("The GetPageRotation() method has failed with the status: " + status.ToString(), caption);
if (i == count)
{
if (gdpicturePDF.SaveToFile("test_RotatePage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been rotated successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been rotated successfully but the file can't be saved.", caption);
}
}
else
{
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Rotates counterclockwise the whole content of the currently selected page in the loaded PDF document through an angle you have specified.
The angle of rotation. This parameter is without any restrictions.
This method is only allowed for use with non-encrypted documents.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to rotate the content of the first page counterclockwise by 45 degrees.
Dim caption As String = "Example: RotatePageEx"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.RotatePageEx(45)
If status = GdPictureStatus.OK Then
Dim message As String = "The page has been rotated successfully"
If gdpicturePDF.SaveToFile("test_RotatePageEx.pdf") = GdPictureStatus.OK Then
message = message + " and the file has been saved."
Else
message = message + ", but the file can't be saved."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The RotatePageEx() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RotatePageEx";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.RotatePageEx(45);
if (status == GdPictureStatus.OK)
{
string message = "The page has been rotated successfully";
if (gdpicturePDF.SaveToFile("test_RotatePageEx.pdf") == GdPictureStatus.OK)
message = message + " and the file has been saved.";
else
message = message + ", but the file can't be saved.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The RotatePageEx() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Flips the content of the currently selected page in the loaded PDF document horizontally or vertically according to your preference.
Set this parameter to true if you want to horizontally flip the content of the current page. Otherwise set it to false.
Set this parameter to true if you want to vertically flip the content of the current page. Otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to flip the content of the first page horizontally and vertically. This example shows you all four combinations of the flipping parameters. The
flipped pages are subsequently saved into the newly created PDF document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If count > 0 Then
status = gdpicturePDF.SelectPage(1)
Else
status = GdPictureStatus.InvalidParameter
End If
If status = GdPictureStatus.OK Then
Dim oGdPictureNewPDF As New GdPicturePDF()
status = oGdPictureNewPDF.NewPDF()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.FlipPage(True, False)
If status = GdPictureStatus.OK Then
status = oGdPictureNewPDF.ClonePage(gdpicturePDF, 1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.FlipPage(False, True)
If status = GdPictureStatus.OK Then
status = oGdPictureNewPDF.ClonePage(gdpicturePDF, 1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.FlipPage(True, True)
If status = GdPictureStatus.OK Then
status = oGdPictureNewPDF.ClonePage(gdpicturePDF, 1)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.FlipPage(False, False)
If status = GdPictureStatus.OK Then
status = oGdPictureNewPDF.ClonePage(gdpicturePDF, 1)
If status = GdPictureStatus.OK Then
status = oGdPictureNewPDF.SaveToFile("test_FlipPage.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully.", "Example: FlipPage")
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
oGdPictureNewPDF.Dispose()
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), "Example: FlipPage")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: FlipPage")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (count > 0)
status = gdpicturePDF.SelectPage(1);
else
status = GdPictureStatus.InvalidParameter;
if (status == GdPictureStatus.OK)
{
GdPicturePDF oGdPictureNewPDF = new GdPicturePDF();
status = oGdPictureNewPDF.NewPDF();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.FlipPage(true, false);
if (status == GdPictureStatus.OK)
{
status = oGdPictureNewPDF.ClonePage(gdpicturePDF, 1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.FlipPage(false, true);
if (status == GdPictureStatus.OK)
{
status = oGdPictureNewPDF.ClonePage(gdpicturePDF, 1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.FlipPage(true, true);
if (status == GdPictureStatus.OK)
{
status = oGdPictureNewPDF.ClonePage(gdpicturePDF, 1);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.FlipPage(false, false);
if (status == GdPictureStatus.OK)
{
status = oGdPictureNewPDF.ClonePage(gdpicturePDF, 1);
if (status == GdPictureStatus.OK)
{
status = oGdPictureNewPDF.SaveToFile("test_FlipPage.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully.", "Example: FlipPage");
}
}
}
}
}
}
}
}
}
oGdPictureNewPDF.Dispose();
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), "Example: FlipPage");
}
else
MessageBox.Show("The file can't be loaded.", "Example: FlipPage");
gdpicturePDF.Dispose();
Rotates clockwise all pages of the currently loaded PDF document. The rotation angle can be set to 90, 180 or 270 degrees.
The rotation angle, in degrees, determining the clockwise rotation. This parameter can be set to 90, -90, 180, -180, 270, -270 or any multiple of 90.
This method is only allowed for use with non-encrypted documents.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to rotate all pages of the PDF document by 90 degrees.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.RotatePages(90)
If status = GdPictureStatus.OK Then
Dim message As String = "The pages have been rotated successfully"
If gdpicturePDF.SaveToFile("test_RotatePages.pdf") = GdPictureStatus.OK Then
message = message + " and the file has been saved."
Else
message = message + ", but the file can't be saved."
End If
MessageBox.Show(message, "Example: RotatePages")
Else
MessageBox.Show("The RotatePages() method has failed with the status: " + status.ToString(), "Example: RotatePages")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: RotatePages")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.RotatePages(90);
if (status == GdPictureStatus.OK)
{
string message = "The pages have been rotated successfully";
if (gdpicturePDF.SaveToFile("test_RotatePages.pdf") == GdPictureStatus.OK)
message = message + " and the file has been saved.";
else
message = message + ", but the file can't be saved.";
MessageBox.Show(message, "Example: RotatePages");
}
else
MessageBox.Show("The RotatePages() method has failed with the status: " + status.ToString(), "Example: RotatePages");
}
else
MessageBox.Show("The file can't be loaded.", "Example: RotatePages");
gdpicturePDF.Dispose();
Normalizes the currently selected page in the loaded PDF document, in other words all the page boundary boxes are adjusted to the physical size of the page
(means the CropBox property is equal to the MediaBox property) and the page's rotation is reset to 0. The actual page rendering is not changed.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the purpose of this method is to prepare the content of the current page so that subsequent drawing operations are at the
expected position on the page. This method should be used before the drawing operations, which ignore the page's rotation and cropping.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to normalize all pages in the PDF document.
Dim caption As String = "Example: NormalizePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.NormalizePage()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The NormalizePage() method has failed for the page number " + i.ToString() + " with the status: " + status.ToString(), caption)
Exit For
End If
Else
Exit For
End If
Next
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_NormalizePage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been normalized successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been normalized successfully but the file can't be saved.", caption)
End If
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NormalizePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.NormalizePage();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The NormalizePage() method has failed for the page number " + i.ToString() + " with the status: " + status.ToString(), caption);
break;
}
}
else break;
}
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_NormalizePage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been normalized successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been normalized successfully but the file can't be saved.", caption);
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets up the metadata of the currently selected page in the loaded PDF document according to what you have specified.
Sets up the metadata of the currently selected page.
A new value of the metadata as a string in the XML format.
This method is only allowed for use with non-encrypted documents.
The currently stored metadata entries will be overwritten according to the values you have specified.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the metadata linked with all pages of the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim data As String = "", message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
data = "<head>" + vbCrLf +
"< meta name =""description"" content=""Brief description of the page."" />" + vbCrLf +
"< meta name =""keywords"" content=""metadata of the page"" />" + vbCrLf +
"< meta name =""author"" content=""John Doe"" />" + vbCrLf +
"< meta name =""pagenumber"" content=""" + i.ToString() + """ />" + vbCrLf + "</head>"
status = gdpicturePDF.SetPageMetadata(data)
If status = GdPictureStatus.OK Then
message = message + "The metadata for the page nr." + i.ToString() + " has been set successfully." + vbCrLf
Else
message = message + "The SetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_PageMetadata.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, "Example: SetPageMetadata")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageMetadata")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetPageMetadata")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string data = "", message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
data = "<head>\n< meta name =\"description\" content=\"Brief description of the page.\" />\n"+
"< meta name =\"keywords\" content=\"metadata of the page\" />\n"+
"< meta name =\"author\" content=\"John Doe\" />\n"+
"< meta name =\"pagenumber\" content=\"" + i.ToString() + "\" />\n</head>";
status = gdpicturePDF.SetPageMetadata(data);
if (status == GdPictureStatus.OK)
message = message + "The metadata for the page nr." + i.ToString() + " has been set successfully.\n";
else
message = message + "The SetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_PageMetadata.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, "Example: SetPageMetadata");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageMetadata");
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetPageMetadata");
gdpicturePDF.Dispose();
Sets up the metadata of the currently selected page in the loaded PDF document according to what you have specified.
Sets up the metadata of the currently selected page.
A new value of the metadata as an array of bytes in the XML format.
This method is only allowed for use with non-encrypted documents.
The currently stored metadata entries will be overwritten according to the values you have specified.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the metadata linked with all pages of the PDF document. You can use the metadata files created in the example for the GetPageMetadata() method.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
'Each page has its own metadata xmp-file.
Dim filename As String = "metadata_page" + i.ToString() + ".xmp"
Dim data As Byte() = System.IO.File.ReadAllBytes(filename)
status = gdpicturePDF.SetPageMetadata(data)
If status = GdPictureStatus.OK Then
message = message + "The metadata for the page nr." + i.ToString() + " has been set successfully." + vbCrLf
Else
message = message + "The SetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_Metadata.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, "Example: SetPageMetadata")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageMetadata")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetPageMetadata")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
//Each page has its own metadata xmp-file.
string filename = "metadata_page" + i.ToString()+".xmp";
byte[] data = System.IO.File.ReadAllBytes(filename);
status = gdpicturePDF.SetPageMetadata(data);
if (status == GdPictureStatus.OK)
message = message + "The metadata for the page nr." + i.ToString() + " has been set successfully.\n";
else
message = message + "The SetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_Metadata.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, "Example: SetPageMetadata");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageMetadata");
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetPageMetadata");
gdpicturePDF.Dispose();
Defines a private tag linked with the currently selected page in the loaded PDF document, specified by its name and value.
Tags provide an additional information that allow page content to be extracted and reused for other purposes.
The name of the private tag for the currrent page. It can be a name you prefer, for example "Origin".
The content of the private tag for the currrent page, for example "Application-Xapp".
This method is only allowed for use with non-encrypted documents.
The currently stored tag value will be overwritten according to the new value you have specified.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to define the private tag named MyTag with the specified 'page number' value and link it with each page of your document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = "", content As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
content = "My Value " + i.ToString()
status = gdpicturePDF.SetPagePrivateTag("MyTag", content)
If status = GdPictureStatus.OK Then
message = message + "The private tag for the page nr." + i.ToString() + " has been set successfully." + vbCrLf
Else
message = message + "The SetPagePrivateTag() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_SetPagePrivateTag.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, "Example: SetPagePrivateTag")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPagePrivateTag")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetPagePrivateTag")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "", content = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
content = "My Value " + i.ToString();
status = gdpicturePDF.SetPagePrivateTag("MyTag", content);
if (status == GdPictureStatus.OK)
message = message + "The private tag for the page nr." + i.ToString() + " has been set successfully.\n";
else
message = message + "The SetPagePrivateTag() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_SetPagePrivateTag.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, "Example: SetPagePrivateTag");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPagePrivateTag");
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetPagePrivateTag");
gdpicturePDF.Dispose();
Returns a value for the private tag linked with the currently selected page of the loaded PDF document, specified by its name.
The name of the private tag for the current page, for example "Origin".
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The private page tag value previously defined by the method. The method can be subsequently used to determine if this method has been successful.
How to determine the values for the private tag named MyTag linked with each page of your document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = "", content As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
content = gdpicturePDF.GetPagePrivateTag("MyTag")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "The value of the MyTag for the page nr." + i.ToString() + " is : " + content + vbCrLf
Else
message = message + "The GetPagePrivateTag() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, "Example: GetPagePrivateTag")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPagePrivateTag")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetPagePrivateTag")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "", content = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
content = gdpicturePDF.GetPagePrivateTag("MyTag");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + "The value of the MyTag for the page nr." + i.ToString() + " is : " + content + "\n";
else
message = message + "The GetPagePrivateTag() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, "Example: GetPagePrivateTag");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPagePrivateTag");
}
else
MessageBox.Show("The file can't be loaded.", "Example: GetPagePrivateTag");
gdpicturePDF.Dispose();
Deletes a private tag linked to the currently selected page, previously defined by the method, specified by its name.
The name of the private page tag to delete, for example "Origin".
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to delete the private tag named MyTag linked to each page of your document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.DeletePagePrivateTag("MyTag")
If status = GdPictureStatus.OK Then
message = message + "The MyTag for the page nr." + i.ToString() + " has been successfully deleted." + vbCrLf
Else
message = message + "The DeletePagePrivateTag() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_DeletePagePrivateTag.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, "Example: DeletePagePrivateTag")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: DeletePagePrivateTag")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: DeletePagePrivateTag")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.DeletePagePrivateTag("MyTag");
if (status == GdPictureStatus.OK)
message = message + "The MyTag for the page nr." + i.ToString() + " has been successfully deleted.\n";
else
message = message + "The DeletePagePrivateTag() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_DeletePagePrivateTag.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, "Example: DeletePagePrivateTag");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: DeletePagePrivateTag");
}
else
MessageBox.Show("The file can't be loaded.", "Example: DeletePagePrivateTag");
gdpicturePDF.Dispose();
Deletes a page thumbnail image and its resource, if any is defined for the currently selected page of the loaded PDF document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to delete thumbnail images and their resources from each page of your document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.DeletePageThumbnailImage()
If status = GdPictureStatus.OK Then
message = message + "The thumbnail for the page nr." + i.ToString() + " has been successfully deleted." + vbCrLf
Else
message = message + "The DeletePageThumbnailImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_DeletePageThumbnailImage.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, "Example: DeletePageThumbnailImage")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: DeletePageThumbnailImage")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: DeletePageThumbnailImage")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.DeletePageThumbnailImage();
if (status == GdPictureStatus.OK)
message = message + "The thumbnail for the page nr." + i.ToString() + " has been successfully deleted.\n";
else
message = message + "The DeletePageThumbnailImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_DeletePageThumbnailImage.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, "Example: DeletePageThumbnailImage");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: DeletePageThumbnailImage");
}
else
MessageBox.Show("The file can't be loaded.", "Example: DeletePageThumbnailImage");
gdpicturePDF.Dispose();
Deletes a page PieceInfo dictionary used to hold private application data, if any is defined for the currently selected page of the loaded PDF document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to delete PieceInfo from each page of your document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.DeletePagePieceInfo()
If status = GdPictureStatus.OK Then
message = message + "The PieceInfo for the page nr." + i.ToString() + " has been successfully deleted." + vbCrLf
Else
message = message + "The DeletePagePieceInfo() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_DeletePagePieceInfo.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, "Example: DeletePagePieceInfo")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: DeletePagePieceInfo")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: DeletePagePieceInfo")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.DeletePagePieceInfo();
if (status == GdPictureStatus.OK)
message = message + "The PieceInfo for the page nr." + i.ToString() + " has been successfully deleted.\n";
else
message = message + "The DeletePagePieceInfo() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_DeletePagePieceInfo.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, "Example: DeletePagePieceInfo");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: DeletePagePieceInfo");
}
else
MessageBox.Show("The file can't be loaded.", "Example: DeletePagePieceInfo");
gdpicturePDF.Dispose();
Gets the metadata of the currently selected page in the loaded PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The metadata of the current page as a string, if any are defined. The method can be subsequently used to determine if this method has been successful.
How to obtain the metadata linked with all pages of the PDF document. Metadata linked to each page are subsequently saved into a separate file.
Dim caption As String = "Example: GetPageMetadata"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("testPDF.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim data As String = "", message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
data = gdpicturePDF.GetPageMetadata()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + " contains this metadata: " + data + vbCrLf
//Metadata of each page are saved into a separate file.
Dim filename As String = "metadata_page" + i.ToString() + ".xmp"
System.IO.File.WriteAllText(filename, data)
Else
message = message + "The GetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageMetadata";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("testPDF.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string data = "", message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
data = gdpicturePDF.GetPageMetadata();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + " contains this metadata: " + data + "\n";
//Metadata of each page are saved into a separate file.
string filename = "metadata_page" + i.ToString() + ".xmp";
System.IO.File.WriteAllText(filename, data);
}
else
message = message + "The GetPageMetadata() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the user space unit value defined for the currently selected page in the loaded PDF document.
It is the positive number specifying the size of default user space units, in multiples of 1/72 inch. The default value is 1.
Please note that you need to create or load the PDF document properly to set the valid value, otherwise the method does nothing.
At the same, the specified value only relates to the currently selected page.
The positive number defining the size of default user space units.
The minimum allowed value is 1, the maximum allowed value is not restricted by the toolkit.
The method can be subsequently used to determine if this method has been successful.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that the default value is 1, which means the user unit is 1/72 inch.
Be aware, that the minimum allowed value is 1, the maximum allowed value is not restricted by the toolkit. For further assistance, please refer to the PDF Reference, Section "Page Objects".
How to specify the user space unit value for the current page to define required page dimensions.
Dim caption As String = "Example: SetPageUserUnit"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint)
'The height and the width for the new page in PDF points.
Dim pageDim As Single = 14400
'Be sure you have selected the proper page.
If (gdpicturePDF.NewPage(pageDim, pageDim) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
'To create a page of size 200 * 200 inches.
Dim userUnit As Single = 75000
gdpicturePDF.SetPageUserUnit(userUnit)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
pageDim = gdpicturePDF.GetPageHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The current page height and width is " + pageDim + " inches.", caption)
Else
MessageBox.Show("The GetPageHeight() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SetPageUserUnit() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new page can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetPageUserUnit";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint);
float pageDim = 14400; //The height and the width for the new page in PDF points.
//Be sure you have selected the proper page.
if ((gdpicturePDF.NewPage(pageDim, pageDim) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
{
float userUnit = 75000; //To create a page of size 200 * 200 inches.
gdpicturePDF.SetPageUserUnit(userUnit);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
pageDim = gdpicturePDF.GetPageHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The current page height and width is " + pageDim + " inches.", caption);
else
MessageBox.Show("The GetPageHeight() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SetPageUserUnit() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The new page can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Returns the user space unit value defined for the currently selected page in the loaded PDF document.
It is the positive number specifying the size of default user space units, in multiples of 1/72 inch. The default value is 1.
Please note that you need to create or load the PDF document properly to get the valid value, otherwise the method does nothing.
At the same, the specified value only relates to the currently selected page.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that the default value is 1, which means the user unit is 1/72 inch.
Be aware, that the minimum allowed value is 1, the maximum allowed value is not restricted by the toolkit. For further assistance, please refer to the PDF Reference, Section "Page Objects".
The positive number defining the size of default user space units.
The method can be subsequently used to determine if this method has been successful.
How to find out the current page size dimensions with the help of user space unit value.
Dim caption As String = "Example: GetPageUserUnit"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim message As String = ""
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint)
'Be sure you have selected the proper page.
gdpicturePDF.SelectPage(1)
Dim userUnits As Single = gdpicturePDF.GetPageUserUnit()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message += "Page User Units: " + userUnits.ToString()
Dim pageHeight As Single = gdpicturePDF.GetPageHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pageWidth As Single = gdpicturePDF.GetPageWidth()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim currentPageHeight As Single = pageHeight * userUnits * 1 / 72
Dim currentPageWidth As Single = pageWidth * userUnits * 1 / 72
message += vbCrLf + "Current page dimensions in inches:"
message += vbCrLf + "page height = " + currentPageHeight + vbCrLf + "page width = " + currentPageWidth
Else
message += vbCrLf + "The GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message += vbCrLf + "The GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message += "The GetPageUserUnit() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageUserUnit";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string message = "";
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint);
//Be sure you have selected the proper page.
gdpicturePDF.SelectPage(1);
float userUnits = gdpicturePDF.GetPageUserUnit();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message += "Page User Units: " + userUnits.ToString();
float pageHeight = gdpicturePDF.GetPageHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float pageWidth = gdpicturePDF.GetPageWidth();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float currentPageHeight = pageHeight * userUnits * 1 / 72;
float currentPageWidth = pageWidth * userUnits * 1 / 72;
message += "\nCurrent page dimensions in inches:\npage height = " + currentPageHeight + "\npage width = " + currentPageWidth;
}
else
message += "\nThe GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else
message += "\nThe GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else
message += "The GetPageUserUnit() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Merges list of pages within the currently loaded PDF document.
Pages content will be appended to the first page in list in corresponding order and first page height will be incremented with each appended page.
An array of the integer values specifying page numbers that shall be merged.
Set this parameter to true if you want to remove specified pages after merging, otherwise set it to false.
First page in list will not be deleted even if this parameter is set to true.
This method is only allowed for use with non-encrypted documents.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to merge 2 PDF document pages into single page.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
Dim pages As New List(Of Integer)({ 1, 2 })
gdpicturePDF.MergePages(pages, True)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf", false);
pages = new List { 1, 2 }; ]]>
gdpicturePDF.MergePages(pages, true);
gdpicturePDF.SaveToFile("output.pdf");
}
Overlays currently selected page of loaded PDF document with specified page from the same document.
Page number that shall be used as overlay.
The horizontal (X) coordinate of the bottom left point, where the overlay page is to be drawn,
expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin, related to the currently selected page.
The vertical (Y) coordinate of the bottom left point, where the overlay page is to be drawn,
expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin, related to the currently selected page.
The horizontal scale factor for overlay, it corresponds to the overlay page width.
For example, if this parameter is set to 2.0, it multiplies the width of the overlay page by 2, and if it is set to 0.5, it divides the width by 2.
The vertical scale factor for overlay, it corresponds to the overlay page height.
For example, if this parameter is set to 2.0, it multiplies the height of the overlay page by 2, and if it is set to 0.5, it divides the height by 2.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to overlay specified page from the same document with curent page.
Overlays currently selected page of loaded PDF document with specified page from other document.
A GdPicturePDF object. The source PDF document, which contains the page you want to use as overlay.
Page number that shall be used as overlay.
The horizontal (X) coordinate of the bottom left point, where the overlay page is to be drawn,
expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin, related to the currently selected page.
The vertical (Y) coordinate of the bottom left point, where the overlay page is to be drawn,
expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin, related to the currently selected page.
The horizontal scale factor for overlay, it corresponds to the overlay page width.
For example, if this parameter is set to 2.0, it multiplies the width of the overlay page by 2, and if it is set to 0.5, it divides the width by 2.
The vertical scale factor for overlay, it corresponds to the overlay page height.
For example, if this parameter is set to 2.0, it multiplies the height of the overlay page by 2, and if it is set to 0.5, it divides the height by 2.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to overlay specified page from external document with curent page.
Automaticaly crops currently selected page of loaded PDF document based on page content.
Specifies the width of the left margin for the cropped content.
Sets the height of the top margin for the cropped content.
Sets the width of the right margin for the cropped content.
Sets the height of the bottom margin for the cropped content.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to AutoCrop specified page of loaded PDF document.
Using gdpicturePDF = New GdPicturePDF()
gdpicturePDF.LoadFromFile("sample.pdf")
gdpicturePDF.AutoCropPage(0, 0, 0, 0)
gdpicturePDF.SaveToFile("sample_cropped.pdf")
End Using
using(GdPicturePDF gdpicturePDF = New GdPicturePDF())
{
gdpicturePDF.LoadFromFile("sample.pdf");
gdpicturePDF.AutoCropPage(0, 0, 0, 0);
gdpicturePDF.SaveToFile("sample_cropped.pdf");
}
Automaticaly crops currently selected page of loaded PDF document based on page content.
Specifies the width of the left margin for the cropped content.
Sets the height of the top margin for the cropped content.
Sets the width of the right margin for the cropped content.
Sets the height of the bottom margin for the cropped content.
Set this parameter to true in order to make the algorithm ignore white rectangle objects on page. Otherwise set to false.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to AutoCrop specified page of loaded PDF document.
Using gdpicturePDF = New GdPicturePDF()
gdpicturePDF.LoadFromFile("sample.pdf")
gdpicturePDF.AutoCropPage(0, 0, 0, 0, True)
gdpicturePDF.SaveToFile("sample_cropped.pdf")
End Using
using(GdPicturePDF gdpicturePDF = New GdPicturePDF())
{
gdpicturePDF.LoadFromFile("sample.pdf");
gdpicturePDF.AutoCropPage(0, 0, 0, 0, true);
gdpicturePDF.SaveToFile("sample_cropped.pdf");
}
Splits the curently selected page into separate new pages according to regions defined by uniform grid. The grid defined by row and column counts.
A integer value specifying number of rows in uniform grid. The value is expected to be higher than 0.
A integer value specifying number of columns in uniform grid. The value is expected to be higher than 0.
Member of the PdfGridSplitOrdering enumeration specifying ordering of the splitted page regions."
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to GridSplit specified page of loaded PDF document.
Splits the curently selected page into separate new pages according to regions defined by grid. The grid is defined by row and column stops.
An IEnumerable of row stop values expressed in percentage of page height. Values are expected to be inside 0 to 100 range and sorted incrementaly.
An IEnumerable of column stop values expressed in percentage of page width. Values are expected to be inside 0 to 100 range and sorted incrementaly.
Member of the PdfGridSplitOrdering enumeration specifying ordering of the splitted page regions."
This method is only allowed for use with non-encrypted documents.
Be aware that the values of row and column stops are expected to be a percentage in range from 0 to 100 and sorted incrementaly in the IEnumerable.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to GridSplit specified page of loaded PDF document.
Returns if the currently selected page of the loaded PDF is blank.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the currently selected page is blank, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to find out if the current page is blank.
Using gdpicturePDF = New GdPicturePDF
gdpicturePDF.LoadFromFile("myFile.pdf")
gdpicturePDF.SelectPage(2)
Dim isBlank = gdpicturePDF.PageIsBlank()
End Using
using(GdPicturePDF gdpicturePDF = new GdPicturePDF)
{
gdpicturePDF.LoadFromFile("myFile.pdf");
gdpicturePDF.SelectPage(2);
bool isBlank = gdpicturePDF.PageIsBlank();
}
Specifies whether the OCR engine must automatically detect the page orientation.
Set true enable page orientation detection, false otherwise.
Page orientation detection is activated by default.
Specifies whether an external OCR engine must be used by this instance.
Set true to indicate to the instance to use an external OCR engine, false otherwise.
Returns whether an external OCR engine must be used by this instance.
True indicates the instance must use an external OCR engine, false otherwise.
Runs the optical character recognition (OCR) on the currently selected page of the loaded PDF document according to what you have specified.
The recognized text is added as invisible text on the page. The page orientation is automatically detected.
This method involves a rasterization process so any existing visible text within the current page will become a part of the image of that page before the OCR process starts.
The same applies to the invisible text contained within the current page. It is not kept because of the rasterization process, which simply means any invisible text is removed
from the page before the OCR process starts.
This method uses one thread when processing. You can also benefit from using several OCR related events like , and .
Runs the optical character recognition (OCR) on the currently selected page of the loaded PDF document.
The prefix of the dictionary file to use, for example, "spa" for Spanish, "eng" for English, "fra" for French, etc.
The name of such dictionary file has a predefined format [LANGUAGE].traineddata, where [LANGUAGE] defines the used language.
You can find these files within your standard installation usually in the directory @\GdPicture.Net 14\Redist\OCR or you can download
additional language dictionary files here.
You can also combine multiple dictionaries with the "+" separator, for instance English with French is "eng+fra".
The path with all installed dictionary files the OCR engine will use. The proper path is usually within your standard installation
and it looks like @\GdPicture.Net 14\Redist\OCR. Of course you can specify your own path as well.
Set null if you are using the GdPicture.Resource NuGet package
So called white list of characters, in other words the restricted recognition characters. It means that the engine only returns the specified characters when processing.
For example, if you want to only recognize numeric characters, set this parameter to "0123456789". If you want to only recognize uppercase letters,
set it to "ABCDEFGHIJKLMNOPQRSTUVWXYZ". Set this parameter to the empty string to recognize all characters.
The dpi resolution the OCR engine will use. It is recommended to use 300 by default.
A value between 200 and 300 should give optimal results on A4-sized documents. Generally values over 300 will cause excessive memory usage.
This method is only allowed for use with non-encrypted documents.
Just to inform you that this method uses the GdPicture OCR engine.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to apply OCR method on your scanned PDF document.
You can find another OCR examples included in the Programming section within the GdPicture.NET Reference Guide as well.
Dim caption As String = "Example: OcrPage"
Dim message As String = ""
Dim page_text As String = ""
'Expecting that the input pdf document includes scanned pages.
Const inputPdfPath As String = "test.pdf"
Const outputPdfPath As String = "test_done.pdf"
Const textFile As String = "test_text_after_ocr.txt"
'The path to language-files installed for OCR - please make sure this path is correct according to your installation.
Const pathToOcr As String = "C:\GdPicture.NET 14\Redist\OCR"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile(inputPdfPath, False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Goto [Error]
End If
If pageCount = 0 Then
MessageBox.Show("This input PDF document contains no pages.", caption)
Goto [Error]
End If
Dim text_file As New System.IO.StreamWriter(textFile)
For i As Integer = 1 To pageCount
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
Dim hasText As Boolean = gdpicturePDF.PageHasText()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If hasText AndAlso (MessageBox.Show("The page nr." + i.ToString() + " already has text. Do you want to skip this page?",
caption, MessageBoxButtons.YesNo, MessageBoxIcon.[Stop]) = System.Windows.Forms.DialogResult.Yes) Then
message = message + "The page nr." + i.ToString() + " has been skipped." + vbCrLf
text_file.WriteLine("The page nr." + i.ToString() + " has been skipped.")
Continue For
End If
If gdpicturePDF.OcrPage("eng", pathToOcr, "", 300) = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString() + " has been successfully processed." + vbCrLf
text_file.WriteLine("The page nr." + i.ToString() + " contains this text:")
page_text = gdpicturePDF.GetPageText()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
text_file.WriteLine(page_text)
End If
Else
message = message + "The OcrPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
text_file.WriteLine("The page nr." + i.ToString() + " has not been processed.")
End If
Else
message = message + "The PageHasText() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
text_file.WriteLine("The page nr." + i.ToString() + " has not been processed.")
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
text_file.WriteLine("The page nr." + i.ToString() + " has not been processed.")
End If
Next
If gdpicturePDF.SaveToFile(outputPdfPath, True) = GdPictureStatus.OK Then
message = message + "The file has been successfully saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, caption)
text_file.Close()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: OcrPage";
string message = "";
string page_text = "";
//Expecting that the input pdf document includes scanned pages.
const string inputPdfPath = "test.pdf";
const string outputPdfPath = "test_done.pdf";
const string textFile = "test_text_after_ocr.txt";
//The path to language-files installed for OCR - please make sure this path is correct according to your installation.
const string pathToOcr = "C:\\GdPicture.NET 14\\Redist\\OCR";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile(inputPdfPath, false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
if (pageCount == 0)
{
MessageBox.Show("This input PDF document contains no pages.", caption);
goto error;
}
System.IO.StreamWriter text_file = new System.IO.StreamWriter(textFile);
for (int i = 1; i <= pageCount; i++)
{
if (gdpicturePDF.SelectPage(i) == GdPictureStatus.OK)
{
bool hasText = gdpicturePDF.PageHasText();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (hasText &&
(MessageBox.Show("The page nr." + i.ToString() + " already has text. Do you want to skip this page?",
caption, MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == System.Windows.Forms.DialogResult.Yes))
{
message = message + "The page nr." + i.ToString() + " has been skipped.\n";
text_file.WriteLine("The page nr." + i.ToString() + " has been skipped.");
continue;
}
if (gdpicturePDF.OcrPage("eng", pathToOcr, "", 300) == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString() + " has been successfully processed.\n";
text_file.WriteLine("The page nr." + i.ToString() + " contains this text:");
page_text = gdpicturePDF.GetPageText();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
text_file.WriteLine(page_text);
}
else
{
message = message + "The OcrPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
text_file.WriteLine("The page nr." + i.ToString() + " has not been processed.");
}
}
else
{
message = message + "The PageHasText() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
text_file.WriteLine("The page nr." + i.ToString() + " has not been processed.");
}
}
else
{
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
text_file.WriteLine("The page nr." + i.ToString() + " has not been processed.");
}
}
if (gdpicturePDF.SaveToFile(outputPdfPath, true) == GdPictureStatus.OK)
message = message + "The file has been successfully saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, caption);
text_file.Close();
}
else
MessageBox.Show("The file can't be loaded.", caption);
error:
gdpicturePDF.Dispose();
Runs the optical character recognition (OCR) on the specified page range of the loaded PDF document using a defined number of threads. You can also set other
parameters according to your preferences. The recognized text is added as invisible text on each processed page. The page orientation is automatically detected for each page as well.
This method involves a rasterization process so any existing visible text within the processed pages will become a part of the images of those pages before the OCR process starts.
The same applies to the invisible text contained within pages. It is not kept because of the rasterization process, which simply means any invisible text is removed
from processed pages before the OCR process starts.
This method is running asynchronously, in other words you have to wait for the OCR process ending before manipulating the document further.
You can benefit from using several OCR related events like , and .
Runs the optical character recognition (OCR) on the specified page range of the loaded PDF document using a defined number of threads. All these overloads are running asynchronously.
The page range to be processed, for example, "1;4;5" to process pages 1, 4 and 5 or "1-5;10" to process pages from 1 to 5 and page 10.
Set this parameter to "*" to process all pages of the current document.
The number of threads to use, asynchronously. Set this parameter to 0 to let the engine to automatically maximize the performance.
The prefix of the dictionary file to use, for example, "spa" for Spanish, "eng" for English, "fra" for French, etc.
The name of such dictionary file has a predefined format [LANGUAGE].traineddata, where [LANGUAGE] defines the used language.
You can find these files within your standard installation usually in the directory @\GdPicture.Net 14\Redist\OCR or you can download
additional language dictionary files here.
You can also combine multiple dictionaries with the "+" separator, for instance English with French is "eng+fra".
The path with all installed dictionary files the OCR engine will use. The proper path is usually within your standard installation
and it looks like @\GdPicture.Net 14\Redist\OCR. Of course you can specify your own path as well.
So called white list of characters, in other words the restricted recognition characters. It means that the engine returns only the specified characters when processing.
For example, if you want to only recognize numeric characters, set this parameter to "0123456789". If you want to only recognize uppercase letters, set it to
"ABCDEFGHIJKLMNOPQRSTUVWXYZ". Set this parameter to the empty string to recognize all characters.
The dpi resolution the OCR engine will use. It is recommended to use 300 by default.
A value between 200 and 300 should give optimal results on A4-sized documents. Generally values over 300 will cause excessive memory usage.
This method is only allowed for use with non-encrypted documents. At the same, be aware that this method is running asynchronously.
Just to inform you that this method uses the GdPicture OCR engine.
This method requires the OCR component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert a TIFF image file (one page or multipage) to a searchable PDF document using multithreading.
Dim gdpicturePDF As New GdPicturePDF()
'Adding the OcrPagesDone event.
AddHandler gdpicturePDF.OcrPagesDone, AddressOf OcrPagesDone
Sub OcrPagesDone(status As GdPictureStatus) Handles gdpicturePDF.OcrPagesDone
'Saving the resulting document when the OCR process is finished.
If gdpicturePDF.SaveToFile("output.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The resulting document is saved.", "OcrPages")
Else
MessageBox.Show("The resulting document can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), "OcrPages")
End If
End Sub
Dim caption As String = "OcrPages"
Using oGdPictureImaging As New GdPictureImaging()
Dim imageId As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("image.tif")
If oGdPictureImaging.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
If oGdPictureImaging.TiffIsMultiPage(imageId) = False Then
gdpicturePDF.AddImageFromGdPictureImage(imageId, False, True)
Else
Dim NumberOfPages As Integer = oGdPictureImaging.TiffGetPageCount(imageId)
For i As Integer = 1 To NumberOfPages
If oGdPictureImaging.TiffSelectPage(imageId, i) = GdPictureStatus.OK Then
gdpicturePDF.AddImageFromGdPictureImage(imageId, False, True)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
Exit For
End If
Else
Exit For
End If
Next
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.OcrPages("*", 0, "eng", "C:\GdPicture.NET 14\Redist\OCR", "", 300) = GdPictureStatus.OK Then
MessageBox.Show("OcrPages - Done!", caption)
Else
MessageBox.Show("The OCR process has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The process of adding images has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
oGdPictureImaging.ReleaseGdPictureImage(imageId)
Else
MessageBox.Show("The image file can't be loaded. Status: " + oGdPictureImaging.GetStat().ToString(), caption)
End If
End Using
'Release resources only if all processes are finished.
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Adding the OcrPagesDone event.
gdpicturePDF.OcrPagesDone += OcrPagesDone;
void OcrPagesDone(GdPictureStatus status)
{
//Saving the resulting document when the OCR process is finished.
if (gdpicturePDF.SaveToFile("output.pdf") == GdPictureStatus.OK)
MessageBox.Show("The resulting document is saved.", "OcrPages");
else
MessageBox.Show("The resulting document can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), "OcrPages");
}
string caption = "OcrPages";
using (GdPictureImaging oGdPictureImaging = new GdPictureImaging())
{
int imageId = oGdPictureImaging.CreateGdPictureImageFromFile("image.tif");
if (oGdPictureImaging.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
if (oGdPictureImaging.TiffIsMultiPage(imageId) == false)
{
gdpicturePDF.AddImageFromGdPictureImage(imageId, false, true);
}
else
{
int NumberOfPages = oGdPictureImaging.TiffGetPageCount(imageId);
for (int i = 1; i <= NumberOfPages; i++)
{
if (oGdPictureImaging.TiffSelectPage(imageId, i) == GdPictureStatus.OK)
{
gdpicturePDF.AddImageFromGdPictureImage(imageId, false, true);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
break;
}
else
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.OcrPages("*", 0, "eng", "C:\\GdPicture.NET 14\\Redist\\OCR", "", 300) == GdPictureStatus.OK)
{
MessageBox.Show("OcrPages - Done!", caption);
}
else
MessageBox.Show("The OCR process has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The process of adding images has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
oGdPictureImaging.ReleaseGdPictureImage(imageId);
}
else
MessageBox.Show("The image file can't be loaded. Status: " + oGdPictureImaging.GetStat().ToString(), caption);
}
//Release resources only if all processes are finished.
gdpicturePDF.Dispose();
Runs the optical character recognition (OCR) on the specified page range of the loaded PDF document using a defined number of threads. You can also
set other parameters according to your preferences. The recognized text is added as invisible text on each processed page. The page orientation is automatically detected for each page as well.
This method involves a rasterization process so any existing visible text within the processed pages will become a part of the images of those pages before the OCR process starts.
The same applies to the invisible text contained within pages. It is not kept because of the rasterization process, which simply means any invisible text is removed
from processed pages before the OCR process starts.
This method is running asynchronously, in other words you have to wait for the OCR process ending before manipulating the document further.
You can benefit from using several OCR related events like , and .
Runs the optical character recognition (OCR) on the specified page range of the loaded PDF document using a defined number of threads. All these overloads are running asynchronously.
The page range to be processed, for example, "1;4;5" to process pages 1, 4 and 5 or "1-5;10" to process pages from 1 to 5 and page 10. Set this parameter to "*"
to process all pages of the current document.
The number of threads to use, asynchronously. Set this parameter to 0 to let the engine to automatically maximize the performance.
The prefix of the dictionary file to use, for example, "spa" for Spanish, "eng" for English, "fra" for French, etc.
The name of such dictionary file has a predefined format [LANGUAGE].traineddata, where [LANGUAGE] defines the used language.
You can find these files within your standard installation usually in the directory @\GdPicture.Net 14\Redist\OCR or you can download
additional language dictionary files here.
You can also combine multiple dictionaries with the "+" separator, for instance English with French is "eng+fra".
The path with all installed dictionary files the OCR engine will use. The proper path is usually within your standard installation
and it looks like @\GdPicture.Net 14\Redist\OCR. Of course you can specify your own path as well.
So called white list of characters, in other words the restricted recognition characters. It means that the engine returns only the specified characters when processing.
For example, if you want to only recognize numeric characters, set this parameter to "0123456789". If you want to only recognize uppercase letters, set it to
"ABCDEFGHIJKLMNOPQRSTUVWXYZ". Set this parameter to the empty string to recognize all characters.
The dpi resolution the OCR engine will use. It is recommended to use 300 by default.
A value between 200 and 300 should give optimal results on A4-sized documents. Generally values over 300 will cause excessive memory usage.
The mode to be used during processing. You can choose between speed and accuracy.
The time interval, in other words timeout, in milliseconds, that specifies the maximum time allowed for the whole OCR process before it is automatically interrupted. Use 0 to specify no timeout.
In multi-threading context, this parameter specifies if the method must terminate when all threads are done.
This method is only allowed for use with non-encrypted documents. At the same, be aware that this method is running asynchronously.
Just to inform you that this method uses the GdPicture OCR engine.
This method requires the OCR component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to process OCR on your scanned document using different OCR modes.
Dim caption As String = "OcrPages"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Expecting that the input pdf document includes scanned pages.
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.OcrPages("*", 0, "eng", "C:\GdPicture.NET 14\Redist\OCR", "", 300, OCRMode.FavorAccuracy, 30000, True) = GdPictureStatus.OK Then
'All threads are done.
If gdpicturePDF.SaveToFile("test_accuracy.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The resulting document can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.OcrPages("*", 0, "eng", "C:\GdPicture.NET 14\Redist\OCR", "", 300, OCRMode.FavorSpeed, 30000, True) = GdPictureStatus.OK Then
'All threads are done.
If gdpicturePDF.SaveToFile("test_speed.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The resulting document can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The OCR process has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "OcrPages";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
//Expecting that the input pdf document includes scanned pages.
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.OcrPages("*", 0, "eng", "C:\\GdPicture.NET 14\\Redist\\OCR", "", 300, OCRMode.FavorAccuracy, 30000, true) == GdPictureStatus.OK)
{
//All threads are done.
if (gdpicturePDF.SaveToFile("test_accuracy.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The resulting document can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The OCR process has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.OcrPages("*", 0, "eng", "C:\\GdPicture.NET 14\\Redist\\OCR", "", 300, OCRMode.FavorSpeed, 30000, true) == GdPictureStatus.OK)
{
//All threads are done.
if (gdpicturePDF.SaveToFile("test_speed.pdf") == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The resulting document can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The OCR process has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Creates a custom sized high quality (HQ) thumbnail of the currently selected page of the loaded PDF document. The current page is converted
to an image resource with the size and the background color you have specified, which is subsequently stored as an object of the type GdPictureImage.
The created image is clearly recognizable by the returned unique image identifier and you can take advantages of the class
and its methods for further manipulation with the thumbnail.
The required width of the newly created thumbnail image, in pixels.
The required height of the newly created thumbnail image, in pixels.
A color object that defines the background color of the thumbnail's margins. The created thumbnail image includes predefined margin on both sides,
that is painted with the specified color.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any instead of checking the returned value.
Likewise just to remind you that you need to release the image after being used using either the method
or the static method.
This method requires the Annotations component to run.
A unique image identifier of the GdPictureImage object representing the newly created thumbnail's image resource.
The returned value is non-zero if the image is successfully created. Please first of all use the method to determine if this method has been successful.
Be aware that you need to release the image after being used, for the suitable method please refer to the Remarks section below.
How to create page thumbnails for all pages of the PDF document.
Dim caption As String = "Example: CreateThumbnailHQ"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim thumb_index As Integer = 0
Dim filename As String = "thumbnail_page0.png"
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
thumb_index = gdpicturePDF.CreateThumbnailHQ(300, 300, Color.Orange)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (thumb_index <> 0) Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
status = gdpictureImaging.SaveAsPNG(thumb_index, filename)
If status = GdPictureStatus.OK Then
message = message + "The thumbnail of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(thumb_index)
'Or you can use this one:
'GdPictureDocumentUtilities.DisposeImage(thumb_index)
Else
message = message + "The CreateThumbnailHQ() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: CreateThumbnailHQ";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
int thumb_index = 0;
string filename = "thumbnail_page0.png";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
thumb_index = gdpicturePDF.CreateThumbnailHQ(300, 300, Color.Orange);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (thumb_index != 0))
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
status = gdpictureImaging.SaveAsPNG(thumb_index, filename);
if (status == GdPictureStatus.OK)
message = message + "The thumbnail of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(thumb_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(thumb_index);
}
else
message = message + "The CreateThumbnailHQ() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Renders the currently selected page of the loaded PDF document to an image resource according to what you have specified.
The current page is converted to an image, which is subsequently stored as an object of the type GdPictureImage.
The produced image is in the 32-bit ARGB pixel format. The created image is clearly recognizable by the returned unique image identifier
and you can take advantages of the class and its methods for further manipulation with this object.
Renders the currently selected page of the loaded PDF document to an image resource and then stores it within an object of the type GdPictureImage.
The dpi resolution to be used for rendering.
A value of 72 will give the same result as Acrobat when the zoom level is 100%. Values over 300 will cause excessive memory usage.
Set this parameter to true, if you also want to render form fields and annotations included within the page, else set it to false.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any instead of checking the returned value.
Likewise just to remind you that you need to release the image after being used using either the method
or the static method.
A unique image identifier of the GdPictureImage object representing the newly created image resource.
The method can be subsequently used to determine if this method has been successful.
Be aware that you need to release the image after being used, for the suitable method please refer to the Remarks section below.
How to render all pages of the PDF document to PNG formatted images.
Dim caption As String = "Example: RenderPageToGdPictureImage"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim image_index As Integer = 0
Dim filename As String = "image_page0.png"
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
status = gdpictureImaging.SaveAsPNG(image_index, filename)
If status = GdPictureStatus.OK Then
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(image_index)
'Or you can use this one:
'GdPictureDocumentUtilities.DisposeImage(image_index)
Else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: RenderPageToGdPictureImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
int image_index = 0;
string filename = "image_page0.png";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
status = gdpictureImaging.SaveAsPNG(image_index, filename);
if (status == GdPictureStatus.OK)
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(image_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(image_index)
}
else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Renders the currently selected page of the loaded PDF document to an image resource according to what you have specified.
You can select the preferred pixel format as well. The current page is converted to an image, which is subsequently stored
as an object of the type GdPictureImage. The created image is clearly recognizable by the returned unique image identifier
and you can take advantages of the class and its methods for further manipulation with this object.
Renders the currently selected page of the loaded PDF document to an image resource and then stores it within an object of the type GdPictureImage.
The dpi resolution to be used for rendering.
A value of 72 will give the same result as Acrobat when the zoom level is 100%. Values over 300 will cause excessive memory usage.
Set this parameter to true, if you also want to render form fields and annotations included within the page,
else set it to false.
A member of the PixelFormat enumeration. Specifies the pixel format of the generated image.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any instead of checking the returned value.
Likewise just to remind you that you need to release the image after being used using either the method
or the static method.
A unique image identifier of the GdPictureImage object representing the newly created image resource.
The method can be subsequently used to determine if this method has been successful.
Be aware that you need to release the image after being used, for the suitable method please refer to the Remarks section below.
How to render all pages of the PDF document to PNG formatted images.
Dim caption As String = "Example: RenderPageToGdPictureImage"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim image_index As Integer = 0
Dim filename As String = "image_page0.png"
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, True, PixelFormat.Format32bppArgb)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
status = gdpictureImaging.SaveAsPNG(image_index, filename)
If status = GdPictureStatus.OK Then
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(image_index)
'Or you can use this one:
'GdPictureDocumentUtilities.DisposeImage(image_index)
Else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: RenderPageToGdPictureImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
int image_index = 0;
string filename = "image_page0.png";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, true, PixelFormat.Format32bppArgb);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
status = gdpictureImaging.SaveAsPNG(image_index, filename);
if (status == GdPictureStatus.OK)
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(image_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(image_index)
}
else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Renders the currently selected page of the loaded PDF document to an image resource according to what you have specified.
This method allows to render the specified page on a transparent canvas. The current page is converted to an image,
which is subsequently stored as an object of the type GdPictureImage. The produced image is in the 32-bit ARGB pixel format.
The created image is clearly recognizable by the returned unique image identifier and you can take advantages of the class and
its methods for further manipulation with this object.
Renders the currently selected page of the loaded PDF document to an image resource and then stores it within an object of the type GdPictureImage.
The dpi resolution to be used for rendering.
A value of 72 will give the same result as Acrobat when the zoom level is 100%. Values over 300 will cause excessive memory usage.
Set this parameter to true, if you also want to render form fields and annotations included within the page,
else set it to false.
Set this parameter to true, if you want to keep the initial page's background transparent.
The default value is false, which means that the white opaque initial background is used.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any instead of checking the returned value.
Likewise just to remind you that you need to release the image after being used using either the method
or the static method.
A unique image identifier of the GdPictureImage object representing the newly created image resource.
The method can be subsequently used to determine if this method has been successful.
Be aware that you need to release the image after being used, for the suitable method please refer to the Remarks section below.
How to render all pages of the PDF document to PNG formatted images.
Dim caption As String = "Example: RenderPageToGdPictureImage"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim image_index As Integer = 0
Dim filename As String = "image_page0.png"
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, True, True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
status = gdpictureImaging.SaveAsPNG(image_index, filename)
If status = GdPictureStatus.OK Then
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(image_index)
'Or you can use this one:
'GdPictureDocumentUtilities.DisposeImage(image_index)
Else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: RenderPageToGdPictureImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
int image_index = 0;
string filename = "image_page0.png";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, true, true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
status = gdpictureImaging.SaveAsPNG(image_index, filename);
if (status == GdPictureStatus.OK)
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(image_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(image_index);
}
else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Renders the currently selected page of the loaded PDF document to an image resource according to what you have specified. The current page is converted to
an image, which is subsequently stored as an object of the type GdPictureImage. The produced image is in the 32-bit ARGB pixel format.
The method's behavior is specific for entirely image-based pages, where the whole page area is covered by a single image, so that the whole image is extracted "as is"
in its original bit depth with the original dpi. Additionally, if a rotation is applied to the current page, the resulting image is extracted with the applied rotation as well.
The created image is clearly recognizable by the returned unique image identifier and you can take advantages of the class and its methods for
further manipulation with this object.
Renders the currently selected page of the loaded PDF document to an image resource and then stores it within an object of the type GdPictureImage.
The method's behavior is specific for pages, which are entirely image-based. In addition, the page retains its rotation, if any is defined.
The dpi resolution to be used for rendering. If the page is entirely image-based, means the whole page is only one image,
the original (for the given image) dpi resolution is used instead.
A value of 72 will give the same result as Acrobat when the zoom level is 100%. Values over 300 will cause excessive memory usage.
Set this parameter to true, if you also want to render form fields and annotations included within the page,
else set it to false.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any instead of checking the returned value.
Likewise just to remind you that you need to release the image after being used using either the method
or the static method.
For entirely image-based pages, please consider using the method or its overloads if you need to change the resulting dpi.
A unique image identifier of the GdPictureImage object representing the newly created image resource.
The method can be subsequently used to determine if this method has been successful.
Be aware that you need to release the image after being used, for the suitable method please refer to the Remarks section below.
How to render all pages of the PDF document to PNG formatted images.
Dim caption As String = "Example: RenderPageToGdPictureImageEx"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim image_index As Integer = 0
Dim filename As String = "image_page0.png"
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
image_index = gdpicturePDF.RenderPageToGdPictureImageEx(72, True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
status = gdpictureImaging.SaveAsPNG(image_index, filename)
If status = GdPictureStatus.OK Then
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(image_index)
'Or you can use this one:
'GdPictureDocumentUtilities.DisposeImage(image_index)
Else
message = message + "The RenderPageToGdPictureImageEx() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: RenderPageToGdPictureImageEx";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
int image_index = 0;
string filename = "image_page0.png";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
image_index = gdpicturePDF.RenderPageToGdPictureImageEx(72, true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
status = gdpictureImaging.SaveAsPNG(image_index, filename);
if (status == GdPictureStatus.OK)
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(image_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(image_index);
}
else
message = message + "The RenderPageToGdPictureImageEx() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Renders the currently selected page of the loaded PDF document to an image resource according to what you have specified. You can select the preferred pixel format as well.
The current page is converted to an image, which is subsequently stored as an object of the type GdPictureImage.
The method's behavior is specific for entirely image-based pages, where the whole page area is covered by a single image, so that the whole image is extracted "as is"
in its original bit depth with the original dpi. Additionally, if a rotation is applied to the current page, the resulting image is extracted with the applied rotation as well.
The created image is clearly recognizable by the returned unique image identifier and you can take advantages of the class
and its methods for further manipulation with this object.
Renders the currently selected page of the loaded PDF document to an image resource and then stores it within an object of the type GdPictureImage.
The method's behavior is specific for pages, which are entirely image-based. In addition, the page retains its rotation, if any is defined.
The dpi resolution to be used for rendering. If the page is entirely image-based, means the whole page is only one image, the original
(for the given image) dpi resolution is used instead.
A value of 72 will give the same result as Acrobat when the zoom level is 100%. Values over 300 will cause excessive memory usage.
Set this parameter to true, if you also want to render form fields and annotations included within the page,
else set it to false.
A member of the PixelFormat enumeration. Specifies the pixel format of the generated image.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any instead of checking the returned value.
Likewise just to remind you that you need to release the image after being used using either the method
or the static method.
For entirely image-based pages, please consider using the method or its overloads if you need to change the resulting dpi.
A unique image identifier of the GdPictureImage object representing the newly created image resource.
The method can be subsequently used to determine if this method has been successful.
Be aware that you need to release the image after being used, for the suitable method please refer to the Remarks section below.
How to render all pages of the PDF document to BMP formatted images.
Dim caption As String = "Example: RenderPageToGdPictureImageEx"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim image_index As Integer = 0
Dim filename As String = "image_page0.bmp"
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
image_index = gdpicturePDF.RenderPageToGdPictureImageEx(72, True, PixelFormat.Format8bppIndexed)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
status = gdpictureImaging.SaveAsBMP(image_index, filename)
If status = GdPictureStatus.OK Then
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsBMP() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(image_index)
'Or you can use this one:
'GdPictureDocumentUtilities.DisposeImage(image_index)
Else
message = message + "The RenderPageToGdPictureImageEx() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: RenderPageToGdPictureImageEx";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
int image_index = 0;
string filename = "image_page0.bmp";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
image_index = gdpicturePDF.RenderPageToGdPictureImageEx(72, true, PixelFormat.Format8bppIndexed);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
status = gdpictureImaging.SaveAsBMP(image_index, filename);
if (status == GdPictureStatus.OK)
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsBMP() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(image_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(image_index);
}
else
message = message + "The RenderPageToGdPictureImageEx() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Creates a custom sized high quality (HQ) thumbnail of the currently selected page of the loaded PDF document. The current page is converted
to an image resource with the size and the background color you have specified, which is subsequently stored as an object of the type GdPictureImage.
The produced image is in the 32-bit ARGB pixel format. The created image is clearly recognizable by the returned unique image identifier
and you can take advantages of the class and its methods for further manipulation with the thumbnail.
Creates a custom sized high quality (HQ) thumbnail as an image resource of the currently selected page of the loaded PDF document
and subsequently stores it within an object of the type GdPictureImage.
The required width of the newly created thumbnail image, in pixels.
The required height of the newly created thumbnail image, in pixels.
A color object that defines the background color of the thumbnail's margins. The created thumbnail image includes predefined margin on both sides painted with
the specified color.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any instead of checking the returned value.
Likewise just to remind you that you to release the image after being used using either the method
or the static method.
A unique image identifier of the GdPictureImage object representing the newly created thumbnail's image resource.
The method can be subsequently used to determine if this method has been successful.
Be aware that you need to release the image after being used, for the suitable method please refer to the Remarks section below.
How to get page thumbnails for all pages of the PDF document.
Dim caption As String = "Example: GetPageThumbnail"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim thumb_index As Integer = 0
Dim filename As String = "thumbnail_page0.png"
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
thumb_index = gdpicturePDF.GetPageThumbnail(200, 200, 255, 165, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
status = gdpictureImaging.SaveAsPNG(thumb_index, filename)
If status = GdPictureStatus.OK Then
message = message + "The thumbnail of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(thumb_index)
'Or you can use this one:
'GdPictureDocumentUtilities.DisposeImage(thumb_index)
Else
message = message + "The GetPageThumbnail() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetPageThumbnail";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
int thumb_index = 0;
string filename = "thumbnail_page0.png";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
thumb_index = gdpicturePDF.GetPageThumbnail(200, 200, 255, 165, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
status = gdpictureImaging.SaveAsPNG(thumb_index, filename);
if (status == GdPictureStatus.OK)
message = message + "The thumbnail of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(thumb_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(thumb_index);
}
else
message = message + "The GetPageThumbnail() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Creates a custom sized high quality (HQ) thumbnail of the currently selected page of the loaded PDF document. The current page is converted
to an image resource with the size and the background color you have specified, which is subsequently stored as an object of the type GdPictureImage.
The produced image is in the 32-bit ARGB pixel format. The created image is clearly recognizable by the returned unique image identifier
and you can take advantages of the class and its methods for further manipulation with the thumbnail.
Creates a custom sized high quality (HQ) thumbnail as an image resource of the currently selected page of the loaded PDF document
and subsequently stores it within an object of the type GdPictureImage.
The required width of the newly created thumbnail image, in pixels.
The required height of the newly created thumbnail image, in pixels.
The amount of red color to be used for the background color. Use the value between 0 and 255.
The created thumbnail image includes predefined margin on both sides painted with the specified color.
The amount of green color to be used for the background color. Use the value between 0 and 255.
The created thumbnail image includes predefined margin on both sides painted with the specified color.
The amount of blue color to be used for the background color. Use the value between 0 and 255.
The created thumbnail image includes predefined margin on both sides painted with the specified color.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any instead of checking the returned value.
Likewise just to remind you that you to release the image after being used using either the method
or the static method.
A unique image identifier of the GdPictureImage object representing the newly created thumbnail's image resource.
The method can be subsequently used to determine if this method has been successful.
Be aware that you need to release the image after being used, for the suitable method please refer to the Remarks section below.
How to get page thumbnails for all pages of the PDF document.
Dim caption As String = "Example: GetPageThumbnail"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim thumb_index As Integer = 0
Dim filename As String = "thumbnail_page0.png"
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
thumb_index = gdpicturePDF.GetPageThumbnail(200, 200, 255, 165, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
status = gdpictureImaging.SaveAsPNG(thumb_index, filename)
If status = GdPictureStatus.OK Then
message = message + "The thumbnail of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(thumb_index)
'Or you can use this one:
'GdPictureDocumentUtilities.DisposeImage(thumb_index)
Else
message = message + "The GetPageThumbnail() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetPageThumbnail";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = "";
int thumb_index = 0;
string filename = "thumbnail_page0.png";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
thumb_index = gdpicturePDF.GetPageThumbnail(200, 200, 255, 165, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
status = gdpictureImaging.SaveAsPNG(thumb_index, filename);
if (status == GdPictureStatus.OK)
message = message + "The thumbnail of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(thumb_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(thumb_index);
}
else
message = message + "The GetPageThumbnail() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Flattens all form fields included in the currently loaded PDF document.
Flattening form fields means removing the form field objects from the document's internal structure and placing their data within the PDF document as
regular items, so the previously defined form fields are no longer fillable or available for user's interaction.
Flattens form fields included in the current PDF document or in the specified page within this document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Flattening all form fields included in the current document.
Using gdpicturePdf As GdPicturePDF = New GdPicturePDF()
gdpicturePDF.LoadFromFile("document.pdf", False)
gdpicturePDF.FlattenFormFields()
MessageBox.Show("The number of form fields available: " + gdpicturePDF.GetFormFieldsCount(), "Flattening form fields", MessageBoxButtons.OK, MessageBoxIcon.Information)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePdf = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("document.pdf", false);
gdpicturePDF.FlattenFormFields();
MessageBox.Show("The number of form fields available: " + gdpicturePDF.GetFormFieldsCount(), "Flattening form fields", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpicturePDF.SaveToFile("output.pdf");
}
Flattens all form fields available within the specified page in the currently loaded PDF document.
Flattening form fields means removing the form field objects from the document's internal structure and placing their data within the PDF document as
regular items, so the previously defined form fields are no longer fillable or available for user's interaction.
Flattens form fields included in the current PDF document or in the specified page within this document.
The page number for flattening form fields included within this page.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Flattening form fields on the first page of the current document.
Using gdpicturePdf As GdPicturePDF = New GdPicturePDF()
gdpicturePDF.LoadFromFile("document.pdf", True)
gdpicturePDF.FlattenFormFields(1)
gdpicturePDF.SaveToFile("document.pdf")
End Using
using (GdPicturePDF gdpicturePdf = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("document.pdf", true);
gdpicturePDF.FlattenFormFields(1);
gdpicturePDF.SaveToFile("document.pdf");
}
Adds a push button form field to the currently selected page of the loaded PDF document according to what you have specified. A push button field is a purely
interactive control that responds immediately to user input without retaining a permanent value.
This method uses the RGB color space for specifying the required color of the displayed push button's caption.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a push button form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The push button's normal caption, displayed when the field is not interacting with the user. It can be an empty string.
The resource name of the font you prefer for displaying the push button's caption. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for the displayed caption. Please note that 1 point = 1/72 inch.
The amount of red color to be used for the resulting color when displaying the push button's caption. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying the push button's caption. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying the push button's caption. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created push button form field. The method can be subsequently used to determine if this method has been successful.
How to add a push button form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddPushButtonFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddPushButtonFormField(1, 2, 5, 2, "PushButton_Name", "GO!", fontResName, 20, 255, 69, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldAction(formID, actionID) = GdPictureStatus.OK) Then
Dim message As String = "The push button has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_pushbutton.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddPushButtonFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddPushButtonFormField(1, 2, 5, 2, "PushButton_Name", "GO!", fontResName, 20, 255, 69, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldAction(formID, actionID) == GdPictureStatus.OK))
{
string message = "The push button has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_pushbutton.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a push button form field to the currently selected page of the loaded PDF document according to what you have specified. A push button field is a purely
interactive control that responds immediately to user input without retaining a permanent value.
This method uses the CMYK color space for specifying the required color of the displayed push button's caption.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a push button form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The push button's normal caption, displayed when the field is not interacting with the user. It can be an empty string.
The resource name of the font you prefer for displaying the push button's caption. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for the displayed caption. Please note that 1 point = 1/72 inch.
The amount of cyan color to be used for the resulting color when displaying text in the form field. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color when displaying the push button's caption. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying the push button's caption. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying the push button's caption. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created push button form field. The method can be subsequently used to determine if this method has been successful.
How to add a push button form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddPushButtonFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddPushButtonFormField(1, 2, 5, 2, "PushButton_Name", "GO!", fontResName, 20, 0, 186, 255, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0, 0) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldAction(formID, actionID) = GdPictureStatus.OK) Then
Dim message As String = "The push button has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_pushbutton.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddPushButtonFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddPushButtonFormField(1, 2, 5, 2, "PushButton_Name", "GO!", fontResName, 20, 0, 186, 255, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0, 0) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldAction(formID, actionID) == GdPictureStatus.OK))
{
string message = "The push button has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile(forms_pushbutton.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a push button form field to the currently selected page of the loaded PDF document according to what you have specified. A push button field is a purely
interactive control that responds immediately to user input without retaining a permanent value.
This method uses the RGB color space for specifying the required color of the displayed push button's caption.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a push button form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The push button's normal caption, displayed when the field is not interacting with the user. It can be an empty string.
The resource name of the font you prefer for displaying the push button's caption. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for the displayed caption. Please note that 1 point = 1/72 inch.
A color object that defines the color to be used for displaying the push button's caption.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created push button form field. The method can be subsequently used to determine if this method has been successful.
How to add a push button form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddPushButtonFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddPushButtonFormField(1, 2, 5, 2, "PushButton_Name", "GO!", fontResName, 20, Color.OrangeRed)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Black) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldAction(formID, actionID) = GdPictureStatus.OK) Then
Dim message As String = "The push button has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_pushbutton.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddPushButtonFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddPushButtonFormField(1, 2, 5, 2, "PushButton_Name", "GO!", fontResName, 20, Color.OrangeRed);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Black) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldAction(formID, actionID) == GdPictureStatus.OK))
{
string message = "The push button has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_pushbutton.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a text form field to the currently selected page of the loaded PDF document according to what you have specified. A text field is a box or space in
which the user can enter text from the keyboard. The text may be restricted to a single line or may be permitted to span multiple lines.
This method uses the RGB color space for specifying the required color of text displayed in the field.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a text form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The text to be displayed in the form field, applying the defined font and color. This value is used both as the current value and as the default value as well.
Use an empty string to create a blank field without setting a default value.
Set this parameter to true to allow the field to contain multiple lines of text, otherwise set it to false to restrict the field to accept only a single line.
The resource name of the font you prefer for displaying text in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for displayed text. Please note that 1 point = 1/72 inch.
The amount of red color to be used for the resulting color when displaying text in the form field. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying text in the form field. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying text in the form field. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created text form field. The method can be subsequently used to determine if this method has been successful.
How to add a text form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddTextFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 2, 8, 1, "TextField_Name", "GdPicture", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDoNotScroll(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMaxLen(formID, 20) = GdPictureStatus.OK) Then
Dim message As String = "The text form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTextFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddTextFormField(1, 2, 8, 1, "TextField_Name", "GdPicture", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDoNotScroll(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMaxLen(formID, 20) == GdPictureStatus.OK))
{
string message = "The text form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a text form field to the currently selected page of the loaded PDF document according to what you have specified. A text field is a box or space in
which the user can enter text from the keyboard. The text may be restricted to a single line or may be permitted to span multiple lines.
This method uses the CMYK color space for specifying the required color of text displayed in the field.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a text form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The text to be displayed in the form field, applying the defined font and color. This value is used both as the current value and as the default value as well.
Use an empty string to create a blank field without setting a default value.
Set this parameter to true to allow the field to contain multiple lines of text, otherwise set it to false to restrict the field to accept only a single line.
The resource name of the font you prefer for displaying text in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for displayed text. Please note that 1 point = 1/72 inch.
The amount of cyan color to be used for the resulting color when displaying text in the form field. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color when displaying text in the form field. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying text in the form field. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying text in the form field. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created text form field. The method can be subsequently used to determine if this method has been successful.
How to add a text form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddTextFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 2, 8, 1, "TextField_Name", "GdPicture", False, fontResName, 20, 90, 213, 213, 90)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 186, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDoNotScroll(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMaxLen(formID, 20) = GdPictureStatus.OK) Then
Dim message As String = "The text form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTextFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddTextFormField(1, 2, 8, 1, "TextField_Name", "GdPicture", false, fontResName, 20, 90, 213, 213, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 186, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDoNotScroll(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMaxLen(formID, 20) == GdPictureStatus.OK))
{
string message = "The text form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a text form field to the currently selected page of the loaded PDF document according to what you have specified. A text field is a box or space in
which the user can enter text from the keyboard. The text may be restricted to a single line or may be permitted to span multiple lines.
This method uses the RGB color space for specifying the required color of text displayed in the field.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a text form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The text to be displayed in the form field, applying the defined font and color. This value is used both as the current value and as the default value as well.
Use an empty string to create a blank field without setting a default value.
Set this parameter to true to allow the field to contain multiple lines of text, otherwise set it to false to restrict the field to accept only a single line.
The resource name of the font you prefer for displaying text in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for displayed text. Please note that 1 point = 1/72 inch.
A color object that defines the color to be used for displaying text in the form field.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created text form field. The method can be subsequently used to determine if this method has been successful.
How to add a text form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddTextFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 2, 8, 1, "TextField_Name", "GdPicture", False, fontResName, 20, Color.Brown)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.White) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.OrangeRed) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDoNotScroll(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMaxLen(formID, 20) = GdPictureStatus.OK) Then
Dim message As String = "The text form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTextFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddTextFormField(1, 2, 8, 1, "TextField_Name", "GdPicture", false, fontResName, 20, Color.Brown);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.White) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.OrangeRed) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDoNotScroll(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMaxLen(formID, 20) == GdPictureStatus.OK))
{
string message = "The text form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a check box form field to the currently selected page of the loaded PDF document according to what you have specified. A check box field toggles
between two states, checked (on) and unchecked (off), when interacted by the user.
This method uses the RGB color space for specifying the required color of the displayed check box field's checkmark.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a check box form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
A member of the PdfCheckBoxStyle enumeration. The style of the checkmark to be used to display a checked state of a check box field.
The state value of a check box field. Set this parameter to true, if you want to check the check box field, otherwise set it to false.
The amount of red color to be used for the resulting color when displaying the check box's checkmark. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying the check box's checkmark. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying the check box's checkmark. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created check box form field. The method can be subsequently used to determine if this method has been successful.
How to add two check boxes on the first page of the newly created PDF document.
Dim caption As String = "Example: AddCheckBoxFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the first checkbox.
Dim formID As Integer = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "CheckBox1", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, True, 0, 0, 255)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 2.5F, 1.5F, "checked")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(6, 1, 1, 1, "CheckBox2", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, False, 0, 0, 255)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 7.5F, 1.5F, "unchecked")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Saving the document.
If gdpicturePDF.SaveToFile("forms_checkbox.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddCheckBoxFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the first checkbox.
int formID = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "CheckBox1", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, true, 0, 0, 255);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 2.5f, 1.5f, "checked");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(6, 1, 1, 1, "CheckBox2", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, false, 0, 0, 255);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 7.5f, 1.5f, "unchecked");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Saving the document.
if (gdpicturePDF.SaveToFile("forms_checkbox.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a check box form field to the currently selected page of the loaded PDF document according to what you have specified. A check box field toggles
between two states, checked (on) and unchecked (off), when interacted by the user.
This method uses the CMYK color space for specifying the required color of the displayed check box field's checkmark.You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a check box form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
A member of the PdfCheckBoxStyle enumeration. The style of the checkmark to be used to display a checked state of a check box field.
The state value of a check box field. Set this parameter to true, if you want to check the check box field, otherwise set it to false.
The amount of cyan color to be used for the resulting color when displaying the check box's checkmark. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color when displaying the check box's checkmark. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying the check box's checkmark. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying the check box's checkmark. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created check box form field. The method can be subsequently used to determine if this method has been successful.
How to add two check boxes on the first page of the newly created PDF document.
Dim caption As String = "Example: AddCheckBoxFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the first checkbox.
Dim formID As Integer = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "CheckBox1", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, True, 255, 255, 0, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 213, 213, 90) = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 2.5F, 1.5F, "checked")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(6, 1, 1, 1, "CheckBox2", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, False, 255, 255, 0, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 213, 213, 90) = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 7.5F, 1.5F, "unchecked")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Saving the document.
If gdpicturePDF.SaveToFile("forms_checkbox.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddCheckBoxFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the first checkbox.
int formID = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "CheckBox1", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, true, 255, 255, 0, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 213, 213, 90) == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 2.5f, 1.5f, "checked");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(6, 1, 1, 1, "CheckBox2", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, false, 255, 255, 0, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 213, 213, 90) == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 7.5f, 1.5f, "unchecked");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Saving the document.
if (gdpicturePDF.SaveToFile("forms_checkbox.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a check box form field to the currently selected page of the loaded PDF document according to what you have specified. A check box field toggles
between two states, checked (on) and unchecked (off), when interacted by the user.
This method uses the RGB color space for specifying the required color of the displayed check box field's checkmark.You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a check box form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
A member of the PdfCheckBoxStyle enumeration. The style of the checkmark to be used to display a checked state of a check box field.
The state value of a check box field. Set this parameter to true, if you want to check the check box field, otherwise set it to false.
A color object that defines the color to be used for displaying the check box's checkmark.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created check box form field. The method can be subsequently used to determine if this method has been successful.
How to add two check boxes on the first page of the newly created PDF document.
Dim caption As String = "Example: AddCheckBoxFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the first checkbox.
Dim formID As Integer = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "CheckBox1", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, True, Color.Blue)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 2.5F, 1.5F, "checked")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(6, 1, 1, 1, "CheckBox2", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, False, Color.Blue)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 7.5F, 1.5F, "unchecked")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Saving the document.
If gdpicturePDF.SaveToFile("forms_checkbox.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddCheckBoxFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the first checkbox.
int formID = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "CheckBox1", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, true, Color.Blue);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 2.5f, 1.5f, "checked");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(6, 1, 1, 1, "CheckBox2", PdfCheckBoxStyle.PdfCheckBoxStyleCheck, false, Color.Blue);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 7.5f, 1.5f, "unchecked");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Saving the document.
if (gdpicturePDF.SaveToFile("forms_checkbox.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a list box form field to the currently selected page of the loaded PDF document according to what you have specified. A list box field is a scrollable
choice field, which contains several text items, more than one of which can be selected. You have to populate the newly created list box field with the
required items according to your preference. All items are always displayed in that order, in which they are added to the list box.
This method uses the RGB color space for specifying the required color of the displayed items in the list box field.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a list box form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The resource name of the font you prefer for displaying text items in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for displayed items. Please note that 1 point = 1/72 inch.
The amount of red color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
Set this parameter to true, if you want to sort the field's items alphabetically, otherwise set it to false. Be aware that this option is
intended for use by form authoring tools, not by PDF viewer applications. In other words, the items are always displayed in that order, in which they are added to the list box.
Set this parameter to true, if you want to allow more than one of the field’s items to be selected simultaneously.
Set it to false, if you do not want to allow more than one item at a time to be selected.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created list box form field. The method can be subsequently used to determine if this method has been successful.
How to add a list box form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddListFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddListFormField(1, 1, 5, 6, "ListBox_Name", fontResName, 20, 0, 0, 139, False, True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentCenter) = GdPictureStatus.OK) Then
If (gdpicturePDF.AddFormFieldItem(formID, "Artichoke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Onion") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Potato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Zucchini") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") = GdPictureStatus.OK) Then
Dim message As String = "The list box form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_listbox.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddListFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddListFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddListFormField(1, 1, 5, 6, "ListBox_Name", fontResName, 20, 0, 0, 139, false, true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentCenter) == GdPictureStatus.OK))
{
if ((gdpicturePDF.AddFormFieldItem(formID, "Artichoke") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Onion") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Potato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Zucchini") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") == GdPictureStatus.OK))
{
string message = "The list box form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_listbox.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddListFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a list box form field to the currently selected page of the loaded PDF document according to what you have specified. A list box field is a scrollable
choice field, which contains several text items, more than one of which can be selected. You have to populate the newly created list box field with the
required items according to your preference. All items are always displayed in that order, in which they are added to the list box.
This method uses the CMYK color space for specifying the required color of the displayed items in the list box field.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a list box form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The resource name of the font you prefer for displaying text items in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for displayed items. Please note that 1 point = 1/72 inch.
The amount of cyan color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
Set this parameter to true, if you want to sort the field's items alphabetically, otherwise set it to false. Be aware that this option is
intended for use by form authoring tools, not by PDF viewer applications. In other words, the items are always displayed in that order, in which they are added to the list box.
Set this parameter to true, if you want to allow more than one of the field’s items to be selected simultaneously.
Set it to false, if you do not want to allow more than one item at a time to be selected.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created list box form field. The method can be subsequently used to determine if this method has been successful.
How to add a list box form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddListFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddListFormField(1, 1, 5, 6, "ListBox_Name", fontResName, 20, 255, 255, 116, 0, False, True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 255, 116, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentCenter) = GdPictureStatus.OK) Then
If (gdpicturePDF.AddFormFieldItem(formID, "Artichoke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Onion") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Potato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Zucchini") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") = GdPictureStatus.OK) Then
Dim message As String = "The list box form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_listbox.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddListFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddListFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddListFormField(1, 1, 5, 6, "ListBox_Name", fontResName, 20, 255, 255, 116, 0, false, true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 255, 116, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentCenter) == GdPictureStatus.OK))
{
if ((gdpicturePDF.AddFormFieldItem(formID, "Artichoke") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Onion") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Potato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Zucchini") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") == GdPictureStatus.OK))
{
string message = "The list box form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_listbox.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddListFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a list box form field to the currently selected page of the loaded PDF document according to what you have specified. A list box field is a scrollable
choice field, which contains several text items, more than one of which can be selected. You have to populate the newly created list box field with the
required items according to your preference. All items are always displayed in that order, in which they are added to the list box.
This method uses the RGB color space for specifying the required color of the displayed items in the list box field.You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a list box form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The resource name of the font you prefer for displaying text items in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for displayed items. Please note that 1 point = 1/72 inch.
A color object that defines the color to be used for displaying items in the list box.
Set this parameter to true, if you want to sort the field's items alphabetically, otherwise set it to false. Be aware that this option is
intended for use by form authoring tools, not by PDF viewer applications. In other words, the items are always displayed in that order, in which they are added to the list box.
Set this parameter to true, if you want to allow more than one of the field’s items to be selected simultaneously.
Set it to false, if you do not want to allow more than one item at a time to be selected.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created list box form field. The method can be subsequently used to determine if this method has been successful.
How to add a list box form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddListFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddListFormField(1, 1, 5, 6, "ListBox_Name", fontResName, 20, Color.DarkBlue, False, True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentCenter) = GdPictureStatus.OK) Then
If (gdpicturePDF.AddFormFieldItem(formID, "Artichoke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Onion") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Potato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Zucchini") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") = GdPictureStatus.OK) Then
Dim message As String = "The list box form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_listbox.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddListFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddListFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddListFormField(1, 1, 5, 6, "ListBox_Name", fontResName, 20, Color.DarkBlue, false, true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentCenter) == GdPictureStatus.OK))
{
if ((gdpicturePDF.AddFormFieldItem(formID, "Artichoke") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Onion") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Potato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Zucchini") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") == GdPictureStatus.OK))
{
string message = "The list box form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_listbox.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddListFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a combo box form field to the currently selected page of the loaded PDF document according to what you have specified. A combo box field is a drop-down
choice field, which contains several text items, only one of which can be selected. You have to populate the newly created combo box field with the required
items according to your preference. All items are always displayed in that order, in which they are added to the combo box.
This method uses the RGB color space for specifying the required color of the displayed items in the combo box field.You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a combo box form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The resource name of the font you prefer for displaying text items in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for displayed items. Please note that 1 point = 1/72 inch.
The amount of red color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
Set this parameter to true, if you want to sort the field's items alphabetically, otherwise set it to false. Be aware that this option is
intended for use by form authoring tools, not by PDF viewer applications. In other words, the items are always displayed in that order, in which they are added to the combo box.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created combo box form field. The method can be subsequently used to determine if this method has been successful.
How to add a combo box form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddComboBoxFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddComboFormField(1, 1, 5, 2, "ComboBox_Name", fontResName, 20, 0, 0, 139, False)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) = GdPictureStatus.OK) Then
If (gdpicturePDF.AddFormFieldItem(formID, "Artichoke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Onion") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") = GdPictureStatus.OK) Then
Dim message As String = "The combo box form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_combobox.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddComboFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddComboBoxFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddComboFormField(1, 1, 5, 2, "ComboBox_Name", fontResName, 20, 0, 0, 139, false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) == GdPictureStatus.OK))
{
if ((gdpicturePDF.AddFormFieldItem(formID, "Artichoke") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Onion") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") == GdPictureStatus.OK))
{
string message = "The combo box form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_combobox.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddComboFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a combo box form field to the currently selected page of the loaded PDF document according to what you have specified. A combo box field is a drop-down
choice field, which contains several text items, only one of which can be selected. You have to populate the newly created combo box field with the required
items according to your preference. All items are always displayed in that order, in which they are added to the combo box.
This method uses the CMYK color space for specifying the required color of the displayed items in the combo box field.You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a combo box form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The resource name of the font you prefer for displaying text items in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for displayed items. Please note that 1 point = 1/72 inch.
The amount of cyan color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying text items in the form field. Use the value between 0 and 255.
Set this parameter to true, if you want to sort the field's items alphabetically, otherwise set it to false. Be aware that this option is
intended for use by form authoring tools, not by PDF viewer applications. In other words, the items are always displayed in that order, in which they are added to the combo box.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created combo box form field. The method can be subsequently used to determine if this method has been successful.
How to add a combo box form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddComboBoxFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddComboFormField(1, 1, 5, 2, "ComboBox_Name", fontResName, 20, 255, 255, 116, 0, False)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 255, 116, 0) = GdPictureStatus.OK) Then
If (gdpicturePDF.AddFormFieldItem(formID, "Artichoke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Onion") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") = GdPictureStatus.OK) Then
Dim message As String = "The combo box form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_combobox.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddComboFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddComboBoxFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddComboFormField(1, 1, 5, 2, "ComboBox_Name", fontResName, 20, 255, 255, 116, 0, false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 255, 116, 0) == GdPictureStatus.OK))
{
if ((gdpicturePDF.AddFormFieldItem(formID, "Artichoke") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Onion") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") == GdPictureStatus.OK))
{
string message = "The combo box form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_combobox.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddComboFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a combo box form field to the currently selected page of the loaded PDF document according to what you have specified. A combo box field is a drop-down
choice field, which contains several text items, only one of which can be selected. You have to populate the newly created combo box field with the required
items according to your preference. All items are always displayed in that order, in which they are added to the combo box.
This method uses the RGB color space for specifying the required color of the displayed items in the combo box field.You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a combo box form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
The resource name of the font you prefer for displaying text items in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for displayed items. Please note that 1 point = 1/72 inch.
A color object that defines the color to be used for displaying items in the combo box.
Set this parameter to true, if you want to sort the field's items alphabetically, otherwise set it to false. Be aware that this option is
intended for use by form authoring tools, not by PDF viewer applications. In other words, the items are always displayed in that order, in which they are added to the combo box.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created combo box form field. The method can be subsequently used to determine if this method has been successful.
How to add a combo box form field on the first page of the newly created PDF document and how to set its several properties.
Dim caption As String = "Example: AddComboBoxFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddComboFormField(1, 1, 5, 2, "ComboBox_Name", fontResName, 20, Color.DarkBlue, False)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) = GdPictureStatus.OK) Then
If (gdpicturePDF.AddFormFieldItem(formID, "Artichoke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Onion") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") = GdPictureStatus.OK) Then
Dim message As String = "The combo box form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_combobox.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddComboFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddComboBoxFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddComboFormField(1, 1, 5, 2, "ComboBox_Name", fontResName, 20, Color.DarkBlue, false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) == GdPictureStatus.OK))
{
if ((gdpicturePDF.AddFormFieldItem(formID, "Artichoke") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Onion") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") == GdPictureStatus.OK))
{
string message = "The combo box form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_combobox.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddComboFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a radio button form field to the currently selected page of the loaded PDF document according to what you have specified. Radio button fields are
typically grouped into a set of related buttons, in which can each be on or off. Only one child radio button in a group may be on at any time and selecting another one
in this group automatically deselects the previous one, if the RadiosInUnison flag is not set. The first added child radio button in a group is selected as on
after the successful creation. If the RadiosInUnison flag is set, no child radio button in a group is selected by default.
All radio buttons added within the same group are handled as one form field object after the successful creation.
You can determine the number of child radio buttons in a group by using the method.
To access the individual child objects, please use their corresponding sequence index according to that order, in which they have been added to the group.
This method uses the RGB color space for specifying the required color of the displayed radio button's checkmark.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a radio button form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the group, which includes the newly added child radio button. All child radio buttons with the same GroupName identify a group of related buttons.
The name of the child radio button in a group. It is recommended to set a unique value for each of the child radio buttons within one group.
A member of the PdfCheckBoxStyle enumeration. The style of the checkmark to be used to display a checked radio button (the on state).
Please note that the first added child radio button in a group is automatically selected as on.
The amount of red color to be used for the resulting color when displaying the radio button's checkmark. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying the radio button's checkmark. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying the radio button's checkmark. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
Just to remind you, that the first added child radio button in a group is automatically selected as on (assuming the RadiosInUnison flag is not set).
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created radio button form field. The method can be subsequently used to determine if this method has been successful.
How to add two groups of radio button form fields on the first page of the newly created PDF document.
Dim caption As String = "Example: AddRadioButtonFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 0) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String() {"RED", "GREEN", "BLUE"}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String() {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddRadioButtonFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 0) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[] { "RED", "GREEN", "BLUE" };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 0, 0, 0);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 0, 0, 0);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a radio button form field to the currently selected page of the loaded PDF document according to what you have specified. Radio button fields are
typically grouped into a set of related buttons, in which can each be on or off. Only one child radio button in a group may be on at any time and selecting another one
in this group automatically deselects the previous one, if the RadiosInUnison flag is not set. The first added child radio button in a group is selected as on
after the successful creation. If the RadiosInUnison flag is set, no child radio button in a group is selected by default.
All radio buttons added within the same group are handled as one form field object after the successful creation.
You can determine the number of child radio buttons in a group by using the method.
To access the individual child objects, please use their corresponding sequence index according to that order, in which they have been added to the group.
This method uses the CMYK color space for specifying the required color of the displayed radio button's checkmark.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a radio button form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the group, which includes the newly added child radio button. All child radio buttons with the same GroupName identify a group of related buttons.
The name of the child radio button in a group. It is recommended to set a unique value for each of the child radio buttons within one group.
A member of the PdfCheckBoxStyle enumeration. The style of the checkmark to be used to display a checked radio button (the on state).
Please note that the first added child radio button in a group is automatically selected as on.
The amount of cyan color to be used for the resulting color when displaying the radio button's checkmark. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color when displaying the radio button's checkmark. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying the radio button's checkmark. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying the radio button's checkmark. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
Just to remind you, that the first added child radio button in a group is automatically selected as on (assuming the RadiosInUnison flag is not set).
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method according to the current coordinate space defined by the method.
The unique identifier of the newly created radio button form field. The method can be subsequently used to determine if this method has been successful.
How to add two groups of radio button form fields on the first page of the newly created PDF document.
Dim caption As String = "Example: AddRadioButtonFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 255, 255, 255) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String() {"RED", "GREEN", "BLUE"}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 255, 255, 255, 255)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 90, 213, 90) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String() {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 255, 255, 255, 255)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 90, 213, 90) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddRadioButtonFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 255, 255, 255) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[] { "RED", "GREEN", "BLUE" };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 255, 255, 255, 255);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 90, 213, 90) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 255, 255, 255, 255);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 90, 213, 90) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a radio button form field to the currently selected page of the loaded PDF document according to what you have specified. Radio button fields are
typically grouped into a set of related buttons, in which can each be on or off. Only one child radio button in a group may be on at any time and selecting another one
in this group automatically deselects the previous one, if the RadiosInUnison flag is not set. The first added child radio button in a group is selected as on
after the successful creation. If the RadiosInUnison flag is set, no child radio button in a group is selected by default.
All radio buttons added within the same group are handled as one form field object after the successful creation.
You can determine the number of child radio buttons in a group by using the method.
To access the individual child objects, please use their corresponding sequence index according to that order, in which they have been added to the group.
This method uses the RGB color space for specifying the required color of the displayed radio button's checkmark.
You can subsequently use other methods for assigning more form field properties, as it is shown in the Example section below.
Adds a radio button form field to the currently selected page of the loaded PDF document according to your preference.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the group, which includes the newly added child radio button. All child radio buttons with the same GroupName identify a group of related buttons.
The name of the child radio button in a group. It is recommended to set a unique value for each of the child radio buttons within one group.
A member of the PdfCheckBoxStyle enumeration. The style of the checkmark to be used to display a checked radio button (the on state).
Please note that the first added child radio button in a group is automatically selected as on.
A color object that defines the color to be used for displaying the radio button's checkmark.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
Just to remind you, that the first added child radio button in a group is automatically selected as on (assuming the RadiosInUnison flag is not set).
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method according to the current coordinate space defined by the method.
The unique identifier of the newly created radio button form field. The method can be subsequently used to determine if this method has been successful.
How to add two groups of radio button form fields on the first page of the newly created PDF document.
Dim caption As String = "Example: AddRadioButtonFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Black) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String() {"RED", "GREEN", "BLUE"}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.Black)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String() {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, Color.Black)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddRadioButtonFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Black) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[] { "RED", "GREEN", "BLUE" };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.Black);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i+1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, Color.Black);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds an empty signature form field, so called signature placeholder, on the current page of loaded PDF document according to what you have specified.
A signature field is intended to be used when digitally signing a document. For further assistance, please see the Digital Signature section of the GdPicturePDF class in the Reference Guide.
You can subsequently use other methods for assigning more form field properties.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the form field's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the form field's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The name of the form field. It can be an empty string, but it is recommended to set a value.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required form field.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique identifier of the newly created empty signature form field. The method can be subsequently used to determine if this method has been successful.
How to add an empty (unsigned) signature form field to the PDF document.
Dim caption As String = "AddSignatureFormField"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(300, 100, 200, 50, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 320, 80, "Apply your signature here.") = GdPictureStatus.OK) Then
Dim signatureID As Integer = gdpicturePDF.AddSignatureFormField(300, 100, 200, 50, "Signature1")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_AddSignatureFormField.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The signature field with the index " + signatureID.ToString() + " has been added successfully and the file has been saved.", caption)
Else
MessageBox.Show("The method SaveToFile() has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The method AddSignatureFormField() has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method or one of the Draw... methods has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The method AddStandardFont() has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The method NewPDF() has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "AddSignatureFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(300, 100, 200, 50, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 320, 80, "Apply your signature here.") == GdPictureStatus.OK))
{
int signatureID = gdpicturePDF.AddSignatureFormField(300, 100, 200, 50, "Signature1");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_AddSignatureFormField.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The signature field with the index " + signatureID.ToString() + " has been added successfully and the file has been saved.", caption);
else
MessageBox.Show("The method SaveToFile() has failed with the status: " + status.ToString(), caption);
}
else
{
MessageBox.Show("The method AddSignatureFormField() has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The NewPage() method or one of the Draw... methods has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The method AddStandardFont() has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The method NewPDF() has failed with the status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Adds a new item to a choice form field, hereabout a combo box or a list box, specified by its unique form field's identifier. At the same, this
item is set to be the current value of the specified form field right after adding. The items are always displayed in that order, in which they are
added to the specified form field, it means they are not sorted in any way. Be aware that this method is only applicable to choice form field objects.
Adds a new item to a choice form field specified by its unique form field's identifier.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , , or .
A text string to be displayed in the form field as the name of the newly added form field's item. It represents the form field's value.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is meaningful for the choice form fields, that means it is enabled to only add items to combo boxes or list boxes.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to populate a newly created combo box form field with required text items.
Dim caption As String = "Example: AddFormFieldItem"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddComboFormField(1, 1, 5, 2, "ComboBox1", fontResName, 20, Color.DarkBlue, False)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) = GdPictureStatus.OK) Then
If (gdpicturePDF.AddFormFieldItem(formID, "Artichoke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Onion") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") = GdPictureStatus.OK) Then
Dim message As String = "The combo box form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("ComboBox_AddItem.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddComboFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddFormFieldItem";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddComboFormField(1, 1, 5, 2, "ComboBox1", fontResName, 20, Color.DarkBlue, false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) == GdPictureStatus.OK))
{
if ((gdpicturePDF.AddFormFieldItem(formID, "Artichoke") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Tomato") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Carrot") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Onion") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Lentils") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldValue(formID, "Artichoke") == GdPictureStatus.OK))
{
string message = "The combo box form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("ComboBox_AddItem.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddComboFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a new item to a choice form field, hereabout a combo box or a list box, specified by its unique form field's identifier. At the same, this
item is set to be the current value of the specified form field roght after adding. The items are always displayed in that order, in which they are added
to the specified form field, it means they are not sorted in any way. Be aware that this method is only applicable to choice form field objects.
Adds a new item to a choice form field specified by its unique form field's identifier.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , , or .
A text string to be displayed in the form field as the name of the newly added form field's item. It represents the form field's value.
An export value of the newly added item, which is used when exporting form field's data from the document.
Please do not confuse an export value of the added item with its name. The export value does not represent the item's value.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is meaningful for the choice form fields, that means it is enabled to only add items to combo boxes or list boxes.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to populate a newly created list box form field with required text items together with their export values.
Dim caption As String = "Example: AddFormFieldItem"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddListFormField(1, 1, 3, 4, "ListBox1", fontResName, 20, Color.DarkBlue, False, True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMultiSelect(formID, True) = GdPictureStatus.OK) Then
If (gdpicturePDF.AddFormFieldItem(formID, "English", "ENG") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "German", "GER") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "French", "FRA") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddFormFieldItem(formID, "Slovak", "SVK") = GdPictureStatus.OK) Then
Dim message As String = "The list box form field has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("ListBox_ExportValue.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddListFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddFormFieldItem";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddListFormField(1, 1, 3, 4, "ListBox1", fontResName, 20, Color.DarkBlue, false, true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMultiSelect(formID, true) == GdPictureStatus.OK))
{
if ((gdpicturePDF.AddFormFieldItem(formID, "English", "ENG") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "German", "GER") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "French", "FRA") == GdPictureStatus.OK) &&
(gdpicturePDF.AddFormFieldItem(formID, "Slovak", "SVK") == GdPictureStatus.OK))
{
string message = "The list box form field has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("ListBox_ExportValue.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field items has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddListFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the number of all items included in the required choice form field, hereabout a combo box or a list box, that is specified by its unique form field's
identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to combo boxes and list boxes.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for choice form fields, that means for combo boxes and list boxes, otherwise it will fail.
The number of items included in the required form field. The method can be subsequently used to determine if this method has been successful.
How to find out the total number of items in the combo box field.
Dim caption As String = "Example: GetFormFieldItemCount"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCombo Then
Dim itemsCount As Integer = gdpicturePDF.GetFormFieldItemCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If itemsCount > 0 Then
If gdpicturePDF.DeleteFormFieldItem(formID, 0) = GdPictureStatus.OK Then
Dim message As String = "The item has been successfully deleted." + vbCrLf
If gdpicturePDF.AddFormFieldItem(formID, "Zucchini") = GdPictureStatus.OK Then
message = message + "The new item has been successfully added." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The AddFormFieldItem() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Exit For
Else
MessageBox.Show("The DeleteFormFieldItem() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The first combo box includes no items.", caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If count = 0 Then MessageBox.Show("This document includes no form fields.", caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldItemCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCombo)
{
int itemsCount = gdpicturePDF.GetFormFieldItemCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (itemsCount > 0)
{
if (gdpicturePDF.DeleteFormFieldItem(formID, 0) == GdPictureStatus.OK)
{
string message = "The item has been successfully deleted.\n";
if (gdpicturePDF.AddFormFieldItem(formID, "Zucchini") == GdPictureStatus.OK)
{
message = message + "The new item has been successfully added.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
else
{
message = "The AddFormFieldItem() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
break;
}
else
{
MessageBox.Show("The DeleteFormFieldItem() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The first combo box includes no items.", caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Returns the text of a required item of a choice form field, that is specified by its unique form field's identifier and it is related to the currently
loaded PDF document. The item is identified by its index, that simply represents its position in the item's list.
The item's text is the string to be displayed as the name of the specified option, it can be different than the item's (export) value.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , , or .
The index of the required item. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for choice form fields, that means for combo boxes or list boxes, otherwise it will fail.
The text of the specified item. The method can be subsequently used to determine if this method has been successful.
How to retrieve all items and their values in all list boxes in the current document.
Dim caption As String = "Example: GetFormFieldItemText"
Dim message As String = ""
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) <> GdPictureStatus.OK Then
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If count = 0 Then
message = "This document includes no form fields."
GoTo [error]
End If
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If type = PdfFormFieldType.PdfFormFieldTypeList Then
Dim title As String = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "listbox: " + title
Dim itemsCount As Integer = gdpicturePDF.GetFormFieldItemCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " items: " + itemsCount + vbCrLf
Dim text As String = "", value As String = ""
For j As Integer = 0 To itemsCount - 1
text = gdpicturePDF.GetFormFieldItemText(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "text: " + text
Else
message = message + "text: " + gdpicturePDF.GetStat().ToString()
End If
value = gdpicturePDF.GetFormFieldItemValue(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " value: " + value
Else
message = message + " value: " + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Next
Else
message = message + vbCrLf + "The GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Else
message = "The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
End If
Next
[error]:
If message.Equals("") Then message = "This document includes no list boxes."
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldItemText";
string message = "";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) != GdPictureStatus.OK)
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if (count == 0)
{
message = "This document includes no form fields.";
goto error;
}
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if (type == PdfFormFieldType.PdfFormFieldTypeList)
{
string title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "listbox: " + title;
int itemsCount = gdpicturePDF.GetFormFieldItemCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + " items: " + itemsCount + "\n";
string text = "", value = "";
for (int j = 0; j < itemsCount; j++)
{
text = gdpicturePDF.GetFormFieldItemText(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + "text: " + text;
else
message = message + "text: " + gdpicturePDF.GetStat().ToString();
value = gdpicturePDF.GetFormFieldItemValue(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " value: " + value;
else
message = message + " value: " + gdpicturePDF.GetStat().ToString();
message += "\n";
}
}
else
{
message = message + "\nThe GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
}
else
{
message = "The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
}
}
error:
if (message.Equals(""))
message = "This document includes no list boxes.";
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Removes a required item from a choice form field, hereabout a combo box or a list box, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. The item to remove is identified by its index, that simply represents its position in the item's list.
Please note that if the specified form field does not contain any items, this method will fail.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , , or .
The index of the required item to remove. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is meaningful for the choice form fields, that means it is only enabled to remove items from combo boxes or list boxes. If
the specified form field does not contain any items, this method will fail as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to delete the first item in the combo box field and add another one.
Dim caption As String = "Example: DeleteFormFieldItem"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCombo Then
Dim itemsCount As Integer = gdpicturePDF.GetFormFieldItemCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If itemsCount > 0 Then
If gdpicturePDF.DeleteFormFieldItem(formID, 0) = GdPictureStatus.OK Then
Dim message As String = "The item has been successfully deleted." + vbCrLf
If gdpicturePDF.AddFormFieldItem(formID, "Zucchini") = GdPictureStatus.OK Then
message = message + "The new item has been successfully added." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The AddFormFieldItem() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Exit For
Else
MessageBox.Show("The DeleteFormFieldItem() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The first combo box includes no items.", caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If count = 0 Then MessageBox.Show("This document includes no form fields.", caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DeleteFormFieldItem";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCombo)
{
int itemsCount = gdpicturePDF.GetFormFieldItemCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (itemsCount > 0)
{
if (gdpicturePDF.DeleteFormFieldItem(formID, 0) == GdPictureStatus.OK)
{
string message = "The item has been successfully deleted.\n";
if (gdpicturePDF.AddFormFieldItem(formID, "Zucchini") == GdPictureStatus.OK)
{
message = message + "The new item has been successfully added.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
else
{
message = "The AddFormFieldItem() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
break;
}
else
{
MessageBox.Show("The DeleteFormFieldItem() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The first combo box includes no items.", caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Returns the normal caption of a required form field, here a button form field, that is specified by its unique form field's identifier and it is
related to the currently loaded PDF document. As stated, this attribute is only specific to button form fields, so this method is explicitly applicable to
button form field objects.
This caption is displayed when the button form field is not interacting with the user.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for button form fields (these are push buttons, check boxes, radio buttons), otherwise it will fail.
The normal caption of the specified form field. The method can be subsequently used to determine if this method has been successful.
How to find out and change the caption of all push buttons in the current document.
Dim caption As String = "Example: GetFormFieldNormalCaption"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0
Dim normalCaption As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypePushButton Then
normalCaption = gdpicturePDF.GetFormFieldNormalCaption(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
normalCaption = "* " + normalCaption + " *"
If gdpicturePDF.SetFormFieldNormalCaption(formID, normalCaption) <> GdPictureStatus.OK Then
message = message + i.ToString() + ": The SetFormFieldNormalCaption() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldNormalCaption() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
End If
If message.Equals("") Then message = "The example has been followed successfully." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldNormalCaption";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0;
string normalCaption = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypePushButton)
{
normalCaption = gdpicturePDF.GetFormFieldNormalCaption(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
normalCaption = "* " + normalCaption + " *";
if (gdpicturePDF.SetFormFieldNormalCaption(formID, normalCaption) != GdPictureStatus.OK)
message = message + i.ToString() + ": The SetFormFieldNormalCaption() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldNormalCaption() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
if (message.Equals("")) message = "The example has been followed successfully.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the normal caption of a required form field, here a button form field, that is specified by its unique form field's identifier and it is
related to the currently loaded PDF document. As stated, this attribute is only specific to button form fields, so this method is explicitly applicable to
button form field objects.
This caption is displayed when the button form field is not interacting with the user.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is only meaningful for button form fields (these are push buttons, check boxes, radio buttons), otherwise it will fail.
The new normal caption of the specified form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to find out and change the caption of all push buttons in the current document.
Dim caption As String = "Example: SetFormFieldNormalCaption"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0
Dim normalCaption As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypePushButton Then
normalCaption = gdpicturePDF.GetFormFieldNormalCaption(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
normalCaption = "* " + normalCaption + " *"
If gdpicturePDF.SetFormFieldNormalCaption(formID, normalCaption) <> GdPictureStatus.OK Then
message = message + i.ToString() + ": The SetFormFieldNormalCaption() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldNormalCaption() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
End If
If message.Equals("") Then message = "The example has been followed successfully." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldNormalCaption";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0;
string normalCaption = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypePushButton)
{
normalCaption = gdpicturePDF.GetFormFieldNormalCaption(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
normalCaption = "* " + normalCaption + " *";
if (gdpicturePDF.SetFormFieldNormalCaption(formID, normalCaption) != GdPictureStatus.OK)
message = message + i.ToString() + ": The SetFormFieldNormalCaption() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldNormalCaption() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
if (message.Equals("")) message = "The example has been followed successfully.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the border color of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The method only returns the correct form field's border color if this attribute is specified in the form field object itself, otherwise the method will fail.
The form field's border color attribute is not assigned automatically when creating the form field, however, you can specify the border color using
the method right after adding the required form field on the page. Otherwise, the form field may display invisible.
Be aware that if the border color differs for each single child radio button in a group of radio buttons within a radio button field, this method will fail.
Please use the method to determine the individual border color for each child radio button in a group instead.
Returns the border color, if any is defined, of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that the form field's border color attribute is not assigned automatically when creating the form field. If this attribute is not specified, this method will fail.
The border color of the specified form field, if defined. The method can be subsequently used to determine if this method has been successful.
How to determine the border color of those form fields, which do have some defined.
Dim caption As String = "Example: GetFormFieldBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0
Dim borderColor As Color = Color.Black
Dim hasColor As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 0 To count - 1
message = message + i.ToString() + ".field: "
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "has borderColor: " + hasColor.ToString()
If hasColor Then
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " borderColor: " + borderColor.ToString()
Else
message = message + " borderColor: " + gdpicturePDF.GetStat().ToString()
End If
Else
If gdpicturePDF.SetFormFieldBorderColor(formID, Color.Fuchsia) = GdPictureStatus.OK Then
message = message + " color set to: " + Color.Fuchsia.ToString()
Else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString()
End If
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
status = GdPictureStatus.OK
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
status = GdPictureStatus.Aborted
Exit For
End If
message += vbCrLf
Next
If status = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, caption)
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
Color borderColor = Color.Black;
bool hasColor = false;
GdPictureStatus status = GdPictureStatus.OK;
for (int i = 0; i < count; i++)
{
message = message + i.ToString() + ".field: ";
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "has borderColor: " + hasColor.ToString();
if (hasColor)
{
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " borderColor: " + borderColor.ToString();
else
message = message + " borderColor: " + gdpicturePDF.GetStat().ToString();
}
else
{
if (gdpicturePDF.SetFormFieldBorderColor(formID, Color.Fuchsia) == GdPictureStatus.OK)
message = message + " color set to: " + Color.Fuchsia.ToString();
else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString();
}
}
else
message = message + gdpicturePDF.GetStat().ToString();
status = GdPictureStatus.OK;
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
status = GdPictureStatus.Aborted;
break;
}
message += "\n";
}
if (status == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the border color of a required form field, here a child radio button in a group. The radio button group is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. Please note that every single child radio button in a group can have its own border color defined. As said, this method is only applicable to radio buttons.
The method only returns the correct form field's border color if this attribute is specified in the form field object itself, otherwise it will fail.
The form field's border color attribute is not assigned automatically when creating the form field, however, you can specify the border color
using the method right after adding the required form field on the page. Otherwise, the form field may display invisible.
Returns the border color, if any is defined, of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that the form field's border color attribute is not assigned automatically when creating the form field. If this attribute is not specified, this method will fail.
The border color of the specified form field, if defined. The method can be subsequently used to determine if this method has been successful.
How to find out the the border color for radio button form fields.
Dim caption As String = "Example: GetFormFieldBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0
Dim hasColor As Boolean = False, hasRB As Boolean = False
Dim borderColor As Color = Color.Black
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID)
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The border color is the same (either undefined or specified) for all child radio buttons in this group.
message = message + " - borderColor: "
If hasColor Then
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + borderColor.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + " undefined"
End If
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The border color is different for the individual child radio buttons in this group.
message = message + " has a different border color for its child radio buttons."
Dim kids As Integer = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To kids - 1
message = message + vbCrLf + " " + j.ToString() + ".child - border color: "
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If hasColor Then
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + borderColor.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "undefined"
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Next
Else
message = message + vbCrLf + " The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + " The FormFieldHasBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
message += vbCrLf
Next
If count = 0 Then
message = "This file doesn't include forms."
ElseIf Not hasRB Then
message = "This file doesn't include radio button form fields."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
bool hasColor = false, hasRB = false;
Color borderColor = Color.Black;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID);
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The border color is the same (either undefined or specified) for all child radio buttons in this group.
message = message + " - border color: ";
if (hasColor)
{
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + borderColor.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else message = message + " undefined";
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The border color is different for the individual child radio buttons in this group.
message = message + " has a different border color for its child radio buttons.";
int kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < kids; j++)
{
message = message + "\n " + j.ToString() + ".child - border color: ";
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (hasColor)
{
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + borderColor.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else message = message + "undefined";
}
else message = message + gdpicturePDF.GetStat().ToString();
}
}
else message = message + "\n The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else message = message + "\n The FormFieldHasBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
message += "\n";
}
if (count == 0) message = "This file doesn't include forms.";
else if (!hasRB) message = "This file doesn't include radio button form fields.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the border color of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
This method uses the RGB color space for specifying the required color.
Please use this method right after adding the required form field on the page, as the form field's border color attribute is not assigned automatically.
Otherwise, the form field may display invisible.
Sets the border color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that the form field's border color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the border color for the newly added push button form field.
Dim caption As String = "Example: SetFormFieldBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 2, "PushButton_GO", "GO!", fontResName, 20, 139, 0, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 65, 105, 225) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldAction(formID, actionID) = GdPictureStatus.OK) Then
Dim message As String = "The push button has been created."
If gdpicturePDF.SaveToFile("forms_pushbutton.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 2, "PushButton_GO", "GO!", fontResName, 20, 139, 0, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 65, 105, 225) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldAction(formID, actionID) == GdPictureStatus.OK))
{
string message = "The push button has been created.";
if (gdpicturePDF.SaveToFile("forms_pushbutton.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the border color of a required form field, here a child radio button in a group. The radio button group is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. Please note that every single child radio button in a group of radio buttons within a radio button field
can have its own border color defined, that you are allowed to set using this method. As said, this method is only applicable to radio buttons.
Please use this method right after adding the required form field on the page, as the form field's border color attribute is not assigned automatically.
Otherwise, the form field may display invisible.This method uses the RGB color space for specifying the required color.
Sets the border color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to remind you, that the form field's border color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the border color for the newly added radio button group. Each child radio button will have its own border color.
Dim caption As String = "Example: SetFormFieldBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 0.8F, "What colour do you prefer for your T-shirt?") = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
Dim colors1 As String() = New String(5) {"white", "yellow", "red", "blue", "green", "black"}
Dim colors2 As Byte()() = New Byte(5)() {New Byte(2) {245, 245, 245}, New Byte(2) {255, 255, 0}, New Byte(2) {255, 0, 0},
New Byte(2) {0, 0, 255}, New Byte(2) {0, 255, 0}, New Byte(2) {0, 0, 0}}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCheck, 255, 255, 255)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 255, 255) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, i, colors2(i)(0), colors2(i)(1), colors2(i)(2)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, colors2(i)(0), colors2(i)(1), colors2(i)(2)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors1(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the SaveToFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 0.8f, "What colour do you prefer for your T-shirt?") == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
string[] colors1 = new string[6] { "white", "yellow", "red", "blue", "green", "black" };
byte[][] colors2 = new byte[6][] { new byte[3] { 245, 245, 245 }, new byte[3] { 255, 255, 0 }, new byte[3] { 255, 0, 0 },
new byte[3] { 0, 0, 255 }, new byte[3] { 0, 255, 0 }, new byte[3] { 0, 0, 0 } };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCheck, 255, 255, 255);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, (byte)255, (byte)255, (byte)255) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, i, colors2[i][0], colors2[i][1], colors2[i][2]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, colors2[i][0], colors2[i][1], colors2[i][2]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors1[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the SaveToFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the border color of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
This method uses the CMYK color space for specifying the required color.
Please use this method right after adding the required form field on the page, as the form field's border color attribute is not assigned automatically.
Otherwise, the form field may display invisible.
Sets the border color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color. Use the value between 0 and 255.
The amount of black color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that the form field's border color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the border color for the newly added push button form field.
Dim caption As String = "Example: SetFormFieldBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 2, "PushButton_GO", "GO!", fontResName, 20, 116, 255, 255, 116)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 190, 150, 30, 30) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldAction(formID, actionID) = GdPictureStatus.OK) Then
Dim message As String = "The push button has been created."
If gdpicturePDF.SaveToFile("forms_pushbutton.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 2, "PushButton_GO", "GO!", fontResName, 20, 116, 255, 255, 116);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 27, 59, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 190, 150, 30, 30) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldAction(formID, actionID) == GdPictureStatus.OK))
{
string message = "The push button has been created.";
if (gdpicturePDF.SaveToFile("forms_pushbutton.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the border color of a required form field, here a child radio button in a group. The radio button group is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. Please note that every single child radio button in a group of radio buttons within a radio button field
can have its own border color defined, that you are allowed to set using this method. As said, this method is only applicable to radio buttons.
Please use this method right after adding the required form field on the page, as the form field's border color attribute is not assigned automatically.
Otherwise, the form field may display invisible.This method uses the CMYK color space for specifying the required color.
Sets the border color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color. Use the value between 0 and 255.
The amount of black color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to remind you, that the form field's border color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the border color for the newly added radio button group. Each child radio button will have its own border color.
Dim caption As String = "Example: SetFormFieldBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 0.8F, "What colour do you prefer for your T-shirt?") = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
Dim colors1 As String() = New String(5) {"white", "yellow", "red", "blue", "green", "black"}
Dim colors2 As Byte()() = New Byte(5)() {New Byte(3) {10, 10, 10, 10}, New Byte(3) {0, 0, 255, 0}, New Byte(3) {0, 255, 255, 0},
New Byte(3) {255, 255, 0, 0}, New Byte(3) {255, 127, 255, 127}, New Byte(3) {255, 255, 255, 255}}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCheck, 0, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 0, 0, 0, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, i, colors2(i)(0), colors2(i)(1), colors2(i)(2), colors2(i)(3)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, colors2(i)(0), colors2(i)(1), colors2(i)(2), colors2(i)(3)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors1(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the SaveToFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 0.8f, "What colour do you prefer for your T-shirt?") == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
string[] colors1 = new string[6] { "white", "yellow", "red", "blue", "green", "black" };
byte[][] colors2 = new byte[6][] { new byte[4] { 10, 10, 10, 10 }, new byte[4] { 0, 0, 255, 0 }, new byte[4] { 0, 255, 255, 0 },
new byte[4] { 255, 255, 0, 0 }, new byte[4] { 255, 127, 255, 127 }, new byte[4] { 255, 255, 255, 255 } };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCheck, 0, 0, 0, 0);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, (byte)0, (byte)0, (byte)0, (byte)0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, i, colors2[i][0], colors2[i][1], colors2[i][2], colors2[i][3]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, colors2[i][0], colors2[i][1], colors2[i][2], colors2[i][3]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors1[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the SaveToFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the border color of a required form field, that is specified by its unique form field's identifier and it it related to the currently loaded PDF document.
This method uses the RGB color space for specifying the required color.
Please use this method right after adding the required form field on the page, as the form field's border color attribute is not assigned automatically.
Otherwise, the form field may display invisible.
Sets the border color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A color object that defines the new border color to be used for displaying a specified form field.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that the form field's border color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the border color for the newly added push button form field.
Dim caption As String = "Example: SetFormFieldBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 2, "PushButton_GO", "GO!", fontResName, 20, Color.DarkRed)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.RoyalBlue) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldAction(formID, actionID) = GdPictureStatus.OK) Then
Dim message As String = "The push button has been created."
If gdpicturePDF.SaveToFile("forms_pushbutton.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddPushButtonFormField(1, 1, 5, 2, "PushButton_GO", "GO!", fontResName, 20, Color.DarkRed);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.RoyalBlue) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldAction(formID, actionID) == GdPictureStatus.OK))
{
string message = "The push button has been created.";
if (gdpicturePDF.SaveToFile("forms_pushbutton.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the border color of a required form field, here a child radio button in a group. The radio button group is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. Please note that every single child radio button in a group of radio buttons within a radio button field
can have its own border color defined, that you are allowed to set using this method. As said, this method is only applicable to radio buttons.
Please use this method right after adding the required form field on the page, as the form field's border color attribute is not assigned automatically.
Otherwise, the form field may display invisible.This method uses the RGB color space for specifying the required color.
Sets the border color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
A color object that defines the new border color to be used for displaying a specified child radio button in a group.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to remind you, that the form field's border color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the border color for the newly added radio button group. Each child radio button will have its own border color.
Dim caption As String = "Example: SetFormFieldBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 0.8F, "What colour do you prefer for your T-shirt?") = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
Dim colors1 As String() = New String(5) {"white", "yellow", "red", "blue", "green", "black"}
Dim colors2 As Color() = New Color(5) {Color.WhiteSmoke, Color.Yellow, Color.Red, Color.Blue, Color.Green, Color.Black}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCheck, Color.White)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.White) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, i, colors2(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, colors2(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors1(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the SaveToFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 0.8f, "What colour do you prefer for your T-shirt?") == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
string[] colors1 = new string[6] { "white", "yellow", "red", "blue", "green", "black" };
Color[] colors2 = new Color[6] { Color.WhiteSmoke, Color.Yellow, Color.Red, Color.Blue, Color.Green, Color.Black};
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCheck, Color.White);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.White) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, i, colors2[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, colors2[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors1[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the SaveToFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the style of the line used to draw the border of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The border's line dimensions need to be set in the current units defined in the PDF document.
You can use the method to determine the currently defined units and you can use the method to reset the units according to your preference.
Sets the style of the line used to draw the border of check boxes and radio buttons.
The required form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The width of the line used to draw the form field's border, expressed in the current units specified by the SetMeasurementUnit method.
A member of the PdfAnnotationBorderStyle enumeration. The style of the line used to draw the form field's border.
If the style of the border's line (the BorderStyle parameter) is dashed, this value defines the width of the dashes in the dash pattern used to draw the
border's line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
If the style of the border's line (the BorderStyle parameter) is dashed, this value defines the width of the gaps in the dash pattern used to draw the border's
line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
Likewise, be aware that both DashOn and DashOff parameters are valid only if the specified value of the BorderStyle parameter is
PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, otherwise they are ignored.
Just to remind you that the values of dimensions need to be set in the current units defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the dashed border for the newly added push button.
Dim caption As String = "Example: SetFormFieldBorderStyle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddPushButtonFormField(1, 1, 6, 2, "PushButton", "GO!", fontResName, 20, 255, 69, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderStyle(formID, 0.2F, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, 0.4F, 0.2F) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldAction(formID, actionID) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBorderStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddPushButtonFormField(1, 1, 6, 2, "PushButton", "GO!", fontResName, 20, 255, 69, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderStyle(formID, 0.2f, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, 0.4f, 0.2f) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldAction(formID, actionID) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The file has been saved successfully.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the style of the line used to draw the border of a required form field, here a child radio button in a group.
The radio button group is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The border's line dimensions need to be set in the current units defined in the PDF document. You can use the method
to determine the currently defined units and you can use the method to reset the units according to your preference.
Please note that every single child radio button in a group of radio buttons within a radio button field can have its own border's line style defined.
Sets the style of the line used to draw the border of check boxes and radio buttons.
The required form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
The width of the line used to draw the form field's border, expressed in the current units specified by the SetMeasurementUnit method.
A member of the PdfAnnotationBorderStyle enumeration. The style of the line used to draw the form field's border.
If the style of the border's line (the BorderStyle parameter) is dashed, this value defines the width of the dashes in the dash pattern used to draw the
border's line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
If the style of the border's line (the BorderStyle parameter) is dashed, this value defines the width of the gaps in the dash pattern used to draw the border's
line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Likewise, be aware that both DashOn and DashOff parameters are valid only if the specified value of the BorderStyle parameter is
PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, otherwise they are ignored.Just to remind you that the values of dimensions need to be set in the current units defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the different border style for checked and unchecked child radio buttons in a group.
Dim caption As String = "Example: SetFormFieldBorderStyle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0, childCount As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim hasRB As Boolean = False, isChecked As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
childCount = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To childCount - 1
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If isChecked Then
status = gdpicturePDF.SetFormFieldBorderStyle(formID, j, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleBeveled, 0, 0)
Else
status = gdpicturePDF.SetFormFieldBorderStyle(formID, j, 1, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleInset, 0, 0)
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldBorderStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
Else
MessageBox.Show("The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If Not hasRB Then
MessageBox.Show("This file doesn't include radio button form fields.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBorderStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0, childCount = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool hasRB = false, isChecked = false;
GdPictureStatus status = GdPictureStatus.OK;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
childCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < childCount; j++)
{
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (isChecked)
status = gdpicturePDF.SetFormFieldBorderStyle(formID, j, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleBeveled, 0, 0);
else
status = gdpicturePDF.SetFormFieldBorderStyle(formID, j, 1, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleInset, 0, 0);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldBorderStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0) MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (!hasRB) MessageBox.Show("This file doesn't include radio button form fields.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the style of the line used to draw the border of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The border's line dimensions are expressed in the current units defined in the PDF document. You can use the method to determine
the currently defined units and you can use the method to reset the units according to your preference.
Be aware that if the border's line style differs for each single child radio button in a group of radio buttons within a radio button field, this method will fail.
Please use the method
to determine the individual border's line style for each child radio button in a group instead.
Returns the style of the line used to draw the border of check boxes and radio buttons.
The required form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
Output parameter. The width of the line used to draw the form field's border, expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. A member of the PdfAnnotationBorderStyle enumeration. The style of the line used to draw the form field's border.
Output parameter. If the style of the border's line (the BorderStyle parameter) is dashed, this value defines the width of the dashes in the dash pattern used
to draw the border's line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. If the style of the border's line (the BorderStyle parameter) is dashed, this value defines the width of the gaps in the dash pattern used to
draw the border's line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
Likewise, be aware that both DashOn and DashOff parameters are valid only if the returned value of the BorderStyle parameter is
PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, otherwise they are ignored.
Just to remind you that the values of dimensions are expressed in the current units defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to determine border's properties for each form field in the current document.
Dim caption As String = "Example: GetFormFieldBorderStyle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim message As String = ""
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim style As PdfAnnotationBorderStyle = PdfAnnotationBorderStyle.PdfAnnotationBorderStyleSolid
Dim width As Single = 0, dOn As Single = 0, dOff As Single = 0
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".field's type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type + vbCrLf + " style: "
status = gdpicturePDF.GetFormFieldBorderStyle(formID, width, style, dOn, dOff)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + style.ToString() + " width=" + width.ToString("N2")
If style = PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed Then
message = message + "; dash(" + dOn.ToString("N2") + "," + dOff.ToString("N2") + ")"
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
If count = 0 Then message = "This file doesn't include forms."
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldBorderStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string message = "";
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
PdfAnnotationBorderStyle style = PdfAnnotationBorderStyle.PdfAnnotationBorderStyleSolid;
float width = 0, dOn = 0, dOff = 0;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".field's type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + type + "\n style: ";
status = gdpicturePDF.GetFormFieldBorderStyle(formID, ref width, ref style, ref dOn, ref dOff);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + style.ToString() + " width=" + width.ToString("N2");
if (style == PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed)
message = message + "; dash(" + dOn.ToString("N2") + "," + dOff.ToString("N2") + ")";
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
if (count == 0) message = "This file doesn't include forms.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the style of the line used to draw the border of a required form field, here a child radio button in a group.
The radio button group is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The border's line dimensions are expressed in the current units defined in the PDF document. You can use the method to determine
the currently defined units and you can use the method to reset the units according to your preference.
Please note that every single child radio button in a group of radio buttons within a radio button field can have its own border's line style defined.
Returns the style of the line used to draw the border of check boxes and radio buttons.
The required form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
Output parameter. The width of the line used to draw the form field's border, expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. A member of the PdfAnnotationBorderStyle enumeration. The style of the line used to draw the form field's border.
Output parameter. If the style of the border's line (the BorderStyle parameter) is dashed, this value defines the width of the dashes in the dash pattern used
to draw the border's line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. If the style of the border's line (the BorderStyle parameter) is dashed, this value defines the width of the gaps in the dash pattern used to
draw the border's line. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Likewise, be aware that both DashOn and DashOff parameters are valid only if the returned value of the BorderStyle parameter is
PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, otherwise they are ignored.Just to remind you that the values of dimensions are expressed in the current units defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to properly determine border's properties for radio button form fields in the current document.
Dim caption As String = "Example: GetFormFieldBorderStyle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim message As String = ""
Dim formID As Integer = 0
Dim hasRB As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim width As Single = 0, dOn As Single = 0, dOff As Single = 0
Dim style As PdfAnnotationBorderStyle = PdfAnnotationBorderStyle.PdfAnnotationBorderStyleSolid
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID)
status = gdpicturePDF.GetFormFieldBorderStyle(formID, width, style, dOn, dOff)
If status = GdPictureStatus.OK Then
'The border style is the same for all child radio buttons in this group.
message = message + " - style: " + style.ToString() + " width: " + width.ToString("N2")
If style = PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed Then
message = message + "; dash(" + dOn.ToString("N2") + "," + dOff.ToString("N2") + ")"
End If
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The border style is different for the individual child radio buttons in this group.
message = message + " has a different border style for its child radio buttons."
Dim kids As Integer = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To kids - 1
message = message + vbCrLf + " " + j.ToString() + ".child - style: "
status = gdpicturePDF.GetFormFieldBorderStyle(formID, j, width, style, dOn, dOff)
If status = GdPictureStatus.OK Then
message = message + style.ToString() + " width: " + width.ToString("N2")
If style = PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed Then
message = message + "; dash(" + dOn.ToString("N2") + "," & dOff.ToString("N2") + ")"
End If
Else
message = message + status.ToString()
End If
Next
Else
message = message + vbCrLf + " The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + " The GetFormFieldBorderStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
message += vbCrLf
Next
If count = 0 Then
message = "This file doesn't include forms."
ElseIf Not hasRB Then
message = "This file doesn't include radio button form fields."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldBorderStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string message = "";
int formID = 0;
bool hasRB = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
float width = 0, dOn = 0, dOff = 0;
PdfAnnotationBorderStyle style = PdfAnnotationBorderStyle.PdfAnnotationBorderStyleSolid;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID);
status = gdpicturePDF.GetFormFieldBorderStyle(formID, ref width, ref style, ref dOn, ref dOff);
if (status == GdPictureStatus.OK)
{
//The border style is the same for all child radio buttons in this group.
message = message + " - style: " + style.ToString() + " width: " + width.ToString("N2");
if (style == PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed)
message = message + "; dash(" + dOn.ToString("N2") + "," + dOff.ToString("N2") + ")";
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The border style is different for the individual child radio buttons in this group.
message = message + " has a different border style for its child radio buttons.";
int kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < kids; j++)
{
message = message + "\n " + j.ToString() + ".child - style: ";
status = gdpicturePDF.GetFormFieldBorderStyle(formID, j, ref width, ref style, ref dOn, ref dOff);
if (status == GdPictureStatus.OK)
{
message = message + style.ToString() + " width: " + width.ToString("N2");
if (style == PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed)
message = message + "; dash(" + dOn.ToString("N2") + "," + dOff.ToString("N2") + ")";
}
else
message = message + status.ToString();
}
}
else message = message + "\n The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else message = message + "\n The GetFormFieldBorderStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
message += "\n";
}
if (count == 0) message = "This file doesn't include forms.";
else if (!hasRB) message = "This file doesn't include radio button form fields.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the background (fill) color of a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. This method uses the RGB color space for specifying the required color.
Please use this method right after adding the required form field on the page, as the form field's background (fill) color
attribute is not assigned automatically. Otherwise, the form field may display invisible.
Sets the background (fill) color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that the form field's background (fill) color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the background color for the newly added text form field.
Dim caption As String = "Example: SetFormFieldBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 2, 19, 15, "TextField_Story", "", False, fontResName, 16, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 173, 216, 230) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMultiLine(formID, True) = GdPictureStatus.OK) Then
Dim message As String = "The text form field has been created."
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(1, 2, 19, 15, "TextField_Story", "", false, fontResName, 16, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 173, 216, 230) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMultiLine(formID, true) == GdPictureStatus.OK))
{
string message = "The text form field has been created.";
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the background (fill) color of a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. Please note that every single child radio button in a group
of radio buttons within a radio button field can have its own background (fill) color defined, that you are allowed to set using this method.
As said, this method is only applicable to radio buttons.
Please use this method right after adding the required form field on the page, as the form field's background (fill) color attribute is not assigned automatically.
Otherwise, the form field may display invisible.This method uses the RGB color space for specifying the required color.
Sets the background (fill) color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to remind you, that the form field's background (fill) color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the background color for the newly added radio button group. Each child radio button will have its own background color.
Dim caption As String = "Example: SetFormFieldBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 0) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String() {"RED", "GREEN", "BLUE"}
Dim backColors1 As Color() = New Color() {Color.Red, Color.Green, Color.Blue}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 255, 255, 255)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1(i).R, backColors1(i).G, backColors1(i).B) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String() {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
Dim backColors2 As Color() = New Color() {Color.Cyan, Color.Magenta, Color.Yellow, Color.Black}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 255, 255, 255)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors2(i).R, backColors2(i).G, backColors2(i).B) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 0) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[] { "RED", "GREEN", "BLUE" };
Color[] backColors1 = new Color[] { Color.Red, Color.Green, Color.Blue };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 255, 255, 255);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1[i].R, backColors1[i].G, backColors1[i].B) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
Color[] backColors2 = new Color[] { Color.Cyan, Color.Magenta, Color.Yellow, Color.Black };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 255, 255, 255);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors2(i).R, backColors2(i).G, backColors2(i).B) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the background (fill) color of a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. This method uses the CMYK color space for specifying the required color.
Please use this method right after adding the required form field on the page, as the form field's background (fill) color attribute
is not assigned automatically. Otherwise, the form field may display invisible.
Sets the background (fill) color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color. Use the value between 0 and 255.
The amount of black color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that the form field's background (fill) color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the background color for the newly added text form field.
Dim caption As String = "Example: SetFormFieldBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 2, 19, 15, "TextField_Story", "", False, fontResName, 16, 90, 213, 213, 90)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 82, 39, 25, 25) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 255, 116, 116) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMultiLine(formID, True) = GdPictureStatus.OK) Then
Dim message As String = "The text form field has been created."
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(1, 2, 19, 15, "TextField_Story", "", false, fontResName, 16, 90, 213, 213, 90);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 82, 39, 25, 25) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 255, 116, 116) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMultiLine(formID, true) == GdPictureStatus.OK))
{
string message = "The text form field has been created.";
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the background (fill) color of a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. Please note that every single child radio button in a group
of radio buttons within a radio button field can have its own background (fill) color defined, that you are allowed to set using this method.
As said, this method is only applicable to radio buttons.
Please use this method right after adding the required form field on the page, as the form field's background (fill) color attribute is not assigned automatically.
Otherwise, the form field may display invisible.This method uses the CMYK color space for specifying the required color.
Sets the background (fill) color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color. Use the value between 0 and 255.
The amount of black color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to remind you, that the form field's background (fill) color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the background color for the newly added radio button group. Each child radio button will have its own background color.
Dim caption As String = "Example: SetFormFieldBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 255, 255, 255) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String() {"RED", "GREEN", "BLUE"}
Dim backColors1 As Byte()() = New Byte(2)() {New Byte(3) {0, 255, 255, 0}, New Byte(3) {255, 128, 255, 0}, New Byte(3) {255, 255, 0, 0}}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 0, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1(i)(0), backColors1(i)(1), backColors1(i)(2), backColors1(i)(3)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 213, 213, 90) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String() {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
Dim backColors2 As Byte()() = New Byte(3)() {New Byte(3) {255, 0, 0, 0}, New Byte(3) {0, 255, 0, 0}, New Byte(3) {0, 0, 255, 0}, New Byte(3) {255, 255, 255, 255}}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 0, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors2(i)(0), backColors2(i)(1), backColors2(i)(2), backColors2(i)(3)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 213, 213, 90) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 255, 255, 255) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[] { "RED", "GREEN", "BLUE" };
byte[][] backColors1 = new byte[3][] { new byte[4] {0, 255, 255, 0}, new byte[4] {255, 128, 255, 0}, new byte[4] {255, 255, 0, 0} };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 0, 0, 0, 0);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1[i][0], backColors1[i][1], backColors1[i][2], backColors1[i][3]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, (byte)90, (byte)213, (byte)213, (byte)90) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
byte[][] backColors2 = new byte[4][] { new byte[4] { 255, 0, 0, 0 }, new byte[4] { 0, 255, 0, 0 }, new byte[4] { 0, 0, 255, 0 }, new byte[4] { 255, 255, 255, 255 } };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 255, 255, 255);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors2[i][0], backColors2[i][1], backColors2[i][2], backColors2[i][3]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, (byte)90, (byte)213, (byte)213, (byte)90) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the background (fill) color of a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. This method uses the RGB color space for specifying the required color.
Please use this method right after adding the required form field on the page, as the form field's background (fill) color attribute
is not assigned automatically. Otherwise, the form field may display invisible.
Sets the background (fill) color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A color object that defines the new background (fill) color to be used for displaying a specified form field.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that the form field's background (fill) color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the background color for the newly added text form field.
Dim caption As String = "Example: SetFormFieldBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 2, 19, 15, "TextField_Story", "", False, fontResName, 16, Color.Brown)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.LightBlue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMultiLine(formID, True) = GdPictureStatus.OK) Then
Dim message As String = "The text form field has been created."
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(1, 2, 19, 15, "TextField_Story", "", false, fontResName, 16, Color.Brown);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.LightBlue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.DarkBlue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMultiLine(formID, true) == GdPictureStatus.OK))
{
string message = "The text form field has been created.";
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the background (fill) color of a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. Please note that every single child radio button in a group
of radio buttons within a radio button field can have its own background (fill) color defined, that you are allowed to set using this method.
As said, this method is only applicable to radio buttons.
Please use this method right after adding the required form field on the page, as the form field's background (fill) color attribute is not assigned automatically.
Otherwise, the form field may display invisible.This method uses the RGB color space for specifying the required color.
Sets the background (fill) color of a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
A color object that defines the new background (fill) color to be used for displaying a specified child radio button in a group.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to remind you, that the form field's background (fill) color attribute is not assigned automatically when creating the form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the background color for the newly added radio button group. Each child radio button will have its own background color.
Dim caption As String = "Example: SetFormFieldBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Black) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String() {"RED", "GREEN", "BLUE"}
Dim backColors1 As Color() = New Color() {Color.Red, Color.Green, Color.Blue}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.White)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String() {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
Dim backColors2 As Color() = New Color() {Color.Cyan, Color.Magenta, Color.Yellow, Color.Black}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, Color.White)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors2(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Black) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[] { "RED", "GREEN", "BLUE" };
Color[] backColors1 = new Color[] { Color.Red, Color.Green, Color.Blue };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.White);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
Color[] backColors2 = new Color[] { Color.Cyan, Color.Magenta, Color.Yellow, Color.Black };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, Color.White);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors2[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the background (fill) color of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The method only returns the correct form field's background (fill) color if this attribute is specified in the form field object itself, otherwise it will fail.
The form field's background (fill) color attribute is not assigned automatically when creating the form field, however, you can specify the background
color using the method right after adding the required form field on the page. Otherwise, the form field may display invisible.
Be aware that if the background (fill) color differs for each single child radio button in a group of radio buttons within a radio button field, this method will fail.
Please use the method to determine the individual background (fill) color for each child radio button in a group instead.
Returns the background (fill) color, if any is defined, of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that the form field's background (fill) color attribute is not assigned automatically when creating the form field.
If this attribute is not specified, this method will fail.
The background (fill) color of the specified form field, if defined. The method can be subsequently used to determine if this method has been successful.
How to determine the background color of those form fields, which do have some defined.
Dim caption As String = "Example: GetFormFieldBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0
Dim bkColor As Color = Color.Black
Dim hasColor As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 0 To count - 1
message = message + i.ToString() + ".field: "
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "has bkColor: " + hasColor.ToString()
If hasColor Then
bkColor = gdpicturePDF.GetFormFieldBackgroundColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " bkColor: " + bkColor.ToString()
Else
message = message + " bkColor: " + gdpicturePDF.GetStat().ToString()
End If
Else
If gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Fuchsia) = GdPictureStatus.OK Then
message = message + " color set to: " + Color.Fuchsia.ToString()
Else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString()
End If
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
status = GdPictureStatus.OK
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
status = GdPictureStatus.Aborted
Exit For
End If
message += vbCrLf
Next
If status = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, caption)
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
Color bkColor = Color.Black;
bool hasColor = false;
GdPictureStatus status = GdPictureStatus.OK;
for (int i = 0; i < count; i++)
{
message = message + i.ToString() + ".field: ";
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "has bkColor: " + hasColor.ToString();
if (hasColor)
{
bkColor = gdpicturePDF.GetFormFieldBackgroundColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " bkColor: " + bkColor.ToString();
else
message = message + " bkColor: " + gdpicturePDF.GetStat().ToString();
}
else
{
if (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Fuchsia) == GdPictureStatus.OK)
message = message + " color set to: " + Color.Fuchsia.ToString();
else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString();
}
}
else
message = message + gdpicturePDF.GetStat().ToString();
status = GdPictureStatus.OK;
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
status = GdPictureStatus.Aborted;
break;
}
message += "\n";
}
if (status == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the background (fill) color of a required form field, here a child radio button in a group. The radio button group is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. Please note that every single child radio button in a group can have its own background (fill) color defined. As said, this method is only applicable to radio buttons.
The method only returns the correct form field's background (fill) color if this attribute is specified in the form field object itself, otherwise it will fail.
The form field's background (fill) color attribute is not assigned automatically when creating the form field, however, you can specify the background
color using the method right after adding the required form field on the page. Otherwise, the form field may display invisible.
Returns the background (fill) color, if any is defined, of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that the form field's background (fill) color attribute is not assigned automatically when creating the form field. If this attribute is not
specified, this method will fail.
The background (fill) color of the specified form field, if defined. The method can be subsequently used to determine if this method has been successful.
How to find out the background color for radio button form fields.
Dim caption As String = "Example: GetFormFieldBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0
Dim hasColor As Boolean = False, hasRB As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim bgColor As Color = Color.Black
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID)
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The background color is the same (either undefined or specified) for all child radio buttons in this group.
message = message + " - bgColor: "
If hasColor Then
bgColor = gdpicturePDF.GetFormFieldBackgroundColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + bgColor.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + " undefined"
End If
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The background color is different for the individual child radio buttons in this group.
message = message + " has a different bgColor for its child radio buttons."
Dim kids As Integer = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To kids - 1
message = message + vbCrLf + " " + j.ToString() + ".child - bgColor: "
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If hasColor Then
bgColor = gdpicturePDF.GetFormFieldBackgroundColor(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + bgColor.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "undefined"
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Next
Else
message = message + vbCrLf + " The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + " The FormFieldHasBackgroundColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
message += vbCrLf
Next
If count = 0 Then
message = "This file doesn't include forms."
ElseIf Not hasRB Then
message = "This file doesn't include radio button form fields."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
bool hasColor = false, hasRB = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
Color bgColor = Color.Black;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID);
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The background color is the same (either undefined or specified) for all child radio buttons in this group.
message = message + " - bgColor: ";
if (hasColor)
{
bgColor = gdpicturePDF.GetFormFieldBackgroundColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + bgColor.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else message = message + " undefined";
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The background color is different for the individual child radio buttons in this group.
message = message + " has a different bgColor for its child radio buttons.";
int kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < kids; j++)
{
message = message + "\n " + j.ToString() + ".child - bgColor: ";
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (hasColor)
{
bgColor = gdpicturePDF.GetFormFieldBackgroundColor(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + bgColor.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else message = message + "undefined";
}
else message = message + gdpicturePDF.GetStat().ToString();
}
}
else message = message + "\n The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else message = message + "\n The FormFieldHasBackgroundColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
message += "\n";
}
if (count == 0) message = "This file doesn't include forms.";
else if (!hasRB) message = "This file doesn't include radio button form fields.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the total number of all form fields in the currently loaded PDF document. Form fields are interactive objects for gathering information from users through the PDF document.
Please use the method to retrieve the unique form field identifier in order to correctly identify the specific form field object.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The total number of form field objects in the current document. The method can be subsequently used to determine if this method has been successful.
How to find out the total number of form fields in the loaded PDF document.
Dim caption As String = "Example: GetFormFieldsCount"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, pagenr As Integer = 0
Dim name As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
'Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
'Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's type.
message = message + " type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's page.
message = message + " page nr."
pagenr = gdpicturePDF.GetFormFieldPage(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + pagenr.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldsCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, pagenr = 0;
string name = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
//Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
//Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's type.
message = message + " type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's page.
message = message + " page nr.";
pagenr = gdpicturePDF.GetFormFieldPage(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + pagenr.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the unique form field identifier of a form field specified by its index related to the currently loaded PDF document. You always have to
apply this identifier when working with the specified form field object.
The 0-based index of the required form field within the current document. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you correctly identify the form field's ID using this method in order to handle the specific form field object.
A unique form field identifier of the specified form field. The method can be subsequently used to determine if this method has been successful.
How to correctly determine the form field identifier to be able to subsequently handle the form field object.
Dim caption As String = "Example: GetFormFieldId"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, pagenr As Integer = 0
Dim name As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
'Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
'Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's type.
message = message + " type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's page.
message = message + " page nr."
pagenr = gdpicturePDF.GetFormFieldPage(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + pagenr.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldId";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, pagenr = 0;
string name = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
//Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
//Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's type.
message = message + " type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's page.
message = message + " page nr.";
pagenr = gdpicturePDF.GetFormFieldPage(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + pagenr.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the justification, in other words the mode of the text alignment used when displaying text in a required form field,
that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you that this property is only related to the form fields, which contains variable text, like text fields or scrollable list boxes.
A member of the TextAlignment enumeration. The method can be subsequently used to determine if this method has been successful.
How to change the centered text alignment to near one for all multiline text form fields in the current document.
Dim caption As String = "Example: GetFormFieldTextAlignment"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then message = "This document does not contain any forms."
Dim formID As Integer = 0
Dim multiline As Boolean = False, save As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim textalign As TextAlignment = TextAlignment.TextAlignmentCenter
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
multiline = gdpicturePDF.GetFormFieldMultiLine(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
textalign = gdpicturePDF.GetFormFieldTextAlignment(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If textalign = TextAlignment.TextAlignmentCenter Then
If gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) = GdPictureStatus.OK Then
save = True
Else
message = message + "The SetFormFieldTextAlignment() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + "The GetFormFieldTextAlignment() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + "The GetFormFieldMultiLine() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
Exit For
End If
Next
If save Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "The document has not been changed, so it has not been saved as well."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldTextAlignment";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
int formID = 0;
bool multiline = false, save = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
TextAlignment textalign = TextAlignment.TextAlignmentCenter;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
multiline = gdpicturePDF.GetFormFieldMultiLine(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
textalign = gdpicturePDF.GetFormFieldTextAlignment(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (textalign == TextAlignment.TextAlignmentCenter)
if (gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) == GdPictureStatus.OK)
save = true;
else
message = message + "The SetFormFieldTextAlignment() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + "The GetFormFieldTextAlignment() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + "The GetFormFieldMultiLine() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
break;
}
}
if (save)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
else
message = message + "The document has not been changed, so it has not been saved as well.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the justification, in other words the mode of the text alignment, used when displaying text in a required form field,
that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A member of the TextAlignment enumeration. A new value of the text alignment mode to be used to display text in a form field.
This method is only allowed for use with non-encrypted documents.
Just to inform you that this property is only related to the form fields, which contains variable text, like text fields or scrollable list boxes.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the text alignment for the newly added text form field.
Dim caption As String = "Example: SetFormFieldTextAlignment"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 2, 19, 15, "TextField_Story", "", False, fontResName, 16, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 173, 216, 230) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentCenter) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMultiLine(formID, True) = GdPictureStatus.OK) Then
Dim message As String = "The text form field has been created."
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldTextAlignment";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(1, 2, 19, 15, "TextField_Story", "", false, fontResName, 16, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 173, 216, 230) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentCenter) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMultiLine(formID, true) == GdPictureStatus.OK))
{
string message = "The text form field has been created.";
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the title (the name) of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that the field name is optional, so it can be an empty string. But it is recommended to set a value.
The title (name) of the specified form field.
How to determine all used form fields in the document, their types and their names.
Dim caption As String = "Example: GetFormFieldTitle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, pagenr As Integer = 0
Dim name As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
'Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
'Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's type.
message = message + " type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's page.
message = message + " page nr."
pagenr = gdpicturePDF.GetFormFieldPage(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + pagenr.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, pagenr = 0;
string name = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
//Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
//Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's type.
message = message + " type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's page.
message = message + " page nr.";
pagenr = gdpicturePDF.GetFormFieldPage(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + pagenr.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the number of the immediate children of a required form field, that is specified by its unique form field's identifier and it is related
to the currently loaded PDF document. For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A unique form field identifier specifying a required parent form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of the immediate children of the specified parent form field.
The method can be subsequently used to determine if this method has been successful.
How to find out the number of kids and their types of all form fields in the current document.
Dim caption As String = "Example: GetFormFieldChildCount"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim message As String = ""
Dim formID As Integer = 0, chCount As Integer = 0, kidsID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".field's type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString() + " number of kids: "
chCount = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + chCount.ToString()
For j As Integer = 0 To chCount - 1
kidsID = gdpicturePDF.GetFormFieldChildID(formID, j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + vbCrLf + " " + (j + 1).ToString() + ".kid's type: "
type = gdpicturePDF.GetFormFieldType(kidsID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + "The GetFormFieldChildID() method has failed with the status: " + status.ToString()
Exit For
End If
Next
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf
If status <> GdPictureStatus.OK Then Exit For
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
If count = 0 Then message = "This file doesn't include forms."
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldChildCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string message = "";
int formID = 0, chCount = 0, kidsID = 0 ;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".field's type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + type.ToString() + " number of kids: ";
chCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + chCount.ToString();
for (int j = 0; j < chCount; j++)
{
kidsID = gdpicturePDF.GetFormFieldChildID(formID, j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "\n " + (j + 1).ToString() + ".kid's type: ";
type = gdpicturePDF.GetFormFieldType(kidsID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
{
message = message + "\nThe GetFormFieldChildID() method has failed with the status: " + status.ToString();
break;
}
}
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n";
if (status != GdPictureStatus.OK)
break;
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
if (count == 0) message = "This file doesn't include forms.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the unique form field identifier of an immediate child, specified by its index related to the required parent form field.
This parent form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A unique form field identifier specifying a required parent form field object. You can obtain this identifier using the method
and all methods intended to add form fields.
The 0-based index of the required form field child of the specified parent form field. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A unique form field identifier of the specified child form field. The method can be subsequently used to determine if this method has been successful.
How to find out the number of kids and their types of all form fields in the current document.
Dim caption As String = "Example: GetFormFieldChildID"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim message As String = ""
Dim formID As Integer = 0, chCount As Integer = 0, kidsID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".field's type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString() + " number of kids: "
chCount = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + chCount.ToString()
For j As Integer = 0 To chCount - 1
kidsID = gdpicturePDF.GetFormFieldChildID(formID, j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + vbCrLf + " " + (j + 1).ToString() + ".kid's type: "
type = gdpicturePDF.GetFormFieldType(kidsID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + "The GetFormFieldChildID() method has failed with the status: " + status.ToString()
Exit For
End If
Next
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf
If status <> GdPictureStatus.OK Then Exit For
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
If count = 0 Then message = "This file doesn't include forms."
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldChildID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string message = "";
int formID = 0, chCount = 0, kidsID = 0 ;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".field's type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + type.ToString() + " number of kids: ";
chCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + chCount.ToString();
for (int j = 0; j < chCount; j++)
{
kidsID = gdpicturePDF.GetFormFieldChildID(formID, j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "\n " + (j + 1).ToString() + ".kid's type: ";
type = gdpicturePDF.GetFormFieldType(kidsID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
{
message = message + "\nThe GetFormFieldChildID() method has failed with the status: " + status.ToString();
break;
}
}
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n";
if (status != GdPictureStatus.OK)
break;
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
if (count == 0) message = "This file doesn't include forms.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the title (the name) of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The new title (name) of the specified form field.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the title (the name) of all form fields in the current document.
Dim caption As String = "Example: SetFormFieldTitle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "", title As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
title = i.ToString() + "_" + title
If gdpicturePDF.SetFormFieldTitle(formID, title) = GdPictureStatus.OK Then
message = message + i.ToString() + ": The title has been changed successfully." + vbCrLf
Else
message = message + i.ToString() + ": The SetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "", title = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
title = i.ToString() + "_" + title;
if (gdpicturePDF.SetFormFieldTitle(formID, title) == GdPictureStatus.OK)
message = message + i.ToString() + ": The title has been changed successfully.\n";
else
message = message + i.ToString() + ": The SetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the maximum length of the text, in characters, allowed to enter into a required form field, here a text field, that is specified by its unique
form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is
explicitly applicable to text form field objects.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods:
, or .
The new value of the maximum length of the field's text, in characters, that is user allowed to enter.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the maximum length of the inserted text for the newly added text form fields.
Dim caption As String = "Example: SetFormFieldMaxLen"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 2, "GER") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 4, "FRA") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(3, 1, 3, 1, "GER-PostalCode", "", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldMaxLen(formID, 5) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldComb(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDefaultValue(formID, "00000") <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
formID = gdpicturePDF.AddTextFormField(3, 3, 3, 1, "FRA-PostalCode", "", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldMaxLen(formID, 4) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldComb(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDefaultValue(formID, "0000") <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldMaxLen";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 2, "GER") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 4, "FRA") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(3, 1, 3, 1, "GER-PostalCode", "", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldMaxLen(formID, 5) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldComb(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDefaultValue(formID, "00000") != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
formID = gdpicturePDF.AddTextFormField(3, 3, 3, 1, "FRA-PostalCode", "", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldMaxLen(formID, 4) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldComb(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDefaultValue(formID, "0000") != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the defined maximum length of the field's text, in characters, of a required form field, here a text field. The text field is specified by its
unique form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is
explicitly applicable to text form field objects.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods:
, or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
The maximum length of the field's text, in characters, of the specified text field. The method can be subsequently used to determine if this method has been successful.
How to utilize the MaxLen attribute to check the input values of the text form fields, which represent the different postal codes.
Dim caption As String = "Example: GetFormFieldMaxLen"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldMaxLen() method.
If gdpicturePDF.LoadFromFile("forms_textfield.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "", value As String = ""
If count = 0 Then message = "This document does not contain any forms."
Dim formID As Integer = 0, maxLen As Integer = 0, j As Integer = 0
Dim comb As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
j += 1
comb = gdpicturePDF.GetFormFieldComb(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
maxLen = gdpicturePDF.GetFormFieldMaxLen(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If comb Then
If (value.Length = maxLen) AndAlso (Not value.Contains(" ")) Then
message = message + "The " + j.ToString() + ".text field holds the CORRECT value = " + value + vbCrLf
Else
message = message + "The " + j.ToString() + ".text field holds the INCORRECT value = " + value + vbCrLf
End If
Else
message = message + "The " + j.ToString() + ".text field has not set the Comb flag. Its value is " + value + "." + vbCrLf
End If
Else
message = message + "The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldMaxLen() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldComb() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldMaxLen";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldMaxLen() method.
if (gdpicturePDF.LoadFromFile("forms_textfield.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "", value = "";
if (count == 0)
message = "This document does not contain any forms.";
int formID = 0, maxLen = 0, j = 0;
bool comb = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
j++;
comb = gdpicturePDF.GetFormFieldComb(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
maxLen = gdpicturePDF.GetFormFieldMaxLen(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (comb)
{
if ((value.Length == maxLen) && (!value.Contains(" ")))
message = message + "The " + j.ToString() + ".text field holds the CORRECT value = " + value + "\n";
else
message = message + "The " + j.ToString() + ".text field holds the INCORRECT value = " + value + "\n";
}
else
{
message = message + "The " + j.ToString() + ".text field has not set the Comb flag. Its value is " + value + ".\n";
}
}
else
{
message = message + "The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldMaxLen() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldComb() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
}
else
{
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the Multiline flag of a required form field, here a text field, that is specified by its unique form field's identifier and it is
related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly applicable to text form field objects.
If this flag is set, then the text field can contain multiple lines of text. It it is not set, the field's text is restricted to a single line.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to enable the Multiline flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize the Multiline flag when creating the text form field.
Dim caption As String = "Example: SetFormFieldMultiLine"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 1, 19, 12, "TextField_Story", "", False, fontResName, 16, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 173, 216, 230) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMultiLine(formID, True) = GdPictureStatus.OK) Then
Dim message As String = "The text form field has been created."
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldMultiLine";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "Write your story here ...") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(1, 2, 19, 15, "TextField_Story", "", false, fontResName, 16, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 173, 216, 230) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 139) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMultiLine(formID, true) == GdPictureStatus.OK))
{
string message = "The text form field has been created.";
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns, if the Multiline flag of a required form field, here a text field, is set. The text field is specified by its unique form field's
identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly
applicable to text form field objects.
If this flag is set, then the text field can contain multiple lines of text. It it is not set, the field's text is restricted to a single line.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
true if the Multiline flag of the specified text field is set, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to determine if the MultiLine flag is set for the text form fields in the current document.
Dim caption As String = "Example: GetFormFieldMultiLine"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then message = "This document does not contain any forms."
Dim formID As Integer = 0, j As Integer = 0
Dim scroll As Boolean = False, spell As Boolean = False, multiline As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
j += 1
message = message + j.ToString() + ".text field:" + vbCrLf
scroll = gdpicturePDF.GetFormFieldDoNotScroll(formID)
message = message + " DoNotScroll = "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + scroll.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
spell = gdpicturePDF.GetFormFieldDoNotSpellCheck(formID)
message = message + " DoNotSpellCheck = "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + spell.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
multiline = gdpicturePDF.GetFormFieldMultiLine(formID)
message = message + " MultiLine = "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + multiline.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldMultiLine";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
int formID = 0, j = 0;
bool scroll = false, spell = false, multiline = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
j++;
message = message + j.ToString() + ".text field:\n";
scroll = gdpicturePDF.GetFormFieldDoNotScroll(formID);
message = message + " DoNotScroll = ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + scroll.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
spell = gdpicturePDF.GetFormFieldDoNotSpellCheck(formID);
message = message + " DoNotSpellCheck = ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + spell.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
multiline = gdpicturePDF.GetFormFieldMultiLine(formID);
message = message + " MultiLine = ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + multiline.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
}
else
{
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Checks or unchecks the required form field, here a check box, in other words toggles the field's checked state to On or Off. The check box is
specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to check boxes.
Checks or unchecks a required form field, here a check box or a radio button, in other words toggles the field's checked state to On or Off.
The form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to check the specified checkbox (select it as On),
otherwise set it to false to uncheck it (select it as Off).
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for check boxes, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the checked state to its opposite value for all check boxes in the current document.
Dim caption As String = "Example: SetFormFieldChecked"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim selected As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCheckBoxButton Then
selected = gdpicturePDF.GetFormFieldChecked(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SetFormFieldChecked(formID, Not selected) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldChecked";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
bool selected = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCheckBoxButton)
{
selected = gdpicturePDF.GetFormFieldChecked(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SetFormFieldChecked(formID, !selected) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Checks a required form field, here a child radio button in a group, in other words toggles the field's checked state to On. The radio button group
is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
As only one child radio button in a group may be checked at a time (assuming the RadiosInUnison flag is not set), the currently selected child radio button
is automatically unchecked, it means its checked state is set to Off. You can completely remove the current selection in a radio button group
using the method.
Checks or unchecks a required form field, here a check box or a radio button, in other words toggles the field's checked state to On or Off.
The form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for radio buttons, otherwise it will fail. Be aware that selecting any one of the child radio buttons
in a group automatically deselects all the others (assuming the RadiosInUnison flag is not set).
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to check the last radio button in a group for all radio buttons in the current document.
Dim caption As String = "Example: SetFormFieldChecked"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms_radiobutton.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, radioButtons As Integer = 0, childCount As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
radioButtons += 1
childCount = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SetFormFieldChecked(formID, childCount - 1) <> GdPictureStatus.OK Then
MessageBox.Show(message + "The SetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show(message + "The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show(message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show(message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + radioButtons.ToString() + " radio buttons have changed their checked value." + vbCrLf
If gdpicturePDF.SaveToFile("forms_radiobutton_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved successfully."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldChecked";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms_radiobutton.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, radioButtons = 0, childCount = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
radioButtons++;
childCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SetFormFieldChecked(formID, childCount - 1) != GdPictureStatus.OK)
{
MessageBox.Show(message + "The SetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show(message + "The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show(message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show(message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + radioButtons.ToString() + " radio buttons have changed their checked value.\n";
if (gdpicturePDF.SaveToFile("forms_radiobutton_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved successfully.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns, if a required form field, here a check box, is checked, in other words, if it's checked state is On. The check box is
specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to check boxes.
Returns, if a required form field, here a check box or a radio button, is checked, in other words, if it's checked state is On.
The form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for check boxes, otherwise it will fail.
true if the specified check box is checked (it's checked state is On), otherwise false.
How to change the checked state to its opposite value for all check boxes in the current document.
Dim caption As String = "Example: GetFormFieldChecked"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim selected As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCheckBoxButton Then
selected = gdpicturePDF.GetFormFieldChecked(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SetFormFieldChecked(formID, Not selected) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldChecked";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
bool selected = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCheckBoxButton)
{
selected = gdpicturePDF.GetFormFieldChecked(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SetFormFieldChecked(formID, !selected) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns, if a required form field, here a child radio button in a group, is checked, in other words, if it's checked state is On. The radio button is
specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
Returns, if a required form field, here a check box or a radio button, is checked, in other words, if it's checked state is On.
The form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for radio buttons, otherwise it will fail.
true if the specified child radio button in a group is checked (it's checked state is On), otherwise false.
How to find out indexes of the checked child radio buttons in a group.
Dim caption As String = "Example: GetFormFieldChecked"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, radioButtons As Integer = 0, childCount As Integer = 0
Dim isChecked As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
radioButtons += 1
message = message + (i + 1).ToString() + ". rb group - index if checked: "
childCount = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To childCount - 1
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If isChecked Then message = message + (j + 1).ToString() + " "
Else
MessageBox.Show(message + "The GetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK message += VbCrLf Else Exit For
Else
MessageBox.Show(message + "The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show(message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show(message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If radioButtons = 0 Then message = message + "This document does not contain radio buttons."
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldChecked";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, radioButtons = 0, childCount = 0;
bool isChecked = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
radioButtons++;
message = message + (i+1).ToString() + ". rb group - index if checked: ";
childCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < childCount; j++)
{
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (isChecked) message = message + (j + 1).ToString() + " ";
}
else
{
MessageBox.Show(message + "The GetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK) message += "\n"; else break;
}
else
{
MessageBox.Show(message + "The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show(message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show(message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (radioButtons == 0) message = message + "This document does not contain radio buttons.";
MessageBox.Show(message, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the ReadOnly flag of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
If this flag is set, then the user may not change the value of the field. Likewise, the field will not interact with the user in any way,
for example, it will not respond to mouse clicks or mouse motion, etc.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
Set this parameter to true, if you want to enable the ReadOnly flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to make a newly added text field non-editable.
Dim caption As String = "Example: SetFormFieldReadOnly"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 0.5F, 1, "Code snippet filename") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 0.5F, 4, "Code snippet") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 1.5F, 10, 1, "Filename", "", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotScroll(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldMultiLine(formID, False) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldReadOnly(formID, False) <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
formID = gdpicturePDF.AddTextFormField(1, 4.5F, 10, 10, "Code snippet", "", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotScroll(formID, False) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldMultiLine(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldReadOnly(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldRichText(formID, True) <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldReadOnly";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 0.5f, 1, "Code snippet filename") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 0.5f, 4, "Code snippet") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(1, 1.5f, 10, 1, "Filename", "", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotScroll(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldMultiLine(formID, false) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldReadOnly(formID, false) != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
formID = gdpicturePDF.AddTextFormField(1, 4.5f, 10, 10, "Code snippet", "", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotScroll(formID, false) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldMultiLine(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldReadOnly(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldRichText(formID, true) != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns, if the ReadOnly flag of a required form field is set. The form field is specified by its unique form field's identifier and it is related to
the currently loaded PDF document.
If this flag is set, then the user may not change the value of the field. Likewise, the field will not interact with the user in any way, for example, it
will not respond to mouse clicks or mouse motion, etc.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the ReadOnly flag of the specified form field is set, otherwise false. The method can be subsequently used to determine if
this method has been successful.
How to determine, which form fields are read-only in the current document.
Dim caption As String = "Example: GetFormFieldReadOnly"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0
Dim title As String = "", messageRO As String = "ReadOnly fields:" + vbCrLf, messageREQ As String = "Required fields:" + vbCrLf
Dim roFlag As Boolean = False, reqFlag As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
roFlag = gdpicturePDF.GetFormFieldReadOnly(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If roFlag Then messageRO = messageRO + title + "; "
Else
message = message + title + ": GetFormFieldReadOnly - " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
reqFlag = gdpicturePDF.GetFormFieldRequired(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If reqFlag Then messageREQ = messageREQ + title + "; "
Else
message = message + title + ": GetFormFieldRequired - " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
message = messageRO + vbCrLf + vbCrLf + messageREQ + vbCrLf + vbCrLf + message + vbCrLf + "Done!"
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldReadOnly";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0;
string title = "", messageRO = "ReadOnly fields:\n", messageREQ = "Required fields:\n";
bool roFlag = false, reqFlag = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
roFlag = gdpicturePDF.GetFormFieldReadOnly(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (roFlag)
messageRO = messageRO + title + "; ";
}
else
message = message + title + ": GetFormFieldReadOnly - " + gdpicturePDF.GetStat().ToString() + "\n";
reqFlag = gdpicturePDF.GetFormFieldRequired(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (reqFlag)
messageREQ = messageREQ + title + "; ";
}
else
message = message + title + ": GetFormFieldRequired - " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
message = messageRO + "\n\n" + messageREQ + "\n\n" + message + "\nDone!";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the current value of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The value's format varies depending on the type of the form field. This method sets the string representation of the field's current value.
Sets the current value of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A string representation of the new current value of the specified form field.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that for list boxes allowing multiple selections you need to use the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set a newly defined value to the required text form field.
Dim caption As String = "Example: SetFormFieldValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldReadOnly() method.
Dim filename As String = "forms_textfield.pdf"
If gdpicturePDF.LoadFromFile(filename, True) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then message = "This document doesn't contain form fields."
Dim formID As Integer = 0, formIDFile As Integer = 0, formIDCode As Integer = 0
Dim name As String = ""
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If name.Equals("Filename") Then formIDFile = formID
If name.Equals("Code snippet") Then formIDCode = formID
Else
message = "The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
If (count <> 0) AndAlso (gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
Dim value As String = gdpicturePDF.GetFormFieldValue(formIDFile)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If Not value.Equals("") Then
Dim reader As StreamReader = New StreamReader(value)
Dim content As String = reader.ReadToEnd()
If gdpicturePDF.SetFormFieldValue(formIDCode, content) = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile(filename) = GdPictureStatus.OK Then
message = "The example has been followed successfully and the file has been saved."
Else
message = "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The SetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
reader.Dispose()
Else
message = "The expected filename with the code snippet is not specified."
End If
Else
message = "The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldReadOnly() method.
string filename = "forms_textfield.pdf";
if (gdpicturePDF.LoadFromFile(filename, true) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0) message = "This document doesn't contain form fields.";
int formID = 0, formIDFile = 0, formIDCode = 0;
string name = "";
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (name.Equals("Filename"))
formIDFile = formID;
if (name.Equals("Code snippet"))
formIDCode = formID;
}
else
{
message = "The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
if ((count != 0) && (gdpicturePDF.GetStat() == GdPictureStatus.OK))
{
string value = gdpicturePDF.GetFormFieldValue(formIDFile);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (!value.Equals(""))
{
StreamReader reader = new StreamReader(value);
string content = reader.ReadToEnd();
if (gdpicturePDF.SetFormFieldValue(formIDCode, content) == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile(filename) == GdPictureStatus.OK)
message = "The example has been followed successfully and the file has been saved.";
else
message = "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
else
message = "The SetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
reader.Dispose();
}
else
message = "The expected filename with the code snippet is not specified.";
}
else
message = "The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the current value of a required form field, here a list box, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. This method is intended to be used for list boxes, which allow multiple selections.
The names of the individual items need to be delimited in the specified Value parameter with the defined Separator parameter.
The items represented by its names, which are included in the Value, are subsequently selected in the required list box as its current value.
Returns the current value of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A string representation of the new current value of the specified form field.
A string separator, that is used to delimit the item names in the Value parameter.
This parameter is meaningful only for list boxes allowing multiple selections.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is only meaningful for list boxes that allow multiple selections,
otherwise, the Separator parameter is not taking into account.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set multiple selections into a list box that supports this feature.
Dim caption As String = "Example: SetFormFieldValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the AddFormFieldItem(Integer, String, String) method.
If gdpicturePDF.LoadFromFile("ListBox_ExportValue.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim value As String = ""
Dim isMulti As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Getting the form field's type.
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeList Then
'Getting the form field's current value.
message = message + " current value: "
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
'Setting the form field's new current value.
isMulti = gdpicturePDF.GetFormFieldMultiSelect(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If isMulti Then
value = "German,French"
If gdpicturePDF.SetFormFieldValue(formID, value, ",") = GdPictureStatus.OK Then
value = gdpicturePDF.GetFormFieldValue(formID, ";")
message = message + " new value: "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + " setvalue: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
value = "French"
If gdpicturePDF.SetFormFieldValue(formID, value) = GdPictureStatus.OK Then
value = gdpicturePDF.GetFormFieldValue(formID)
message = message + " new value: "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + " setvalue: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + " multiselection: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
If gdpicturePDF.SaveToFile("ListBox_NewValue.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the AddFormFieldItem(Int, String, String) method.
if (gdpicturePDF.LoadFromFile("ListBox_ExportValue.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string value = "";
bool isMulti = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Getting the form field's type.
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeList)
{
//Getting the form field's current value.
message = message + " current value: ";
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
//Setting the form field's new current value.
isMulti = gdpicturePDF.GetFormFieldMultiSelect(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (isMulti)
{
value = "German,French";
if (gdpicturePDF.SetFormFieldValue(formID, value, ",") == GdPictureStatus.OK)
{
value = gdpicturePDF.GetFormFieldValue(formID, ";");
message = message + " new value: ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
message = message + " setvalue: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
{
value = "French";
if (gdpicturePDF.SetFormFieldValue(formID, value) == GdPictureStatus.OK)
{
value = gdpicturePDF.GetFormFieldValue(formID);
message = message + " new value: ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
message = message + " setvalue: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + " multiselection: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
{
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
if (gdpicturePDF.SaveToFile("ListBox_NewValue.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the current value of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The value's format varies depending on the type of the form field. This method returns the string representation of the field's current value.
Returns the current value of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that for list boxes allowing multiple selections the currently selected items are delimited in the resulting string with the separator set
to "," by default. You can use the method to set this separator to your preferred value.
A string representation of the current value of the specified form field. The method can be subsequently used to determine if this method has been successful.
How to determine all used form fields in the document, their types, names and values.
Dim caption As String = "Example: GetFormFieldValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim name As String = "", value As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
'Getting the form field's type.
message = message + "type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form fields' title (name).
message = message + " title: "
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's value.
message = message + " value: "
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string name = "", value = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
//Getting the form field's type.
message = message + "type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form fields' title (name).
message = message + " title: ";
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's value.
message = message + " value: ";
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the current value of a required form field, here a list box, that is specified by its unique form field's identifier and it is related to the currently
loaded PDF document. This method is intended to be used for list boxes, which allow multiple selections.
The returned value is the string composed from the names of the currently selected items in the required list box, where individual names are delimited
with the specified parameter Separator.
Returns the current value of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
A string separator, that is used to delimit names of the currently selected items of the list box in the resulting value.
This parameter is meaningful only for list boxes allowing multiple selections.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for list boxes that allow multiple selections, otherwise, the Separator parameter is not taking into account.
A string representation of the current value of the specified form field. The method can be subsequently used to determine if this method has been successful.
How to use your own separator to delimit currently selected items in a list box with multiple selections allowed.
Dim caption As String = "Example: GetFormFieldValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document includes no form fields.", caption)
Else
Dim title As String = "", value As String = "", message As String = ""
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim multi As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeList Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
multi = gdpicturePDF.GetFormFieldMultiSelect(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetFormFieldMultiSelect() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
'If multiple selections are allowed, the default separator is used.
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
message = message + title + ":" + vbCrLf + " value: " + value
If multi Then
'Using your preferred separator.
value = gdpicturePDF.GetFormFieldValue(formID, ";")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
message = message + " value: " + value + vbCrLf
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
End Sub
string caption = "Example: GetFormFieldValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
else
{
string title = "", value = "", message = "";
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool multi = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeList)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
multi = gdpicturePDF.GetFormFieldMultiSelect(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldMultiSelect() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
//If multiple selections are allowed, the default separator is used.
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
message = message + title + ":\n value: " + value;
if (multi)
{
//Using your preferred separator.
value = gdpicturePDF.GetFormFieldValue(formID, ";");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
message = message + " value: " + value + "\n";
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show(message, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Returns the resource name of the font used to display text in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. This attribute is not restricted to any form fields, even if the form field's appearance doesn't display text.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms" .
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default, even if the form field's appearance
doesn't display text. For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
The resource name of the defined font for the specified form field. The method can be subsequently used to determine if this method has been successful.
How to find out font properties of fonts used for all form fields in the current document.
Dim caption As String = "Example: GetFormFieldFontName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim fName As String = "", fFamily As String = ""
Dim fSize As Single = 0
Dim fStyle As GdPicture14.FontStyle = GdPicture14.FontStyle.FontStyleRegular
Dim isStdF As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
message = message + "type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " font: "
fName = gdpicturePDF.GetFormFieldFontName(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fName
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " size: "
fSize = gdpicturePDF.GetFormFieldFontSize(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fSize.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf + " properties: "
status = gdpicturePDF.GetFormFieldFontProperties(formID, fFamily, fStyle, isStdF)
If status = GdPictureStatus.OK Then
message = message + " family: " + fFamily + " style: " + fStyle.ToString() + " isStandard: " + isStdF.ToString()
Else
message = message + status.ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldFontName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string fName = "", fFamily = "";
float fSize = 0;
GdPicture14.FontStyle fStyle = GdPicture14.FontStyle.FontStyleRegular;
bool isStdF = false;
GdPictureStatus status = GdPictureStatus.OK;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
message = message + "type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " font: ";
fName = gdpicturePDF.GetFormFieldFontName(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fName;
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " size: ";
fSize = gdpicturePDF.GetFormFieldFontSize(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fSize.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n properties: ";
status = gdpicturePDF.GetFormFieldFontProperties(formID, ref fFamily, ref fStyle, ref isStdF);
if (status == GdPictureStatus.OK)
message = message + " family: " + fFamily + " style: " +fStyle.ToString() + " isStandard: " + isStdF.ToString();
else
message = message + status.ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the size, in points, of the font used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. This attribute is not restricted to any form fields, even if the form field's appearance doesn't display text.
In other words, this value also defines the size of the checkmark in a required form field.
Be aware that if the checkmark's size differs for each single child radio button in a group of radio buttons within a radio button field, this method will fail.
Please use the method to determine the individual size of the checkmark for each child radio button in a group instead.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Returns the size, in points, of the font used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Likewise, only to remind you, that 1 point = 1/72 inch.
The size of the defined font, in points, for displayed text or the checkmark of a specified form field.
The method can be subsequently used to determine if this method has been successful.
How to find out font properties of fonts used for all form fields in the current document.
Dim caption As String = "Example: GetFormFieldFontSize"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim fName As String = "", fFamily As String = ""
Dim fSize As Single = 0
Dim fStyle As GdPicture14.FontStyle = GdPicture14.FontStyle.FontStyleRegular
Dim isStdF As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
message = message + "type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " font: "
fName = gdpicturePDF.GetFormFieldFontName(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fName
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " size: "
fSize = gdpicturePDF.GetFormFieldFontSize(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fSize.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf + " properties: "
status = gdpicturePDF.GetFormFieldFontProperties(formID, fFamily, fStyle, isStdF)
If status = GdPictureStatus.OK Then
message = message + " family: " + fFamily + " style: " + fStyle.ToString() + " isStandard: " + isStdF.ToString()
Else
message = message + status.ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldFontSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string fName = "", fFamily = "";
float fSize = 0;
GdPicture14.FontStyle fStyle = GdPicture14.FontStyle.FontStyleRegular;
bool isStdF = false;
GdPictureStatus status = GdPictureStatus.OK;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
message = message + "type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " font: ";
fName = gdpicturePDF.GetFormFieldFontName(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fName;
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " size: ";
fSize = gdpicturePDF.GetFormFieldFontSize(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fSize.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n properties: ";
status = gdpicturePDF.GetFormFieldFontProperties(formID, ref fFamily, ref fStyle, ref isStdF);
if (status == GdPictureStatus.OK)
message = message + " family: " + fFamily + " style: " +fStyle.ToString() + " isStandard: " + isStdF.ToString();
else
message = message + status.ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the size, in points, used to display the checkmark in a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The font size attribute is not restricted to any form fields, meaning that this value also defines the size of the checkmark in the radio button field.
Please note that every single child radio button in a group of radio buttons within a radio button field can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Returns the size, in points, of the font used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".Likewise, only to remind you, that 1 point = 1/72 inch.
The size of the displayed checkmark, in points, of the specified child radio button. The method can be subsequently used to determine if this method has been successful.
How to find out the correct font size defined for radio button fields.
Dim caption As String = "Example: GetFormFieldFontSize"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "", ftitle As String = ""
Dim formID As Integer = 0, kids As Integer = 0
Dim hasRB As Boolean = False
Dim fsize As Single = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (i + 1).ToString() + ".form field - GetFormFieldId() finished with the status: "
Exit For
End If
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (i + 1).ToString() + ".form field - GetFormFieldType() finished with the status: "
Exit For
End If
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
ftitle = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (i + 1).ToString() + ".form field - GetFormFieldTitle() finished with the status: "
Exit For
End If
fsize = gdpicturePDF.GetFormFieldFontSize(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The font size is same for all child radio buttons in the given group.
message = message + ftitle + " radio button - font size is " + fsize.ToString() + " - same for all children." + vbCrLf
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The font size is different for individual child radio buttons in the given group.
kids = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The radio button " + ftitle + " - GetFormFieldChildCount() finished with the status: "
Exit For
End If
message = message + ftitle + " radio button - font size is different for child buttons." + vbCrLf
For j As Integer = 0 To kids - 1
fsize = gdpicturePDF.GetFormFieldFontSize(formID, j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (j + 1).ToString() + ".child of " + ftitle + " - GetFormFieldFontSize() finished with the status: "
Exit For
End If
message = message + " " + (j + 1).ToString() + ".child - font size: " + fsize.ToString() + vbCrLf
Next
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
Else
'This is an error in getting the font size.
message = "The radio button " + ftitle + " - GetFormFieldFontSize() finished with the status: " + gdpicturePDF.GetStat()
Exit For
End If
End If
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
message = "This file doesn't include forms."
ElseIf Not hasRB Then
message = "This file doesn't include radio button form fields."
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldFontSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "", ftitle = "";
int formID = 0, kids = 0;
bool hasRB = false;
float fsize = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (i + 1).ToString() + ".form field - GetFormFieldId() finished with the status: ";
break;
}
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (i + 1).ToString() + ".form field - GetFormFieldType() finished with the status: ";
break;
}
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
ftitle = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (i + 1).ToString() + ".form field - GetFormFieldTitle() finished with the status: ";
break;
}
fsize = gdpicturePDF.GetFormFieldFontSize(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The font size is same for all child radio buttons in the given group.
message = message + ftitle + " radio button - font size is " + fsize.ToString() + " - same for all children.\n";
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The font size is different for individual child radio buttons in the given group.
kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The radio button " + ftitle + " - GetFormFieldChildCount() finished with the status: ";
break;
}
message = message + ftitle + " radio button - font size is different for child buttons.\n";
for (int j = 0; j < kids; j++)
{
fsize = gdpicturePDF.GetFormFieldFontSize(formID, j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (j + 1).ToString() + ".child of " + ftitle + " - GetFormFieldFontSize() finished with the status: ";
break;
}
message = message + " " + (j + 1).ToString() + ".child - font size: " + fsize.ToString() + "\n";
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
}
else
{
//This is an error in getting the font size.
message = "The radio button " + ftitle + " - GetFormFieldFontSize() finished with the status: " + gdpicturePDF.GetStat();
break;
}
}
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0) message = "This file doesn't include forms.";
else if (!hasRB) message = "This file doesn't include radio button form fields.";
}
else message = message + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the font properties, namely font family name, font style and a standard font flag, of the font used to display text in a required form field,
that is specified by its unique form field's identifier and it is related to the currently loaded PDF document. The font related attributes are not restricted
to any form fields, even if the form field's appearance doesn't display text. For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
Output parameter. The font family name of the defined font.
Output parameter. A member of the FontStyle enumeration. The font style of the defined font.
Output parameter. true if the defined font is a standard font, otherwise false.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default, even if the form field's appearance
doesn't display text. For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to find out font properties of fonts used for all form fields in the current document.
Dim caption As String = "Example: GetFormFieldFontProperties"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim fName As String = "", fFamily As String = ""
Dim fSize As Single = 0
Dim fStyle As GdPicture14.FontStyle = GdPicture14.FontStyle.FontStyleRegular
Dim isStdF As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
message = message + "type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " font: "
fName = gdpicturePDF.GetFormFieldFontName(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fName
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " size: "
fSize = gdpicturePDF.GetFormFieldFontSize(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fSize.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf + " properties: "
status = gdpicturePDF.GetFormFieldFontProperties(formID, fFamily, fStyle, isStdF)
If status = GdPictureStatus.OK Then
message = message + " family: " + fFamily + " style: " + fStyle.ToString() + " isStandard: " + isStdF.ToString()
Else
message = message + status.ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldFontProperties";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string fName = "", fFamily = "";
float fSize = 0;
GdPicture14.FontStyle fStyle = GdPicture14.FontStyle.FontStyleRegular;
bool isStdF = false;
GdPictureStatus status = GdPictureStatus.OK;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
message = message + "type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " font: ";
fName = gdpicturePDF.GetFormFieldFontName(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fName;
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " size: ";
fSize = gdpicturePDF.GetFormFieldFontSize(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fSize.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n properties: ";
status = gdpicturePDF.GetFormFieldFontProperties(formID, ref fFamily, ref fStyle, ref isStdF);
if (status == GdPictureStatus.OK)
message = message + " family: " + fFamily + " style: " +fStyle.ToString() + " isStandard: " + isStdF.ToString();
else
message = message + status.ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the location on the page of a required form field, that is specified by its unique form field's identifier and it is related to the
currently loaded PDF document. This location is represented by the bounding box of the form field on that page, where the form field is currently located. The
coordinates of the field's bounding box are expressed in the current units used in this document with respect to the currently defined origin.
You can use the method to reset the units and the method to reset the origin's location according to your preference.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
Output parameter. The horizontal (X) coordinate of the closest point to the currently defined origin,
where the form field's bounding box is located, expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The vertical (Y) coordinate of the closest point to the currently defined origin,
where the form field's bounding box is located, expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The horizontal (X) coordinate of the furthest point to the currently defined origin,
where the form field's bounding box is located, expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The vertical (Y) coordinate of the furthest point to the currently defined origin,
where the form field's bounding box is located, expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that form fields can't be moved between pages at that time.
Be aware that the values of the coordinates are expressed in the current units defined by the method according to the current
coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to shift all form fields in the current document by two centimetres down when keeping their size.
Dim caption As String = "Example: GetFormFieldLocation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0
Dim left As Single = 0, top As Single = 0, right As Single = 0, bottom As Single = 0
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.GetFormFieldLocation(formID, left, top, right, bottom) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldLocation(formID, left, top + 2, right, bottom + 2) <> GdPictureStatus.OK) Then
message = message + i.ToString() + ": The GetFormFieldLocation()/SetFormFieldLocation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
End If
If message.Equals("") Then message = "The example has been followed successfully." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldLocation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0;
float left = 0, top = 0, right = 0, bottom = 0;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.GetFormFieldLocation(formID, ref left, ref top, ref right, ref bottom) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldLocation(formID, left, top+2, right, bottom+2) != GdPictureStatus.OK))
message = message + i.ToString() + ": The GetFormFieldLocation()/SetFormFieldLocatio() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
if (message.Equals("")) message = "The example has been followed successfully.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the number of that page, where the required form field is located. The form field is specified by its unique form field's identifier and it is
related to the currently loaded PDF document. The page is strictly given when adding the form field, it is the currently selected page. Already added
form fields can't be moved between pages.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that already added form fields can't be moved between pages.
The page number, where the specified form field is located. The method can be subsequently used to determine if this method has been successful.
How to determine the pages, where all form fields in the current document are located.
Dim caption As String = "Example: GetFormFieldPage"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, pagenr As Integer = 0
Dim name As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
'Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
'Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's type.
message = message + " type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's page.
message = message + " page nr."
pagenr = gdpicturePDF.GetFormFieldPage(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + pagenr.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, pagenr = 0;
string name = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
//Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
//Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's type.
message = message + " type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's page.
message = message + " page nr.";
pagenr = gdpicturePDF.GetFormFieldPage(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + pagenr.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the type of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
PDF Reference (see Section "Interactive Forms") defines these field types: Button Fields - these are push buttons, check boxes and radio buttons,
Text Fields, Choice Fields - these are combo boxes and list boxes, and Signature Fields.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfFormFieldType enumeration. The method can be subsequently used to determine if this method has been successful.
How to determine types of all used form fields in the document.
Dim caption As String = "Example: GetFormFieldType"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, pagenr As Integer = 0
Dim name As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
'Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
'Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's type.
message = message + " type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's page.
message = message + " page nr."
pagenr = gdpicturePDF.GetFormFieldPage(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + pagenr.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldType";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, pagenr = 0;
string name = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
//Getting the form field unique identifier.
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
//Getting the form fields' title (name).
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's type.
message = message + " type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's page.
message = message + " page nr.";
pagenr = gdpicturePDF.GetFormFieldPage(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + pagenr.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Removes a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove all push buttons from the current document.
Dim caption As String = "Example: RemoveFormField"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0, removedCount As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypePushButton Then
If gdpicturePDF.RemoveFormField(formID) = GdPictureStatus.OK Then
removedCount += 1
count -= 1
Else
MessageBox.Show("The RemoveFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_removed.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Number of removed push buttons: " + removedCount.ToString() + vbCrLf + "The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveFormField";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0, removedCount = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypePushButton)
if (gdpicturePDF.RemoveFormField(formID) == GdPictureStatus.OK)
{
removedCount++;
count--;
}
else
{
MessageBox.Show("The RemoveFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_removed.pdf") == GdPictureStatus.OK)
MessageBox.Show("Number of removed push buttons: " + removedCount.ToString() + "\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Removes all form fields included in the currently loaded PDF document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove all form fields included in the current document.
Dim caption As String = "Example: RemoveFormFields"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.RemoveFormFields() = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_removed.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Number of form fields: " + count.ToString() + vbCrLf + "The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The RemoveFormFields() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveFormFields";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.RemoveFormFields() == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_removed.pdf") == GdPictureStatus.OK)
MessageBox.Show("Number of form fields: " + count.ToString() + "\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The RemoveFormFields() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Returns, if the border color attribute is defined for a required form field, that is specified by its unique form field's identifier and it is related
to the currently loaded PDF document.
The form field's border color attribute is not assigned automatically when creating the form field. However, you can specify the border color using
the method right after adding the required form field on the page. Otherwise, the form field may display invisible.
Be aware that if the border color differs for each single child radio button in a group of radio buttons within a radio button field, this method will fail.
Please use the method instead to find out, if the border color attribute is defined for each child radio button in a group.
Returns, if the border color attribute is defined for a required form field, that is specified by its unique form field's identifier and it is
related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that the form field's border color attribute is not assigned automatically when creating the form field.
true if the border color attribute is defined for the specified form field object, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to set the border color to only those form fields, which don't have any defined.
Dim caption As String = "Example: FormFieldHasBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0
Dim borderColor As Color = Color.Black
Dim hasColor As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 0 To count - 1
message = message + i.ToString() + ".field: "
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "has borderColor: " + hasColor.ToString()
If hasColor Then
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " borderColor: " + borderColor.ToString()
Else
message = message + " borderColor: " + gdpicturePDF.GetStat().ToString()
End If
Else
If gdpicturePDF.SetFormFieldBorderColor(formID, Color.Fuchsia) = GdPictureStatus.OK Then
message = message + " color set to: " + Color.Fuchsia.ToString()
Else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString()
End If
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
status = GdPictureStatus.OK
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
status = GdPictureStatus.Aborted
Exit For
End If
message += vbCrLf
Next
If status = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, caption)
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FormFieldHasBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
Color borderColor = Color.Black;
bool hasColor = false;
GdPictureStatus status = GdPictureStatus.OK;
for (int i = 0; i < count; i++)
{
message = message + i.ToString() + ".field: ";
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "has borderColor: " + hasColor.ToString();
if (hasColor)
{
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " borderColor: " + borderColor.ToString();
else
message = message + " borderColor: " + gdpicturePDF.GetStat().ToString();
}
else
{
if (gdpicturePDF.SetFormFieldBorderColor(formID, Color.Fuchsia) == GdPictureStatus.OK)
message = message + " color set to: " + Color.Fuchsia.ToString();
else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString();
}
}
else
message = message + gdpicturePDF.GetStat().ToString();
status = GdPictureStatus.OK;
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
status = GdPictureStatus.Aborted;
break;
}
message += "\n";
}
if (status == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns, if the border color attribute is defined for a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. Please note that every single child radio button in a group of radio buttons
within a radio button field can have its own border color defined. As said, this method is only applicable to radio buttons.
The form field's border color attribute is not assigned automatically when creating the form field. However, you can specify the border color
using the method right after adding the required form field on the page. Otherwise, the form field may display invisible.
Returns, if the border color attribute is defined for a required form field, that is specified by its unique form field's identifier and it is
related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
It is recommend to use the method to identify the specific reason for the method's failure, if any.Just to remind you, that the form field's border color attribute is not assigned automatically when creating the form field.
true if the border color attribute is defined for the specified child radio button, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to properly find out the the border color for radio button form fields in the current document.
Dim caption As String = "Example: FormFieldHasBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0
Dim hasColor As Boolean = False, hasRB As Boolean = False
Dim borderColor As Color = Color.Black
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID)
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The border color is the same (either undefined or specified) for all child radio buttons in this group.
message = message + " - borderColor: "
If hasColor Then
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + borderColor.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + " undefined"
End If
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The border color is different for the individual child radio buttons in this group.
message = message + " has a different border color for its child radio buttons."
Dim kids As Integer = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To kids - 1
message = message + vbCrLf + " " + j.ToString() + ".child - border color: "
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If hasColor Then
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + borderColor.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "undefined"
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Next
Else
message = message + vbCrLf + " The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + " The FormFieldHasBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
message += vbCrLf
Next
If count = 0 Then
message = "This file doesn't include forms."
ElseIf Not hasRB Then
message = "This file doesn't include radio button form fields."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FormFieldHasBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
bool hasColor = false, hasRB = false;
Color borderColor = Color.Black;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID);
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The border color is the same (either undefined or specified) for all child radio buttons in this group.
message = message + " - border color: ";
if (hasColor)
{
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + borderColor.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else message = message + " undefined";
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The border color is different for the individual child radio buttons in this group.
message = message + " has a different border color for its child radio buttons.";
int kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < kids; j++)
{
message = message + "\n " + j.ToString() + ".child - border color: ";
hasColor = gdpicturePDF.FormFieldHasBorderColor(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (hasColor)
{
borderColor = gdpicturePDF.GetFormFieldBorderColor(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + borderColor.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else message = message + "undefined";
}
else message = message + gdpicturePDF.GetStat().ToString();
}
}
else message = message + "\n The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else message = message + "\n The FormFieldHasBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
message += "\n";
}
if (count == 0) message = "This file doesn't include forms.";
else if (!hasRB) message = "This file doesn't include radio button form fields.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Removes the border color attribute of a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. Be aware that the border color attribute becomes undefined using this method,
which causes the form field border not to appear on the page.
Removes the border color attribute of a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
Be aware that the border color attribute becomes undefined using this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove the border of all push buttons in the current document.
Dim caption As String = "Example: SetFormFieldNoBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypePushButton Then
If gdpicturePDF.SetFormFieldNoBorderColor(formID) <> GdPictureStatus.OK Then
message = message + i.ToString() + ": The SetFormFieldNoBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
End If
If message.Equals("") Then message = "The example has been followed successfully." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldNoBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypePushButton)
{
if (gdpicturePDF.SetFormFieldNoBorderColor(formID) != GdPictureStatus.OK)
message = message + i.ToString() + ": The SetFormFieldNoBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
if (message.Equals("")) message = "The example has been followed successfully.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Removes the border color attribute of a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. Please note that every single child radio button in a group
of radio buttons within a radio button field can have its own border color defined, that you are allowed to remove using this method.
As said, this method is only applicable to radio buttons.
Be aware that the border color attribute becomes undefined using this method, which causes the form field border not to appear on the page.
Removes the border color attribute of a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Be aware that the border color attribute becomes undefined using this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove the border color for checked child radio buttons.
Dim caption As String = "Example: SetFormFieldNoBorderColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0, kids As Integer = 0
Dim hasRB As Boolean = False, isChecked As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
kids = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To kids - 1
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If Not isChecked Then
'Removing the border color (setting it to No Color) for checked child radio button.
If gdpicturePDF.SetFormFieldNoBorderColor(formID, j) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldNoBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
Else
MessageBox.Show("The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
ElseIf Not hasRB Then
MessageBox.Show("This file doesn't include radio button form fields.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the SaveToFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldNoBorderColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0, kids = 0;
bool hasRB = false, isChecked = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < kids; j++)
{
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (!isChecked)
{
//Removing the border color (setting it to No Color) for unchecked child radio button.
if (gdpicturePDF.SetFormFieldNoBorderColor(formID, j) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldNoBorderColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0) MessageBox.Show("This file doesn't include forms.", caption);
else
if (!hasRB) MessageBox.Show("This file doesn't include radio button form fields.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the SaveToFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns, if the background (fill) color attribute is defined for a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The form field's background (fill) color attribute is not assigned automatically when creating the form field. However, you can specify the background
color using the method right after adding the required form field on the page. Otherwise, the form field may display invisible.
Be aware that if the background (fill) color differs for each single child radio button in a group of radio buttons within a radio button field, this method will fail.
Please use the method instead to find out, if the background (fill) color attribute is defined for each child radio button in a group.
Returns, if the background (fill) color attribute is defined for a required form field, that is specified by its unique form field's identifier and it is
related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that the form field's background (fill) color attribute is not assigned automatically when creating the form field.
true if the background (fill) color attribute is defined for the specified form field object, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to set the background color to only those form fields, which don't have any defined.
Dim caption As String = "Example: FormFieldHasBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0
Dim bkColor As Color = Color.Black
Dim hasColor As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 0 To count - 1
message = message + i.ToString() + ".field: "
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "has bkColor: " + hasColor.ToString()
If hasColor Then
bkColor = gdpicturePDF.GetFormFieldBackgroundColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " bkColor: " + bkColor.ToString()
Else
message = message + " bkColor: " + gdpicturePDF.GetStat().ToString()
End If
Else
If gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Fuchsia) = GdPictureStatus.OK Then
message = message + " color set to: " + Color.Fuchsia.ToString()
Else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString()
End If
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
status = GdPictureStatus.OK
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
status = GdPictureStatus.Aborted
Exit For
End If
message += vbCrLf
Next
If status = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, caption)
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FormFieldHasBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
Color bkColor = Color.Black;
bool hasColor = false;
GdPictureStatus status = GdPictureStatus.OK;
for (int i = 0; i < count; i++)
{
message = message + i.ToString() + ".field: ";
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "has bkColor: " + hasColor.ToString();
if (hasColor)
{
bkColor = gdpicturePDF.GetFormFieldBackgroundColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " bkColor: " + bkColor.ToString();
else
message = message + " bkColor: " + gdpicturePDF.GetStat().ToString();
}
else
{
if (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Fuchsia) == GdPictureStatus.OK)
message = message + " color set to: " + Color.Fuchsia.ToString();
else
message = message + " color set to: " + gdpicturePDF.GetStat().ToString();
}
}
else
message = message + gdpicturePDF.GetStat().ToString();
status = GdPictureStatus.OK;
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
status = GdPictureStatus.Aborted;
break;
}
message += "\n";
}
if (status == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns, if the background (fill) color attribute is defined for a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. Please note that every single child radio button in a group of radio buttons
within a radio button field can have its own background (fill) color defined. As said, this method is only applicable to radio buttons.
The form field's background (fill) color attribute is not assigned automatically when creating the form field. However, you can specify the background (fill)
color using the method right after adding the required form field on the page. Otherwise, the form field may display invisible.
Returns, if the background (fill) color attribute is defined for a required form field, that is specified by its unique form field's identifier and it is
related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
It is recommend to use the method to identify the specific reason for the method's failure, if any.Just to remind you, that the form field's background (fill) color attribute is not assigned automatically when creating the form field.
true if the background (fill) color attribute is defined for the specified child radio button, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to find out the background color for radio button form fields.
Dim caption As String = "Example: FormFieldHasBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0
Dim hasColor As Boolean = False, hasRB As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim bgColor As Color = Color.Black
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID)
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The background color is the same (either undefined or specified) for all child radio buttons in this group.
message = message + " - bgColor: "
If hasColor Then
bgColor = gdpicturePDF.GetFormFieldBackgroundColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + bgColor.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + " undefined"
End If
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The background color is different for the individual child radio buttons in this group.
message = message + " has a different bgColor for its child radio buttons."
Dim kids As Integer = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To kids - 1
message = message + vbCrLf + " " + j.ToString() + ".child - bgColor: "
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If hasColor Then
bgColor = gdpicturePDF.GetFormFieldBackgroundColor(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + bgColor.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "undefined"
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Next
Else
message = message + vbCrLf + " The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + " The FormFieldHasBackgroundColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
message += vbCrLf
Next
If count = 0 Then
message = "This file doesn't include forms."
ElseIf Not hasRB Then
message = "This file doesn't include radio button form fields."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FormFieldHasBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
bool hasColor = false, hasRB = false;
Color bgColor = Color.Black;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID);
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The background color is the same (either undefined or specified) for all child radio buttons in this group.
message = message + " - bgColor: ";
if (hasColor)
{
bgColor = gdpicturePDF.GetFormFieldBackgroundColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + bgColor.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else message = message + " undefined";
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The background color is different for the individual child radio buttons in this group.
message = message + " has a different bgColor for its child radio buttons.";
int kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < kids; j++)
{
message = message + "\n " + j.ToString() + ".child - bgColor: ";
hasColor = gdpicturePDF.FormFieldHasBackgroundColor(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (hasColor)
{
bgColor = gdpicturePDF.GetFormFieldBackgroundColor(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + bgColor.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else message = message + "undefined";
}
else message = message + gdpicturePDF.GetStat().ToString();
}
}
else message = message + "\n The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else message = message + "\n The FormFieldHasBackgroundColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
message += "\n";
}
if (count == 0) message = "This file doesn't include forms.";
else if (!hasRB) message = "This file doesn't include radio button form fields.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Removes the background (fill) color attribute of a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. Be aware that the background (fill) color attribute becomes undefined using this method,
which causes the form field background not to appear on the page.
Removes the background (fill) color attribute of a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
Be aware that the background (fill) color attribute becomes undefined using this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove the background color of all push buttons in the current document.
Dim caption As String = "Example: SetFormFieldNoBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypePushButton Then
If gdpicturePDF.SetFormFieldNoBackgroundColor(formID) <> GdPictureStatus.OK Then
message = message + i.ToString() + ": The SetFormFieldNoBackgroundColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
End If
If message.Equals("") Then message = "The example has been followed successfully." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldNoBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypePushButton)
{
if (gdpicturePDF.SetFormFieldNoBackgroundColor(formID) != GdPictureStatus.OK)
message = message + i.ToString() + ": The SetFormFieldNoBackgroundColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
if (message.Equals("")) message = "The example has been followed successfully.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Removes the background (fill) color attribute of a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. Please note that every single child radio button in a group
of radio buttons within a radio button field can have its own background (fill) color defined, that you are allowed to remove using this method.
As said, this method is only applicable to radio buttons.
Be aware that the background (fill) color attribute becomes undefined using this method, which causes the form field background not to appear on the page.
Removes the background (fill) color attribute of a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Be aware that the background (fill) color attribute becomes undefined using this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove the background color for checked child radio buttons.
Dim caption As String = "Example: SetFormFieldNoBackgroundColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0, kids As Integer = 0
Dim hasRB As Boolean = False, isChecked As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
kids = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To kids - 1
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If isChecked Then
'Removing the background color (setting it to No Color) for checked child radio button.
If gdpicturePDF.SetFormFieldNoBackgroundColor(formID, j) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldNoBackgroundColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
Else
MessageBox.Show("The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
ElseIf Not hasRB Then
MessageBox.Show("This file doesn't include radio button form fields.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldNoBackgroundColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0, kids = 0;
bool hasRB = false, isChecked = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < kids; j++)
{
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (isChecked)
{
//Removing the background color (setting it to No Color) for checked child radio button.
if (gdpicturePDF.SetFormFieldNoBackgroundColor(formID, j) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldNoBackgroundColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0) MessageBox.Show("This file doesn't include forms.", caption);
else
if (!hasRB) MessageBox.Show("This file doesn't include radio button form fields.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the graphical style of a checkmark used to represent the checked state of check boxes and radio buttons.
The required form field (check box or radio button group) is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
As said, this method is only applicable to check boxes and radio buttons.
The checkmark is a shape, that appears in the corresponding form field (check box or radio button), when it is checked/selected.
Be aware that if the checkmark's style differs for each single child radio button in a group of radio buttons within a radio button field, this method will fail.
Please use the method to determine the individual checkmark's style for each child radio button in a group instead.
Returns the graphical style of a checkmark used to represent the checked state of check boxes and radio buttons.
The required form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for check boxes and radio buttons, otherwise it will fail.
A member of the PdfCheckBoxStyle enumeration. The method can be subsequently used to determine if this method has been successful.
How to change the circle checkmark to the cross checkmark for all check boxes in the current document.
Dim caption As String = "Example: GetFormFieldCheckBoxStyle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim style As PdfCheckBoxStyle = PdfCheckBoxStyle.PdfCheckBoxStyleCheck
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCheckBoxButton Then
style = gdpicturePDF.GetFormFieldCheckBoxStyle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If style = PdfCheckBoxStyle.PdfCheckBoxStyleCircle Then
If gdpicturePDF.SetFormFieldCheckBoxStyle(formID, PdfCheckBoxStyle.PdfCheckBoxStyleCross) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldCheckBoxStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
PdfCheckBoxStyle style = PdfCheckBoxStyle.PdfCheckBoxStyleCheck;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCheckBoxButton)
{
style = gdpicturePDF.GetFormFieldCheckBoxStyle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (style == PdfCheckBoxStyle.PdfCheckBoxStyleCircle)
{
if (gdpicturePDF.SetFormFieldCheckBoxStyle(formID, PdfCheckBoxStyle.PdfCheckBoxStyleCross) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the graphical style of a checkmark used to represent the checked state of a required form field, here a child radio button in a group.
The radio button group is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The checkmark is a shape, that appears in the specified radio button field, when it is checked/selected. Please note that every single child radio button
in a group of radio buttons within a radio button field can have its own checkmark defined.
Returns the graphical style of a checkmark used to represent the checked state of check boxes and radio buttons.
The required form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.Just to remind you that this method is only meaningful for radio buttons, otherwise it will fail.
A member of the PdfCheckBoxStyle enumeration. The method can be subsequently used to determine if this method has been successful.
How to find out the style of the checkmark for child radio buttons in a group.
Dim caption As String = "Example: GetFormFieldCheckBoxStyle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0
Dim hasRB As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim style As PdfCheckBoxStyle = PdfCheckBoxStyle.PdfCheckBoxStyleCheck
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID)
style = gdpicturePDF.GetFormFieldCheckBoxStyle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The style of the checkmark is the same for all child radio buttons in this group.
message = message + " - style: " + style.ToString()
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The style of the checkmark is different for the individual child radio buttons in this group.
message = message + " has a different style for its child radio buttons."
Dim kids As Integer = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To kids - 1
message = message + vbCrLf + " " + j.ToString() + ".child - style: "
style = gdpicturePDF.GetFormFieldCheckBoxStyle(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + style.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Next
Else
message = message + vbCrLf + " The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + vbCrLf + " The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
message += vbCrLf
Next
If count = 0 Then
message = "This file doesn't include forms."
ElseIf Not hasRB Then
message = "This file doesn't include radio button form fields."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldCheckBoxStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0;
bool hasRB = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
PdfCheckBoxStyle style = PdfCheckBoxStyle.PdfCheckBoxStyleCheck;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
message = message + "RB " + gdpicturePDF.GetFormFieldTitle(formID);
style = gdpicturePDF.GetFormFieldCheckBoxStyle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The style of the checkmark is the same for all child radio buttons in this group.
message = message + " - style: " + style.ToString();
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The style of the checkmark is different for the individual child radio buttons in this group.
message = message + " has a different style for its child radio buttons.";
int kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < kids; j++)
{
message = message + "\n " + j.ToString() + ".child - style: ";
style = gdpicturePDF.GetFormFieldCheckBoxStyle(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + style.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
}
else message = message + "\n The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else message = message + "\n The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
message += "\n";
}
if (count == 0) message = "This file doesn't include forms.";
else if (!hasRB) message = "This file doesn't include radio button form fields.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the graphical style of a checkmark used to represent the checked state of a required form field, hereabout a check box or a radio button group.
The form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to check boxes and radio buttons.
The checkmark is a shape, that appears in the corresponding form field, here a check box or a radio button group, when it is checked/selected.
This method doesn't alter the form field's visual appearance in any way.
Sets the graphical style of a checkmark used to represent the checked state of check boxes and radio buttons.
The required form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A member of the PdfCheckBoxStyle enumeration. A graphical style of a checkmark to be used when checking/selecting the required form field.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for check boxes and radio buttons, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the circle checkmark to the cross checkmark for all check boxes in the current document.
Dim caption As String = "Example: SetFormFieldCheckBoxStyle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim style As PdfCheckBoxStyle = PdfCheckBoxStyle.PdfCheckBoxStyleCheck
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCheckBoxButton Then
style = gdpicturePDF.GetFormFieldCheckBoxStyle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If style = PdfCheckBoxStyle.PdfCheckBoxStyleCircle Then
If gdpicturePDF.SetFormFieldCheckBoxStyle(formID, PdfCheckBoxStyle.PdfCheckBoxStyleCross) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldCheckBoxStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
PdfCheckBoxStyle style = PdfCheckBoxStyle.PdfCheckBoxStyleCheck;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCheckBoxButton)
{
style = gdpicturePDF.GetFormFieldCheckBoxStyle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (style == PdfCheckBoxStyle.PdfCheckBoxStyleCircle)
{
if (gdpicturePDF.SetFormFieldCheckBoxStyle(formID, PdfCheckBoxStyle.PdfCheckBoxStyleCross) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldCheckBoxStyle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the graphical style of a checkmark used to represent the checked state of a required form field, here a child radio button in a group.
The radio button group is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The checkmark is a shape, that appears in the specified radio button field, when it is checked/selected. Please note that every single child radio button
in a group of radio buttons within a radio button field can have its own checkmark defined. This method doesn't alter the form field's visual appearance in any way.
Sets the graphical style of a checkmark used to represent the checked state of check boxes and radio buttons.
The required form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
A member of the PdfCheckBoxStyle enumeration. A graphical style of a checkmark to be used when checking/selecting the required child radio button in a group.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for radio buttons, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set a different style of the checkmark for each child radio button in a group.
Dim caption As String = "Example: SetFormFieldCheckBoxStyle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 0.8F, "What colour do you prefer for your T-shirt?") = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
Dim colors1 As String() = New String() {"white", "yellow", "red", "blue", "green", "black"}
Dim colors2 As Byte()() = New Byte(5)() {New Byte(2) {255, 255, 255}, New Byte(2) {255, 255, 0}, New Byte(2) {255, 0, 0}, New Byte(2) {0, 0, 255}, New Byte(2) {0, 255, 0}, New Byte(2) {0, 0, 0}}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCheck, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, CByte(255), CByte(228), CByte(196)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, CByte(165), CByte(42), CByte(42)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldCheckBoxStyle(formID, i, CType(i, PdfCheckBoxStyle)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, colors2(i)(0), colors2(i)(1), colors2(i)(2)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors1(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldCheckBoxStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 0.8f, "What colour do you prefer for your T-shirt?") == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
string[] colors1 = new string[] { "white", "yellow", "red", "blue", "green", "black" };
byte[][] colors2 = new byte[6][] { new byte[3] { 255, 255, 255 }, new byte[3] { 255, 255, 0 }, new byte[3] { 255, 0, 0 },
new byte[3] { 0, 0, 255 }, new byte[3] { 0, 255, 0 }, new byte[3] { 0, 0, 0 } };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCheck, 0, 0, 0);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, (byte)255, (byte)228, (byte)196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, (byte)165, (byte)42, (byte)42) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldCheckBoxStyle(formID, i, (PdfCheckBoxStyle)i) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, colors2[i][0], colors2[i][1], colors2[i][2]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors1[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the string representation of the normal appearance (the On state) of a required form field, here a check box, that is specified by its
unique form field's identifier and it is related to the currently loaded PDF document. The normal appearance represents the checked state of a check box
and it is used when a check box is not interacting with the user and for printing. As said, this method is only applicable to check boxes.
If this attribute is not defined for the specified check box, then the predefined value for the On state is "On" by default.
Sets the string representation of the normal appearance of a required form field, hereabout a radio button or a check box, that is specified by its unique
form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
A string representation of the On state of the specified check box.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for check boxes, otherwise it will fail. If this attribute is undefined for the specified
check box, then the resulting value is "On" by default. The value for the opposite state used internally is always "Off".
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the value representing the On state attribute of the newly added check box.
Dim caption As String = "Example: SetFormFieldOnStateName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the first checkbox.
Dim formID As Integer = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "LoveIt", PdfCheckBoxStyle.PdfCheckBoxStyleStar, True, Color.Blue)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldOnStateName(formID, "love") = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 2.5F, 1.5F, "I love GdPicturePDF.")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(1, 4, 1, 1, "UseIt", PdfCheckBoxStyle.PdfCheckBoxStyleStar, True, Color.Blue)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldOnStateName(formID, "use") = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 2.5F, 4.5F, "I use it.")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_checkbox.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldOnStateName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the first checkbox.
int formID = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "LoveIt", PdfCheckBoxStyle.PdfCheckBoxStyleStar, true, Color.Blue);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldOnStateName(formID, "love") == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 2.5f, 1.5f, "I love GdPicturePDF.");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(1, 4, 1, 1, "UseIt", PdfCheckBoxStyle.PdfCheckBoxStyleStar, true, Color.Blue);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldOnStateName(formID, "use") == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 2.5f, 4.5f, "I use it.");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_checkbox.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the string representation of the normal appearance (the On state, same as the radio button's choice attribute) of a required form field, here a child radio button in a group, that is specified by its
unique form field's identifier and it is related to the currently loaded PDF document. The normal appearance represents the checked state of a radio button
and it is used when a radio button is not interacting with the user and for printing. As said, this method is only applicable to radio buttons.
If this attribute is not defined for the specified child radio button, then the predefined value for the On state is "On" by default.
Sets the string representation of the normal appearance of a required form field, hereabout a radio button or a check box, that is specified by its unique
form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
A string representation of the On state (radio button's choice attribute) of the specified child radio button in a group.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for radio buttons, otherwise it will fail. If this attribute is undefined for the specified
child radio button, then the resulting value is "On" by default. The value for the opposite state used internally is always "Off".
In other words, the On state name represents so called radio button's choice attribute.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the value representing the On state attribute of the newly added radio buttons.
Dim caption As String = "Example: SetFormFieldOnStateName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 0.8F, "What color do you prefer for your T-shirt?") = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
Dim colors As String() = New String() {"white", "yellow", "red", "blue", "green", "black"}
For i As Integer = 0 To colors.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.Black)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldOnStateName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 0.8f, "What colour do you prefer for your T-shirt?") == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
string[] colors = new string[] { "white", "yellow", "red", "blue", "green", "black" };
for (int i = 0; i < colors.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.Black);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors[i]) != GdPictureStatus.OK))
{
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the string representation of the normal appearance (the On state) of a required form field, here a check box, that is specified by its unique
form field's identifier and it is related to the currently loaded PDF document. The normal appearance represents the checked state of a check box
and it is used when a check box is not interacting with the user and for printing. As said, this method is only applicable to check boxes.
If this attribute is not defined for the specified check box, then the resulting value for the On state is "On" by default.
Returns the string representation of the normal appearance of a required form field, hereabout a radio button or a check box, that is specified by its unique
form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for check boxes, otherwise it will fail. If this attribute is undefined for the specified check box,
then the resulting value is "On" by default. The value for the opposite state used internally is always "Off".
A string representation of the On state of the specified check box. The method can be subsequently used to determine if this method has been successful.
How to utilize the value representing the On state attribute of check boxes.
Dim caption As String = "Example: GetFormFieldOnStateName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldOnStateName() method.
If gdpicturePDF.LoadFromFile("forms_checkbox.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim isChecked As Boolean = False, hasCheckBoxes As Boolean = False
Dim onName As String = "", userSelection As String = ""
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If type = PdfFormFieldType.PdfFormFieldTypeCheckBoxButton Then
hasCheckBoxes = True
isChecked = gdpicturePDF.GetFormFieldChecked(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
onName = gdpicturePDF.GetFormFieldOnStateName(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If isChecked Then
userSelection = userSelection + "They " + onName + " our product." + vbCrLf
Else
userSelection = userSelection + "They do not " + onName + " our product." + vbCrLf
End If
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If Not hasCheckBoxes Then userSelection = "This file doesn't include check boxes." + vbCrLf
Else
userSelection = userSelection + "Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(userSelection, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldOnStateName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldOnStateName() method.
if (gdpicturePDF.LoadFromFile("forms_checkbox.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool isChecked = false, hasCheckBoxes = false;
string onName = "", userSelection = "";
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (type == PdfFormFieldType.PdfFormFieldTypeCheckBoxButton)
{
hasCheckBoxes = true;
isChecked = gdpicturePDF.GetFormFieldChecked(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
onName = gdpicturePDF.GetFormFieldOnStateName(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (isChecked)
userSelection = userSelection + "They " + onName + " our product.\n";
else
userSelection = userSelection + "They do not " + onName + " our product.\n";
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (!hasCheckBoxes)
userSelection = "This file doesn't include check boxes.\n";
}
else
userSelection = userSelection + "Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(userSelection,caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the string representation of the normal appearance (the On state) of a required form field, here a child radio button in a group, that is specified by its unique
form field's identifier and it is related to the currently loaded PDF document. The normal appearance represents the checked state of a radio button
and it is used when a radio button is not interacting with the user and for printing. As said, this method is only applicable to radio buttons.
If this attribute is not defined for the specified child radio button, then the resulting value for the On state is "On" by default.
Returns the string representation of the normal appearance of a required form field, hereabout a radio button or a check box, that is specified by its unique
form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for radio buttons, otherwise it will fail. If this attribute is undefined for the specified child radio button,
then the resulting value is "On" by default. The value for the opposite state used internally is always "Off".
A string representation of the On state of the specified child radio button in a group.
The method can be subsequently used to determine if this method has been successful.
How to utilize the value representing the On state attribute of radio buttons.
Dim caption As String = "Example: GetFormFieldOnStateName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldOnStateName() method.
If gdpicturePDF.LoadFromFile("test_radiobutton.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim isChecked As Boolean = False, hasRadioButtons As Boolean = False
Dim onName As String = "", userSelection As String = ""
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
Type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If Type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRadioButtons = True
Dim rbCount As Integer = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
For j As Integer = 0 To rbCount - 1
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If isChecked Then
onName = gdpicturePDF.GetFormFieldOnStateName(formID, j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
userSelection = "They prefer " + onName + " colour."
Exit For 'Only one radio button is selected at a time.
End If
Next
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If Not hasRadioButtons Then
userSelection = "This file doesn't include radio buttons."
Else
userSelection = "Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString()
End If
End If
MessageBox.Show(userSelection, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldOnStateName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldOnStateName() method.
if (gdpicturePDF.LoadFromFile(m_filename, false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool isChecked = false, hasRadioButtons = false;
string onName = "", userSelection = "";
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRadioButtons = true;
int rbCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
for (int j = 0; j < rbCount; j++)
{
isChecked = gdpicturePDF.GetFormFieldChecked(formID, j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (isChecked)
{
onName = gdpicturePDF.GetFormFieldOnStateName(formID, j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
userSelection = "They prefer " + onName + " colour.";
break; //Only one radio button is selected at a time.
}
}
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (!hasRadioButtons)
userSelection = "This file doesn't include radio buttons.";
}
else
userSelection = "Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(userSelection, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the default value of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
It is a value to which the form field reverts when it is reset, that means reset-form action is executed. The format of this value is the same as defined for the
field's current value attribute.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A string representation of the default value of the specified form field. The method can be subsequently used to determine if this method has been successful.
How to determine the current values and the default values for all used form fields in the document.
Dim caption As String = "Example: GetFormFieldDefaultValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim name As String = "", value As String = "", defValue As String = ""
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Getting the form fields' title (name).
message = message + "Form field "
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's current value.
message = message + ": current value = "
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
'Getting the form field's default value.
message = message + " default value = "
defValue = gdpicturePDF.GetFormFieldDefaultValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + defValue
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldDefaultValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string name = "", value = "", defValue = "";
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Getting the form fields' title (name).
message = message + "Form field ";
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's current value.
message = message + ": current value = ";
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
//Getting the form field's default value.
message = message + " default value = ";
defValue = gdpicturePDF.GetFormFieldDefaultValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + defValue;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the default value of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
It is a value to which the form field reverts when it is reset, that means reset-form action is executed. The format of this value is the same as defined for the
field's current value attribute.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A string representation of the new default value of the specified form field.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the default value for the list box and combo box form fields.
Dim caption As String = "Example: SetFormFieldDefaultValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, itemCount As Integer = 0
Dim value As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim save As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (type = PdfFormFieldType.PdfFormFieldTypeList) OrElse
(type = PdfFormFieldType.PdfFormFieldTypeCombo) Then
itemCount = gdpicturePDF.GetFormFieldItemCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If itemCount > 0 Then
value = gdpicturePDF.GetFormFieldItemValue(formID, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SetFormFieldDefaultValue(formID, value) = GdPictureStatus.OK Then
save = True
Else
message = message + i.ToString() + ": The SetFormFieldDefaultValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldItemValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + i.ToString() + ": The GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
Exit For
End If
Next
If save Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "The document has not been changed, so it has not been saved as well."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldDefaultValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, itemCount = 0;
string value = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool save = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((type == PdfFormFieldType.PdfFormFieldTypeList) ||
(type == PdfFormFieldType.PdfFormFieldTypeCombo))
{
itemCount = gdpicturePDF.GetFormFieldItemCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (itemCount > 0)
{
value = gdpicturePDF.GetFormFieldItemValue(formID, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SetFormFieldDefaultValue(formID, value) == GdPictureStatus.OK)
save = true;
else
message = message + i.ToString() + ": The SetFormFieldDefaultValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldItemValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + i.ToString() + ": The GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
{
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
break;
}
}
if (save)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
else
message = message + "The document has not been changed, so it has not been saved as well.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns, if a required form field, here a check box, is checked by default. The check box is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. As said, this method is only applicable to check boxes.
If this flag is set for the specified check box, then this check box is checked by default.
Returns, if a required form field, here a check box or a radio button, is checked by default. The form field is specified
by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for check boxes, otherwise it will fail.
true if the specified check box is checked by default, otherwise false. The method can be subsequently used to determine
if this method has been successful.
How to remove the default checked property for all check boxes, which have this attribute defined.
Dim caption As String = "Example: GetFormFieldDefaultChecked"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim defChecked As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCheckBoxButton Then
defChecked = gdpicturePDF.GetFormFieldDefaultChecked(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If defChecked Then
If (gdpicturePDF.SetFormFieldChecked(formID, False) <> GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDefaultChecked(formID, False) <> GdPictureStatus.OK) Then
MessageBox.Show("The SetFormFieldChecked()/SetFormFieldDefaultChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldDefaultChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldDefaultChecked";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool defChecked = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCheckBoxButton)
{
defChecked = gdpicturePDF.GetFormFieldDefaultChecked(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (defChecked)
{
if ((gdpicturePDF.SetFormFieldChecked(formID, false) != GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDefaultChecked(formID, false) != GdPictureStatus.OK))
{
MessageBox.Show("The SetFormFieldChecked()/SetFormFieldDefaultChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldDefaultChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns, if a required form field, here a child radio button in a group, is checked by default. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
If this flag is set for the specified child radio button in a group, then this radio button is checked by default in this group.
Returns, if a required form field, here a check box or a radio button, is checked by default. The form field is specified
by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for radio buttons, otherwise it will fail.
true if the specified child radio button is checked by default, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to reset all radio buttons in the current document to be not checked by default. All radio buttons are completely unchecked.
Dim caption As String = "Example: GetFormFieldDefaultChecked"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, childCount As Integer = 0, radioButtons As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim defChecked As Boolean = False, isChanged As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
radioButtons += 1
childCount = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To childCount - 1
defChecked = gdpicturePDF.GetFormFieldDefaultChecked(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If defChecked Then
'Removing the current default selection for the given radio button completely.
If gdpicturePDF.ResetFormFieldDefaultCheckedState(formID) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". rb group has been changed successfully." + vbCrLf
isChanged = True
'Removing the current selection for the given radio button completely.
If gdpicturePDF.ResetFormFieldCheckedState(formID) <> GdPictureStatus.OK Then
MessageBox.Show(message + "Something has failed in unchecking buttons with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show(message + "Something has failed in changing default settings with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Only one radio button can be checked by default at a time.
Exit For
End If
Else
MessageBox.Show(message + " The GetFormFieldDefaultChecked() method failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Next
Else
MessageBox.Show(message + "The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If radioButtons = 0 Then
message = message + "This document does not contain radio buttons." + vbCrLf
ElseIf Not isChanged Then
message = message + "This document has not been changed."
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldDefaultChecked";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, childCount = 0, radioButtons = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool defChecked = false, isChanged = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
radioButtons++;
childCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < childCount; j++)
{
defChecked = gdpicturePDF.GetFormFieldDefaultChecked(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (defChecked)
{
//Removing the current default selection for the given radio button completely.
if (gdpicturePDF.ResetFormFieldDefaultCheckedState(formID) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". rb group has been changed successfully.\n";
isChanged = true;
//Removing the current selection for the given radio button completely.
if (gdpicturePDF.ResetFormFieldCheckedState(formID) != GdPictureStatus.OK)
MessageBox.Show(message + "Something has failed in unchecking buttons with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show(message + "Something has failed in changing default settings with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //Only one radio button can be checked by default at a time.
}
}
else
MessageBox.Show(message + " The GetFormFieldDefaultChecked() method failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show(message + "The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (radioButtons == 0) message = message + "This document does not contain radio buttons.\n";
else if (!isChanged) message = message + "This document has not been changed.";
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets, if a required form field, here a check box, is checked by default. The check box is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. As said, this method is only applicable to check boxes.
If this flag is set for the specified check box, then this check box is checked by default.
Sets, if a required form field, here a check box or a radio button, is checked by default. The form field is specified
by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to check the specified check box by default, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for check boxes, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to define that the newly created check box will be checked by default.
Dim caption As String = "Example: SetFormFieldDefaultChecked"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the first checkbox.
Dim formID As Integer = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "CheckBox1", PdfCheckBoxStyle.PdfCheckBoxStyleStar, False, Color.Blue)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDefaultChecked(formID, True) = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 2.5F, 1.5F, "I love GdPicturePDF.")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(1, 4, 1, 1, "CheckBox2", PdfCheckBoxStyle.PdfCheckBoxStyleStar, False, Color.Blue)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDefaultChecked(formID, False) = GdPictureStatus.OK) Then
gdpicturePDF.DrawText(fontResName, 2.5F, 4.5F, "I will use it.")
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Saving the document.
If gdpicturePDF.SaveToFile("forms_checkbox.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldDefaultChecked";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the first checkbox.
int formID = gdpicturePDF.AddCheckBoxFormField(1, 1, 1, 1, "CheckBox1", PdfCheckBoxStyle.PdfCheckBoxStyleStar, false, Color.Blue);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDefaultChecked(formID, true) == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 2.5f, 1.5f, "I love GdPicturePDF.");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second checkbox.
formID = gdpicturePDF.AddCheckBoxFormField(1, 4, 1, 1, "CheckBox2", PdfCheckBoxStyle.PdfCheckBoxStyleStar, false, Color.Blue);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDefaultChecked(formID, false) == GdPictureStatus.OK))
{
gdpicturePDF.DrawText(fontResName, 2.5f, 4.5f, "I will use it.");
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddCheckBoxFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Saving the document.
if (gdpicturePDF.SaveToFile("forms_checkbox.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets, if a required form field, here a child radio button in a group, is checked by default. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
If this flag is set for the specified child radio button in a group, then this child radio button is checked by default in this group.
As only one child radio button in a group may be checked at a time (assuming the RadiosInUnison flag is not set), the currently selected child radio button
is automatically unchecked, it means its checked state is set to Off. You can completely remove the currently defined default selection
in a radio button group using the method.
Sets, if a required form field, here a check box or a radio button, is checked by default. The form field is specified
by its unique form field's identifier and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for radio buttons, otherwise it will fail. Be aware that selecting any one of the child radio
buttons in a group automatically deselects all the others (assuming the RadiosInUnison flag is not set).
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to check the last child radio button in a group to be checked by default in this group.
Dim caption As String = "Example: SetFormFieldDefaultChecked"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 0.8F, "What colour do you prefer for your T-shirt?") = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
Dim colors As String() = New String() {"white", "yellow", "red", "blue", "green", "black"}
For i As Integer = 0 To colors.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.Black)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Setting the last child radio button in a group to be checked by default.
If gdpicturePDF.SetFormFieldDefaultChecked(formID, colors.Length - 1) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldDefaultChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldDefaultChecked";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesItalic);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 0.8f, "What colour do you prefer for your T-shirt?") == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
string[] colors = new string[] { "white", "yellow", "red", "blue", "green", "black" };
for (int i = 0; i < colors.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.Black);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.Bisque) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldOnStateName(formID, i, colors[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors[i]) != GdPictureStatus.OK))
{
MessageBox.Show("Adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Setting the last child radio button in a group to be checked by default.
if (gdpicturePDF.SetFormFieldDefaultChecked(formID, colors.Length - 1) != GdPictureStatus.OK)
MessageBox.Show("The SetFormFieldDefaultChecked() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Adding font or drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the fully qualified field name of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The fully qualified field name is constructed from the partial field name of the specified field and all of its ancestors, separated by a period (.) .
For a field with no parent, the partial and fully qualified names are the same. For further assistance, please refer to the PDF Reference, Section "Field Names".
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The fully qualified field name of the specified form field. The method can be subsequently used to determine if this method has been successful.
How to retrieve full titles and clone numbers of the form fields in the current document.
Dim caption As String = "Example: GetFormFieldFullTitle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0, cloneNr As Integer = 0
Dim message As String = "", fullTitle As String = "", withCloneNr As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "Field nr." + (i + 1).ToString() + ": type=" + type.ToString() + vbCrLf
fullTitle = gdpicturePDF.GetFormFieldFullTitle(formID)
message = message + " fullTitle="
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fullTitle
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
cloneNr = gdpicturePDF.GetFormFieldCloneNumber(formID)
message = message + "; cloneNr="
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + cloneNr.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
withCloneNr = gdpicturePDF.GetFormFieldFullTitle(formID)
message = message + "; titleWithCloneNr="
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + withCloneNr
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
message += vbCrLf
Next
If count = 0 Then MessageBox.Show("This file doesn't include forms.", caption) Else MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldFullTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0, cloneNr = 0;
string message = "", fullTitle = "", withCloneNr = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "Field nr." + (i + 1).ToString() + ": type=" + type.ToString() + "\n";
fullTitle = gdpicturePDF.GetFormFieldFullTitle(formID);
message = message + " fullTitle=";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fullTitle;
else
message = message + gdpicturePDF.GetStat().ToString();
cloneNr = gdpicturePDF.GetFormFieldCloneNumber(formID);
message = message + "; cloneNr=";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + cloneNr.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
withCloneNr = gdpicturePDF.GetFormFieldFullTitle(formID);
message = message + "; titleWithCloneNr=";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + withCloneNr;
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
message += "\n";
}
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the fully qualified field name, which is completed with a '#' and the corresponding clone number, of a required form field, that is specified by
its unique form field's identifier and it is related to the currently loaded PDF document. The clone numbers distinguish full titles of all kids form fields
belonging to one parent form field. For a field with no parent, the fully qualified name and that with clone number are the same.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The fully qualified field name completed with the clone number of the specified form field, in this form: name#clone_number.
The method can be subsequently used to determine if this method has been successful.
How to retrieve full titles and clone numbers of the form fields in the current document.
Dim caption As String = "Example: GetFormFieldFullTitleWithCloneNumber"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0, cloneNr As Integer = 0
Dim message As String = "", fullTitle As String = "", withCloneNr As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "Field nr." + (i + 1).ToString() + ": type=" + type.ToString() + vbCrLf
fullTitle = gdpicturePDF.GetFormFieldFullTitle(formID)
message = message + " fullTitle="
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fullTitle
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
cloneNr = gdpicturePDF.GetFormFieldCloneNumber(formID)
message = message + "; cloneNr="
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + cloneNr.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
withCloneNr = gdpicturePDF.GetFormFieldFullTitle(formID)
message = message + "; titleWithCloneNr="
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + withCloneNr
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
message += vbCrLf
Next
If count = 0 Then MessageBox.Show("This file doesn't include forms.", caption) Else MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldFullTitleWithCloneNumber";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0, cloneNr = 0;
string message = "", fullTitle = "", withCloneNr = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "Field nr." + (i + 1).ToString() + ": type=" + type.ToString() + "\n";
fullTitle = gdpicturePDF.GetFormFieldFullTitle(formID);
message = message + " fullTitle=";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fullTitle;
else
message = message + gdpicturePDF.GetStat().ToString();
cloneNr = gdpicturePDF.GetFormFieldCloneNumber(formID);
message = message + "; cloneNr=";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + cloneNr.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
withCloneNr = gdpicturePDF.GetFormFieldFullTitle(formID);
message = message + "; titleWithCloneNr=";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + withCloneNr;
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
message += "\n";
}
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the alternate title (the alternate field name) of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
This alternate name is used in place of the actual field name wherever the field must be identified in the user interface (such as in error or status
messages referring to the field). This text is also useful when extracting the document’s content in support of accessibility to users with disabilities or
for other purposes. For example, it can be displayed as the field's tooltip when users are hovering with the mouse over the field.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The alternate title (alternate name) of the specified form field. The method can be subsequently used to determine if this method has been successful.
How to change or define the alternate title for the fields, which have this attribute blank or undefined.
Dim caption As String = "Example: GetFormFieldAlternateTitle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim title As String = "", altertitle As String = ""
Dim save As Boolean = True
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If String.IsNullOrEmpty(title) Then title = "Created"
altertitle = gdpicturePDF.GetFormFieldAlternateTitle(formID)
Select Case gdpicturePDF.GetStat()
Case GdPictureStatus.OK
If String.IsNullOrEmpty(altertitle) Then status = gdpicturePDF.SetFormFieldAlternateTitle(formID, title + " by GdPicture")
Case GdPictureStatus.PropertyNotFound
status = gdpicturePDF.SetFormFieldAlternateTitle(formID, title + " by GdPicture")
Case Else
MessageBox.Show("The GetFormFieldAlternateTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End Select
If status <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldAlternateTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
save = False
Exit For
End If
Next
If save Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldAlternateTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
string title = "", altertitle = "";
bool save = true;
GdPictureStatus status = GdPictureStatus.OK;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (String.IsNullOrEmpty(title))
title = "Created";
altertitle = gdpicturePDF.GetFormFieldAlternateTitle(formID);
switch (gdpicturePDF.GetStat())
{
case GdPictureStatus.OK:
if (String.IsNullOrEmpty(altertitle)) status = gdpicturePDF.SetFormFieldAlternateTitle(formID, title + " by GdPicture");
break;
case GdPictureStatus.PropertyNotFound:
status = gdpicturePDF.SetFormFieldAlternateTitle(formID, title + " by GdPicture");
break;
default:
MessageBox.Show("The GetFormFieldAlternateTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldAlternateTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
save = false;
break;
}
}
if (save)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the alternate title (the alternate field name) of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
This alternate name is used in place of the actual field name wherever the field must be identified in the user interface (such as in error or status
messages referring to the field). For example, it can be displayed as the field's tooltip when users are hovering with the mouse over the field.
This text is also useful when extracting the document’s content in support of accessibility to users with disabilities or
for other purposes. For the proper usage, please refer to the method.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The new alternate title of the specified form field to be set.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change or specify the alternate title for the fields, which have this attribute blank or undefined.
Dim caption As String = "Example: SetFormFieldAlternateTitle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim title As String = "", altertitle As String = ""
Dim save As Boolean = True
Dim status As GdPictureStatus = GdPictureStatus.OK
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If String.IsNullOrEmpty(title) Then title = "Created"
altertitle = gdpicturePDF.GetFormFieldAlternateTitle(formID)
Select Case gdpicturePDF.GetStat()
Case GdPictureStatus.OK
If String.IsNullOrEmpty(altertitle) Then status = gdpicturePDF.SetFormFieldAlternateTitle(formID, title + " by GdPicture")
Case GdPictureStatus.PropertyNotFound
status = gdpicturePDF.SetFormFieldAlternateTitle(formID, title + " by GdPicture")
Case Else
MessageBox.Show("The GetFormFieldAlternateTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End Select
If status <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldAlternateTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
save = False
Exit For
End If
Next
If save Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldAlternateTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
string title = "", altertitle = "";
bool save = true;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (String.IsNullOrEmpty(title))
title = "Created";
altertitle = gdpicturePDF.GetFormFieldAlternateTitle(formID);
switch (gdpicturePDF.GetStat())
{
case GdPictureStatus.OK:
if (String.IsNullOrEmpty(altertitle)) gdpicturePDF.SetFormFieldAlternateTitle(formID, title + " by GdPicture");
break;
case GdPictureStatus.PropertyNotFound:
gdpicturePDF.SetFormFieldAlternateTitle(formID, title + " by GdPicture");
break;
default:
MessageBox.Show("The GetFormFieldAlternateTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
save = false;
break;
}
}
if (save)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the clone number of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF
document. These clone numbers distinguish kids form fields belonging to one parent form field, if they have the same partial name (it is the feature
supported by Acrobat when creating identically named form fields).
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for kids form fields, otherwise it will fail.
The clone number of the specified form field. The method can be subsequently used to determine if this method has been successful.
How to retrieve full titles and clone numbers of the form fields in the current document.
Dim caption As String = "Example: GetFormFieldCloneNumber"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0, cloneNr As Integer = 0
Dim message As String = "", fullTitle As String = "", withCloneNr As String = ""
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "Field nr." + (i + 1).ToString() + ": type=" + type.ToString() + vbCrLf
fullTitle = gdpicturePDF.GetFormFieldFullTitle(formID)
message = message + " fullTitle="
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fullTitle
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
cloneNr = gdpicturePDF.GetFormFieldCloneNumber(formID)
message = message + "; cloneNr="
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + cloneNr.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
withCloneNr = gdpicturePDF.GetFormFieldFullTitle(formID)
message = message + "; titleWithCloneNr="
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + withCloneNr
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
message += vbCrLf
Next
If count = 0 Then MessageBox.Show("This file doesn't include forms.", caption) Else MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldCloneNumber";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0, cloneNr = 0;
string message = "", fullTitle = "", withCloneNr = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "Field nr." + (i + 1).ToString() + ": type=" + type.ToString() + "\n";
fullTitle = gdpicturePDF.GetFormFieldFullTitle(formID);
message = message + " fullTitle=";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fullTitle;
else
message = message + gdpicturePDF.GetStat().ToString();
cloneNr = gdpicturePDF.GetFormFieldCloneNumber(formID);
message = message + "; cloneNr=";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + cloneNr.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
withCloneNr = gdpicturePDF.GetFormFieldFullTitle(formID);
message = message + "; titleWithCloneNr=";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + withCloneNr;
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
message += "\n";
}
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the defined visibility, either on screen or in print, of a required form field, that is specified by its unique form field's identifier and
it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfFormFieldVisibility enumeration. The method can be subsequently used to determine if this method has been successful.
How to set all currently hidden form fields to become visible.
Dim caption As String = "Example: GetFormFieldVisibility"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim visible As PdfFormFieldVisibility = PdfFormFieldVisibility.PdfFormFieldVisible
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
visible = gdpicturePDF.GetFormFieldVisibility(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If visible = PdfFormFieldVisibility.PdfFormFieldHidden Then
If gdpicturePDF.SetFormFieldVisibility(formID, PdfFormFieldVisibility.PdfFormFieldVisible) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldVisibility() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldVisibility() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (count = 0) Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldVisibility";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldVisibility visible = PdfFormFieldVisibility.PdfFormFieldVisible;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
visible = gdpicturePDF.GetFormFieldVisibility(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (visible == PdfFormFieldVisibility.PdfFormFieldHidden)
{
if (gdpicturePDF.SetFormFieldVisibility(formID, PdfFormFieldVisibility.PdfFormFieldVisible) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldVisibility() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldVisibility() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the specified visibility, either on screen or in print, of a required form field, that is specified by its unique form field's identifier and
it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A member of the PdfFormFieldVisibility enumeration. A new value of the visibility flag for the specified form field to be set.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set all currently hidden form fields to become visible.
Dim caption As String = "Example: SetFormFieldVisibility"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim visible As PdfFormFieldVisibility = PdfFormFieldVisibility.PdfFormFieldVisible
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
visible = gdpicturePDF.GetFormFieldVisibility(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If visible = PdfFormFieldVisibility.PdfFormFieldHidden Then
If gdpicturePDF.SetFormFieldVisibility(formID, PdfFormFieldVisibility.PdfFormFieldVisible) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldVisibility() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldVisibility() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (count = 0) Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldVisibility";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldVisibility visible = PdfFormFieldVisibility.PdfFormFieldVisible;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
visible = gdpicturePDF.GetFormFieldVisibility(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (visible == PdfFormFieldVisibility.PdfFormFieldHidden)
{
if (gdpicturePDF.SetFormFieldVisibility(formID, PdfFormFieldVisibility.PdfFormFieldVisible) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldVisibility() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldVisibility() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the Required flag of a required form field, that is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
If this flag is set, then the field must have a value at the time it is exported by a submit-form action. Unfortunately the GdPicturePDF doesn't support this feature yet.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
Set this parameter to true, if you want to enable the Required flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Likewise, be aware that the GdPicturePDF doesn't support the submit-form action yet.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize the Required flag for the newly added text field.
Dim caption As String = "Example: SetFormFieldRequired"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 2, "GER") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 4, "FRA") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(3, 1, 3, 1, "GER-PostalCode", "12345", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldMaxLen(formID, 5) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldComb(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldRequired(formID, true) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDefaultValue(formID, "00000") <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
formID = gdpicturePDF.AddTextFormField(3, 3, 3, 1, "FRA-PostalCode", "1234", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldMaxLen(formID, 4) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldComb(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldRequired(formID, true) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDefaultValue(formID, "0000") <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldRequired";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 2, "GER") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 4, "FRA") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(3, 1, 3, 1, "GER-PostalCode", "12345", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldMaxLen(formID, 5) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldComb(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldRequired(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDefaultValue(formID, "00000") != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
formID = gdpicturePDF.AddTextFormField(3, 3, 3, 1, "FRA-PostalCode", "1234", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldMaxLen(formID, 4) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldComb(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldRequired(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDefaultValue(formID, "0000") != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns, if the Required flag of a required form field is set. The form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
If this flag is set, then the field must have a value at the time it is exported by a submit-form action. Unfortunately the GdPicturePDF doesn't support this feature yet.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that the GdPicturePDF class doesn't support the submit-form action yet.
true if the Required flag of the specified form field is set, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to determine, which form fields are required in the current document.
Dim caption As String = "Example: GetFormFieldRequired"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0
Dim title As String = "", messageRO As String = "ReadOnly fields:" + vbCrLf, messageREQ As String = "Required fields:" + vbCrLf
Dim roFlag As Boolean = False, reqFlag As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
roFlag = gdpicturePDF.GetFormFieldReadOnly(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If roFlag Then messageRO = messageRO + title + "; "
Else
message = message + title + ": GetFormFieldReadOnly - " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
reqFlag = gdpicturePDF.GetFormFieldRequired(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If reqFlag Then messageREQ = messageREQ + title + "; "
Else
message = message + title + ": GetFormFieldRequired - " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
message = messageRO + vbCrLf + vbCrLf + messageREQ + vbCrLf + vbCrLf + message + vbCrLf + "Done!"
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldRequired";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0;
string title = "", messageRO = "ReadOnly fields:\n", messageREQ = "Required fields:\n";
bool roFlag = false, reqFlag = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
roFlag = gdpicturePDF.GetFormFieldReadOnly(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (roFlag)
messageRO = messageRO + title + "; ";
}
else
message = message + title + ": GetFormFieldReadOnly - " + gdpicturePDF.GetStat().ToString() + "\n";
reqFlag = gdpicturePDF.GetFormFieldRequired(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (reqFlag)
messageREQ = messageREQ + title + "; ";
}
else
message = message + title + ": GetFormFieldRequired - " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
message = messageRO + "\n\n" + messageREQ + "\n\n" + message + "\nDone!";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the (export) value of a specific item of a choice form field, that is specified by its unique form field's identifier and it is related to the
currently loaded PDF document. The item is identified by its index, that simply represents its position in the item's list.
The item's value is an export value assigned to the specified option, it can be different than the item's text.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , , or .
The index of the required item. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for choice form fields, that means for combo boxes or list boxes, otherwise it will fail.
A string representing the value of the selected item. The method can be subsequently used to determine if this method has been successful.
How to retrieve all items and their values in all list boxes in the current document.
Dim caption As String = "Example: GetFormFieldItemValue"
Dim message As String = ""
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) <> GdPictureStatus.OK Then
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If count = 0 Then
message = "This document includes no form fields."
GoTo [error]
End If
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If type = PdfFormFieldType.PdfFormFieldTypeList Then
Dim title As String = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "listbox: " + title
Dim itemsCount As Integer = gdpicturePDF.GetFormFieldItemCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " items: " + itemsCount + vbCrLf
Dim text As String = "", value As String = ""
For j As Integer = 0 To itemsCount - 1
text = gdpicturePDF.GetFormFieldItemText(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "text: " + text
Else
message = message + "text: " + gdpicturePDF.GetStat().ToString()
End If
value = gdpicturePDF.GetFormFieldItemValue(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " value: " + value
Else
message = message + " value: " + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Next
Else
message = message + vbCrLf + "The GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Else
message = "The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
End If
Next
[error]:
If message.Equals("") Then message = "This document includes no list boxes."
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldItemValue";
string message = "";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) != GdPictureStatus.OK)
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if (count == 0)
{
message = "This document includes no form fields.";
goto error;
}
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if (type == PdfFormFieldType.PdfFormFieldTypeList)
{
string title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + "listbox: " + title;
int itemsCount = gdpicturePDF.GetFormFieldItemCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + " items: " + itemsCount + "\n";
string text = "", value = "";
for (int j = 0; j < itemsCount; j++)
{
text = gdpicturePDF.GetFormFieldItemText(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + "text: " + text;
else
message = message + "text: " + gdpicturePDF.GetStat().ToString();
value = gdpicturePDF.GetFormFieldItemValue(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " value: " + value;
else
message = message + " value: " + gdpicturePDF.GetStat().ToString();
message += "\n";
}
}
else
{
message = message + "\nThe GetFormFieldItemCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
}
else
{
message = "The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
}
}
error:
if (message.Equals(""))
message = "This document includes no list boxes.";
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns, if the RadiosInUnison flag of a required form field, here a radio button, is set. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to
radio button fields, so this method is explicitly applicable to radio button form field objects.
If this flag is set, a group of radio buttons within a radio button field that use the same value for the On state will turn on and off in unison; that
is if one is checked, they are all checked. If this flag is not set, the buttons are mutually exclusive.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for radio buttons, otherwise it will fail.
Be aware that the same value of this flag is assigned to all child radio buttons in a group.
true if the RadiosInUnison flag of the specified radio button is set, otherwise false. The method can be subsequently used
to determine if this method has been successful.
How to determine, if the RadiosInUnison flag is set and how to subsequently deselect this flag for all radio buttons in the current document.
Dim caption As String = "Example: GetFormFieldRadioInUnison"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document does not contain any forms.", caption)
Else
Dim title As String = ""
Dim formID As Integer = 0
Dim isUnison As Boolean = False, save As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
isUnison = gdpicturePDF.GetFormFieldRadioInUnison(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If isUnison Then
If gdpicturePDF.SetFormFieldRadioInUnison(formID, False) <> GdPictureStatus.OK Then Exit For
save = True
End If
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If save Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("This document does not contain any radio buttons.", caption)
End If
Else
MessageBox.Show("Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldRadioInUnison";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document does not contain any forms.", caption);
else
{
string title = "";
int formID = 0;
bool isUnison = false, save = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
isUnison = gdpicturePDF.GetFormFieldRadioInUnison(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (isUnison)
{
if (gdpicturePDF.SetFormFieldRadioInUnison(formID, false) != GdPictureStatus.OK) break;
save = true;
}
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (save)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("This document does not contain any radio buttons.", caption);
}
else
MessageBox.Show("Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the RadiosInUnison flag of a required form field, here a radio button. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific
to radio button fields, so this method is explicitly applicable to radio button form field objects.
If this flag is set, a group of radio buttons within a radio button field, that use the same value for the On state (radio button's choice attribute),
will turn on and off in unison; that is if one is checked, they are all checked. If this flag is not set, the buttons in the group are mutually exclusive.
If you set this flag to true for a required radio button group, no radio button in the group is selected as On. If you set the flag to false,
the first radio button in the group is selected as On.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to enable the RadiosInUnison flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is only meaningful for radio buttons, otherwise it will fail.
At the same, the specified value of this flag is assigned to all child radio buttons in a group.
Be aware that this flag has no effect on the child radio buttons in a group, if they all hold different On state names (radio button's choice attribute).
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize the RadiosInUnison flag when adding new radio buttons. The items in the Group2 with same names are always selected together.
Dim caption As String = "Example: SetFormFieldRadioInUnison"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 0) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim choices1 As String() = New String() {"choice 1", "choice 2", "choice 3"}
For i As Integer = 0 To choices1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", choices1(i), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, choices1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The flag is set for all radio buttons in a newly created group.
If gdpicturePDF.SetFormFieldRadioInUnison(formID, False) <> GdPictureStatus.OK Then
MessageBox.Show("The 1.SetFormFieldRadioInUnison() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim choices2 As String() = New String() {"choice 1", "choice 2", "choice 1", "choice 2"}
For i As Integer = 0 To choices2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", choices2(i), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, choices2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
'stop creating anything
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The flag is set for all radio buttons in a newly created group.
If gdpicturePDF.SetFormFieldRadioInUnison(formID, True) <> GdPictureStatus.OK Then
MessageBox.Show("The 2.SetFormFieldRadioInUnison() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldRadioInUnison";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 0) == GdPictureStatus.OK))
{
int formID = 0;
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] choices1 = new string[] { "choice 1", "choice 2", "choice 3" };
for (int i = 0; i < choices1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", choices1[i], PdfCheckBoxStyle.PdfCheckBoxStyleStar, 0, 0, 0);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, choices1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The flag is set for all radio buttons in a newly created group.
if (gdpicturePDF.SetFormFieldRadioInUnison(formID, false) != GdPictureStatus.OK)
MessageBox.Show("The 1.SetFormFieldRadioInUnison() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] choices2 = new string[] { "choice 1", "choice 2", "choice 1", "choice 2" };
for (int i = 0; i < choices2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", choices2[i], PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 0, 0, 0);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, choices2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i+1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The flag is set for all radio buttons in a newly created group.
if (gdpicturePDF.SetFormFieldRadioInUnison(formID, true) != GdPictureStatus.OK)
MessageBox.Show("The 2.SetFormFieldRadioInUnison() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the counterclockwise rotation, in degrees, of a specified form field, relative to the page, where the form field is located. The
required form field is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The resulting value is always a multiple of 90.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of degrees by which the specified form field is rotated counterclockwise relative to the page. The default value is 0.
The method can be subsequently used to determine if this method has been successful.
How to rotate each check box in the current document upside down.
Dim caption As String = "Example: GetFormFieldRotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0, rotation As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCheckBoxButton Then
rotation = gdpicturePDF.GetFormFieldRotation(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SetFormFieldRotation(formID, rotation + 180) <> GdPictureStatus.OK Then
message = message + i.ToString() + ": The SetFormFieldRotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldRotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
End If
If message.Equals("") Then message = "The example has been followed successfully." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldRotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0, rotation = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCheckBoxButton)
{
rotation = gdpicturePDF.GetFormFieldRotation(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SetFormFieldRotation(formID, rotation + 180) != GdPictureStatus.OK)
message = message + i.ToString() + ": The SetFormFieldRotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldRotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
if (message.Equals("")) message = "The example has been followed successfully.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the counterclockwise rotation, in degrees, of a specified form field, relative to the page, where the form field is located. The required form field
object is specified by its unique form field's identifier and it is related to the currently loaded PDF document.
The value of the parameter Rotation must be always a multiple of 90, otherwise the method will fail. The default value is 0.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The new number of degrees by which the specified form field is rotated counterclockwise relative to the page. This value must be a multiple of 90.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to rotate each check box in the current document upside down.
Dim caption As String = "Example: SetFormFieldRotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0, rotation As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCheckBoxButton Then
rotation = gdpicturePDF.GetFormFieldRotation(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SetFormFieldRotation(formID, rotation + 180) <> GdPictureStatus.OK Then
message = message + i.ToString() + ": The SetFormFieldRotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldRotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
End If
If message.Equals("") Then message = "The example has been followed successfully." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldRotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0, rotation = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCheckBoxButton)
{
rotation = gdpicturePDF.GetFormFieldRotation(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SetFormFieldRotation(formID, rotation + 180) != GdPictureStatus.OK)
message = message + i.ToString() + ": The SetFormFieldRotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldRotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + i.ToString() + ": The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
if (message.Equals("")) message = "The example has been followed successfully.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the color of the font used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. This attribute is not restricted to any form fields, even if the form field's appearance doesn't display text.
In other words, this value also defines the color of the checkmark in a required form field.
Be aware that if the checkmark's color differs for each single child radio button in a group of radio buttons within a radio button field, this method will fail.
Please use the method to determine the individual color of the checkmark for each child radio button in a group instead.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Returns the color of the font used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
The color of the defined font or the checkmark of a specified form field. The method can be subsequently used to determine if this method has been successful.
How to find out font properties of fonts used for all form fields in the current document.
Dim caption As String = "Example: GetFormFieldFontColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim fName As String = "", fFamily As String = ""
Dim fSize As Single = 0
Dim fColor As Color = Color.Black
Dim fStyle As GdPicture14.FontStyle = GdPicture14.FontStyle.FontStyleRegular
Dim isStdF As Boolean = False
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". "
message = message + "type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " font: "
fName = gdpicturePDF.GetFormFieldFontName(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fName
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " size: "
fSize = gdpicturePDF.GetFormFieldFontSize(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fSize.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " color: "
fColor = gdpicturePDF.GetFormFieldFontColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + fColor.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf + " properties: "
status = gdpicturePDF.GetFormFieldFontProperties(formID, fFamily, fStyle, isStdF)
If status = GdPictureStatus.OK Then
message = message + " family: " + fFamily + " style: " + fStyle.ToString() + " isStandard: " + isStdF.ToString()
Else
message = message + status.ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldFontColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string fName = "", fFamily = "";
float fSize = 0;
Color fColor = Color.Black;
GdPicture14.FontStyle fStyle = GdPicture14.FontStyle.FontStyleRegular;
bool isStdF = false;
GdPictureStatus status = GdPictureStatus.OK;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". ";
message = message + "type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + type.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " font: ";
fName = gdpicturePDF.GetFormFieldFontName(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fName;
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " size: ";
fSize = gdpicturePDF.GetFormFieldFontSize(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fSize.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " color: ";
fColor = gdpicturePDF.GetFormFieldFontColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + fColor.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n properties: ";
status = gdpicturePDF.GetFormFieldFontProperties(formID, ref fFamily, ref fStyle, ref isStdF);
if (status == GdPictureStatus.OK)
message = message + " family: " + fFamily + " style: " +fStyle.ToString() + " isStandard: " + isStdF.ToString();
else
message = message + status.ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the color used to display the checkmark in a required form field, here a child radio button in a group. The radio button group is specified by
its unique form field's identifier and it is related to the currently loaded PDF document.As said, this method is only applicable to radio buttons.
The font color attribute is not restricted to any form fields, meaning that this value also defines the color of the checkmark in the radio button field.
Please note that every single child radio button in a group of radio buttons within a radio button field can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Returns the color of the font used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
The color of the displayed checkmark of a specified child radio button. The method can be subsequently used to determine if this method has been successful.
How to find out the correct color of the checkmark defined for radio button fields.
Dim caption As String = "Example: GetFormFieldFontColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "", ftitle As String = ""
Dim formID As Integer = 0, kids As Integer = 0
Dim hasRB As Boolean = False
Dim fcolor As Color = Color.White
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (i + 1).ToString() + ".form field - GetFormFieldId() finished with the status: "
Exit For
End If
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (i + 1).ToString() + ".form field - GetFormFieldType() finished with the status: "
Exit For
End If
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
hasRB = True
ftitle = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (i + 1).ToString() + ".form field - GetFormFieldTitle() finished with the status: "
Exit For
End If
fcolor = gdpicturePDF.GetFormFieldFontColor(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The font/text color is same for all child radio buttons in the given group.
message = message + ftitle + " radio button - font color is " + fcolor.ToString() + " - same for all children." + vbCrLf
Else
If gdpicturePDF.GetStat() = GdPictureStatus.Aborted Then
'The font/text color is different for individual child radio buttons in the given group.
kids = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The radio button " + ftitle + " - GetFormFieldChildCount() finished with the status: "
Exit For
End If
message = message + ftitle + " radio button - font/text color is different for child buttons." + vbCrLf
For j As Integer = 0 To kids - 1
fcolor = gdpicturePDF.GetFormFieldFontColor(formID, j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = (j + 1).ToString() + ".child of " + ftitle + " - GetFormFieldFontColor() finished with the status: "
Exit For
End If
message = message + " " + (j + 1).ToString() + ".child - font color: " + fsize.ToString() + vbCrLf
Next
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
Else
'This is an error in getting the font/text color.
message = "The radio button " + ftitle + " - GetFormFieldFontColor() finished with the status: " + gdpicturePDF.GetStat()
Exit For
End If
End If
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
message = "This file doesn't include forms."
ElseIf Not hasRB Then
message = "This file doesn't include radio button form fields."
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldFontColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "", ftitle = "";
int formID = 0, kids = 0;
bool hasRB = false;
Color fcolor = Color.White;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (i + 1).ToString() + ".form field - GetFormFieldId() finished with the status: ";
break;
}
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (i + 1).ToString() + ".form field - GetFormFieldType() finished with the status: ";
break;
}
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
hasRB = true;
ftitle = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (i + 1).ToString() + ".form field - GetFormFieldTitle() finished with the status: ";
break;
}
fcolor = gdpicturePDF.GetFormFieldFontColor(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The font/text color is same for all child radio buttons in the given group.
message = message + ftitle + " radio button - font color is " + fcolor.ToString() + " - same for all children.\n";
}
else
{
if (gdpicturePDF.GetStat() == GdPictureStatus.Aborted)
{
//The font/text color is different for individual child radio buttons in the given group.
kids = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The radio button " + ftitle + " - GetFormFieldChildCount() finished with the status: ";
break;
}
message = message + ftitle + " radio button - font color is different for child buttons.\n";
for (int j = 0; j < kids; j++)
{
fcolor = gdpicturePDF.GetFormFieldFontColor(formID, j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = (j + 1).ToString() + ".child of " + ftitle + " - GetFormFieldFontColor() finished with the status: ";
break;
}
message = message + " " + (j + 1).ToString() + ".child - font color: " + fsize.ToString() + "\n";
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
}
else
{
//This is an error in getting the font/text color.
message = "The radio button " + ftitle + " - GetFormFieldFontColor() finished with the status: " + gdpicturePDF.GetStat();
break;
}
}
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0) message = "This file doesn't include forms.";
else if (!hasRB) message = "This file doesn't include radio button form fields.";
}
else message = message + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the location on the page of a required form field, that is specified by its unique form field's identifier and it is related to the currently
loaded PDF document. This location is represented by the bounding box of the form field on that page, where the form field is currently located. The
coordinates of the field's bounding box are expressed in the current units used in this document with respect to the currently defined origin.
The page, where the form field is located, is not affected in any way using this method.
You can use the method to reset the units and the method to reset the origin's location according to your preference.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The horizontal (X) coordinate of the closest point to the currently defined origin,
where the form field's bounding box is to be located, expressed in the current units specified by the SetMeasurementUnit method.
The vertical (Y) coordinate of the closest point to the currently defined origin,
where the form field's bounding box is to be located, expressed in the current units specified by the SetMeasurementUnit method.
The horizontal (X) coordinate of the furthest point to the currently defined origin,
where the form field's bounding box is to be located, expressed in the current units specified by the SetMeasurementUnit method.
The vertical (Y) coordinate of the furthest point to the currently defined origin,
where the form field's bounding box is to be located, expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that the page, where the form field is currently located, is not affected in any way using this method and can not be changed as well.
Be aware that the values of the coordinates are expressed in the current units defined by the method according to the current
coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to shift all form fields in the current document by two centimeters down when keeping their size.
Dim caption As String = "Example: SetFormFieldLocation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then
message = "This document does not contain any forms."
Else
Dim formID As Integer = 0
Dim left As Single = 0, top As Single = 0, right As Single = 0, bottom As Single = 0
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.GetFormFieldLocation(formID, left, top, right, bottom) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldLocation(formID, left, top + 2, right, bottom + 2) <> GdPictureStatus.OK) Then
message = message + i.ToString() + ": The GetFormFieldLocation()/SetFormFieldLocation() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
End If
If message.Equals("") Then message = "The example has been followed successfully." + vbCrLf
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldLocation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
else
{
int formID = 0;
float left = 0, top = 0, right = 0, bottom = 0;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.GetFormFieldLocation(formID, ref left, ref top, ref right, ref bottom) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldLocation(formID, left, top+2, right, bottom+2) != GdPictureStatus.OK))
message = message + i.ToString() + ": The GetFormFieldLocation()/SetFormFieldLocatio() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ": The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
if (message.Equals("")) message = "The example has been followed successfully.\n";
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the DoNotScroll flag of a required form field, here a text field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly applicable to text form field objects.
If this flag is set, then the text field does not scroll to include more text than fits within its rectangle. Once the field is full, no further text is accepted.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to enable the DoNotScroll flag, otherwise set it to false to disable it.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
How to utilize the DoNotScroll flag when creating different text form fields.
Dim caption As String = "Example: SetFormFieldDoNotScroll"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 0.5F, 2, "Name") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 0.5F, 4, "Address") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(3.5F, 1, 6, 1, "Name", "", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotScroll(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
formID = gdpicturePDF.AddTextFormField(3.5F, 3, 6, 2, "Address", "", True, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotScroll(formID, False) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldDoNotScroll";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 0.5f, 2, "Name") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 0.5f, 4, "Address") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(3.5f, 1, 6, 1, "Name", "", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotScroll(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
formID = gdpicturePDF.AddTextFormField(3.5f, 3, 6, 2, "Address", "", true, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotScroll(formID, false) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns, if the DoNotScroll flag of a required form field, here a text field, is set. The text field is specified by its unique form field's
identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly
applicable to text form field objects.
If this flag is set, then the text field does not scroll to include more text than fits within its rectangle. Once the field is full, no further text is accepted.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
true if the DoNotScroll flag of the specified text field is set, otherwise false. The method can be subsequently used to determine if this
method has been successful.
How to determine if the DoNotScroll flag is set for the text form fields in the current document.
Dim caption As String = "Example: GetFormFieldDoNotScroll"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldDoNotScroll() method.
If gdpicturePDF.LoadFromFile("forms_textfield.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then message = "This document does not contain any forms."
Dim formID As Integer = 0, j As Integer = 0
Dim scroll As Boolean = False, spell As Boolean = False, multiline As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
j += 1
message = message + j.ToString() + ".text field:" + vbCrLf
scroll = gdpicturePDF.GetFormFieldDoNotScroll(formID)
message = message + " DoNotScroll = "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + scroll.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
spell = gdpicturePDF.GetFormFieldDoNotSpellCheck(formID)
message = message + " DoNotSpellCheck = "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + spell.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
multiline = gdpicturePDF.GetFormFieldMultiLine(formID)
message = message + " MultiLine = "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + multiline.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldDoNotScroll";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldDoNotScroll() method.
if (gdpicturePDF.LoadFromFile("forms_textfield.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
int formID = 0, j = 0;
bool scroll = false, spell = false, multiline = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
j++;
message = message + j.ToString() + ".text field:\n";
scroll = gdpicturePDF.GetFormFieldDoNotScroll(formID);
message = message + " DoNotScroll = ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + scroll.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
spell = gdpicturePDF.GetFormFieldDoNotSpellCheck(formID);
message = message + " DoNotSpellCheck = ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + spell.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
multiline = gdpicturePDF.GetFormFieldMultiLine(formID);
message = message + " MultiLine = ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + multiline.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
}
else
{
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the RichText flag of a required form field, here a text field, that is specified by its unique form field's identifier and it is
related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly applicable to text form field objects.
If this flag is set, then the value of this text field should be represented as a rich text string.
For further assistance, please refer to the PDF Reference, Section "Rich Text Strings".
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to enable the RichText flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize the RichText flag for the newly added text field, which represents the formatted code section.
Dim caption As String = "Example: SetFormFieldRichText"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "Code section") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 2, 10, 5, "Code", "", True, fontResName, 15, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotScroll(formID, False) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldRichText(formID, True) <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldRichText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "Code section") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(1, 2, 10, 5, "Code", "", true, fontResName, 15, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotScroll(formID, false) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldRichText(formID, true) != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns, if the RichText flag of a required form field, here a text field, is set. The text field is specified by its unique form field's
identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly
applicable to text form field objects.
If this flag is set, then the value of this text field should be represented as a rich text string.
For further assistance, please refer to the PDF Reference, Section "Rich Text Strings".
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
true if the RichText flag of the specified text field is set, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to utilize the RichText flag when saving the formatted string value of the text form field.
Dim caption As String = "Example: GetFormFieldRichText"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldRichText() method.
If gdpicturePDF.LoadFromFile("forms_textfield.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "", value As String = "", name As String = "code"
If count = 0 Then message = "This document does not contain any forms."
Dim formID As Integer = 0, j As Integer = 0
Dim rich As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
j += 1
message = message + j.ToString() + ".text field: RichText: "
rich = gdpicturePDF.GetFormFieldRichText(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + rich.ToString() + " Value: "
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
name = name + j.ToString()
If rich Then name = name + ".rtf" Else name = name + ".txt"
Using writer As StreamWriter = New StreamWriter(name)
writer.Write(value)
message = message + name
End Using
Else
message = gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldRichText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldRichText() method.
if (gdpicturePDF.LoadFromFile("forms_textfield.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "", value = "", name = "code";
if (count == 0)
message = "This document does not contain any forms.";
int formID = 0, j = 0;
bool rich = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
j++;
message = message + j.ToString() + ".text field: RichText: ";
rich = gdpicturePDF.GetFormFieldRichText(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + rich.ToString() + " Value: ";
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
name = name + j.ToString();
if (rich)
name = name + ".rtf";
else
name = name + ".txt";
using (StreamWriter writer = new StreamWriter(name))
{
writer.Write(value);
message = message + name;
}
}
else
message = gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
}
else
{
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the Password flag of a required form field, here a text field, that is specified by its unique form field's identifier and it is related to the
currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly applicable to text form field objects.
If this flag is set, then the text field is intended for entering a secure password that should not be echoed visibly to the screen. Instead, the characters
typed from the keyboard should be displayed in some unreadable form, usually asterisks.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to enable the Password flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize the Password flag when creating the text form field intended for adding a password.
Dim caption As String = "Example: SetFormFieldPassword"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierOblique)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "Enter your name") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 4, "Enter your password") = GdPictureStatus.OK) Then
'Adding the name text field.
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 1.5F, 10, 1, "Name", "", False, fontResName, 16, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 255, 255) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotScroll(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) <> GdPictureStatus.OK) Then
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Adding the password text field.
formID = gdpicturePDF.AddTextFormField(1, 4.5F, 10, 1, "Password", "", False, fontResName, 16, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDoNotScroll(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldPassword(formID, True) = GdPictureStatus.OK) Then
Dim message As String = "The example has been followed successfully"
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
message = message + " and the file has been saved successfully."
Else
message = message + ", but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The AddStandardFont() method or drawing has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldPassword";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierOblique);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "Enter your name") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 4, "Enter your password") == GdPictureStatus.OK))
{
//Adding the name text field.
int formID = gdpicturePDF.AddTextFormField(1, 2, 10, 1, "Name", "", false, fontResName, 16, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 255, 255) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotScroll(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) != GdPictureStatus.OK))
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Adding the password text field.
formID = gdpicturePDF.AddTextFormField(1, 4, 10, 1, "Password", "", false, fontResName, 16, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDoNotScroll(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldPassword(formID, true) == GdPictureStatus.OK))
{
string message = "The example has been followed successfully";
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
message = message + " and the file has been saved successfully.";
else
message = message + ", but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddStandardFont() method or drawing has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns, if the Password flag of a required form field, here a text field, is set. The text field is specified by its unique form field's
identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly
applicable to text form field objects.
If this flag is set, then the text field is intended for entering a secure password that should not be echoed visibly to the screen. Instead, the characters
typed from the keyboard should be displayed in some unreadable form, usually asterisks.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
true if the Password flag of the specified text field is set, otherwise false. The method can be subsequently used to determine if this
method has been successful.
How to determine the text fields in the current document, which have the Password flag set.
Dim caption As String = "Example: GetFormFieldPassword"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF
If (gdpicturePDF.LoadFromFile("forms.pdf", True) = GdPictureStatus.OK) Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount
If (gdpicturePDF.GetStat = GdPictureStatus.OK) Then
If (count = 0) Then
MessageBox.Show("This file doesn't include forms.", caption)
End If
Dim formID As Integer = 0
Dim title As String = ""
Dim message As String = "Password text form fields:" + vbCrLf
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim isPass As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If (gdpicturePDF.GetStat <> GdPictureStatus.OK) Then Exit For
type = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat <> GdPictureStatus.OK) Then Exit For
If (type = PdfFormFieldType.PdfFormFieldTypeText) Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If (gdpicturePDF.GetStat <> GdPictureStatus.OK) Then Exit For
isPass = gdpicturePDF.GetFormFieldPassword(formID)
If (gdpicturePDF.GetStat <> GdPictureStatus.OK) Then Exit For
If isPass Then message = message + title + "; "
End If
Next
If (gdpicturePDF.GetStat = GdPictureStatus.OK) Then
MessageBox.Show(message, caption)
Else
MessageBox.Show("Something goes wrong. Status: " + gdpicturePDF.GetStat.ToString, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat.ToString, caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldPassword";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", true) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
{
int formID = 0;
string message = "Password text form fields:\n", title = "";
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool isPass = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
isPass = gdpicturePDF.GetFormFieldPassword(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (isPass)
message = message + title + "; ";
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show(message, caption);
else
MessageBox.Show("Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the DoNotSpellCheck flag of a required form field, hereabout a text field or an editable combo box, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields and editable combo boxes, so this method is explicitly
applicable to text and combo box form field objects.If this flag is set, then text entered in the form field is not spell-checked.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
Set this parameter to true, if you want to enable the DoNotSpellCheck flag, otherwise set it to false to disable it.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for text fields and editable combo boxes, otherwise it will fail.
How to utilize the DoNotSpellCheck flag when creating different text form fields.
Dim caption As String = "Example: SetFormFieldDoNotSpellCheck"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 0.5F, 2, "Name") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 0.5F, 4, "Address") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(3.5F, 1, 6, 1, "Name", "", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotScroll(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
formID = gdpicturePDF.AddTextFormField(3.5F, 3, 6, 2, "Address", "", True, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotScroll(formID, False) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldDoNotSpellCheck";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 0.5f, 2, "Name") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 0.5f, 4, "Address") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(3.5f, 1, 6, 1, "Name", "", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotScroll(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
formID = gdpicturePDF.AddTextFormField(3.5f, 3, 6, 2, "Address", "", true, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotScroll(formID, false) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldTextAlignment(formID, TextAlignment.TextAlignmentNear) != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns, if the DoNotSpellCheck flag of a required form field, hereabout a text field or an editable combo box, is set. The required form field
object is specified by its unique form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text
fields and editable combo boxes, so this method is explicitly applicable to text and combo box form field objects.
If this flag is set, then text entered in the form field is not spell-checked.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for text fields and editable combo boxes, otherwise it will fail.
true if the DoNotSpellCheck flag of the specified form field is set, otherwise false. The method can be subsequently used to determine if this
method has been successful.
How to determine if the DoNotSpellCheck flag is set for the text form fields in the current document.
Dim caption As String = "Example: GetFormFieldDoNotSpellCheck"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldDoNotSpellCheck() method.
If gdpicturePDF.LoadFromFile("forms_textfield.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
If count = 0 Then message = "This document does not contain any forms."
Dim formID As Integer = 0, j As Integer = 0
Dim scroll As Boolean = False, spell As Boolean = False, multiline As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
j += 1
message = message + j.ToString() + ".text field:" + vbCrLf
scroll = gdpicturePDF.GetFormFieldDoNotScroll(formID)
message = message + " DoNotScroll = "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + scroll.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
spell = gdpicturePDF.GetFormFieldDoNotSpellCheck(formID)
message = message + " DoNotSpellCheck = "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + spell.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
multiline = gdpicturePDF.GetFormFieldMultiLine(formID)
message = message + " MultiLine = "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + multiline.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldDoNotSpellCheck";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldDoNotSpellCheck() method.
if (gdpicturePDF.LoadFromFile("forms_textfield.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
if (count == 0)
message = "This document does not contain any forms.";
int formID = 0, j = 0;
bool scroll = false, spell = false, multiline = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
j++;
message = message + j.ToString() + ".text field:\n";
scroll = gdpicturePDF.GetFormFieldDoNotScroll(formID);
message = message + " DoNotScroll = ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + scroll.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
spell = gdpicturePDF.GetFormFieldDoNotSpellCheck(formID);
message = message + " DoNotSpellCheck = ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + spell.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
multiline = gdpicturePDF.GetFormFieldMultiLine(formID);
message = message + " MultiLine = ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + multiline.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
}
else
{
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the FileSelect flag of a required form field, here a text field, that is specified by its unique form field's identifier and it is related to the
currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly applicable to text form field objects.
If this flag is set, then the text entered in the text field represents the pathname of a file whose content are to be submitted as the value of the text
field. By submission it is meant the use of the submit-form action, unfortunately the GdPicturePDF doesn't support this feature yet. The current
value of the specified text field always represents the text entered in this field, please do not confuse it with the content of the
file, whose pathname represents the text field value.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to enable the FileSelect flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
Likewise, be aware that the GdPicturePDF class doesn't support the submit-form action yet.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify that the newly added text form field is used for file selection.
Dim caption As String = "Example: SetFormFieldFileSelect"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 1, "Enter filename") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(1, 1.5F, 10, 1, "Filename", "", False, fontResName, 14, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotScroll(formID, False) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFileSelect(formID, True) <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFileSelect";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 1, "Enter filename") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(1, 1.5f, 10, 1, "Filename", "", false, fontResName, 14, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotScroll(formID, false) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDoNotSpellCheck(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFileSelect(formID, true) != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The SetTextSize()/DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns, if the FileSelect flag of a required form field, here a text field, is set. The text field is specified by its unique form field's
identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly
applicable to text form field objects.
If this flag is set, then the text entered in the text field represents the pathname of a file whose content are to be submitted as the value of the text
field. By submission it is meant the use of the submit-form action, unfortunately the GdPicturePDF doesn't support this feature yet. The current value of the
specified text field always represents the text entered in this field, please do not confuse it with the content of the file, whose
pathname represents the text field value.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail.
Likewise, be aware that the GdPicturePDF class doesn't support the submit-form action yet.
true if the FileSelect flag of the specified text field is set, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to find out if the text field is used for file selection and how to subsequently find out the name of the file to submit.
Dim caption As String = "Example: GetFormFieldFileSelect"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
If count > 0 Then message = message + "These text fields are set for file selection:" + vbCrLf
Dim formID As Integer = 0
Dim value As String = "", name As String = ""
Dim fileSelect As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString()
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
fileSelect = gdpicturePDF.GetFormFieldFileSelect(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If fileSelect Then
message = message + ". field named "
name = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + name
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + " - file to be submitted: "
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
End If
Else
message = message + "GetFormFieldFileSelect failed: " + gdpicturePDF.GetStat().ToString()
End If
End If
Else
message = message + "GetFormFieldType failed: " + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldFileSelect";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
if (count > 0)
message = message + "These text fields are set for file selection:\n";
int formID = 0;
string value = "", name = "";
bool fileSelect = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString();
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
fileSelect = gdpicturePDF.GetFormFieldFileSelect(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (fileSelect)
{
message = message + ". field named ";
name = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + name;
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + " - file to be submitted: ";
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
}
}
else
message = message + "GetFormFieldFileSelect failed: " + gdpicturePDF.GetStat().ToString();
}
}
else
message = message + "GetFormFieldType failed: " + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the Comb flag of a required form field, here a text field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitely applicable
to text form field objects.
If this flag is set, then the text field is automatically divided into as many equally spaced positions, or combs, as the value of maximum length of the
field's text defines, and the text is laid out into those combs. This flag is meaningful only if the MaxLen attribute is defined for the text form field
and if the Multiline, Password, and FileSelect flags are not set.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to enable the Comb flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail. Likewise, be careful about constraints when using this method,
please refer to the Summary section above.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize the Comb flag for the newly added text form fields, which represent the different postal codes.
Dim caption As String = "Example: SetFormFieldComb"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 2, "GER") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 4, "FRA") = GdPictureStatus.OK) Then
Dim formID As Integer = gdpicturePDF.AddTextFormField(3, 1, 3, 1, "GER-PostalCode", "12345", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldMaxLen(formID, 5) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldComb(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDefaultValue(formID, "00000") <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
formID = gdpicturePDF.AddTextFormField(3, 3, 3, 1, "FRA-PostalCode", "1234", False, fontResName, 20, 165, 42, 42)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldMaxLen(formID, 4) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldComb(formID, True) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldDefaultValue(formID, "0000") <> GdPictureStatus.OK) Then
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_textfield.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldComb";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 2, "GER") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 4, "FRA") == GdPictureStatus.OK))
{
int formID = gdpicturePDF.AddTextFormField(3, 1, 3, 1, "GER-PostalCode", "12345", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldMaxLen(formID, 5) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldComb(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDefaultValue(formID, "00000") != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
formID = gdpicturePDF.AddTextFormField(3, 3, 3, 1, "FRA-PostalCode", "1234", false, fontResName, 20, 165, 42, 42);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 255, 69, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldMaxLen(formID, 4) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldComb(formID, true) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldDefaultValue(formID, "0000") != GdPictureStatus.OK))
{
MessageBox.Show("Setting properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The AddTextFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_textfield.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("Drawing text has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns, if the Comb flag of a required form field, here a text field, is set. The text field is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. As stated, this flag is only specific to text fields, so this method is explicitly applicable to text
form field objects.
If this flag is set, then the text field is automatically divided into as many equally spaced positions, or combs, as the value of maximum length of the
field's text defines, and the text is laid out into those combs. This flag is meaningful only if the MaxLen attribute is defined for the text form field
and if the Multiline, Password, and FileSelect flags are not set.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that this method is only meaningful for text fields, otherwise it will fail. Likewise, be careful about constraints when using this method,
please refer to the Summary section above.
true if the Comb flag of the specified text field is set, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to utilize the Comb flag to check the input values of the text form fields, which represent the different postal codes.
Dim caption As String = "Example: GetFormFieldComb"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the SetFormFieldComb() method.
If gdpicturePDF.LoadFromFile("forms_textfield.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "", value As String = ""
If count = 0 Then message = "This document does not contain any forms."
Dim formID As Integer = 0, maxLen As Integer = 0, j As Integer = 0
Dim comb As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
j += 1
comb = gdpicturePDF.GetFormFieldComb(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
maxLen = gdpicturePDF.GetFormFieldMaxLen(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If comb Then
If (value.Length = maxLen) AndAlso (Not value.Contains(" ")) Then
message = message + "The " + j.ToString() + ".text field holds the CORRECT value = " + value + vbCrLf
Else
message = message + "The " + j.ToString() + ".text field holds the INCORRECT value = " + value + vbCrLf
End If
Else
message = message + "The " + j.ToString() + ".text field has not set the Comb flag. Its value is " + value + "." + vbCrLf
End If
Else
message = message + "The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldMaxLen() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldComb() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldComb";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the SetFormFieldComb() method.
if (gdpicturePDF.LoadFromFile("forms_textfield.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "", value = "";
if (count == 0)
message = "This document does not contain any forms.";
int formID = 0, maxLen = 0, j = 0;
bool comb = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
j++;
comb = gdpicturePDF.GetFormFieldComb(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
maxLen = gdpicturePDF.GetFormFieldMaxLen(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (comb)
{
if ((value.Length == maxLen) && (!value.Contains(" ")))
message = message + "The " + j.ToString() + ".text field holds the CORRECT value = " + value + "\n";
else
message = message + "The " + j.ToString() + ".text field holds the INCORRECT value = " + value + "\n";
}
else
{
message = message + "The " + j.ToString() + ".text field has not set the Comb flag. Its value is " + value + ".\n";
}
}
else
{
message = message + "The GetFormFieldValue() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldMaxLen() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldComb() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
}
else
{
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the Sort flag of a required form field, hereabout a choice field. The required form field is specified by its unique form field's
identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to choice fields, so this method is explicitly
applicable to combo box and list box form field objects.
If this flag is set, the field's items should be sorted alphabetically. Be aware that this flag is only bear in mind when creating or processing
forms within applications, not by PDF viewer. Viewers should simply display the options in the order in which the corresponding items are added in the form field.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
Set this parameter to true, if you want to enable the Sort flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is only meaningful for choice form fields, that means for combo boxes or list boxes, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the Sort flag for all list boxes in the current document.
Dim caption As String = "Example: SetFormFieldItemSort"
Dim save As Boolean = False
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document includes no form fields.", caption)
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeList Then
If (gdpicturePDF.SetFormFieldItemSort(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMultiSelect(formID, True) = GdPictureStatus.OK) Then
save = True
Else
MessageBox.Show("The SetFormFieldItemSort()/SetFormFieldMultiSelect() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If save Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("This document includes no list boxes. The file has not been changed and has not been saved as well.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldItemSort";
bool save = false;
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeList)
{
if ((gdpicturePDF.SetFormFieldItemSort(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMultiSelect(formID, true) == GdPictureStatus.OK))
{
save = true;
}
else
{
MessageBox.Show("The SetFormFieldItemSort()/SetFormFieldMultiSelect() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (save)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("This document includes no list boxes. The file has not been changed and has not been saved as well.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Returns, if the Sort flag of a required form field, hereabout a choice field, is set. The required form field is specified by its unique form field's
identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to choice fields, so this method is explicitly
applicable to combo box and list box form field objects.
If this flag is set, the field's items should be sorted alphabetically. Be aware that this flag is only bear in mind when creating or processing
forms within applications, not by PDF viewer. Viewers should simply display the options in the order in which the corresponding items are added in the form field.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for choice form fields, that means for combo boxes or list boxes, otherwise it will fail.
true if the Sort flag of the specified choice form field is set, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to determine those choice form fields, which items are sorted internally.
Dim caption As String = "Example: GetFormFieldItemSort"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document includes no form fields.", caption)
Else
Dim sorted As String = "Sorted choice form fields:" + vbCrLf, title As String = ""
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim sort As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeList Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
sort = gdpicturePDF.GetFormFieldItemSort(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetFormFieldItemSort() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
If sort Then sorted = sorted + title + "; "
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then MessageBox.Show(sorted, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldItemSort";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
else
{
string sorted = "Sorted choice form fields:\n", title = "";
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool sort = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((type == PdfFormFieldType.PdfFormFieldTypeList) ||
(type == PdfFormFieldType.PdfFormFieldTypeCombo))
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
sort = gdpicturePDF.GetFormFieldItemSort(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldItemSort() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
if (sort)
sorted = sorted + title + "; ";
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show(sorted, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Sets the CommitOnSelChange flag of a required form field, hereabout a choice field. The required form field is specified by its unique
form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to choice fields, so this method is
explicitly applicable to combo box and list box form field objects.
If this flag set, the new value is committed as soon as a selection is made with the pointing device. This option enables applications to perform an action
once a selection is made, without requiring the user to exit the field. If this flag is not set, the new value is not committed until the user exits the field.
Be aware that it is only allowed to set this flag if the MultiSelect flag is not set for a list box, otherwise the method will fail.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , , or .
Set this parameter to true, if you want to enable the CommitOnSelChange flag, otherwise set it to false to disable it.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is only meaningful for choice form fields, that means for combo boxes or list boxes, otherwise it will fail.
It is also not allowed to set this flag if the MultiSelect flag is set for a list box and vice versa.
How to set the CommitOnSelChange flag to all combo boxes in the current document.
Dim caption As String = "Example: SetFormFieldItemCommit"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document includes no form fields.", caption)
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim save As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCombo Then
If (gdpicturePDF.SetFormFieldItemEdit(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldItemCommit(formID, True) = GdPictureStatus.OK) Then
save = True
Else
MessageBox.Show("The SetFormFieldItemEdit()/SetFormFieldItemCommit() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If save Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("This document includes no combo boxes. The file has not been changed and has not been saved as well.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldItemCommit";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool save = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCombo)
{
if ((gdpicturePDF.SetFormFieldItemEdit(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldItemCommit(formID, true) == GdPictureStatus.OK))
{
save = true;
}
else
{
MessageBox.Show("The SetFormFieldItemEdit()/SetFormFieldItemCommit() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (save)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("This document includes no combo boxes. The file has not been changed and has not been saved as well.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Returns, if the CommitOnSelChange flag of a required form field, hereabout a choice field, is set. The required form field is specified by its unique
form field's identifier and it is related to the currently loaded PDF document. As stated, this flag is only specific to choice fields, so this method is
explicitly applicable to combo box and list box form field objects.
If this flag set, the new value is committed as soon as a selection is made with the pointing device. This option enables applications to perform an action
once a selection is made, without requiring the user to exit the field. If this flag is not set, the new value is not committed until the user exits the field.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for choice form fields, that means for combo boxes or list boxes, otherwise it will fail.
true if the CommitOnSelChange flag of the specified choice form field is set, otherwise false. The method can be subsequently used to determine
if this method has been successful.
How to determine, which combo boxes have the CommitOnSelChange flag set in the current document.
Dim caption As String = "Example: GetFormFieldItemCommit"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document includes no form fields.", caption)
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim edit As Boolean = False, commit As Boolean = False
Dim title As String = "", editM As String = "Editable combo boxes:" + vbCrLf, commitM As String = "Combo boxes with CommitOnSelChange flag:" + vbCrLf
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCombo Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) Then
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
edit = gdpicturePDF.GetFormFieldItemEdit(formID)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) Then
MessageBox.Show("The GetFormFieldItemEdit() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
commit = gdpicturePDF.GetFormFieldItemCommit(formID)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) Then
MessageBox.Show("The GetFormFieldItemCommit() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
If (edit) Then editM = editM + title + "; "
If (commit) Then commitM = commitM + title + "; "
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then MessageBox.Show(editM + vbCrLf + commitM, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldItemCommit";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool edit = false, commit = false;
string title = "", editM = "Editable combo boxes:\n", commitM = "Combo boxes with CommitOnSelChange flag:\n";
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCombo)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
edit = gdpicturePDF.GetFormFieldItemEdit(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldItemEdit() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
commit = gdpicturePDF.GetFormFieldItemCommit(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldItemCommit() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
if (edit) editM = editM + title + "; ";
if (commit) commitM = commitM + title + "; ";
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK) MessageBox.Show(editM + "\n" + commitM, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Sets the MultiSelect flag of a required form field, here a list box, that is specified by its unique form field's identifier and it is related to the
currently loaded PDF document. As stated, this flag is only specific to list boxes, so this method is explicitly applicable to list box form field objects.
If this flag is set, more than one of the field's items may be selected simultaneously, if this flag is not set, no more than one item may be selected.
If you set this flag to false when it has been previously set to true, the current selection is removed and the last item in the list box is selected by default.
Be aware that it is only allowed to set this flag if the CommitOnSelChange flag is not set for a list box, otherwise the method will fail.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to enable the MultiSelect flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is only meaningful for list boxes, otherwise it will fail. It is also not allowed to set this flag to true
if the CommitOnSelChange flag is already defined for a required list box and vice versa.
Be aware that it is not possible to specify multiple items to be selected as the default value of a list box that supports multiple selections.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the MultiSelect flag for all list boxes in the current document.
Dim caption As String = "Example: SetFormFieldMultiSelect"
Dim save As Boolean = False
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document includes no form fields.", caption)
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeList Then
If (gdpicturePDF.SetFormFieldItemSort(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldMultiSelect(formID, True) = GdPictureStatus.OK) Then
save = True
Else
MessageBox.Show("The SetFormFieldItemSort()/SetFormFieldMultiSelect() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If save Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("This document includes no list boxes. The file has not been changed and has not been saved as well.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldMultiSelect";
bool save = false;
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeList)
{
if ((gdpicturePDF.SetFormFieldItemSort(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldMultiSelect(formID, true) == GdPictureStatus.OK))
{
save = true;
}
else
{
MessageBox.Show("The SetFormFieldItemSort()/SetFormFieldMultiSelect() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (save)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("This document includes no list boxes. The file has not been changed and has not been saved as well.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Returns, if the MultiSelect flag of a required form field, here a list box, is set. The list box is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. As stated, this flag is only specific to list boxes, so this method is explicitly applicable to list box form field objects.
If this flag is set, more than one of the field's items may be selected simultaneously, if this flag is not set, no more than one item may be selected.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for list boxes, otherwise it will fail.
true if the MultiSelect flag of the specified choice form field is set, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to determine those list boxes, which allow multiselection.
Dim caption As String = "Example: GetFormFieldMultiSelect"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document includes no form fields.", caption)
Else
Dim sorted As String = "Sorted:" + vbCrLf, selected As String = "Multiselected:" + vbCrLf, title As String = ""
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim multi As Boolean = False, sort As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeList Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
sort = gdpicturePDF.GetFormFieldItemSort(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetFormFieldItemSort() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
If sort Then sorted = sorted + title + "; "
multi = gdpicturePDF.GetFormFieldMultiSelect(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The GetFormFieldMultiSelect() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
If multi Then selected = selected + title + "; "
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = sorted + vbCrLf + selected
MessageBox.Show(message, caption)
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldMultiSelect";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
else
{
string sorted = "Sorted:\n", selected = "Multiselected:\n", title = "";
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool multi = false, sort = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeList)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
sort = gdpicturePDF.GetFormFieldItemSort(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldItemSort() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
if (sort)
sorted = sorted + title + "; ";
multi = gdpicturePDF.GetFormFieldMultiSelect(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldMultiSelect() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
if (multi)
selected = selected + title + "; ";
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = sorted + "\n" + selected;
MessageBox.Show(message, caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Sets the Edit flag of a required form field, here a combo box, that is specified by its unique form field's identifier and it is related to the
currently loaded PDF document. As stated, this flag is only specific to combo boxes, so this method is explicitly applicable to combo box form field objects.
If this flag is set, the combo box includes an editable text box as well as a drop-down list, if this flag is not set, the combo box includes only a
drop-down list. In other words, if the flag is set, the combo box is editable and allows to enter custom text.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
Set this parameter to true, if you want to enable the Edit flag, otherwise set it to false to disable it.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that this method is only meaningful for combo boxes, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change all combo boxes in the current document to be editable.
Dim caption As String = "Example: SetFormFieldItemEdit"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document includes no form fields.", caption)
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim save As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCombo Then
If (gdpicturePDF.SetFormFieldItemEdit(formID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldItemCommit(formID, True) = GdPictureStatus.OK) Then
save = True
Else
MessageBox.Show("The SetFormFieldItemEdit()/SetFormFieldItemCommit() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If save Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("This document includes no combo boxes. The file has not been changed and has not been saved as well.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldItemEdit";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool save = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCombo)
{
if ((gdpicturePDF.SetFormFieldItemEdit(formID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldItemCommit(formID, true) == GdPictureStatus.OK))
{
save = true;
}
else
{
MessageBox.Show("The SetFormFieldItemEdit()/SetFormFieldItemCommit() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (save)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("This document includes no combo boxes. The file has not been changed and has not been saved as well.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Returns, if the Edit flag of a required form field, here a combo box, is set. The combo box field is specified by its unique form field's identifier and
it is related to the currently loaded PDF document. As stated, this flag is only specific to combo boxes, so this method is explicitly applicable to combo box form field objects.
If this flag is set, the combo box includes an editable text box as well as a drop-down list, if this flag is not set, the combo box includes only a
drop-down list. In other words, if the flag is set, the combo box is editable and allows to enter custom text.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that this method is only meaningful for combo boxes, otherwise it will fail.
true if the Edit flag of the specified combo box field is set, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to determine, which combo boxes are editable in the current document.
Dim caption As String = "Example: GetFormFieldItemEdit"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document includes no form fields.", caption)
Else
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim edit As Boolean = False, commit As Boolean = False
Dim title As String = "", editM As String = "Editable combo boxes:" + vbCrLf, commitM As String = "Combo boxes with CommitOnSelChange flag:" + vbCrLf
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeCombo Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) Then
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
edit = gdpicturePDF.GetFormFieldItemEdit(formID)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) Then
MessageBox.Show("The GetFormFieldItemEdit() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
commit = gdpicturePDF.GetFormFieldItemCommit(formID)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) Then
MessageBox.Show("The GetFormFieldItemCommit() method has failed with the status: " + gdpicturePDF.GetStat().ToString())
Exit For
End If
If (edit) Then editM = editM + title + "; "
If (commit) Then commitM = commitM + title + "; "
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then MessageBox.Show(editM + vbCrLf + commitM, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldItemEdit";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document includes no form fields.", caption);
else
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool edit = false, commit = false;
string title = "", editM = "Editable combo boxes:\n", commitM = "Combo boxes with CommitOnSelChange flag:\n";
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeCombo)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldTitle() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
edit = gdpicturePDF.GetFormFieldItemEdit(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldItemEdit() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
commit = gdpicturePDF.GetFormFieldItemCommit(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
MessageBox.Show("The GetFormFieldItemCommit() method has failed with the status: " + gdpicturePDF.GetStat().ToString());
break;
}
if (edit) editM = editM + title + "; ";
if (commit) commitM = commitM + title + "; ";
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK) MessageBox.Show(editM + "\n" + commitM, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Sets the color used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier and it is related
to the currently loaded PDF document. The usage of this attribute is not restricted to any form fields, even if the form field's appearance doesn't display text.
In other words, you are allowed to set the color of the checkmark in a required form field using this method.
For further assistance, please refer to the c.
This method uses the RGB color space for specifying the required color.
Sets the color used to display text or the checkmark in a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the font color for all text fields in the currently loaded PDF document.
Dim caption As String = "Example: SetFormFieldFontColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
If gdpicturePDF.SetFormFieldFontColor(formID, 210, 105, 30) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldFontColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFontColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
if (gdpicturePDF.SetFormFieldFontColor(formID, 210, 105, 30) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldFontColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the color used to display the checkmark in a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The usage of this attribute is not restricted to any form fields. In other words, you are allowed to set the color of the checkmark for every single child radio button
in a group using this method. Please note that every single child radio button in a group of radio buttons within a radio button field can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".This method uses the RGB color space for specifying the required color.
Sets the color used to display text or the checkmark in a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
That said, every single child radio button in a group can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set different font attributes to single child radio buttons. These attributes are used to display the checkmark in the buttons.
Dim caption As String = "Example: SetFormFieldFontColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 0) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String(2) {"RED", "GREEN", "BLUE"}
Dim backColors1 As Byte()() = New Byte(2)() {New Byte(2) {255, 0, 0}, New Byte(2) {0, 128, 0}, New Byte(2) {0, 0, 255}}
Dim fontColors1 As Byte()() = New Byte(2)() {New Byte(2) {255, 182, 193}, New Byte(2) {144, 238, 144}, New Byte(2) {173, 216, 230}}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName & (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 255, 255, 255)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1(i)(0), backColors1(i)(1), backColors1(i)(2)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors1(i)(0), fontColors1(i)(1), fontColors1(i)(2)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For 'stop creating anything
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String(3) {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
Dim fontColors2 As Byte()() = New Byte(3)() {New Byte(2) {0, 255, 255}, New Byte(2) {255, 0, 255}, New Byte(2) {255, 255, 0}, New Byte(2) {0, 0, 0}}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName & (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 255, 255, 255)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 245, 245, 245) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, fontColors2(i)(0), fontColors2(i)(1), fontColors2(i)(2)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors2(i)(0), fontColors2(i)(1), fontColors2(i)(2)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For 'stop creating anything
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show(vbCrLf + "The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show(vbCrLf + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFontColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 0) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[3] { "RED", "GREEN", "BLUE" };
byte[][] backColors1 = new byte[3][] { new byte[3] { 255, 0, 0 }, new byte[3] { 0, 128, 0}, new byte[3] { 0, 0, 255} };
byte[][] fontColors1 = new byte[3][] { new byte[3] { 255, 182, 193}, new byte[3] { 144, 238, 144}, new byte[3] { 173, 216, 230} };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 255, 255, 255);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1[i][0], backColors1[i][1], backColors1[i][2]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 165, 42, 42) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors1[i][0], fontColors1[i][1], fontColors1[i][2]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[4] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
byte[][] fontColors2 = new byte[4][] { new byte[3] { 0, 255, 255}, new byte[3] { 255, 0, 255}, new byte[3] { 255, 255, 0}, new byte[3] { 0, 0, 0} };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 255, 255, 255);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 245, 245, 245) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, fontColors2[i][0], fontColors2[i][1], fontColors2[i][2]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors2[i][0], fontColors2[i][1], fontColors2[i][2]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the color used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier and it is related
to the currently loaded PDF document. The usage of this attribute is not restricted to any form fields, even if the form field's appearance doesn't display text.
In other words, you are allowed to set the color of the checkmark in a required form field using this method.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".This method uses the CMYK color space for specifying the required color.
Sets the color used to display text or the checkmark in a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color. Use the value between 0 and 255.
The amount of black color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the font color for all text fields in the currently loaded PDF document.
Dim caption As String = "Example: SetFormFieldFontColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
If gdpicturePDF.SetFormFieldFontColor(formID, 45, 150, 225, 45) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldFontColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFontColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
if (gdpicturePDF.SetFormFieldFontColor(formID, 45, 150, 225, 45) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldFontColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the color used to display the checkmark in a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The usage of this attribute is not restricted to any form fields. In other words, you are allowed to set the color of the checkmark for every single child radio button
in a group using this method. Please note that every single child radio button in a group of radio buttons within a radio button field can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".This method uses the CMYK color space for specifying the required color.
Sets the color used to display text or the checkmark in a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color. Use the value between 0 and 255.
The amount of black color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
That said, every single child radio button in a group can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set different font attributes to single child radio buttons. These attributes are used to display the checkmark in the buttons.
Dim caption As String = "Example: SetFormFieldFontColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 255, 255, 255) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String(2) {"RED", "GREEN", "BLUE"}
Dim backColors1 As Byte()() = New Byte(2)() {New Byte(3) {0, 255, 255, 0}, New Byte(3) {255, 127, 255, 127}, New Byte(3) {255, 255, 0, 0}}
Dim fontColors1 As Byte()() = New Byte(2)() {New Byte(3) {0, 73, 62, 0}, New Byte(3) {111, 17, 111, 17}, New Byte(3) {82, 39, 25, 25}}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName & (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 0, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1(i)(0), backColors1(i)(1), backColors1(i)(2), backColors1(i)(3)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 213, 213, 90) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors1(i)(0), fontColors1(i)(1), fontColors1(i)(2), fontColors1(i)(3)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For 'stop creating anything
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String(3) {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
Dim fontColors2 As Byte()() = New Byte(3)() {New Byte(3) {255, 0, 0, 0}, New Byte(3) {0, 255, 0, 0}, New Byte(3) {0, 0, 255, 0}, New Byte(3) {255, 255, 255, 255}}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName & (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 0, 0, 0, 0)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 10, 10, 10, 10) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, fontColors2(i)(0), fontColors2(i)(1), fontColors2(i)(2), fontColors2(i)(3)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors2(i)(0), fontColors2(i)(1), fontColors2(i)(2), fontColors2(i)(3)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For 'stop creating anything
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show(vbCrLf + "The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show(vbCrLf + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFontColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 255, 255, 255) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[3] { "RED", "GREEN", "BLUE" };
byte[][] backColors1 = new byte[3][] { new byte[4] { 0, 255, 255, 0 }, new byte[4] { 255, 127, 255, 127 }, new byte[4] { 255, 255, 0, 0} };
byte[][] fontColors1 = new byte[3][] { new byte[4] { 0, 73, 62, 0}, new byte[4] { 111, 17, 111, 17}, new byte[4] { 82, 39, 25, 25} };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, 0, 0, 0, 0);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1[i][0], backColors1[i][1], backColors1[i][2], backColors1[i][3]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, 90, 213, 213, 90) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors1[i][0], fontColors1[i][1], fontColors1[i][2], fontColors1[i][3]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[4] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
byte[][] fontColors2 = new byte[4][] { new byte[4] { 255, 0, 0, 0}, new byte[4] { 0, 255, 0, 0}, new byte[4] { 0, 0, 255, 0}, new byte[4] { 255, 255, 255, 255} };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, 0, 0, 0, 0);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 10, 10, 10, 10) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, fontColors2[i][0], fontColors2[i][1], fontColors2[i][2], fontColors2[i][3]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors2[i][0], fontColors2[i][1], fontColors2[i][2], fontColors2[i][3]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the color used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier and it is related
to the currently loaded PDF document. The usage of this attribute is not restricted to any form fields, even if the form field's appearance doesn't display text.
In other words, you are allowed to set the color of the checkmark in a required form field using this method.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".This method uses the RGB color space for specifying the required color.
Sets the color used to display text or the checkmark in a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A color object that defines the new color to be used for displaying text or the checkmark in a specified form field.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the font color for all text fields in the currently loaded PDF document.
Dim caption As String = "Example: SetFormFieldFontColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeText Then
If gdpicturePDF.SetFormFieldFontColor(formID, Color.Chocolate) <> GdPictureStatus.OK Then
MessageBox.Show("The SetFormFieldFontColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption)
End If
End If
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFontColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeText)
{
if (gdpicturePDF.SetFormFieldFontColor(formID, Color.Chocolate) != GdPictureStatus.OK)
{
MessageBox.Show("The SetFormFieldFontColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This file doesn't include forms.", caption);
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption);
}
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the color used to display the checkmark in a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The usage of this attribute is not restricted to any form fields. In other words, you are allowed to set the color of the checkmark for every single child radio button
in a group using this method. Please note that every single child radio button in a group of radio buttons within a radio button field can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".This method uses the RGB color space for specifying the required color.
Sets the color used to display text or the checkmark in a required form field specified by its unique form field's identifier related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
A color object that defines the new color to be used for displaying checkmark in a specified child radio button in a group.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
That said, every single child radio button in a group can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set different font attributes to single child radio buttons. These attributes are used to display the checkmark in the buttons.
Dim caption As String = "Example: SetFormFieldFontColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Black) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String(2) {"RED", "GREEN", "BLUE"}
Dim backColors1 As Color() = New Color(2) {Color.Red, Color.Green, Color.Blue}
Dim fontColors1 As Color() = New Color(2) {Color.LightPink, Color.LightGreen, Color.LightBlue}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.White)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors1(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For 'stop creating anything
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String(3) {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
Dim fontColors2 As Color() = New Color(3) {Color.Cyan, Color.Magenta, Color.Yellow, Color.Black}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, Color.White)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.WhiteSmoke) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, fontColors2(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors2(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For 'stop creating anything
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show(vbCrLf + "The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show(vbCrLf + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFontColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Black) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[3] { "RED", "GREEN", "BLUE" };
Color[] backColors1 = new Color[3] { Color.Red, Color.Green, Color.Blue };
Color[] fontColors1 = new Color[3] { Color.LightPink, Color.LightGreen, Color.LightBlue };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.White);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors1[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[4] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
Color[] fontColors2 = new Color[4] { Color.Cyan, Color.Magenta, Color.Yellow, Color.Black };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, Color.White);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.WhiteSmoke) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, fontColors2[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors2[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the size, in points, of the font used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. The usage of this attribute is not restricted to any form fields, even if the form field's appearance doesn't display text.
In other words, you are allowed to set the size of the checkmark in a required form field using this method.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Sets the size, in points, of the font used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The new size of the defined font or the new size of the checkmark, in points, for displayed text or for the displayed checkmark in the form field.
A zero value means that the font or the checkmark is to be autosized within the form field's rectangle.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Likewise, only to remind you, that 1 point = 1/72 inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the font and its size, which is used to display the push button's caption for all push buttons in the current document.
Dim caption As String = "Example: SetFormFieldFontSize"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
GoTo finish
End If
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim found As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypePushButton Then
If (gdpicturePDF.SetFormFieldFontResName(formID, fontResName) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldFontSize(formID, 24) = GdPictureStatus.OK) Then
found = True
Else
MessageBox.Show("The SetFormFieldFontResName() method or the SetFormFieldFontSize() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If found Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("This file doesn't include push buttons, so it has not been saved.", caption)
End If
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
finish:
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFontSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
{
MessageBox.Show("This file doesn't include forms.", caption);
goto finish;
}
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool found = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypePushButton)
{
if ((gdpicturePDF.SetFormFieldFontResName(formID, fontResName) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldFontSize(formID, 24) == GdPictureStatus.OK))
{
found = true;
}
else
{
MessageBox.Show("The SetFormFieldFontResName() method or the SetFormFieldFontSize() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (found)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption);
}
else
MessageBox.Show("This file doesn't include push buttons, so it has not been saved.", caption);
}
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
finish:
gdpicturePDF.Dispose();
Sets the size, in points, used to display the checkmark in a required form field, here a child radio button in a group. The radio button group is specified
by its unique form field's identifier and it is related to the currently loaded PDF document. As said, this method is only applicable to radio buttons.
The usage of this attribute is not restricted to any form fields. In other words, you are allowed to set the size of the checkmark for every single child radio button
in a group using this method. Please note that every single child radio button in a group of radio buttons within a radio button field can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
Sets the size, in points, of the font used to display text or the checkmark in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document.
A unique form field identifier specifying a required form field object. You can obtain this identifier using
these methods: , or .
The index of the required child radio button in a group. It must be a value from 0 to -1.
It is simply a sequence index of a radio button in a group, it does not correspond to the unique form field's identifier.
The new size of the displayed checkmark, in points, for a required child radio button in a group.
A zero value means that the checkmark is to be autosized within the form field's rectangle.
This method is only allowed for use with non-encrypted documents. At the same, this method is only meaningful for radio buttons, otherwise it will fail.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default.
That said, every single child radio button in a group can have its own font attributes as well.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".Likewise, only to remind you, that 1 point = 1/72 inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set different font attributes to single child radio buttons. These attributes are used to display the checkmark in the buttons.
Dim caption As String = "Example: SetFormFieldFontSize"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Black) = GdPictureStatus.OK) Then
Dim formID As Integer = 0
Dim buttonName As String = "RadioButton"
'Creating the first group of radio buttons.
If gdpicturePDF.DrawRectangle(0.5F, 0.5F, 4, 4, False, True) = GdPictureStatus.OK Then
Dim colors1 As String() = New String(2) {"RED", "GREEN", "BLUE"}
Dim backColors1 As Color() = New Color(2) {Color.Red, Color.Green, Color.Blue}
Dim fontColors1 As Color() = New Color(2) {Color.LightPink, Color.LightGreen, Color.LightBlue}
For i As Integer = 0 To colors1.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.White)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors1(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 2.5F, 1.65F + i, colors1(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For 'stop creating anything
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Creating the second group of radio buttons.
If gdpicturePDF.DrawRectangle(5.5F, 0.5F, 5, 5, False, True) = GdPictureStatus.OK Then
Dim colors2 As String() = New String(3) {"CYAN", "MAGENTA", "YELLOW", "BLACK"}
Dim fontColors2 As Color() = New Color(3) {Color.Cyan, Color.Magenta, Color.Yellow, Color.Black}
For i As Integer = 0 To colors2.Length - 1
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, Color.White)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.WhiteSmoke) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, fontColors2(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors2(i)) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 7.5F, 1.65F + i, colors2(i)) <> GdPictureStatus.OK) Then
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For 'stop creating anything
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("forms_radiobutton.pdf") = GdPictureStatus.OK Then
MessageBox.Show(vbCrLf + "The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show(vbCrLf + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFontSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Black) == GdPictureStatus.OK))
{
int formID = 0;
string buttonName = "RadioButton";
//Creating the first group of radio buttons.
if (gdpicturePDF.DrawRectangle(0.5f, 0.5f, 4, 4, false, true) == GdPictureStatus.OK)
{
string[] colors1 = new string[3] { "RED", "GREEN", "BLUE" };
Color[] backColors1 = new Color[3] { Color.Red, Color.Green, Color.Blue };
Color[] fontColors1 = new Color[3] { Color.LightPink, Color.LightGreen, Color.LightBlue };
for (int i = 0; i < colors1.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(1, 1 + i, 1, 1, "Group1", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleStar, Color.White);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, i, backColors1[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors1[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 2.5f, 1.65f + i, colors1[i]) != GdPictureStatus.OK))
{
MessageBox.Show("1.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Creating the second group of radio buttons.
if (gdpicturePDF.DrawRectangle(5.5f, 0.5f, 5, 5, false, true) == GdPictureStatus.OK)
{
string[] colors2 = new string[4] { "CYAN", "MAGENTA", "YELLOW", "BLACK" };
Color[] fontColors2 = new Color[4] { Color.Cyan, Color.Magenta, Color.Yellow, Color.Black };
for (int i = 0; i < colors2.Length; i++)
{
formID = gdpicturePDF.AddRadioButtonFormField(6, 1 + i, 1, 1, "Group2", buttonName + (i + 1).ToString(), PdfCheckBoxStyle.PdfCheckBoxStyleCircle, Color.White);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.WhiteSmoke) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, fontColors2[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontSize(formID, i, 12 + 4 * i) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldFontColor(formID, i, fontColors2[i]) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 7.5f, 1.65f + i, colors2[i]) != GdPictureStatus.OK))
{
MessageBox.Show("2.group: adding the radio button nr." + (i + 1).ToString() + " has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //stop creating anything
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("forms_radiobutton.pdf") == GdPictureStatus.OK)
MessageBox.Show("\nThe example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("\nThe example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 2.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The 1.DrawRectangle() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() or the SetLineColor() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Sets the resource name of the font used to display text in a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. The usage of this attribute is not restricted to any form fields, even if the form field's appearance doesn't display text.
For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
The new resource name of the font you prefer for displaying text in the form field. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that the attributes representing the font and its resources are defined for all form field objects by default, even if the form field's appearance
doesn't display text. For further assistance, please refer to the PDF Reference, Section "Interactive Forms".
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the font and its size, which is used to display the push button's caption for all push buttons in the current document.
Dim caption As String = "Example: SetFormFieldFontResName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This file doesn't include forms.", caption)
GoTo finish
End If
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim found As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypePushButton Then
If (gdpicturePDF.SetFormFieldFontResName(formID, fontResName) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldFontSize(formID, 24) = GdPictureStatus.OK) Then
found = True
Else
MessageBox.Show("The SetFormFieldFontResName() method or the SetFormFieldFontSize() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If found Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption)
End If
Else
MessageBox.Show("This file doesn't include push buttons, so it has not been saved.", caption)
End If
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
finish:
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldFontResName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
{
MessageBox.Show("This file doesn't include forms.", caption);
goto finish;
}
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool found = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypePushButton)
{
if ((gdpicturePDF.SetFormFieldFontResName(formID, fontResName) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldFontSize(formID, 24) == GdPictureStatus.OK))
{
found = true;
}
else
{
MessageBox.Show("The SetFormFieldFontResName() method or the SetFormFieldFontSize() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (found)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved.", caption);
}
else
MessageBox.Show("This file doesn't include push buttons, so it has not been saved.", caption);
}
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
finish:
gdpicturePDF.Dispose();
Returns the action's unique identifier of the action associated with a form field, that is specified by its unique form field's
identifier and it is related to the currently loaded PDF document. You can subsequently use the method to determine the kind of this action.
At this time it is supported by the toolkit to only associate one action within one form field.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that at this time it is not supported by the toolkit to add multiple actions per one form field.
A unique action identifier of the action associated with a specified form field. The method can be subsequently used to determine if this method has been successful.
You can use the method to obtain the type of this action, as it is shown in the example below.
How to find out the types of actions associated with form fields in the currently loaded PDF document.
Dim caption As String = "Example: GetFormFieldActionID"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim formID As Integer = 0, actionID As Integer = -1
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim actionType As PdfActionType = PdfActionType.ActionTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".field's type: "
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + type + " action: "
actionID = gdpicturePDF.GetFormFieldActionID(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
actionType = gdpicturePDF.GetActionType(actionID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + actionType.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
If count = 0 Then message = "This file doesn't include forms."
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldActionID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int formID = 0, actionID = -1;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
PdfActionType actionType = PdfActionType.ActionTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".field's type: ";
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + type + " action: ";
actionID = gdpicturePDF.GetFormFieldActionID(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
actionType = gdpicturePDF.GetActionType(actionID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + actionType.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n";
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
if (count == 0) message = "This file doesn't include forms.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Associates a specified action (identified with a unique action identifier) with a required form field, that is specified by its unique form field's identifier
and it is related to the currently loaded PDF document. At this time it is supported by the toolkit to only associate one action within one form field.
A unique form field identifier specifying a required form field object. You can obtain this identifier using methods
like , or methods intended to add form fields.
A unique action identifier specifying a required action object. You can obtain this identifier when creating an action, for example,
using the , , , , or methods.
This method is only allowed for use with non-encrypted documents.
Also be aware that at this time it is not supported by the toolkit to add multiple actions per one form field.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to associate an URI action with a newly created push button form field.
Dim caption As String = "Example: SetFormFieldAction"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding a form field.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formID As Integer = gdpicturePDF.AddPushButtonFormField(1, 2, 5, 2, "PushButton_Name", "GO!", fontResName, 20, 255, 69, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim formType As PdfFormFieldType = gdpicturePDF.GetFormFieldType(formID)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) = GdPictureStatus.OK) Then
Dim actionID As Integer = gdpicturePDF.NewActionURI("http://www.gdpicture.com", False)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldAction(formID, actionID) = GdPictureStatus.OK) Then
Dim message As String = "The push button has been created." + vbCrLf + "Type: " + formType.ToString() + " ID: " + formID.ToString()
If gdpicturePDF.SaveToFile("forms_pushbutton.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldAction";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding a form field.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int formID = gdpicturePDF.AddPushButtonFormField(1, 2, 5, 2, "PushButton_Name", "GO!", fontResName, 20, 255, 69, 0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PdfFormFieldType formType = gdpicturePDF.GetFormFieldType(formID);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(formID, 255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(formID, 0, 0, 0) == GdPictureStatus.OK))
{
int actionID = gdpicturePDF.NewActionURI("http://www.gdpicture.com", false);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldAction(formID, actionID) == GdPictureStatus.OK))
{
string message = "The push button has been created.\n" + "Type: " + formType.ToString() + " ID: " + formID.ToString();
if (gdpicturePDF.SaveToFile("forms_pushbutton.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("Creating an action has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting form field properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddPushButtonFormField() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns if the currently loaded PDF document contains XFA form fields.
XFA stands for XML Forms Architecture, which is Adobe’s proprietary XML-based form technology and it has not been standardized in any public specification.
With introducing the first version of PDF 2.0 as ISO-32000-2 published in May 2017, XFA entries have been officially excluded from this specification Therefore this format is
not supported by GdPicturePDF and we will never support it in the future as well.Please note that you may encounter potential rendering problems
when viewing a PDF document with XFA forms using GdPicturePDF. Probably you will see this fallback message introduced by Adobe:
"If this message is not eventually replaced by the proper content of the document, your PDF viewer may not be able to display this type of document."
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please be aware that we do not support this format now and we will never support it in the future as it is not standardized and has been excluded from the PDF Reference.
true if the currently loaded PDF document contains XFA form fields, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to find out if the PDF document contains XFA forms.
Dim caption As String = "Example: HasXFAFormFields"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim hasXFA As Boolean = gdpicturePDF.HasXFAFormFields()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If hasXFA Then
MessageBox.Show("This PDF document contains XFA forms, you may encounter potential rendering problems.", caption)
Else
MessageBox.Show("This PDF document contains NO XFA forms.", caption)
End If
Else
MessageBox.Show("The HasXFAFormFields() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: HasXFAFormFields";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
bool hasXFA = gdpicturePDF.HasXFAFormFields();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (hasXFA)
MessageBox.Show("This PDF document contains XFA forms, you may encounter potential rendering problems.", caption);
else
MessageBox.Show("This PDF document contains NO XFA forms.", caption);
}
else
MessageBox.Show("The HasXFAFormFields() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Removes XFA form fields data resource for all form fields in currently loaded PDF document.
XFA stands for XML Forms Architecture, which is Adobe’s proprietary XML-based form technology and it has not been standardized in any public specification.
With introducing the first version of PDF 2.0 as ISO-32000-2 published in May 2017, XFA entries have been officially excluded from this specification Therefore this format is
not supported by GdPicturePDF and we will never support it in the future as well.Please note that you may encounter potential rendering problems
when viewing a PDF document with XFA forms using GdPicturePDF. Probably you will see this fallback message introduced by Adobe:
"If this message is not eventually replaced by the proper content of the document, your PDF viewer may not be able to display this type of document."
This method is only allowed for use with non-encrypted documents.
This method is useful only in scenarios where the document contains standard AcroForm form fields with additional XFA resource. If the document is purely XFA based document this method will lead to loss of the document contents.
Please be aware that we do not support this format now and we will never support it in the future as it is not standardized and has been excluded from the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
How to find out if the PDF document contains XFA forms and remove the data.
Dim caption As String = "Example: RemoveXFAFormFieldsData"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim hasXFA As Boolean = gdpicturePDF.HasXFAFormFields()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If hasXFA Then
If gdpicturePDF.RemoveXFAFormFieldsData() = GdPictureStatus.OK Then
MessageBox.Show("XFA form fields data has been successfully remove from the document.", caption)
Else
MessageBox.Show("The RemoveXFAFormFieldsData() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("This PDF document contains NO XFA forms.", caption)
End If
Else
MessageBox.Show("The HasXFAFormFields() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveXFAFormFieldsData";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
bool hasXFA = gdpicturePDF.HasXFAFormFields();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (hasXFA)
{
if(gdpicturePDF.RemoveXFAFormFieldsData() == == GdPictureStatus.OK)
{
MessageBox.Show("XFA form fields data has been successfully remove from the document.", caption)
}
else
{
MessageBox.Show("The RemoveXFAFormFieldsData() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("This PDF document contains NO XFA forms.", caption);
}
}
else
MessageBox.Show("The HasXFAFormFields() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Resets, in other words completely removes the current selection of a required form field, here a radio button. That means no child button in a group
of radio buttons within a radio button field stays selected using this method. The radio button group or the child radio button in this group is specified by its unique
form field's identifier and it is related to the currently loaded PDF document. As said, this method is explicitly applicable to radio button form field objects and their child buttons as well.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
You can use either the identifier of the required radio button field or its child button as well.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for radio buttons, both the radio button fields and their children as well, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset all radio buttons in the current document to be not checked by default. All radio buttons are completely unchecked.
Dim caption As String = "Example: ResetFormFieldCheckedState"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, radioButtons As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim isChanged As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
radioButtons += 1
'Removing the current selection for the given radio button completely.
If gdpicturePDF.ResetFormFieldCheckedState(formID) = GdPictureStatus.OK Then
isChanged = True
Else
MessageBox.Show("The ResetFormFieldCheckedState() method failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If radioButtons = 0 Then
message = message + "This document does not contain radio buttons." + vbCrLf
ElseIf Not isChanged Then
message = message + "This document has not been changed."
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ResetFormFieldCheckedState";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, radioButtons = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool isChanged = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
radioButtons++;
//Removing the current selection for the given radio button completely.
if (gdpicturePDF.ResetFormFieldCheckedState(formID) == GdPictureStatus.OK)
isChanged = true;
else
{
MessageBox.Show("The ResetFormFieldCheckedState() method failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (radioButtons == 0) message = message + "This document does not contain radio buttons.\n";
else if (!isChanged) message = message + "This document has not been changed.";
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Resets, in other words completely removes the currently defined default selection of a required form field, here a radio button. That means no child button in a group
of radio buttons within a radio button field stays selected by default using this method. The radio button group or the child radio button in this group is specified by its unique
form field's identifier and it is related to the currently loaded PDF document. As said, this method is explicitly applicable to radio button form field objects and their child buttons as well.
A unique form field identifier specifying a required form field object. You can obtain this identifier
using these methods: , or .
You can use either the identifier of the required radio button field or its child button as well.
This method is only allowed for use with non-encrypted documents.
Just to remind you that this method is only meaningful for radio buttons, both the radio button fields and their children as well, otherwise it will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset all radio buttons in the current document to be not checked by default. All radio buttons are completely unchecked.
Dim caption As String = "Example: ResetFormFieldDefaultCheckedState"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0, childCount As Integer = 0, radioButtons As Integer = 0
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
Dim defChecked As Boolean = False, isChanged As Boolean = False
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
radioButtons += 1
childCount = gdpicturePDF.GetFormFieldChildCount(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For j As Integer = 0 To childCount - 1
defChecked = gdpicturePDF.GetFormFieldDefaultChecked(formID, j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If defChecked Then
'Removing the current default selection for the given radio button completely.
If gdpicturePDF.ResetFormFieldDefaultCheckedState(formID) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ". rb group has been changed successfully." + vbCrLf
isChanged = True
'Removing the current selection for the given radio button completely.
If gdpicturePDF.ResetFormFieldCheckedState(formID) <> GdPictureStatus.OK Then
MessageBox.Show(message + "Something has failed in unchecking buttons with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show(message + "Something has failed in changing default settings with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
'Only one radio button can be checked by default at a time.
Exit For
End If
Else
MessageBox.Show(message + " The GetFormFieldDefaultChecked() method failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Next
Else
MessageBox.Show(message + "The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
End If
Else
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If radioButtons = 0 Then
message = message + "This document does not contain radio buttons." + vbCrLf
ElseIf Not isChanged Then
message = message + "This document has not been changed."
Else
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
message = message + "The example has been followed successfully and the file has been saved."
Else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ResetFormFieldDefaultCheckedState";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0, childCount = 0, radioButtons = 0;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
bool defChecked = false, isChanged = false;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
radioButtons++;
childCount = gdpicturePDF.GetFormFieldChildCount(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int j = 0; j < childCount; j++)
{
defChecked = gdpicturePDF.GetFormFieldDefaultChecked(formID, j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (defChecked)
{
//Removing the current default selection for the given radio button completely.
if (gdpicturePDF.ResetFormFieldDefaultCheckedState(formID) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ". rb group has been changed successfully.\n";
isChanged = true;
//Removing the current selection for the given radio button completely.
if (gdpicturePDF.ResetFormFieldCheckedState(formID) != GdPictureStatus.OK)
MessageBox.Show(message + "Something has failed in unchecking buttons with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show(message + "Something has failed in changing default settings with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break; //Only one radio button can be checked by default at a time.
}
}
else
MessageBox.Show(message + " The GetFormFieldDefaultChecked() method failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show(message + "The GetFormFieldChildCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
}
else
{
MessageBox.Show("The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
break;
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (radioButtons == 0) message = message + "This document does not contain radio buttons.\n";
else if (!isChanged) message = message + "This document has not been changed.";
else
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
message = message + "The example has been followed successfully and the file has been saved.";
else
message = message + "The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
}
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the value of NeedAppearances flag related to interactive form fields, if any are present in the currently loaded PDF document.
Sometimes fields may contain values that are not know until the document is viewed. This flag specifies whether to construct appearance streams
and appearance dictionaries for form fields in the loaded document to properly render the document when viewing.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you, that this flag is only related to interactive form fields, if any are present in the currently loaded PDF document.
Please use the method to force the renderer to construct form fields appearances before viewing.
true if the NeedAppearances flag is set in the form fields dictionary, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to force form fields appearance reconstruction during the rendering process.
Dim caption As String = "Example: GetFormFieldsNeedAppearances"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim formsCount As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If formsCount > 0 Then
If (gdpicturePDF.GetFormFieldsNeedAppearances() = False) AndAlso
(gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
'Forcing the toolkit to construct form fields appearances for proper rendering.
gdpicturePDF.SetFormFieldsNeedAppearances(True)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim image_index As Integer = 0
Dim filename As String = "image_page0.png"
For i As Integer = 1 To count
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
If gdpictureImaging.SaveAsPNG(image_index, filename) = GdPictureStatus.OK Then
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(image_index)
Else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The handling of form fields appearance flag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: GetFormFieldsNeedAppearances";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int formsCount = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (formsCount > 0)
{
if ((gdpicturePDF.GetFormFieldsNeedAppearances() == false) &&
(gdpicturePDF.GetStat() == GdPictureStatus.OK))
//Forcing the toolkit to construct form fields appearances for proper rendering.
gdpicturePDF.SetFormFieldsNeedAppearances(true);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int image_index = 0;
string filename = "image_page0.png";
for (int i = 1; i <= count; i++)
{
if (gdpicturePDF.SelectPage(i) == GdPictureStatus.OK)
{
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
if (gdpictureImaging.SaveAsPNG(image_index, filename) == GdPictureStatus.OK)
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(image_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(image_index)
}
else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The handling of form fields appearance flag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Sets the value of NeedAppearances flag related to interactive form fields in the currently loaded PDF document.
Sometimes fields may contain values that are not know until the document is viewed. This flag specifies whether to construct appearance streams
and appearance dictionaries for form fields in the loaded document to properly render the document when viewing.
Set this parameter to true, if you want to enable the NeedAppearances flag, otherwise set it to false to disable it.
Setting this flag to true can improve rendering of incorrectly constructed form fields appearances for proper document viewing.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that this flag is only related to interactive form fields, if any are present in the currently loaded PDF document.
Please use the method to find out if form fields appearances need to be constructed before viewing.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to force form fields appearance reconstruction during the rendering process.
Dim caption As String = "Example: SetFormFieldsNeedAppearances"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim formsCount As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If formsCount > 0 Then
If (gdpicturePDF.GetFormFieldsNeedAppearances() = False) AndAlso
(gdpicturePDF.GetStat() = GdPictureStatus.OK) Then
'Forcing the toolkit to construct form fields appearances for proper rendering.
gdpicturePDF.SetFormFieldsNeedAppearances(True)
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim image_index As Integer = 0
Dim filename As String = "image_page0.png"
For i As Integer = 1 To count
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
filename = filename.Replace((i - 1).ToString(), i.ToString())
If gdpictureImaging.SaveAsPNG(image_index, filename) = GdPictureStatus.OK Then
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
gdpictureImaging.ReleaseGdPictureImage(image_index)
Else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The handling of form fields appearance flag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldsNeedAppearances";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int formsCount = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (formsCount > 0)
{
if ((gdpicturePDF.GetFormFieldsNeedAppearances() == false) &&
(gdpicturePDF.GetStat() == GdPictureStatus.OK))
//Forcing the toolkit to construct form fields appearances for proper rendering.
gdpicturePDF.SetFormFieldsNeedAppearances(true);
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
int image_index = 0;
string filename = "image_page0.png";
for (int i = 1; i <= count; i++)
{
if (gdpicturePDF.SelectPage(i) == GdPictureStatus.OK)
{
image_index = gdpicturePDF.RenderPageToGdPictureImage(200, true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
filename = filename.Replace((i - 1).ToString(), i.ToString());
if (gdpictureImaging.SaveAsPNG(image_index, filename) == GdPictureStatus.OK)
message = message + "The image of the page nr." + i.ToString() + " has been successfully saved.\n";
else
message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
gdpictureImaging.ReleaseGdPictureImage(image_index);
//Or you can use this one:
//GdPictureDocumentUtilities.DisposeImage(image_index)
}
else
message = message + "The RenderPageToGdPictureImage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The handling of form fields appearance flag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
Returns the number of links (link objects) stored within the currently selected page of the loaded PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of links embedded within the currently selected page. The method can be subsequently used to determine if this method has been successful.
How to find out the number of all links stored in the PDF document. This example shows you the number of links embedded on every page separately.
Dim caption As String = "Example: GetPageLinksCount"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("links.pdf", False)
If status = GdPictureStatus.OK Then
Dim totalLinksCount As Integer = 0
Dim pagesCount As Integer = gdpicturePDF.GetPageCount()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (pagesCount > 0) Then
Dim linksPerPages As String = ""
For i As Integer = 1 To pagesCount
linksPerPages = linksPerPages + "Page Nr." + i.ToString()
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
Dim linksCount As Integer = gdpicturePDF.GetPageLinksCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If linksCount = 0 Then
linksPerPages = linksPerPages + " has no links." + vbCrLf
Else
linksPerPages = linksPerPages + " has " + linksCount.ToString() + " links." + vbCrLf
totalLinksCount = totalLinksCount + linksCount
End If
Else
linksPerPages = linksPerPages + " has failed to find links. The reason: " + status.ToString() + vbCrLf
End If
Else
linksPerPages = linksPerPages + " has failed to select." + vbCrLf
End If
Next
MessageBox.Show("This PDF document contains " + totalLinksCount.ToString() + " links." + vbCrLf + linksPerPages, caption)
Else
MessageBox.Show("The file has failed to load pages.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageLinksCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("links.pdf", false);
if (status == GdPictureStatus.OK)
{
int totalLinksCount = 0;
int pagesCount = gdpicturePDF.GetPageCount();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) && (pagesCount > 0))
{
string linksPerPages = "";
for (int i = 1; i <= pagesCount; i++)
{
linksPerPages = linksPerPages + "Page Nr." + i.ToString();
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
int linksCount = gdpicturePDF.GetPageLinksCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (linksCount == 0)
linksPerPages = linksPerPages + " has no links.\n";
else
{
linksPerPages = linksPerPages + " has " + linksCount.ToString() + " links.\n";
totalLinksCount = totalLinksCount + linksCount;
}
}
else
{
linksPerPages = linksPerPages + " has failed to find links. The reason: " + status.ToString() + "\n";
}
}
else
{
linksPerPages = linksPerPages + " has failed to select.\n";
}
}
MessageBox.Show("This PDF document contains " + totalLinksCount.ToString() + " links.\n" + linksPerPages, caption);
}
else
{
MessageBox.Show("The file has failed to load pages.", caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Translates a link index (only related to the currently selected page in the loaded PDF document) to an annotation index in order to allow working with this
link object through the given set of methods related to the annotation objects. In a PDF document, a link is a subtype of the annotation type representing
either a hypertext link to a destination elsewhere in the document or an action to be carried out.
The 0-based link index within the currently selected page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The annotation index of the specified link. You can subsequently use this index with the given set of methods related to the annotation objects (see
the Annotations (PDF scheme) group of methods in the Reference Guide).
The method can be subsequently used to determine if this method has been successful.
How to obtain an annotation index for links embedded within the first page of the PDF document. The example shows you how to subsequently use this index with
the set of methods related to annotations.
Dim caption As String = "Example: GetPageLinkAnnotationIdx"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("links.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
Dim linksCount As Integer = gdpicturePDF.GetPageLinksCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If linksCount > 0 Then
Dim message As String = ""
For i As Integer = 0 To linksCount - 1
message = message + "Link Nr." + (i + 1).ToString()
Dim annotIdx As Integer = gdpicturePDF.GetPageLinkAnnotationIdx(i)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationColor(annotIdx, 255, 0, 0) = GdPictureStatus.OK) Then
message = message + " has changed its color successfully." + vbCrLf
Else
message = message + " has failed to change its color." + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("linksColoured.pdf") = GdPictureStatus.OK Then
MessageBox.Show(message + "The file has been saved successfully.", caption)
Else
MessageBox.Show(message + "The file can't be saved.", caption)
End If
Else
MessageBox.Show("This page has no links.", caption)
End If
Else
MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageLinkAnnotationIdx";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("links.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
int linksCount = gdpicturePDF.GetPageLinksCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (linksCount > 0)
{
string message = "";
for (int i = 0; i <= linksCount - 1; i++)
{
message = message + "Link Nr." + (i + 1).ToString();
int annotIdx = gdpicturePDF.GetPageLinkAnnotationIdx(i);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetAnnotationColor(annotIdx, 255, 0, 0) == GdPictureStatus.OK))
{
message = message + " has changed its color successfully.\n";
}
else
{
message = message + " has failed to change its color.\n";
}
}
if (gdpicturePDF.SaveToFile("linksColoured.pdf") == GdPictureStatus.OK)
{
MessageBox.Show(message + "The file has been saved successfully.", caption);
}
else
{
MessageBox.Show(message + "The file can't be saved.", caption);
}
}
else
{
MessageBox.Show("This page has no links.", caption);
}
}
else
{
MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Removes a link specified by its index related to the currently selected page of the loaded PDF document.
The 0-based link index within the currently selected page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
Also, be sure that you have selected the correct page to work with.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove the first link embedded within the first page of the PDF document.
Dim caption As String = "Example: RemovePageLink"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("links.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
Dim linksCount As Integer = gdpicturePDF.GetPageLinksCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If linksCount > 0 Then
status = gdpicturePDF.RemovePageLink(0)
If status = GdPictureStatus.OK Then
MessageBox.Show("The first link on the first page has been removed successfully.", caption)
If gdpicturePDF.SaveToFile("linksFirstRemoved.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
Else
MessageBox.Show("The RemovePageLink() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("This page has no links.", caption)
End If
Else
MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemovePageLink";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("links.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
int linksCount = gdpicturePDF.GetPageLinksCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (linksCount > 0)
{
status = gdpicturePDF.RemovePageLink(0);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("The first link on the first page has been removed successfully.", caption);
if (gdpicturePDF.SaveToFile("linksFirstRemoved.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", caption);
}
else
{
MessageBox.Show("The file can't be saved.", caption);
}
}
else
{
MessageBox.Show("The RemovePageLink() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("This page has no links.", caption);
}
}
else
{
MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Removes all links embedded within the currently selected page of the loaded PDF document.
This method is only allowed for use with non-encrypted documents.
Also, be sure that you have selected the correct page to work with. If the selected page doesn't contain any links,
this method always returns the value of GdPictureStatus.OK.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to successfully remove all links embedded within the first page of the PDF document.
Dim caption As String = "Example: RemovePageLinks"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("links.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
Dim linksCount As Integer = gdpicturePDF.GetPageLinksCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If linksCount > 0 Then
status = gdpicturePDF.RemovePageLinks()
If status = GdPictureStatus.OK Then
MessageBox.Show("All links on the first page have been removed successfully.", caption)
If gdpicturePDF.SaveToFile("links.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The file has been saved successfully.", caption)
Else
MessageBox.Show("The file can't be saved.", caption)
End If
Else
MessageBox.Show("The RemovePageLinks() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("This page has no links.", caption)
End If
Else
MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemovePageLinks";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("links.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
int linksCount = gdpicturePDF.GetPageLinksCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (linksCount > 0)
{
status = gdpicturePDF.RemovePageLinks();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("All links on the first page have been removed successfully.", caption);
if (gdpicturePDF.SaveToFile("links.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The file has been saved successfully.", caption);
}
else
{
MessageBox.Show("The file can't be saved.", caption);
}
}
else
{
MessageBox.Show("The RemovePageLinks() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("This page has no links.", caption);
}
}
else
{
MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Changes the level of quality (compression rate or quality score) used to compress JPEG2000 image within the currently loaded PDF document.
You can set the Quality parameter in two ways. Positive values specify the compression rate and negative values define the quality score.
Please note that firstly you need to create or load the PDF document to allow this setting to work properly.
Secondly, you need to set the required value before adding the source image to the current document.
Positive values determine the compression rate between 1 (maximal - lossless) and 512 (poor).
Negative values determine the quality score between -1 (worst quality) and -100 (best quality).
The default value is 16.para>
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.
JPEG2000 compression is only suitable for 8bpp grayscale and non indexed color images.
Please use the method to specify the compression scheme for other color images.
How to set the compression rate correctly.
Dim gdpicturePDF As New GdPicturePDF()
'Firstly, create or load the PDF document.
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
'Set the required parameter.
gdpicturePDF.SetJpeg2000Quality(20)
'Process your document here, for example, add an image.
Else
MessageBox.Show("The file can't be loaded.", "Example: SetJpeg2000Quality")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Firstly, create or load the PDF document.
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
//Set the required parameter.
gdpicturePDF.SetJpeg2000Quality(20);
//Process your document here, for example, add an image.
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetJpeg2000Quality");
gdpicturePDF.Dispose();
Changes the level of quality used to compress JPEG image within the currently loaded PDF document.
Please note that firstly you need to create or load the PDF document to allow this setting to work properly.
Secondly, you need to set the compression level before adding the required image to the current document.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression. The default value is 75.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.
JPEG compression is only suitablefor 8bpp grayscale and non indexed color images. Please use the method
to specify the JPEG compression scheme for other color images.
How to set the compression level correctly.
Dim gdpicturePDF As New GdPicturePDF()
'Firstly, create or load the PDF document.
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
'Set the required parameter.
gdpicturePDF.SetJpegQuality(80)
'Process your document here, for example, add an image.
Else
MessageBox.Show("The file can't be loaded.", "Example: SetJpegQuality")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Firstly, create or load the PDF document.
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
//Set the required parameter.
gdpicturePDF.SetJpegQuality(80);
//Process your document here, for example, add an image.
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetJpegQuality");
gdpicturePDF.Dispose();
Changes the threshold of JBIG2 encoder pattern matching and substitution (PMS). The value can be set in range form 0 to 1. Any number lower than 1 may lead to lossy compression. Default value is 0.75.
Specifies new threshold value between 0 and 1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.
Please use the method to specify the compression scheme for bitonal images.
How to set the JBIG2 PMS threshold correctly.
Dim gdpicturePDF As New GdPicturePDF()
'Firstly, create or load the PDF document.
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
'Set the required parameter.
gdpicturePDF.SetJBIG2PMSThreshold(1)
'Process your document here, for example, add a bitonal image.
Else
MessageBox.Show("The file can't be loaded.", "Example: SetJBIG2PMSThreshold")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Firstly, create or load the PDF document.
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
//Set the required parameter.
gdpicturePDF.SetJBIG2PMSThreshold(1);
//Process your document here, for example, add a bitonal image.
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetJBIG2PMSThreshold");
gdpicturePDF.Dispose();
Sets the scheme to be used to compress bitonal image data within the currently loaded PDF document.
Please note that firstly you need to create or load the PDF document to allow this setting to work properly.
Secondly, you need to set the compression scheme before adding the required image to the current document.
A member of the PdfCompression enumeration. The new compression scheme to be used.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.
How to set the image compression correctly.
Dim caption As String = "Example: SetCompressionForBitonalImage"
Dim oImage As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = oImage.CreateGdPictureImageFromFile("input.tif")
If oImage.GetStat() = GdPictureStatus.OK Then
Dim count As Integer = oImage.GetPageCount(imageID)
If oImage.GetStat() = GdPictureStatus.OK Then
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Firstly, create or load the PDF document.
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
'Secondly, set the required compression.
gdpicturePDF.SetCompressionForBitonalImage(PdfCompression.PdfCompressionCCITT4)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
'Process your document.
For i As Integer = 1 To count
status = oImage.SelectPage(imageID, i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionNone)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Next
'Check, if all is done without errors.
If status = GdPictureStatus.OK Then
'At the end, save the file with the previously selected compression.
If gdpicturePDF.SaveToFile("output.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The SetCompressionForBitonalImage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The new PDF document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + oImage.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption)
End If
string caption = "Example: SetCompressionForBitonalImage";
GdPictureImaging oImage = new GdPictureImaging();
int imageID = oImage.CreateGdPictureImageFromFile("input.tif");
if (oImage.GetStat() == GdPictureStatus.OK)
{
int count = oImage.GetPageCount(imageID);
if (oImage.GetStat() == GdPictureStatus.OK)
{
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Firstly, create or load the PDF document.
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
//Secondly, set the required compression.
gdpicturePDF.SetCompressionForBitonalImage(PdfCompression.PdfCompressionCCITT4);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
//Process your document.
for (int i = 1; i <= count; i++)
{
status = oImage.SelectPage(imageID, i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionNone);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
//Check, if all is done without errors.
if (status == GdPictureStatus.OK)
{
//At the end, save the file with the previously selected compression.
if (gdpicturePDF.SaveToFile("output.pdf", false) == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The SetCompressionForBitonalImage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The new PDF document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + oImage.GetStat().ToString(), caption);
}
else
MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption);
Sets the scheme to be used to compress color image data within the currently loaded PDF document. The default value is PdfCompression.PdfCompressionJPEG.
Please note that firstly you need to create or load the PDF document to allow this setting to work properly.
Secondly, you need to set the compression scheme before adding the required image to the current document.
A member of the PdfCompression enumeration. The new compression scheme to be used.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.
Be aware that if you select the PdfCompression.PdfCompressionCCITT4 or PdfCompression.PdfCompressionJBIG2, the deflate compression will be used instead.
How to set the image compression correctly.
Dim caption As String = "Example: SetCompressionForColorImage"
Dim oImage As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = oImage.CreateGdPictureImageFromFile("input.jpg")
If oImage.GetStat() = GdPictureStatus.OK Then
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Firstly, create or load the PDF document.
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
'Secondly, set the required compression.
gdpicturePDF.SetCompressionForColorImage(PdfCompression.PdfCompressionJPEG2000)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
'Process your document.
status = gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionNone)
If status = GdPictureStatus.OK Then
'At the end, save the file with the previously selected compression.
If gdpicturePDF.SaveToFile("output.pdf", False) = GdPictureStatus.OK Then
MessageBox.Show("Done!", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SetCompressionForBitonalImage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The new PDF document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption)
End If
string caption = "Example: SetCompressionForColorImage";
GdPictureImaging oImage = new GdPictureImaging();
int imageID = oImage.CreateGdPictureImageFromFile("input.jpg");
if (oImage.GetStat() == GdPictureStatus.OK)
{
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Firstly, create or load the PDF document.
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
//Secondly, set the required compression.
gdpicturePDF.SetCompressionForColorImage(PdfCompression.PdfCompressionJPEG2000);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
//Process your document.
status = gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionNone);
if (status == GdPictureStatus.OK)
{
//At the end, save the file with the previously selected compression.
if (gdpicturePDF.SaveToFile("output.pdf", false) == GdPictureStatus.OK)
MessageBox.Show("Done!", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The SetCompressionForColorImage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The new PDF document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption);
Sets the resolution of the background layer of the image, which is subsequently processed by the MRC engine,
for example using the method.
The predefined value is -1, which means that the original resolution of the input image is used.
The required resolution of the background layer of the resulting image produced by the MRC engine.
Set this parameter to -1, if you want to use the original resolution of the input image.
This attribute is only relevant when compressing images using the MRC Compression mechanism.
Just to inform you, that this value is valid continuously when processing each image until you change it.
It is not related to the currently loaded document.
How to affect the resolution of the background layer of the image compressed using the MRC engine.
Dim caption As String = "Example: SetMRCImageBackgroundResolution"
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg")
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetMRCImageBackgroundResolution(100)
gdpicturePDF.SetMRCPreserveSmoothing(True)
If gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC) = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("image.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("The image has been added successfully and the file has been saved.", caption)
Else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
Else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
gdpictureImaging.ReleaseGdPictureImage(imageID)
gdpictureImaging.Dispose()
string caption = "Example: SetMRCImageBackgroundResolution";
GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetMRCImageBackgroundResolution(100);
gdpicturePDF.SetMRCPreserveSmoothing(true);
if (gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC) == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("image.pdf", true) == GdPictureStatus.OK)
MessageBox.Show("The image has been added successfully and the file has been saved.", caption);
else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
}
else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.ReleaseGdPictureImage(imageID);
gdpictureImaging.Dispose();
Enables the use of enhanced smoothing technique when processing the image compression by the MRC engine,
for example using the method.
Smoothing improves the contrast of the image by reducing noise. That means the produced image is less pixelated,
but it's file size can increase. The predefined value is true.
Set this parameter to false to dramatically reduce produced file size,
but get a less contrasting text. Otherwise set it to true.
This attribute is only relevant when compressing images using the MRC Compression mechanism.
Just to inform you, that this value is valid continuously when processing each image until you change it.
It is not related to the currently loaded document.
How to affect properties of the resulting image compressed using the MRC engine.
Dim caption As String = "Example: SetMRCPreserveSmoothing"
Dim gdpictureImaging As GdPictureImaging = New GdPictureImaging()
Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg")
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetMRCImageBackgroundResolution(100)
gdpicturePDF.SetMRCPreserveSmoothing(True)
If gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC) = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("image.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("The image has been added successfully and the file has been saved.", caption)
Else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
Else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
gdpictureImaging.ReleaseGdPictureImage(imageID)
gdpictureImaging.Dispose()
string caption = "Example: SetMRCPreserveSmoothing";
GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.jpg");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetMRCImageBackgroundResolution(100);
gdpicturePDF.SetMRCPreserveSmoothing(true);
if (gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC) == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("image.pdf", true) == GdPictureStatus.OK)
MessageBox.Show("The image has been added successfully and the file has been saved.", caption);
else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
}
else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.ReleaseGdPictureImage(imageID);
gdpictureImaging.Dispose();
Creates an image resource directly from your JPEG image stored in the instantiated Stream object without the need of lossy encoding and decoding process. The
image resource is subsequently added into the currently loaded PDF document. You can use this resource straightforward, for example, with the method.
This process allows you to easily draw an image from your JPEG source file onto a page within the currently loaded PDF document.
A Stream object, a source of your image. Supported file format is JPEG (jpg, jpeg, jpe ...).
This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Also be aware that the input stream should remain open and can only be closed/disposed of by the user.
Returns a name of the newly inserted image resource strictly bounded to the currently loaded PDF document.
The method can be subsequently used to determine if this method has been successful.
This name can be subsequently used with the method to draw an image onto the page. For the correct usage please see the example below.
How to draw a JPEG image stored in the instantiated stream object onto a new page and save it to a PDF file.
Dim caption As String = "Example: AddJpegImageFromStream"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim image_stream As System.IO.Stream = New System.IO.FileStream("image.jpg", System.IO.FileMode.Open)
Dim image_name As String = gdpicturePDF.AddJpegImageFromStream(image_stream)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297) = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("Test_AddJpegStream.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.CloseDocument()
image_stream.Close()
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddJpegImageFromStream";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
System.IO.Stream image_stream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open);
string image_name = gdpicturePDF.AddJpegImageFromStream(image_stream);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if (gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297) == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("Test_AddJpegStream.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
}
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
gdpicturePDF.CloseDocument();
image_stream.Close();
}
else
{
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
Creates an image resource directly from your JPEG image file without the need of lossy encoding and decoding process including option to provide ICC profile data. The image resource is subsequently
added into the currently loaded PDF document. You can use this resource straightforward, for example, with the method.
This process allows you to easily draw an image from your JPEG file onto a page within the currently loaded PDF document.
The file path of the source image. Supported file format is JPEG (jpg, jpeg, jpe ...). Please note that the files of larger size than 2GB are not supported.
The ICC profile data that shall be embedded in the image resource.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Returns a name of the newly created image resource strictly bounded to the currently loaded PDF document.
The method can be subsequently used to determine if this method has been successful.
This name can be subsequently used with the method to draw an image onto the page. For the correct usage please see the example below.
How to draw a JPEG image from a file onto a new page and save it to a PDF file.
Dim caption As String = "Example: AddJpegImageFromFile"
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
If status <> GdPictureStatus.OK Then
Return
End If
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
status = gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297)
If status <> GdPictureStatus.OK Then
Return
End If
status = gdpicturePDF.SaveToFile("Test_AddJpegImage.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: AddJpegImageFromFile";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
if (status != GdPictureStatus.OK) return;
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
status = gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297);
if (status != GdPictureStatus.OK) return;
status = gdpicturePDF.SaveToFile("Test_AddJpegImage.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
}
}
Creates an image resource directly from your JPEG image file without the need of lossy encoding and decoding process. The image resource is subsequently
added into the currently loaded PDF document. You can use this resource straightforward, for example, with the method.
This process allows you to easily draw an image from your JPEG file onto a page within the currently loaded PDF document.
The file path of the source image. Supported file format is JPEG (jpg, jpeg, jpe ...). Please note that the files of larger size than 2GB are not supported.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Returns a name of the newly created image resource strictly bounded to the currently loaded PDF document.
The method can be subsequently used to determine if this method has been successful.
This name can be subsequently used with the method to draw an image onto the page. For the correct usage please see the example below.
How to draw a JPEG image from a file onto a new page and save it to a PDF file.
Dim caption As String = "Example: AddJpegImageFromFile"
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
If status <> GdPictureStatus.OK Then
Return
End If
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
status = gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297)
If status <> GdPictureStatus.OK Then
Return
End If
status = gdpicturePDF.SaveToFile("Test_AddJpegImage.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: AddJpegImageFromFile";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
if (status != GdPictureStatus.OK) return;
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
status = gdpicturePDF.DrawImage(image_name, 0, 0, 210, 297);
if (status != GdPictureStatus.OK) return;
status = gdpicturePDF.SaveToFile("Test_AddJpegImage.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("Your image has been successfully saved to a pdf file.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
}
}
Adds an image resource, specified by its unique image identifier, to the currently loaded PDF document according to what you have specified. You can
obtain this identifier, for example, using methods of the class when you create the image resource using an object of the type GdPictureImage.
Then you can either draw the image directly using this method or you can draw it later using the returned image resource name.
Adds an image resource, specified by its unique image identifier, that represents a GdPictureImage object, and subsequently draws this image within the currently loaded PDF document.
The unique image identifier of the GdPictureImage object representing the required image. You need to add the image resource into the currently loaded PDF document,
for example, using methods of the class, whose returned value is the unique image identifier.
Applicable only for 1 bit per pixel images. Indicates, whether the inserted image shall be treated as an image mask (or stencil mask).
The recommended default value is false.
Set this parameter to true if you want to draw an image directly, otherwise set it to false.
If positive, then the new page is added into the current document as the last page and the image is drawn on its whole surface.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you, that the newly created page is inserted as the last page in the loaded document if you draw the image immediately.
When is true, very large images whose decoded pixel buffer would exceed the .NET array size limit are tiled internally onto the newly created page — no caller-side splitting is required, and the resulting PDF is visually identical to a non-tiled result. When tiling is applied the returned resource name is empty because the image is split across multiple XObjects; rely on rather than reusing the name. Tiling is not applied when is false; for such images, use an overload that creates a new page.
Returns a name of the newly inserted image resource strictly bounded to the currently loaded PDF document.
The method can be subsequently used to determine if this method has been successful.
This name can be subsequently used with the method to draw an image onto the page.
How to add and draw an image from a tif file to a PDF document.
Dim caption As String = "Example: AddImageFromGdPictureImage"
Dim gdpictureImaging As New GdPictureImaging()
Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("image.tif")
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
Dim width As Double = gdpictureImaging.GetWidthInches(imageID)
Dim draw As Boolean = (gdpictureImaging.GetStat() <> GdPictureStatus.OK)
Dim height As Double = gdpictureImaging.GetHeightInches(imageID)
draw = draw OrElse (gdpictureImaging.GetStat() <> GdPictureStatus.OK)
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", True) = GdPictureStatus.OK Then
Dim imageResName As String = ""
If draw Then
'The original width or the height of the image can't be found, so
'the image is drawn directly on the whole surface of the newly added page and
'the dimensions of the page are the same as the original dimensions of the image.
imageResName = gdpicturePDF.AddImageFromGdPictureImage(imageID, False, True)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
'The original width or the height of the image has been found correctly, so
'the image is added into the document, but it is not drawn directly.
imageResName = gdpicturePDF.AddImageFromGdPictureImage(imageID, False, False)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The image is drawn retaining its original size onto the newly added page according to your preferences.
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawImage(imageResName, 0, 0, CSng(width), CSng(height)) <> GdPictureStatus.OK) Then
MessageBox.Show("The NewPage() or the DrawImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
gdpictureImaging.ReleaseGdPictureImage(imageID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'The document is overwritten.
If gdpicturePDF.SaveToFile("test.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The LoadFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
Else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
string caption = "Example: AddImageFromGdPictureImage";
GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
double width = gdpictureImaging.GetWidthInches(imageID);
Boolean draw = (gdpictureImaging.GetStat() != GdPictureStatus.OK);
double height = gdpictureImaging.GetHeightInches(imageID);
draw = draw || (gdpictureImaging.GetStat() != GdPictureStatus.OK);
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", true) == GdPictureStatus.OK)
{
string imageResName = "";
if (draw)
//The original width or the height of the image can't be found.
{
//The image is drawn directly on the whole surface of the newly added page and
//the dimensions of the page are the same as the original dimensions of the image.
imageResName = gdpicturePDF.AddImageFromGdPictureImage(imageID, false, true);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
//The original width or the height of the image has been found correctly.
{
//The image is added into the document, but it is not drawn directly.
imageResName = gdpicturePDF.AddImageFromGdPictureImage(imageID, false, false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The image is drawn retaining its original size onto the newly added page according to your preferences.
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawImage(imageResName, 0, 0, (float)width, (float)height) != GdPictureStatus.OK))
MessageBox.Show("The NewPage() or the DrawImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
gdpictureImaging.ReleaseGdPictureImage(imageID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//The document is overwritten.
if (gdpicturePDF.SaveToFile("test.pdf", true) == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The LoadFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
}
else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
Adds an image resource, specified by its unique image identifier, and then subsequently draws this image onto a newly created page within the currently loaded PDF document.
You can obtain this identifier, for example, using methods of the class when you create the image resource using
an object of the type GdPictureImage. You can also specify an advanced compression mechanism such as color detection or mixed raster content (MRC) compression when drawing an image.
The dimensions of the newly added page are the same as the original dimensions of the inserted image and the page is inserted as the last page in the document.
Adds an image resource, specified by its unique image identifier, that represents a GdPictureImage object, and subsequently draws this image within the currently loaded PDF document.
The unique image identifier of the GdPictureImage object representing the required image.
You need to add the image resource into the currently loaded PDF document, for example, using methods of the class, whose returned value is the unique image identifier.
A member of the PdfAdvancedImageCompression enumeration. Specifies the advanced compression mechanism.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that the newly created page is always inserted as the last page in the loaded document.
Very large images whose decoded pixel buffer would exceed the .NET array size limit are tiled internally and drawn on a single page — no caller-side splitting is required, and the resulting PDF is visually identical to a non-tiled result.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert a multipage tif file to a PDF document using mixed raster content compression.
Dim caption As String = "Example: AddImageFromGdPictureImage"
Dim gdpictureImaging As New GdPictureImaging()
Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("multi_image.tif")
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
Dim count As Integer = gdpictureImaging.GetPageCount(imageID)
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim message As String = ""
gdpicturePDF.SetMRCImageBackgroundResolution(100)
gdpicturePDF.SetMRCPreserveSmoothing(False)
For i As Integer = 1 To count
message = message + "The image nr." + i.ToString()
If (gdpictureImaging.SelectPage(imageID, i) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC) = GdPictureStatus.OK) Then
message = message + " has been successfully drawn." + vbCrLf
Else
message = message + " has not been drawn - the last status is " + gdpicturePDF.GetStat().ToString() + "." + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_AddImageFromGdPictureImage.pdf", True) = GdPictureStatus.OK Then
message = message + "The file has been saved successfully."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
gdpictureImaging.ReleaseGdPictureImage(imageID)
gdpictureImaging.Dispose()
string caption = "Example: AddImageFromGdPictureImage";
GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("multi_image.tif");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
int count = gdpictureImaging.GetPageCount(imageID);
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
string message = "";
gdpicturePDF.SetMRCImageBackgroundResolution(100);
gdpicturePDF.SetMRCPreserveSmoothing(false);
for (int i = 1; i <= count; i++)
{
message = message + "The image nr." + i.ToString();
if ((gdpictureImaging.SelectPage(imageID, i) == GdPictureStatus.OK) &&
(gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC) == GdPictureStatus.OK))
message = message + " has been successfully drawn.\n";
else
message = message + " has not been drawn - the last status is " + gdpicturePDF.GetStat().ToString() + ".\n";
}
if (gdpicturePDF.SaveToFile("test_AddImageFromGdPictureImage.pdf", true) == GdPictureStatus.OK)
message = message + "The file has been saved successfully.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
}
else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.ReleaseGdPictureImage(imageID);
gdpictureImaging.Dispose();
Adds an image resource stored in a Bitmap object to the currently loaded PDF document according to what you have specified. You can either draw the image
directly using this method or you can draw it later using the returned image resource name. The dimensions of the newly added page are the same as the original
dimensions of the inserted image.
Adds and draws an image within the currently loaded PDF document using a bitmap object as an image resource.
A Bitmap object specifying an image resource to be added into the current document.
Applicable only for 1 bit per pixel images. Indicates, whether the inserted image shall be treated as an image mask (or stencil mask).
The recommended default value is false.
Set this parameter to true if you want to draw an image directly, otherwise set it to false.
If positive, then the new page is added into the current document and the image is drawn on its whole surface.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
When is true, very large images whose decoded pixel buffer would exceed the .NET array size limit are tiled internally onto the newly created page — no caller-side splitting is required, and the resulting PDF is visually identical to a non-tiled result. When tiling is applied the returned resource name is empty because the image is split across multiple XObjects; rely on rather than reusing the name. Tiling is not applied when is false; for such images, use an overload that creates a new page.
Returns a name of the newly inserted image resource strictly bounded to the currently loaded PDF document.
The method can be subsequently used to determine if this method has been successful.
This name can be subsequently used with the method to draw an image onto the page.
How to draw an image within a PDF document using a bitmap.
Dim caption As String = "Example: AddImageFromBitmap"
Dim gdpictureImaging As New GdPictureImaging()
Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("image1.tif")
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
Dim bitmap As Bitmap = gdpictureImaging.GetBitmapFromGdPictureImage(imageID)
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim imageResName As String = gdpicturePDF.AddImageFromBitmap(bitmap, False, True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_AddImageFromBitmap.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddImageFromBitmap() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
Else
MessageBox.Show("The GetBitmapFromGdPictureImage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
gdpictureImaging.ReleaseGdPictureImage(imageID)
Else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
gdpictureImaging.Dispose()
string caption = "Example: AddImageFromBitmap";
GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
Bitmap bitmap = gdpictureImaging.GetBitmapFromGdPictureImage(imageID);
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
string imageResName = gdpicturePDF.AddImageFromBitmap(bitmap, false, true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_AddImageFromBitmap.pdf", true) == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddImageFromBitmap() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
}
else
MessageBox.Show("The GetBitmapFromGdPictureImage() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
else
MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.Dispose();
Adds an image resource and then subsequently draws this image onto a newly created page within the currently loaded PDF document. You can specify an advanced
compression mechanism such as color detection or mixed raster content (MRC) compression when drawing an image. The dimensions of the newly added page are
the same as the original dimensions of the inserted image.
Adds and draws an image within the currently loaded PDF document using a bitmap object as an image resource.
A Bitmap object specifying an image resource to be added into the current document.
A member of the PdfAdvancedImageCompression enumeration. Specifies the advanced compression mechanism.
This method is only allowed for use with non-encrypted documents.
Very large images whose decoded pixel buffer would exceed the .NET array size limit are tiled internally and drawn on a single page — no caller-side splitting is required, and the resulting PDF is visually identical to a non-tiled result.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert a tif image to a PDF document using mixed raster content compression.
Dim caption As String = "Example: AddImageFromBitmap"
Dim bitmap As New Bitmap("image.tif")
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.AddImageFromBitmap(bitmap, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_AddImageFromBitmap.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddImageFromBitmap() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddImageFromBitmap";
Bitmap bitmap = new Bitmap("image.tif");
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.AddImageFromBitmap(bitmap, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_AddImageFromBitmap.pdf", true) == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The AddImageFromBitmap() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Deletes a specified image and its corresponding image resource from the currently loaded PDF document. The required image is identified by
its resource name within the current document. If the specified image is used either elsewhere on the same page or on another page, it is removed
from all places within the current document.
The image resource name previously returned by the AddImageFrom...(), AddJpegImageFrom...() or methods.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to successfully delete all image resources included within the first page of a PDF document.
Dim caption As String = "Example: DeleteImage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("deleteimage.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
'The first page is automatically selected as the current page.
Dim imageCount As Integer = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
Dim message As String = "", imageResName As String = ""
For i As Integer = imageCount - 1 To 0 Step -1
'The inverse loop will not work correctly from logical point of view (the number of images decreases).
imageResName = gdpicturePDF.GetPageImageResName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.DeleteImage(imageResName)
If status = GdPictureStatus.OK Then
message = message + "The image resource named " + imageResName + " has been successfully deleted." + vbCrLf
Else
message = message + "The DeleteImage() method has failed for the image resource named " + imageResName + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The GetPageImageResName() method has failed for the image indexed as " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_deleteimage.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved successfully."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("The first page doesn't contain any image.", caption)
Else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DeleteImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
//The first page is automatically selected as the current page.
int imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
string message = "", imageResName = "";
for (int i = imageCount - 1; i >= 0; i--)
//The inverse loop will not work correctly from logical point of view (the number of images decreases).
{
imageResName = gdpicturePDF.GetPageImageResName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.DeleteImage(imageResName);
if (status == GdPictureStatus.OK)
message = message + "The image resource named " + imageResName + " has been successfully deleted.\n";
else
message = message + "The DeleteImage() method has failed for the image resource named " + imageResName + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The GetPageImageResName() method has failed for the image indexed as " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_DeleteImage.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved successfully.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("The first page doesn't contain any image.", caption);
else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Replaces a destination image, specified by its resource name, located in the currently loaded PDF document, by the newly added source image, specified by
its unique image identifier. You can obtain this identifier, for example, using the method or using methods of the class
when creating the source image as an object of the type GdPictureImage. If the destination image is used either elsewhere on the same page or on another page,
it is replaced by the source image on all places within the current document.
Replaces a destination image, specified by its resource name, located in the currently loaded PDF document, by the newly added source image,
specified by its unique image identifier, that refers to an object of the type GdPictureImage.
The image resource name of the destination image, previously returned by the AddImageFrom...(), AddJpegImageFrom...() or methods.
The unique image identifier of the source image refering to an object of the type GdPictureImage.
You need to add this image as a resource into the currently loaded PDF document, for example, using methods of the class, whose returned value is the unique image identifier.
Applicable only for 1 bit per pixel images. Indicates, whether the source image shall be treated as an image mask (or stencil mask).
The commonly recommended default value is false.
Please refer to the Remarks section below or go over the method directly for further information on how to use this parameter.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that you can check the current image masking using the method to apply the ImageMask parameter properly.
If the value returned by the above mentioned method is PdfMaskTypeNone or PdfMaskTypeUnknown, set the ImageMask parameter to false. Otherwise you can set it to true.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to replace all images in the PDF document after converting them into 1 bit per pixel (black and white) images.
Dim caption As String = "Example: ReplaceImage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim imageCount As Integer = 0, imageID As Integer = 0, bitDepth As Integer = 0
Dim message As String = "", imageResName As String = ""
Dim maskMode As PdfImageMaskType = PdfImageMaskType.PdfMaskTypeUnknown
Dim mask As Boolean = False
Dim oImage As New GdPictureImaging()
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + vbCrLf
imageCount = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
For j As Integer = 0 To imageCount - 1
imageResName = gdpicturePDF.GetPageImageResName(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
imageID = gdpicturePDF.ExtractPageImage(j + 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
bitDepth = oImage.GetBitDepth(imageID)
status = oImage.GetStat()
If (status = GdPictureStatus.OK) AndAlso
(oImage.GetBitDepth(imageID) > 1) AndAlso
(oImage.ConvertTo1Bpp(imageID) = GdPictureStatus.OK) Then
maskMode = gdpicturePDF.GetPageImageMaskMode(j)
mask = ((maskMode <> PdfImageMaskType.PdfMaskTypeNone) AndAlso (maskMode <> PdfImageMaskType.PdfMaskTypeUnknown))
status = gdpicturePDF.ReplaceImage(imageResName, imageID, mask)
If status = GdPictureStatus.OK Then
message = message + "The image named as " + imageResName + " has been successfully replaced." + vbCrLf
Else
message = message + "The ReplaceImage() method has failed for the image numbered as " + (j + 1).ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The image numbered as " + (j + 1).ToString() + " has not been converted and replaced." + vbCrLf
End If
Else
message = message + "The ExtractPageImage() method has failed for the image numbered as " + (j + 1).ToString() + " with the status: " + status.ToString() + vbCrLf
End If
'The extracted image need to be released.
oImage.ReleaseGdPictureImage(imageID)
Else
message = message + "The GetPageImageResName() method has failed for the image indexed as " + j.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
Else
If status = GdPictureStatus.OK Then
message = message + "This page doesn't contain any image." + vbCrLf
Else
message = message + "The GetPageImageCount() method has failed with the status: " + status.ToString() + vbCrLf
End If
End If
Else
message = message + "The SelectPage() method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
'It is recommended to pack the document in such cases.
If gdpicturePDF.SaveToFile("test_ReplaceImage.pdf", True) = GdPictureStatus.OK Then
message = message + "The file has been saved successfully."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
oImage.Dispose()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ReplaceImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int imageCount = 0, imageID = 0, bitDepth = 0;
string message = "", imageResName = "";
PdfImageMaskType maskMode = PdfImageMaskType.PdfMaskTypeUnknown;
bool mask = false;
GdPictureImaging oImage = new GdPictureImaging();
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + "\n";
imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
for (int j = 0; j < imageCount; j++)
{
imageResName = gdpicturePDF.GetPageImageResName(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
imageID = gdpicturePDF.ExtractPageImage(j+1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
bitDepth = oImage.GetBitDepth(imageID);
status = oImage.GetStat();
if ((status == GdPictureStatus.OK) &&
(oImage.GetBitDepth(imageID) > 1) &&
(oImage.ConvertTo1Bpp(imageID) == GdPictureStatus.OK))
{
maskMode = gdpicturePDF.GetPageImageMaskMode(j);
mask = ((maskMode != PdfImageMaskType.PdfMaskTypeNone) && (maskMode != PdfImageMaskType.PdfMaskTypeUnknown));
status = gdpicturePDF.ReplaceImage(imageResName, imageID, mask);
if (status == GdPictureStatus.OK)
message = message + "The image named as " + imageResName + " has been successfully replaced.\n";
else
message = message + "The ReplaceImage() method has failed for the image numbered as " + (j + 1).ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The image numbered as " + (j + 1).ToString() + " has not been converted and replaced.\n";
}
else
message = message + "The ExtractPageImage() method has failed for the image numbered as " + (j+1).ToString() + " with the status: " + status.ToString() + "\n";
//The extracted image need to be released.
oImage.ReleaseGdPictureImage(imageID);
}
else
message = message + "The GetPageImageResName() method has failed for the image indexed as " + j.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
if (status == GdPictureStatus.OK)
message = message + "This page doesn't contain any image.\n";
else
message = message + "The GetPageImageCount() method has failed with the status: " + status.ToString() + "\n";
}
}
else
message = message + "The SelectPage() method has failed with the status: " + status.ToString() + "\n";
}
//It is recommended to pack the document in such cases.
if (gdpicturePDF.SaveToFile("test_ReplaceImage.pdf", true) == GdPictureStatus.OK)
message = message + "The file has been saved successfully.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
oImage.Dispose();
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Replaces a destination image, specified by its resource name, located in the currently loaded PDF document, by the newly added source image, specified by
its unique image identifier. You can obtain this identifier, for example, using the method or using methods of the class
when creating the source image as an object of the type GdPictureImage. If the destination image is used either elsewhere on the same page or on another page,
it is replaced by the source image on all places within the current document.
Replaces a destination image, specified by its resource name, located in the currently loaded PDF document, by the newly added source image,
specified by its unique image identifier, that refers to an object of the type GdPictureImage.
The image resource name of the destination image, previously returned by the AddImageFrom...(), AddJpegImageFrom...() or methods.
The unique image identifier of the source image refering to an object of the type GdPictureImage.
You need to add this image as a resource into the currently loaded PDF document, for example, using methods of the class, whose returned value is the unique image identifier.
Applicable only for 1 bit per pixel images. Indicates, whether the source image shall be treated as an image mask (or stencil mask).
The commonly recommended default value is false.
Please refer to the Remarks section below or go over the method directly for further information on how to use this parameter.
Set to true, if you want to overwrite the original image resource only if the size (in bytes) of the newly added image resource is smaller then size
(in bytes) of the original image. Be aware that if you set this parameter to true and the size (in bytes) of the source image is
bigger than the size (in bytes) of the destination image, the method will fail with the GdPictureStatus.Aborted.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that you can check the current image masking using the method to apply the ImageMask parameter properly.
If the value returned by the above mentioned method is PdfMaskTypeNone or PdfMaskTypeUnknown, set the ImageMask parameter to false. Otherwise you can set it to true.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to replace all images in the PDF document after converting them into 1 bit per pixel (black and white) images.
Dim caption As String = "Example: ReplaceImage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim imageCount As Integer = 0, imageID As Integer = 0, bitDepth As Integer = 0
Dim message As String = "", imageResName As String = ""
Dim maskMode As PdfImageMaskType = PdfImageMaskType.PdfMaskTypeUnknown
Dim mask As Boolean = False
Dim oImage As New GdPictureImaging()
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + vbCrLf
imageCount = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
For j As Integer = 0 To imageCount - 1
imageResName = gdpicturePDF.GetPageImageResName(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
imageID = gdpicturePDF.ExtractPageImage(j + 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
bitDepth = oImage.GetBitDepth(imageID)
status = oImage.GetStat()
If (status = GdPictureStatus.OK) AndAlso
(oImage.GetBitDepth(imageID) > 1) AndAlso
(oImage.ConvertTo1Bpp(imageID) = GdPictureStatus.OK) Then
maskMode = gdpicturePDF.GetPageImageMaskMode(j)
mask = ((maskMode <> PdfImageMaskType.PdfMaskTypeNone) AndAlso (maskMode <> PdfImageMaskType.PdfMaskTypeUnknown))
status = gdpicturePDF.ReplaceImage(imageResName, imageID, mask, True)
If status = GdPictureStatus.OK Then
message = message + "The image named as " + imageResName + " has been successfully replaced." + vbCrLf
Else
message = message + "The ReplaceImage() method has failed for the image numbered as " + (j + 1).ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The image numbered as " + (j + 1).ToString() + " has not been converted and replaced." + vbCrLf
End If
Else
message = message + "The ExtractPageImage() method has failed for the image numbered as " + (j + 1).ToString() + " with the status: " + status.ToString() + vbCrLf
End If
'The extracted image need to be released.
oImage.ReleaseGdPictureImage(imageID)
Else
message = message + "The GetPageImageResName() method has failed for the image indexed as " + j.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
Else
If status = GdPictureStatus.OK Then
message = message + "This page doesn't contain any image." + vbCrLf
Else
message = message + "The GetPageImageCount() method has failed with the status: " + status.ToString() + vbCrLf
End If
End If
Else
message = message + "The SelectPage() method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
'It is recommended to pack the document in such cases.
If gdpicturePDF.SaveToFile("test_ReplaceImage.pdf", True) = GdPictureStatus.OK Then
message = message + "The file has been saved successfully."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
oImage.Dispose()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ReplaceImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int imageCount = 0, imageID = 0, bitDepth = 0;
string message = "", imageResName = "";
PdfImageMaskType maskMode = PdfImageMaskType.PdfMaskTypeUnknown;
bool mask = false;
GdPictureImaging oImage = new GdPictureImaging();
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + "\n";
imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
for (int j = 0; j < imageCount; j++)
{
imageResName = gdpicturePDF.GetPageImageResName(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
imageID = gdpicturePDF.ExtractPageImage(j+1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
bitDepth = oImage.GetBitDepth(imageID);
status = oImage.GetStat();
if ((status == GdPictureStatus.OK) &&
(oImage.GetBitDepth(imageID) > 1) &&
(oImage.ConvertTo1Bpp(imageID) == GdPictureStatus.OK))
{
maskMode = gdpicturePDF.GetPageImageMaskMode(j);
mask = ((maskMode != PdfImageMaskType.PdfMaskTypeNone) && (maskMode != PdfImageMaskType.PdfMaskTypeUnknown));
status = gdpicturePDF.ReplaceImage(imageResName, imageID, mask, true);
if (status == GdPictureStatus.OK)
message = message + "The image named as " + imageResName + " has been successfully replaced.\n";
else
message = message + "The ReplaceImage() method has failed for the image numbered as " + (j + 1).ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The image numbered as " + (j + 1).ToString() + " has not been converted and replaced.\n";
}
else
message = message + "The ExtractPageImage() method has failed for the image numbered as " + (j+1).ToString() + " with the status: " + status.ToString() + "\n";
//The extracted image need to be released.
oImage.ReleaseGdPictureImage(imageID);
}
else
message = message + "The GetPageImageResName() method has failed for the image indexed as " + j.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
if (status == GdPictureStatus.OK)
message = message + "This page doesn't contain any image.\n";
else
message = message + "The GetPageImageCount() method has failed with the status: " + status.ToString() + "\n";
}
}
else
message = message + "The SelectPage() method has failed with the status: " + status.ToString() + "\n";
}
//It is recommended to pack the document in such cases.
if (gdpicturePDF.SaveToFile("test_ReplaceImage.pdf", true) == GdPictureStatus.OK)
message = message + "The file has been saved successfully.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
oImage.Dispose();
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Replaces an image, specified by its resource name and the unique image identifier as well, located on the current page of the loaded PDF document,
by compressing this image using the advanced mixed raster content (MRC) compression mechanism and draws a resulting image on the entire page surface.
Please note that both parameters relate to the same image located on the current page. At the same, this method can be used for image-based pages
only, as the MRC engine always draws resulting images on the entire page surface. The attached example demonstrates the proper use of the method.
The image resource name of the source image you want to compress, located on the current page.
Please use the method to obtain this name.
The unique image identifier of the source image you want to compress, located on the current page, referring to an object of the type GdPictureImage.
Please use the method to obtain this identifier.
This method is only allowed for use with non-encrypted documents.
Be aware that this method can be used for image-based pages only, as the MRC engine draws a resulting image on the entire page surface.
Please follow the attached example on how to properly use the method.
This method requires the MRC - Hyper Compression component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to compress image-based pages in the PDF document using the MRC mechanism.
Dim caption As String = "Example: ReplaceImageMRC"
Using pdf As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = pdf.LoadFromFile("source.pdf", False)
If status = GdPictureStatus.OK Then
'Setting MRC options.
pdf.SetMRCImageBackgroundResolution(100)
'You can set it to true to obtain a better quality rendering, but it produces a bigger file.
pdf.SetMRCPreserveSmoothing(False)
'You can also set the compression values for images here, for example:
pdf.SetCompressionForBitonalImage(PdfCompression.PdfCompressionJBIG2)
pdf.SetCompressionForColorImage(PdfCompression.PdfCompressionJPEG2000)
'Using the negative value permits to specify better quality factor versus a compression rate.
pdf.SetJpeg2000Quality(-60)
Dim pageCount As Integer = pdf.GetPageCount()
status = pdf.GetStat()
Dim pageNo As Integer = 1
While (pageNo <= pageCount) AndAlso (status = GdPictureStatus.OK)
status = pdf.SelectPage(pageNo)
If status = GdPictureStatus.OK Then
'We can ignore hidden text in the example.
Dim isPageImage As Boolean = pdf.IsPageImage(True)
status = pdf.GetStat()
If status = GdPictureStatus.OK Then
If isPageImage Then
'As the page is image-based, the image number is 1 and we can extract this image.
Dim imageID As Integer = pdf.ExtractPageImage(1)
status = pdf.GetStat()
If status = GdPictureStatus.OK Then
'Getting the resource name of the extracted image, the index of the image to be used here is 0.
Dim imageResName As String = pdf.GetPageImageResName(0)
status = pdf.GetStat()
If status = GdPictureStatus.OK Then
'The original image is replaced with the compressed image on the whole page surface here.
status = pdf.ReplaceImageMRC(imageResName, imageID)
'You need to dispose of the used image resource here.
GdPictureDocumentUtilities.DisposeImage(imageID)
End If
End If
End If
End If
End If
pageNo += 1
End While
If status = GdPictureStatus.OK Then
status = pdf.SaveToFile("dest.pdf", True)
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has NOT been followed successfully. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: ReplaceImageMRC";
using (GdPicturePDF pdf = new GdPicturePDF())
{
GdPictureStatus status = pdf.LoadFromFile("source.pdf", false);
if (status == GdPictureStatus.OK)
{
//Setting MRC options.
pdf.SetMRCImageBackgroundResolution(100);
//You can set it to true to obtain a better quality rendering, but it produces a bigger file.
pdf.SetMRCPreserveSmoothing(false);
//You can also set the compression values for images here, for example:
pdf.SetCompressionForBitonalImage(PdfCompression.PdfCompressionJBIG2);
pdf.SetCompressionForColorImage(PdfCompression.PdfCompressionJPEG2000);
//Using the negative value permits to specify better quality factor versus a compression rate.
pdf.SetJpeg2000Quality(-60);
int pageCount = pdf.GetPageCount();
status = pdf.GetStat();
for (int pageNo = 1; (pageNo <= pageCount) && (status == GdPictureStatus.OK); pageNo++)
{
status = pdf.SelectPage(pageNo);
if (status == GdPictureStatus.OK)
{
//We can ignore hidden text in the example.
bool isPageImage = pdf.IsPageImage(true);
status = pdf.GetStat();
if (status == GdPictureStatus.OK)
{
if (isPageImage)
{
//As the page is image-based, the image number is 1 and we can extract this image.
int imageID = pdf.ExtractPageImage(1);
status = pdf.GetStat();
if (status == GdPictureStatus.OK)
{
//Getting the resource name of the extracted image, the index of the image to be used here is 0.
string imageResName = pdf.GetPageImageResName(0);
status = pdf.GetStat();
if (status == GdPictureStatus.OK)
{
//The original image is replaced with the compressed image on the whole page surface here.
status = pdf.ReplaceImageMRC(imageResName, imageID);
//You need to dispose of the used image resource here.
GdPictureDocumentUtilities.DisposeImage(imageID);
}
}
}
}
}
}
if (status == GdPictureStatus.OK)
{
status = pdf.SaveToFile("dest.pdf", true);
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has NOT been followed successfully. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
Returns the coordinates, related to the current page, of an image, specified by its index within the currently selected page of the loaded PDF document.
The coordinates are expressed in the currently defined units in the PDF document with respect to the currently defined origin, related to the actual page.
You can use the method to reset the units and the method to reset the origin's location according to your preference.
The 0-based index of the image within the current page. It must be a value from 0 to -1.
Output parameter. The horizontal (X) coordinate of the top left point, where the image is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin.
Output parameter. The vertical (Y) coordinate of the top left point, where the image is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin.
Output parameter. The horizontal (X) coordinate of the top right point, where the image is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin.
Output parameter. The vertical (Y) coordinate of the top right point, where the image is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin.
Output parameter. The horizontal (X) coordinate of the bottom left point, where the image is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin.
Output parameter. The vertical (Y) coordinate of the bottom left point, where the image is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to find out the coordinates of all images contained within the PDF document.
Dim caption As String = "Example: GetPageImageCoordinates"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim message As String = ""
Dim imageCount As Integer = 0
Dim x0 As Single = 0, y0 As Single = 0, x1 As Single = 0, y1 As Single = 0, x2 As Single = 0, y2 As Single = 0
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
For i As Integer = 1 To pageCount
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + ":" + vbCrLf
imageCount = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
For j As Integer = 0 To imageCount - 1
status = gdpicturePDF.GetPageImageCoordinates(j, x0, y0, x1, y1, x2, y2)
If status = GdPictureStatus.OK Then
message = message + "The image indexed as " + j.ToString() + " has the following coordinates:" + vbCrLf +
"TL[" + x0.ToString() + "," + y0.ToString() + "], TR[" + x1.ToString() + "," + y1.ToString() + "], BL[" + x2.ToString() + "," + y2.ToString() + "]" + vbCrLf
Else
message = message + "The GetPageImageCoordinates() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
Else
If status = GdPictureStatus.OK Then
message = message + "This page doesn't contain any image." + vbCrLf
Else
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
End If
Else
message = message + "The SelectPage() method has failed for the image nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageImageCoordinates";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string message = "";
int imageCount = 0;
float x0 = 0, y0 = 0, x1 = 0, y1 = 0, x2 = 0, y2 = 0;
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
for (int i = 1; i <= pageCount; i++)
{
if (gdpicturePDF.SelectPage(i) == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + ":\n";
imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
for (int j = 0; j < imageCount; j++)
{
status = gdpicturePDF.GetPageImageCoordinates(j, ref x0, ref y0, ref x1, ref y1, ref x2, ref y2);
if (status == GdPictureStatus.OK)
message = message + "The image indexed as " + j.ToString() + " has the following coordinates:\nTL[" +
x0.ToString() + "," + y0.ToString() + "], TR[" + x1.ToString() + "," + y1.ToString() + "], BL[" +
x2.ToString() + "," + y2.ToString() + "]\n";
else
message = message + "The GetPageImageCoordinates() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
if (status == GdPictureStatus.OK)
message = message + "This page doesn't contain any image.\n";
else
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
message = message + "The SelectPage() method has failed for the image nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the filters used to encode an image, specified by its index within the currently selected page of the loaded PDF document.
The 0-based index of the image within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to inform you that the supported filters are: ASCIIHexDecode, ASCII85Decode, LZWDecode, FlateDecode, RunLengthDecode, CCITTFaxDecode, JBIG2Decode, DCTDecode, JPXDecode, Crypt.
For further assistance, please refer to the PDF Reference, Section "Filters".
An array of strings including the names of the filters used to encode the specified image.
The method can be subsequently used to determine if this method has been successful.
How to find out used filters of all images contained within the PDF document.
Dim caption As String = "Example: GetPageImageFilters"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim message As String = ""
Dim filters As String() = Nothing
Dim imageCount As Integer = 0
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
For i As Integer = 1 To pageCount
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + ":" + vbCrLf
imageCount = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
For j As Integer = 0 To imageCount - 1
filters = gdpicturePDF.GetPageImageFilters(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "The image indexed as " + j.ToString() + " has the following filters: " + String.Join(",", filters) + "." + vbCrLf
Else
message = message + "The GetPageImageFilters() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
Else
If status = GdPictureStatus.OK Then
message = message + "This page doesn't contain any image." + vbCrLf
Else
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
End If
Else
message = message + "The SelectPage() method has failed for the image nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageImageFilters";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string message = "";
string[] filters = null;
int imageCount = 0;
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
for (int i = 1; i <= pageCount; i++)
{
if (gdpicturePDF.SelectPage(i) == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + ":\n";
imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
for (int j = 0; j < imageCount; j++)
{
filters = gdpicturePDF.GetPageImageFilters(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + "The image indexed as " + j.ToString() + " has the following filters: " + string.Join(",", filters) + "\n";
else
message = message + "The GetPageImageFilters() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
if (status == GdPictureStatus.OK)
message = message + "This page doesn't contain any image.\n";
else
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
message = message + "The SelectPage() method has failed for the image nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the type of the image masking of an image, specified by its index within the currently selected page of the loaded PDF document.
The 0-based index of the image within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfImageMaskType enumeration. A masking type of a specified image.
The method can be subsequently used to determine if this method has been successful.
How to properly use the mask mode when replacing images, which have been converted to black and white.
Dim caption As String = "Example: GetPageImageMaskMode"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim oGdPictureImaging As GdPictureImaging = New GdPictureImaging()
Dim status As GdPictureStatus = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
Dim imageCount As Integer = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim imageID As Integer = 0, bitDepth As Integer = 0
Dim maskMode As PdfImageMaskType = PdfImageMaskType.PdfMaskTypeUnknown
Dim cs As PdfColorSpace = PdfColorSpace.PdfColorSpaceUnknown
Dim mask As Boolean = False
For i As Integer = 0 To imageCount - 1
imageID = gdpicturePDF.ExtractPageImage(i+1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
mask = False
bitDepth = oGdPictureImaging.GetBitDepth(imageID)
status = oGdPictureImaging.GetStat()
If status = GdPictureStatus.OK Then
If bitDepth <> 1 Then
status = oGdPictureImaging.FxGrayscale(imageID)
Else
cs = gdpicturePDF.GetPageImageColorSpace(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If cs <> PdfColorSpace.PdfColorSpaceDeviceGray Then
status = oGdPictureImaging.ConvertTo1Bpp(imageID)
End If
End If
If status = GdPictureStatus.OK Then
maskMode = gdpicturePDF.GetPageImageMaskMode(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
mask = ((maskMode <> PdfImageMaskType.PdfMaskTypeNone) AndAlso (maskMode <> PdfImageMaskType.PdfMaskTypeUnknown))
End If
End If
End If
If status = GdPictureStatus.OK Then
status = gdpicturePDF.ReplaceImage(gdpicturePDF.GetPageImageResName(i), imageID, mask)
End If
End If
oGdPictureImaging.ReleaseGdPictureImage(imageID)
If status <> GdPictureStatus.OK Then
MessageBox.Show("Finding image properties or replacing the image has failed with the status: " + status.ToString(), caption)
Exit For
End If
Else
MessageBox.Show("The ExtractPageImage() method has failed with the status: " + status.ToString(), caption)
Exit For
End If
Next
If imageCount > 0 Then
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_updated.pdf", True)
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The first page does not contain any image. The document has not been saved.", caption)
End If
Else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
oGdPictureImaging.Dispose()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageImageMaskMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
GdPictureStatus status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
int imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int imageID = 0, bitDepth = 0;
PdfImageMaskType maskMode = PdfImageMaskType.PdfMaskTypeUnknown;
PdfColorSpace cs = PdfColorSpace.PdfColorSpaceUnknown;
bool mask = false;
for (int i = 0; i < imageCount; i++)
{
imageID = gdpicturePDF.ExtractPageImage(i+1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
mask = false;
bitDepth = oGdPictureImaging.GetBitDepth(imageID);
status = oGdPictureImaging.GetStat();
if (status == GdPictureStatus.OK)
{
if (bitDepth != 1)
{
status = oGdPictureImaging.FxGrayscale(imageID);
}
else
{
cs = gdpicturePDF.GetPageImageColorSpace(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (cs != PdfColorSpace.PdfColorSpaceDeviceGray)
{
status = oGdPictureImaging.ConvertTo1Bpp(imageID);
}
}
if (status == GdPictureStatus.OK)
{
maskMode = gdpicturePDF.GetPageImageMaskMode(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
mask = ((maskMode != PdfImageMaskType.PdfMaskTypeNone) && (maskMode != PdfImageMaskType.PdfMaskTypeUnknown));
}
}
}
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.ReplaceImage(gdpicturePDF.GetPageImageResName(i), imageID, mask);
}
}
oGdPictureImaging.ReleaseGdPictureImage(imageID);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("Finding image properties or replacing the image has failed with the status: " + status.ToString(), caption);
break;
}
}
else
{
MessageBox.Show("The ExtractPageImage() method has failed with the status: " + status.ToString(), caption);
break;
}
}
if (imageCount > 0)
{
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_updated.pdf", true);
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The first page does not contain any image. The document has not been saved.", caption);
}
else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
oGdPictureImaging.Dispose();
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the color space of an image, specified by its index within the currently selected page of the loaded PDF document.
The 0-based index of the image within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfColorSpace enumeration. A color space of a specified image.
The method can be subsequently used to determine if this method has been successful.
How to find out the colorspace of all images contained within the PDF document.
Dim caption As String = "Example: GetPageImageColorSpace"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim message As String = ""
Dim imageCount As Integer = 0
Dim colorspace As PdfColorSpace = PdfColorSpace.PdfColorSpaceUnknown
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
For i As Integer = 1 To pageCount
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + ":" + vbCrLf
imageCount = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
For j As Integer = 0 To imageCount - 1
colorspace = gdpicturePDF.GetPageImageColorSpace(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "The image indexed as " + j.ToString() + " has the following color space: " + colorspace.ToString() + "." + vbCrLf
Else
message = message + "The GetPageImageColorSpace() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
Else
If status = GdPictureStatus.OK Then
message = message + "This page doesn't contain any image." + vbCrLf
Else
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
End If
Else
message = message + "The SelectPage() method has failed for the image nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageImageColorSpace";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string message = "";
int imageCount = 0;
PdfColorSpace colorspace = PdfColorSpace.PdfColorSpaceUnknown;
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
for (int i = 1; i <= pageCount; i++)
{
if (gdpicturePDF.SelectPage(i) == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + ":\n";
imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
for (int j = 0; j < imageCount; j++)
{
colorspace = gdpicturePDF.GetPageImageColorSpace(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + "The image indexed as " + j.ToString() + " has the following colorspace: " + colorspace.ToString() + ".\n";
else
message = message + "The GetPageImageColorSpace() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
if (status == GdPictureStatus.OK)
message = message + "This page doesn't contain any image.\n";
else
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
message = message + "The SelectPage() method has failed for the image nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the ICC profile of an image, specified by its index within the currently selected page of the loaded PDF document.
The 0-based index of the image within the current page. It must be a value from 0 to -1.
Output parameter. An array of bytes containing the ICC profile data.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the vertical and the horizontal resolution (DPI) of an image, specified by its index within the currently selected page of the loaded PDF document.
The 0-based index of the image within the current page. It must be a value from 0 to -1.
Output parameter. The horizontal resolution (DPI) of the specified image.
Output parameter. The vertical resolution (DPI) of the specified image.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to find out the resolution (both horizontal and vertical) of all images contained within the PDF document.
Dim caption As String = "Example: GetPageImageResolution"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
For i As Integer = 1 To pageCount
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + ":" + vbCrLf
Dim imageCount As Integer = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
Dim hRes As Single = 0, vRes As Single = 0
For j As Integer = 0 To imageCount - 1
status = gdpicturePDF.GetPageImageResolution(j, hRes, vRes)
If status = GdPictureStatus.OK Then
message = message + "The image indexed as " + j.ToString() + " has the following resolution: horizontal = " + hRes.ToString() + ", vertical = " + vRes.ToString() + "." + vbCrLf
Else
message = message + "The GetPageImageResolution() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
Else
If status = GdPictureStatus.OK Then
message = message + "This page doesn't contain any image." + vbCrLf
Else
message = message + "The GetPageImageCount() method has failed with the status: " + status.ToString() + vbCrLf
End If
End If
Else
message = message + "The SelectPage() method has failed for the page nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageImageResolution";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
for (int i = 1; i <= pageCount; i++)
{
if (gdpicturePDF.SelectPage(i) == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + ":\n";
int imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
float hRes = 0, vRes = 0;
for (int j = 0; j < imageCount; j++)
{
status = gdpicturePDF.GetPageImageResolution(j, ref hRes, ref vRes);
if (status == GdPictureStatus.OK)
message = message + "The image indexed as " + j.ToString() + " has the following resolution: horizontal = " + hRes.ToString() + ", vertical = " + vRes.ToString() + ".\n";
else
message = message + "The GetPageImageResolution() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
if (status == GdPictureStatus.OK)
message = message + "This page doesn't contain any image.\n";
else
message = message + "The GetPageImageCount() method has failed with the status: " + status.ToString() + "\n";
}
}
else
{
message = message + "The SelectPage() method has failed for the page nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the width and the height of an image, specified by its index within the currently selected page of the loaded PDF document. Both dimensions are
constantly expressed in pixels.
The 0-based index of the image within the current page. It must be a value from 0 to -1.
Output parameter. The width of the specified image, in pixels.
Output parameter. The height of the specified image, in pixels.
This method is only allowed for use with non-encrypted documents.
Be aware that the width and the height parameters are the original dimensions of the image resource added to the current document,
just before the image itself has been drawn.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to redraw all images from the first page of the PDF document to one image per new page within the same document using the image dimensions.
Dim caption As String = "Example: GetPageImageSize"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
'The first page is automatically selected as the current page.
Dim imageCount As Integer = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
Dim message As String = ""
Dim imageResName As String = ""
Dim width As Integer = 0, height As Integer = 0
For i As Integer = 0 To imageCount - 1
imageResName = gdpicturePDF.GetPageImageResName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.GetPageImageSize(i, width, height) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(imageResName, 0, 0, width, height) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
'We need to move again to the page nr.1 because the newly added page is selected after drawing.
message = message + "The image indexed as " + i.ToString() + " with the dimensions [width = " + width.ToString() + ", height = " + height.ToString() + "] has been drawn successfully." + vbCrLf
Else
message = message + "The image indexed as " + i.ToString() + " has failed to draw with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + "The GetPageImageResName() method has failed with the status: " + status.ToString()
End If
Next
If gdpicturePDF.SaveToFile("test_GetPageImageSize.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved successfully."
Else
message = message + "The file has not been saved successfully."
End If
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("The first page doesn't contain any image.", caption)
Else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageImageSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
//The first page is automatically selected as the current page.
int imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
string message = "";
string imageResName = "";
int width = 0, height = 0;
for (int i = 0; i < imageCount; i++)
{
imageResName = gdpicturePDF.GetPageImageResName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.GetPageImageSize(i, ref width, ref height) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(imageResName, 0, 0, width, height) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
{
//We need to move again to the page nr.1 because the newly added page is selected after drawing.
message = message + "The image indexed as " + i.ToString() + " with the dimensions [width = " + width.ToString() + ", height = " + height.ToString() + "] has been drawn successfully.\n";
}
else
message = message + "The image indexed as " + i.ToString() + " has failed to draw with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + "The GetPageImageResName() method has failed with the status: " + status.ToString();
}
if (gdpicturePDF.SaveToFile("test_GetPageImageSize.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved successfully.";
else
message = message + "The file has not been saved successfully.";
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("The first page doesn't contain any image.", caption);
else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the bit depth of an image, specified by its index within the currently selected page of the loaded PDF document.
The 0-based index of the image within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The bit (color) depth of a specified image. The method can be subsequently used to determine if this method has been successful.
How to find out the bit depth of all images contained within the PDF document.
Dim caption As String = "Example: GetPageImageBitDepth"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim message As String = ""
Dim imageCount As Integer = 0, bitDepth As Integer = 0
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
For i As Integer = 1 To pageCount
If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
message = message + "Page nr." + i.ToString() + ":" + vbCrLf
imageCount = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
For j As Integer = 0 To imageCount - 1
bitDepth = gdpicturePDF.GetPageImageBitDepth(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "The image indexed as " + j.ToString() + " has the following bit depth: " + bitDepth.ToString() + "." + vbCrLf
Else
message = message + "The GetPageImageBitDepth() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
Else
If status = GdPictureStatus.OK Then
message = message + "This page doesn't contain any image." + vbCrLf
Else
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
End If
Else
message = message + "The SelectPage() method has failed for the image nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageImageBitDepth";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string message = "";
int imageCount = 0, bitDepth = 0;
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
for (int i = 1; i <= pageCount; i++)
{
if (gdpicturePDF.SelectPage(i) == GdPictureStatus.OK)
{
message = message + "Page nr." + i.ToString() + ":\n";
imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
for (int j = 0; j < imageCount; j++)
{
bitDepth = gdpicturePDF.GetPageImageBitDepth(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + "The image indexed as " + j.ToString() + " has the following bit depth: " + bitDepth.ToString() + ".\n";
else
message = message + "The GetPageImageBitDepth() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
if (status == GdPictureStatus.OK)
message = message + "This page doesn't contain any image.\n";
else
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
message = message + "The SelectPage() method has failed for the image nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the number of all images contained within the currently selected page of the loaded PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of all images included within the current page. The method can be subsequently used to determine if this method has been successful.
How to find out the number of images contained within all pages of the PDF document.
Dim caption As String = "Example: GetPageImageCount"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
Dim message As String = ""
Dim imageCount As Integer = 0
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
imageCount = gdpicturePDF.GetPageImageCount()
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString() + " contains " + imageCount.ToString() + " images." + vbCrLf
Else
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
MessageBox.Show("The SelectPage() method has failed for the page number " + i.ToString() + " with the status: " + status.ToString(), caption)
Exit For
End If
Next
MessageBox.Show(message, caption)
Else
If (status = GdPictureStatus.OK) Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageImageCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
string message = "";
int imageCount = 0;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
imageCount = gdpicturePDF.GetPageImageCount();
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString() + " contains " + imageCount.ToString() + " images.\n";
}
else
{
message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
}
else
{
MessageBox.Show("The SelectPage() method has failed for the page number " + i.ToString() + " with the status: " + status.ToString(), caption);
break;
}
}
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the resource name of an image, specified by its index within the currently selected page of the loaded PDF document. The returned resource
name is strictly bounded to the current document and can be only used inside this document, for example, when drawing etc.
The 0-based index of the image within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Just to remind you that you need to use the method to be able to handle the image outside of the current document.
The resource name of the image. The method can be subsequently used to determine if this method has been successful.
How to redraw all images from the first page of the PDF document to one image per new page within the same document using the image resource name.
Dim caption As String = "Example: GetPageImageResName"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
'The first page is automatically selected as the current page.
Dim imageCount As Integer = gdpicturePDF.GetPageImageCount()
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
Dim message As String = ""
Dim imageResName As String = ""
Dim width As Integer = 0, height As Integer = 0
For i As Integer = 0 To imageCount - 1
imageResName = gdpicturePDF.GetPageImageResName(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.GetPageImageSize(i, width, height) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(imageResName, 0, 0, width, height) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
'We need to move again to the page nr.1 because the newly added page is selected after drawing.
message = message + "The image indexed as " + i.ToString() + " has been drawn successfully." + vbCrLf
Else
message = message + "The image indexed as " + i.ToString() + " has failed to draw with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
message = message + "The GetPageImageResName() method has failed with the status: " + status.ToString()
End If
Next
If gdpicturePDF.SaveToFile("test_GetPageImageResName.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved successfully."
Else
message = message + "The file has not been saved successfully."
End If
MessageBox.Show(message, caption)
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("The first page doesn't contain any image.", caption)
Else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageImageResName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
//The first page is automatically selected as the current page.
int imageCount = gdpicturePDF.GetPageImageCount();
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
string message = "";
string imageResName = "";
int width = 0, height = 0;
for (int i = 0; i < imageCount; i++)
{
imageResName = gdpicturePDF.GetPageImageResName(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.GetPageImageSize(i, ref width, ref height) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(imageResName, 0, 0, width, height) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
{
//We need to move again to the page nr.1 because the newly added page is selected after drawing.
message = message + "The image indexed as " + i.ToString() + " has been drawn successfully.\n";
}
else
message = message + "The image indexed as " + i.ToString() + " has failed to draw with the status: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
message = message + "The GetPageImageResName() method has failed with the status: " + status.ToString();
}
if (gdpicturePDF.SaveToFile("test_GetPageImageResName.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved successfully.";
else
message = message + "The file has not been saved successfully.";
MessageBox.Show(message, caption);
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("The first page doesn't contain any image.", caption);
else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Extracts an image, specified by its number within the currently selected page of the loaded PDF document, into a new GdPictureImage object.
The specified image is extracted as a resource to an object of the type GdPictureImage, in other words the image resource becomes independent of the source document.
The image is clearly recognizable by the returned unique image identifier and it can be subsequently used outside the source document, for example, you can add this image into another PDF document.
It is also possible to take advantages of the class and its methods for further manipulation with this image.
The image number of the required image within the current page. It must be a value from 1 to .
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A unique image identifier of the newly created image object of the type GdPictureImage. The method can be subsequently used to determine if this method has been successful.
Just to remind you that you need to release the image after being used, for example, using the static method.
How to extract all images from the first page of the source PDF document to the newly created destination PDF document. All images are drawn one image per page.
Dim caption As String = "Example: ExtractPageImage"
Dim gdpicturePDFSrc As New GdPicturePDF()
If gdpicturePDFSrc.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDFSrc.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDFSrc.GetStat()
If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
'The first page is automatically selected as the current page.
Dim imageCount As Integer = gdpicturePDFSrc.GetPageImageCount()
status = gdpicturePDFSrc.GetStat()
If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
Dim gdpicturePDFDest As New GdPicturePDF()
If gdpicturePDFDest.NewPDF() = GdPictureStatus.OK Then
Dim message As String = ""
Dim imageID As Integer = 0
For i As Integer = 1 To imageCount
imageID = gdpicturePDFSrc.ExtractPageImage(i)
status = gdpicturePDFSrc.GetStat()
If status = GdPictureStatus.OK Then
Dim res_name As String = gdpicturePDFDest.AddImageFromGdPictureImage(imageID, False, True)
status = gdpicturePDFSrc.GetStat()
If status = GdPictureStatus.OK Then
message = message + "The image nr. " + i.ToString() + " has been successfully drawn." + vbCrLf
Else
message = message + "The AddImageFromGdPictureImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
If GdPictureDocumentUtilities.DisposeImage(imageID) <> GdPictureStatus.OK Then
message = message + "The DisposeImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The ExtractPageImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDFDest.SaveToFile("test_ExtractPageImage.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved successfully."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDFDest.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDFDest.GetStat().ToString(), caption)
End If
gdpicturePDFDest.Dispose()
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("This file doesn't contain any image.", caption)
Else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.OK Then
MessageBox.Show("The first page doesn't contain any page.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDFSrc.Dispose()
string caption = "Example: ExtractPageImage";
GdPicturePDF gdpicturePDFSrc = new GdPicturePDF();
if (gdpicturePDFSrc.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDFSrc.GetPageCount();
GdPictureStatus status = gdpicturePDFSrc.GetStat();
if ((status == GdPictureStatus.OK) && (pageCount > 0))
{
//The first page is automatically selected as the current page.
int imageCount = gdpicturePDFSrc.GetPageImageCount();
status = gdpicturePDFSrc.GetStat();
if ((status == GdPictureStatus.OK) && (imageCount > 0))
{
GdPicturePDF gdpicturePDFDest = new GdPicturePDF();
if (gdpicturePDFDest.NewPDF() == GdPictureStatus.OK)
{
string message = "";
int imageID = 0;
for (int i = 1; i <= imageCount; i++)
{
imageID = gdpicturePDFSrc.ExtractPageImage(i);
status = gdpicturePDFSrc.GetStat();
if (status == GdPictureStatus.OK)
{
string res_name = gdpicturePDFDest.AddImageFromGdPictureImage(imageID, false, true);
status = gdpicturePDFSrc.GetStat();
if (status == GdPictureStatus.OK)
message = message + "The image nr. " + i.ToString() + " has been successfully drawn.\n";
else
message = message + "The AddImageFromGdPictureImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
if (GdPictureDocumentUtilities.DisposeImage(imageID) != GdPictureStatus.OK)
message = message + "The DisposeImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The ExtractPageImage() method has failed for the image nr. " + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDFDest.SaveToFile("test_ExtractPageImage.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved successfully.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDFDest.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDFDest.GetStat().ToString(), caption);
gdpicturePDFDest.Dispose();
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("The first page doesn't contain any image.", caption);
else
MessageBox.Show("The GetPageImageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.OK)
MessageBox.Show("This file doesn't contain any page.", caption);
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDFSrc.Dispose();
Specifies if fuzzy match is activated during any text search operation.
When enabled, a text search operation searches for text that matches a term closely instead of exactly.
Fuzzy match is disabled by default.
True to enable fuzzy search, false otherwise.
Searches for an occurrence of a given regular expression pattern within the current page of the loaded PDF document according to the parameters you have specified.
This method returns bounding box surrounding the searched expression or set of bounding boxes in case the searched expression spans across multiple lines, defined by its top left coordinates and by its width and height
in inches, if the expression has been found.
The regular expression pattern to search for.
The occurrence (rank) of the searched expression on the current page. Set the occurrence to 1 if you are searching for the first occurrence, set it to 2 for the second etc.
Rank equal to 0 is not accepted, it will always be converted to 1. Please note that the occurrence (rank) is always related to the current page.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
Output parameter. If the searched expression has been found, this parameter will output an IEnumerable of rectangle areas that surround the occurrence in inches.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the given text expression has been found on the current page according to the specified parameters, otherwise false. The method can be subsequently used to determine if this method has been successful.
Searches for an occurrence of a given regular expression pattern within the current page of the loaded PDF document according to the parameters you have specified.
This method returns bounding box surrounding the searched expression or set of bounding boxes in case the searched expression spans across multiple lines, defined by its top left coordinates and by its width and height
in inches, if the expression has been found.
The regular expression pattern to search for.
The occurrence (rank) of the searched expression on the current page. Set the occurrence to 1 if you are searching for the first occurrence, set it to 2 for the second etc.
Rank equal to 0 is not accepted, it will always be converted to 1. Please note that the occurrence (rank) is always related to the current page.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
Set this parameter to true to return the bounding box of only the exact matched text span (e.g., substring/character-level), without expanding to the surrounding word.
Output parameter. If the searched expression has been found, this parameter will output an IEnumerable of rectangle areas that surround the occurrence in inches.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the given text expression has been found on the current page according to the specified parameters, otherwise false. The method can be subsequently used to determine if this method has been successful.
Searches for an occurrence of a given text expression within the current page of the loaded PDF document according to the parameters you have specified.
This method returns the bounding box (rectangle) surrounding the searched expression defined by its top left coordinates and by its width and height
in inches, if the expression has been found.
This method uses the InvariantCulture comparison when searching. It means, that characters are comparing using culture-sensitive sort rules
and the invariant culture, in other words this method respects accents when searching.
Searches for an occurrence of a given text expression within the current page of the loaded PDF document applying either the Ordinal or the InvariantCulture comparison.
The text expression to search for.
The occurrence (rank) of the searched expression on the current page. Set the occurrence to 1 if you are searching for the first occurrence, set it to 2 for the second etc.
Rank equal to 0 is not accepted, it will always be converted to 1. Please note that the occurrence (rank) is always related to the current page.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
Set this parameter to true if you want to search for the whole words only, otherwise set it to false.
Output parameter. If the searched expression has been found, this is the horizontal (X) coordinate of the top left point of its surrounding bounding box, in inches.
Output parameter. If the searched expression has been found, this is the vertical (Y) coordinate of the top left point of its surrounding bounding box, in inches.
Output parameter. If the searched expression has been found, this is the width of the bounding box surrounding the expression, in inches.
Output parameter. If the searched expression has been found, this is the height of the bounding box surrounding the expression, in inches.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that this method respects accents when searching. You can use the
overloaded method for searching not respecting accents.
true if the given text expression has been found on the current page according to the specified parameters, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to search for all occurrences of a specified text expression across the whole PDF document.
Dim caption As String = "Example: SearchText"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim text_file As New System.IO.StreamWriter("search_text.txt")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim textToFind As String = "text"
Dim message As String = Nothing
Dim occurrence As Integer = 1
Dim found As Boolean = False
Dim posLeft As Single = 0, posTop As Single = 0, posWidth As Single = 0, posHeight As Single = 0
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = "Page: " + i.ToString() + " Status: " + status.ToString()
text_file.WriteLine(message)
'The occurrence of the searched text is related to the current page.
occurrence = 1
Do
found = gdpicturePDF.SearchText(textToFind, occurrence, False, False, posLeft, posTop, posWidth, posHeight)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK AndAlso found Then
message = "Occurrence: " + occurrence.ToString() + " Position: (" + posLeft.ToString() + ";" + posTop.ToString() + ";" + posWidth.ToString() + ";" + posHeight.ToString() + ")"
text_file.WriteLine(message)
End If
occurrence += 1
Loop While found = True
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
text_file.Close()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
MessageBox.Show("Searching finished.", caption)
gdpicturePDF.Dispose()
string caption = "Example: SearchText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.StreamWriter text_file = new System.IO.StreamWriter("search_text.txt");
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string textToFind = "text";
string message = null;
int occurrence = 1;
bool found = false;
float posLeft = 0, posTop = 0, posWidth = 0, posHeight = 0;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = "Page: " + i.ToString() + " Status: " + status.ToString();
text_file.WriteLine(message);
//The occurrence of the searched text is related to the current page.
occurrence = 1;
do
{
found = gdpicturePDF.SearchText(textToFind, occurrence, false, false, ref posLeft, ref posTop, ref posWidth, ref posHeight);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK && found)
{
message = "Occurrence: " + occurrence.ToString() + " Position: (" + posLeft.ToString() + ";" + posTop.ToString() + ";" + posWidth.ToString() + ";" + posHeight.ToString() + ")";
text_file.WriteLine(message);
}
occurrence++;
} while (found == true);
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
text_file.Close();
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
MessageBox.Show("Searching finished.", caption);
gdpicturePDF.Dispose();
Searches for an occurrence of a given text expression within the current page of the loaded PDF document according to the parameters you have specified.
This method returns the bounding box (rectangle) surrounding the searched expression defined by its top left coordinates and by its width and height
in inches, if the expression has been found.
You can benefit from selecting the comparison option using this method, in other words, you can search respecting accents or not in the given text expression.
Searches for an occurrence of a given text expression within the current page of the loaded PDF document applying either Ordinal or InvariantCulture comparison.
The text expression to search for.
The occurrence (rank) of the searched expression on the current page. Set the occurrence to 1 if you are searching for the first occurrence, set it to 2 for the second etc.
Rank equal to 0 is not accepted, it will always be converted to 1. Please note that the occurrence (rank) is always related to the current page.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
Set this parameter to true if you want to search for the whole words only, otherwise set it to false.
Set this parameter to true if you want to search applying the ordinal (binary) sort rules, otherwise set it to false.
An ordinal comparison compares strictly on the numeric character values, that means it does not respect accents.
Output parameter. If the searched expression has been found, this is the horizontal (X) coordinate of the top left point of its surrounding bounding box, in inches.
Output parameter. If the searched expression has been found, this is the vertical (Y) coordinate of the top left point of its surrounding bounding box, in inches.
Output parameter. If the searched expression has been found, this is the width of the bounding box surrounding the expression, in inches.
Output parameter. If the searched expression has been found, this is the height of the bounding box surrounding the expression, in inches.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the given text expression has been found on the current page according to the specified parameters, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to search for all occurrences of a specified text expression across the whole PDF document.
Dim caption As String = "Example: SearchText"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim text_file As New System.IO.StreamWriter("search_text.txt")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim textToFind As String = "text"
Dim message As String = Nothing
Dim occurrence As Integer = 1
Dim found As Boolean = False
Dim posLeft As Single = 0, posTop As Single = 0, posWidth As Single = 0, posHeight As Single = 0
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = "Page: " + i.ToString() + " Status: " + status.ToString()
text_file.WriteLine(message)
'The occurrence of the searched text is related to the current page.
occurrence = 1
Do
found = gdpicturePDF.SearchText(textToFind, occurrence, False, False, True, posLeft, posTop, posWidth, posHeight)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK AndAlso found Then
message = "Occurrence: " + occurrence.ToString() + " Position: (" + posLeft.ToString() + ";" + posTop.ToString() + ";" + posWidth.ToString() + ";" + posHeight.ToString() + ")"
text_file.WriteLine(message)
End If
occurrence += 1
Loop While found = True
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
text_file.Close()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
MessageBox.Show("Searching finished.", caption)
gdpicturePDF.Dispose()
string caption = "Example: SearchText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.StreamWriter text_file = new System.IO.StreamWriter("search_text.txt");
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string textToFind = "text";
string message = null;
int occurrence = 1;
bool found = false;
float posLeft = 0, posTop = 0, posWidth = 0, posHeight = 0;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = "Page: " + i.ToString() + " Status: " + status.ToString();
text_file.WriteLine(message);
//The occurrence of the searched text is related to the current page.
occurrence = 1;
do
{
found = gdpicturePDF.SearchText(textToFind, occurrence, false, false, true, ref posLeft, ref posTop, ref posWidth, ref posHeight);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK && found)
{
message = "Occurrence: " + occurrence.ToString() + " Position: (" + posLeft.ToString() + ";" + posTop.ToString() + ";" + posWidth.ToString() + ";" + posHeight.ToString() + ")";
text_file.WriteLine(message);
}
occurrence++;
} while (found == true);
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
text_file.Close();
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
MessageBox.Show("Searching finished.", caption);
gdpicturePDF.Dispose();
Searches for an occurrence of a given text expression within the current page of the loaded PDF document according to the parameters you have specified.
This method returns bounding box surrounding the searched expression or set of bounding boxes in case the searched expression spans across multiple lines, defined by its top left coordinates and by its width and height
in inches, if the expression has been found.
You can benefit from selecting the comparison option using this method, in other words, you can search respecting accents or not in the given text expression.
Searches for an occurrence of a given text expression within the current page of the loaded PDF document applying either Ordinal or InvariantCulture comparison.
The text expression to search for.
The occurrence (rank) of the searched expression on the current page. Set the occurrence to 1 if you are searching for the first occurrence, set it to 2 for the second etc.
Rank equal to 0 is not accepted, it will always be converted to 1. Please note that the occurrence (rank) is always related to the current page.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
Set this parameter to true if you want to search for the whole words only, otherwise set it to false.
Set this parameter to true if you want to search applying the ordinal (binary) sort rules, otherwise set it to false.
An ordinal comparison compares strictly on the numeric character values, that means it does not respect accents.
Output parameter. If the searched expression has been found, this parameter will output array of rectangle areas that surround the occurrence in inches.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the given text expression has been found on the current page according to the specified parameters, otherwise false. The method can be subsequently used to determine if this method has been successful.
Searches for an occurrence of a given text expression within the current page of the loaded PDF document according to the parameters you have specified.
This method returns the bounding box (rectangle) surrounding the searched expression defined by its top left coordinates and by its width and height
in inches, if the expression has been found.
You can benefit from selecting the comparison option using this method, in other words, you can search respecting accents or not in the given text expression.
Searches for an occurrence of a given text expression within the current page of the loaded PDF document applying either Ordinal or InvariantCulture comparison.
The text expression to search for.
The occurrence (rank) of the searched expression on the current page. Set the occurrence to 1 if you are searching for the first occurrence, set it to 2 for the second etc.
Rank equal to 0 is not accepted, it will always be converted to 1. Please note that the occurrence (rank) is always related to the current page.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
Set this parameter to true if you want to search for the whole words only, otherwise set it to false.
Set this parameter to true if you want to search for any word in the search expression, otherwise set it to false.
Set this parameter to true if you want to search applying the ordinal (binary) sort rules, otherwise set it to false.
An ordinal comparison compares strictly on the numeric character values, that means it does not respect accents.
Output parameter. If the searched expression has been found, this is the horizontal (X) coordinate of the top left point of its surrounding bounding box, in inches.
Output parameter. If the searched expression has been found, this is the vertical (Y) coordinate of the top left point of its surrounding bounding box, in inches.
Output parameter. If the searched expression has been found, this is the width of the bounding box surrounding the expression, in inches.
Output parameter. If the searched expression has been found, this is the height of the bounding box surrounding the expression, in inches.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the given text expression has been found on the current page according to the specified parameters, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to search for all occurrences of a specified text expression across the whole PDF document.
Dim caption As String = "Example: SearchText"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim text_file As New System.IO.StreamWriter("search_text.txt")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim textToFind As String = "text"
Dim message As String = Nothing
Dim occurrence As Integer = 1
Dim found As Boolean = False
Dim posLeft As Single = 0, posTop As Single = 0, posWidth As Single = 0, posHeight As Single = 0
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = "Page: " + i.ToString() + " Status: " + status.ToString()
text_file.WriteLine(message)
'The occurrence of the searched text is related to the current page.
occurrence = 1
Do
found = gdpicturePDF.SearchText(textToFind, occurrence, False, False, True, True, posLeft, posTop, posWidth, posHeight)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK AndAlso found Then
message = "Occurrence: " + occurrence.ToString() + " Position: (" + posLeft.ToString() + ";" + posTop.ToString() + ";" + posWidth.ToString() + ";" + posHeight.ToString() + ")"
text_file.WriteLine(message)
End If
occurrence += 1
Loop While found = True
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
text_file.Close()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
MessageBox.Show("Searching finished.", caption)
gdpicturePDF.Dispose()
string caption = "Example: SearchText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.StreamWriter text_file = new System.IO.StreamWriter("search_text.txt");
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string textToFind = "text";
string message = null;
int occurrence = 1;
bool found = false;
float posLeft = 0, posTop = 0, posWidth = 0, posHeight = 0;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = "Page: " + i.ToString() + " Status: " + status.ToString();
text_file.WriteLine(message);
//The occurrence of the searched text is related to the current page.
occurrence = 1;
do
{
found = gdpicturePDF.SearchText(textToFind, occurrence, false, false, true, true, ref posLeft, ref posTop, ref posWidth, ref posHeight);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK && found)
{
message = "Occurrence: " + occurrence.ToString() + " Position: (" + posLeft.ToString() + ";" + posTop.ToString() + ";" + posWidth.ToString() + ";" + posHeight.ToString() + ")";
text_file.WriteLine(message);
}
occurrence++;
} while (found == true);
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
text_file.Close();
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
MessageBox.Show("Searching finished.", caption);
gdpicturePDF.Dispose();
Searches for an occurrence of a given text expression within the current page of the loaded PDF document according to the parameters you have specified.
This method returns bounding box surrounding the searched expression or set of bounding boxes in case the searched expression spans across multiple lines, defined by its top left coordinates and by its width and height
in inches, if the expression has been found.
You can benefit from selecting the comparison option using this method, in other words, you can search respecting accents or not in the given text expression.
Searches for an occurrence of a given text expression within the current page of the loaded PDF document applying either Ordinal or InvariantCulture comparison.
The text expression to search for.
The occurrence (rank) of the searched expression on the current page. Set the occurrence to 1 if you are searching for the first occurrence, set it to 2 for the second etc.
Rank equal to 0 is not accepted, it will always be converted to 1. Please note that the occurrence (rank) is always related to the current page.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
Set this parameter to true if you want to search for the whole words only, otherwise set it to false.
Set this parameter to true if you want to search for any word in the search expression, otherwise set it to false.
Set this parameter to true if you want to search applying the ordinal (binary) sort rules, otherwise set it to false.
An ordinal comparison compares strictly on the numeric character values, that means it does not respect accents.
Output parameter. If the searched expression has been found, this parameter will output array of rectangle areas that surround the occurrence in inches.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the given text expression has been found on the current page according to the specified parameters, otherwise false. The method can be subsequently used to determine if this method has been successful.
Returns the whole text, regardless if visible or hidden, of the current page of the loaded PDF document.
Just to inform you, that you can use the method to determine if the presented text is rotated on the current page.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please consider using the method to determine the possible text rotation on the current page.
The whole text of the currently selected page as a string. The method can be subsequently used to determine if this method has been successful.
How to extract text of all pages in the PDF document to a text file.
Dim caption As String = "Example: GetPageText"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim text_file As New System.IO.StreamWriter("text_from_pages.txt")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = Nothing
Dim page_text As String = Nothing
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
page_text = gdpicturePDF.GetPageText()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = "Page: " + i.ToString() + " Status: " + status.ToString()
MessageBox.Show(message, caption)
text_file.WriteLine(message)
text_file.WriteLine(page_text)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
text_file.Close()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.StreamWriter text_file = new System.IO.StreamWriter("text_from_pages.txt");
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = null;
string page_text = null;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
page_text = gdpicturePDF.GetPageText();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = "Page: " + i.ToString() + " Status: " + status.ToString();
MessageBox.Show(message, caption);
text_file.WriteLine(message);
text_file.WriteLine(page_text);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
text_file.Close();
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the whole text, regardless if visible or hidden, of the current page of the loaded PDF document including the text properties such as the bounding box coordinates, the font information,
the text mode and the text size. The extracted text from the current page is divided by words. Each word together with its text and font properties is recorded
in one separated line. The space character (between the words in text) is also considered as a word. Two or more spaces in a row are considered as one word.
The resulting string for one word is formatted this way:
the horizontal (X) coordinate of the top left point of the rendering area + [FieldSeparator] +
the vertical (Y) coordinate of the top left point of the rendering area + [FieldSeparator] +
the horizontal (X) coordinate of the top right point of the rendering area + [FieldSeparator] +
the vertical (Y) coordinate of the top right point of the rendering area + [FieldSeparator] +
the horizontal (X) coordinate of the bottom right point of the rendering area + [FieldSeparator] +
the vertical (Y) coordinate of the bottom right point of the rendering area + [FieldSeparator] +
the horizontal (X) coordinate of the bottom left point of the rendering area + [FieldSeparator] +
the vertical (Y) coordinate of the bottom left point of the rendering area + [FieldSeparator] +
extracted word + [FieldSeparator] +
font name + [FieldSeparator] +
font box height + [FieldSeparator] +
text mode + [FieldSeparator] +
text size + EOLThe rendering area means the rectangle area on the page where the extracted word is really situated (rendered).
You can use the provided coordinates to easily calculate the dimensions of this area and the text rotation angle, for more details please refer to the second example below.
You can also benefit from using the method if the presented text is rotated in various angles on the current page.
The result for the current page should contain exactly the same number of lines as is the count of all words including the space-words in the text on that page.
The string that is used to delimit the above enumerated fields in the resulting text.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All returned coordinates are given in points, 1 point = 1/72 inch.
The font box height specifies the height of the font bounding box, expressed in the glyph coordinate system. The font bounding box is the smallest rectangle
enclosing the shape that would result if all the glyphs of the font were placed with their origins coincident and then filled.
Be aware that this value is extracted directly from the font program. If the font program provides incorrect data or if it does not contain any such data,
this value can be misleading.The returned text mode is a member of the PdfTextMode enumeration.
Please consider also using the method to determine the possible text rotation on the current page.
The whole page text divided by one word per text line including the text coordinates and its properties in the above described format.
The method can be subsequently used to determine if this method has been successful.
The first example shows you how to extract the whole text of the PDF document with its coordinates and other properties to a text file.
The second example demonstrates how you can use the provided coordinates to calculate dimensions of rendering areas and possible text rotation angles.
Dim caption As String = "Example: GetPageTextWithCoords"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim text_file As New System.IO.StreamWriter("text_with_coord.txt")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim text As String = ""
Dim message As String = Nothing
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = "Page: " + i.ToString() + " Status: " + status.ToString()
text_file.WriteLine(message)
'You can use your own separator here.
text = gdpicturePDF.GetPageTextWithCoords("---")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
text_file.WriteLine(text)
Else
MessageBox.Show("The GetPageTextWithCoords() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
text_file.Close()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
MessageBox.Show("Searching finished.", caption)
gdpicturePDF.Dispose()
string caption = "Example: GetPageTextWithCoords";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.StreamWriter text_file = new System.IO.StreamWriter("text_with_coord.txt");
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string text = "";
string message = null;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = "Page: " + i.ToString() + " Status: " + status.ToString();
text_file.WriteLine(message);
//You can use your own separator here.
text = gdpicturePDF.GetPageTextWithCoords("---");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
text_file.WriteLine(text);
}
else
{
MessageBox.Show("The GetPageTextWithCoords() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
text_file.Close();
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
MessageBox.Show("Searching finished.", caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: GetPageTextWithCoords"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
gdpicturePDF.SelectPage(1)
Dim text As String = gdpicturePDF.GetPageTextWithCoords("~")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim coord As String() = text.Split("~")
'Considering only the first word as an example. Let assume the text is rotated.
'Calculating the vector to determine the height of the rendering area for the first word.
Dim vectorXH As Double = Double.Parse(coord(0)) - Double.Parse(coord(6))
Dim vectorYH As Double = Double.Parse(coord(7)) - Double.Parse(coord(1))
'Calculating the height of the area.
Dim areaHeight As Double = Math.Sqrt(vectorXH * vectorXH + vectorYH * vectorYH)
'Calculating the vector to determine the width of the rendering area for the first word.
Dim vectorXW As Double = Double.Parse(coord(6)) - Double.Parse(coord(4))
Dim vectorYW As Double = Double.Parse(coord(7)) - Double.Parse(coord(5))
'Calculating the width of the area.
Dim areaWidth As Double = Math.Sqrt(vectorXW * vectorXW + vectorYW * vectorYW)
'Calculating the text rotation angle.
Dim angle As Double = Math.Atan2(vectorXH, vectorYH) * (180 / Math.PI)
'Be aware that the resulting angle is relative to the chosen base axis.
'Continue...
Else
MessageBox.Show("The GetPageTextWithCoords() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
End Using
string caption = "Example: GetPageTextWithCoords";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
gdpicturePDF.SelectPage(1);
string text = gdpicturePDF.GetPageTextWithCoords("~");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string[] coord = text.Split('~');
//Considering only the first word as an example. Let assume the text is rotated.
//Calculating the vector to determine the height of the rendering area for the first word.
double vectorXH = double.Parse(coord[0]) - double.Parse(coord[6]);
double vectorYH = double.Parse(coord[7]) - double.Parse(coord[1]);
//Calculating the height of the area.
double boxHeight = Math.Sqrt(vectorXH * vectorXH + vectorYH * vectorYH);
//Calculating the vector to determine the width of the rendering area for the first word.
double vectorXW = double.Parse(coord[6]) - double.Parse(coord[4]);
double vectorYW = double.Parse(coord[7]) - double.Parse(coord[5]);
//Calculating the width of the area.
double boxWidth = Math.Sqrt(vectorXW * vectorXW + vectorYW * vectorYW);
//Calculating the text rotation angle.
double angle = Math.Atan2(vectorXH, vectorYH) * (180 / Math.PI);
//Be aware that the resulting angle is relative to the chosen base axis.
//Continue...
}
else
{
MessageBox.Show("The GetPageTextWithCoords() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
}
Returns various information about extracted text, regardless if visible or hidden, on the current page of the loaded PDF document such as the bounding box coordinates, the font information,
the text mode and the text size, glyph widths and glyph character representations. The extracted text from the current page is divided by words.
This method allows to include and exclude each information to better suit the use case.
Each word together with its text and font properties completed with widths of single characters is recorded in one separated line.
The space character (between the words in text) is also considered as a word. Two or more spaces in a row are considered as one word.
The resulting string for one word is formatted this way if all flags are set:
the horizontal (X) coordinate of the top left point of the rendering area + [FieldSeparator] +
the vertical (Y) coordinate of the top left point of the rendering area + [FieldSeparator] +
the horizontal (X) coordinate of the top right point of the rendering area + [FieldSeparator] +
the vertical (Y) coordinate of the top right point of the rendering area + [FieldSeparator] +
the horizontal (X) coordinate of the bottom right point of the rendering area + [FieldSeparator] +
the vertical (Y) coordinate of the bottom right point of the rendering area + [FieldSeparator] +
the horizontal (X) coordinate of the bottom left point of the rendering area + [FieldSeparator] +
the vertical (Y) coordinate of the bottom left point of the rendering area + [FieldSeparator] +
extracted word + [FieldSeparator] +
font name + [FieldSeparator] +
font box height + [FieldSeparator] +
text mode + [FieldSeparator] +
text size + [FieldSeparator] +
array of widths for each single glyph of the extracted word delimited by the [FieldSeparator] +
array of character representations for each single glyph of the extracted word delimited by the [FieldSeparator] + EOL
The rendering area means the rectangle area on the page where the extracted word is really situated (rendered).
You can use the provided coordinates to easily calculate the dimensions of this area, the coordinates of the single characters and the text rotation angle.
You can also benefit from using the method if the presented text is rotated in various angles on the current page.
The result for the current page should contain exactly the same number of lines as is the count of all words including the space-words in the text on that page.
The string that is used to delimit the above enumerated fields in the resulting text.
A bitwise combination of values of the TextExtractionOutputInfo enumeration. Specifies which information should be provided in the output.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All returned coordinates are given in points, 1 point = 1/72 inch.
The font box height specifies the height of the font bounding box, expressed in the glyph coordinate system. The font bounding box is the smallest rectangle
enclosing the shape that would result if all the glyphs of the font were placed with their origins coincident and then filled.
Be aware that this value is extracted directly from the font program. If the font program provides incorrect data or if it does not contain any such data,
this value can be misleading.The returned text mode is a member of the PdfTextMode enumeration.
Please consider also using the method to determine the possible text rotation on the current page.
The whole page text divided by one word per text line including the text coordinates and its properties in the above described format.
The method can be subsequently used to determine if this method has been successful.
How to find out and calculate the dimensions of the rendering area for the first word and for the single characters.
Dim caption As String = "Example: GetPageTextWithCoords"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim text As String = gdpicturePDF.GetPageTextWithCoords(" ", TextExtractionOutputInfo.IncludeWordBounds Or
TextExtractionOutputInfo.IncludeWordString Or
TextExtractionOutputInfo.IncludeFontName Or
TextExtractionOutputInfo.IncludeFontBoxHeight Or
TextExtractionOutputInfo.IncludeTextMode Or
TextExtractionOutputInfo.IncludeTextSize Or
TextExtractionOutputInfo.IncludeGlyphWidths)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Considering only the first word as an example.
'Getting the first line with properties of the first word.
Dim index As Integer = text.IndexOf(vbCrLf)
Dim firstLine As String = text.Substring(0, index)
Dim coord As String() = firstLine.Split("~")
'Calculating the vector to determine the height of the rendering area for the first word.
Dim vectorXH As Double = Double.Parse(coord(0)) - Double.Parse(coord(6))
Dim vectorYH As Double = Double.Parse(coord(7)) - Double.Parse(coord(1))
'Calculating the height of the area.
Dim boxHeight As Double = Math.Sqrt(vectorXH * vectorXH + vectorYH * vectorYH)
'Calculating the vector to determine the width of the rendering area for the first word.
Dim vectorXW As Double = Double.Parse(coord(6)) - Double.Parse(coord(4))
Dim vectorYW As Double = Double.Parse(coord(7)) - Double.Parse(coord(5))
'Calculating the width of the area.
Dim boxWidth As Double = Math.Sqrt(vectorXW * vectorXW + vectorYW * vectorYW)
'Getting the first extracted word.
Dim word As String = coord(8)
Dim wordWidth As Double = 0
'13 is the position of the width of first character in the extracted word
For i As Integer = 13 To (13 + word.Length) - 1
'Getting the widths of all single characters in the first word.
wordWidth += Double.Parse(coord(i))
Next
'Calculating the word rotation angle.
Dim angle As Double = Math.Atan2(vectorXH, vectorYH) * (180 / Math.PI)
'Be aware that the resulting angle is relative to the chosen base axis.
'wordWidth should be the same as the boxWidth
If Math.Round(wordWidth, 2) = Math.Round(boxWidth, 2) Then
MessageBox.Show("The example is followed successfully.", caption)
Else
MessageBox.Show("Something is wrong:" + vbCrLf + " wordWidth = " + Math.Round(wordWidth, 2).ToString() + vbCrLf + " boxWidth = " + Math.Round(boxWidth, 2).ToString(), caption)
End If
'Continue...
Else
MessageBox.Show("The GetPageTextWithCoords() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
End Using
string caption = "Example: GetPageTextWithCoords";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string text = gdpicturePDF.GetPageTextWithCoords("~", TextExtractionOutputInfo.IncludeWordBounds |
TextExtractionOutputInfo.IncludeWordString
TextExtractionOutputInfo.IncludeFontName
TextExtractionOutputInfo.IncludeFontBoxHeight
TextExtractionOutputInfo.IncludeTextMode
TextExtractionOutputInfo.IncludeTextSize
TextExtractionOutputInfo.IncludeGlyphWidths);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Considering only the first word as an example.
//Getting the first line with properties of the first word.
int index = text.IndexOf("\r\n");
string firstLine = text.Substring(0, index);
string[] coord = firstLine.Split('~');
//Calculating the vector to determine the height of the rendering area for the first word.
double vectorXH = double.Parse(coord[0]) - double.Parse(coord[6]);
double vectorYH = double.Parse(coord[7]) - double.Parse(coord[1]);
//Calculating the height of the area.
double boxHeight = Math.Sqrt(vectorXH * vectorXH + vectorYH * vectorYH);
//Calculating the vector to determine the width of the rendering area for the first word.
double vectorXW = double.Parse(coord[6]) - double.Parse(coord[4]);
double vectorYW = double.Parse(coord[7]) - double.Parse(coord[5]);
//Calculating the width of the area.
double boxWidth = Math.Sqrt(vectorXW * vectorXW + vectorYW * vectorYW);
//Getting the first extracted word.
string word = coord[8];
double wordWidth = 0;
//13 is the position of the width of first character in the extracted word
for (int i = 13; i < (13 + word.Length); i++)
{
//Getting the widths of all single characters in the first word.
wordWidth += double.Parse(coord[i]);
}
//Calculating the word rotation angle.
double angle = Math.Atan2(vectorXH, vectorYH) * (180 / Math.PI);
//Be aware that the resulting angle is relative to the chosen base axis.
//wordWidth should be the same as the boxWidth
if (Math.Round(wordWidth, 2) == Math.Round(boxWidth, 2))
MessageBox.Show("The example is followed successfully.", caption);
else
MessageBox.Show("Something is wrong:\n wordWidth = " + Math.Round(wordWidth, 2).ToString() + "\n boxWidth = " + Math.Round(boxWidth, 2).ToString(), caption);
//Continue...
}
else
{
MessageBox.Show("The GetPageTextWithCoords() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
}
Returns the text, regardless if visible or hidden, contained within a specific area of the current page of the loaded PDF document.
You have to specify the required page area as a rectangle. This rectangle is defined by its top left coordinates and by its width and height in inches.
Just to inform you, that you can use the method to determine if all text is rotated on the current page.
The horizontal (X) coordinate of the top left point of the rectangle in inches.
The vertical (Y) coordinate of the top left point of the rectangle in inches.
The width of the rectangle in inches.
The height of the rectangle in inches.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please consider using the method to determine the possible text rotation on the current page.
The text contained within the specified area of the currently selected page as a string. The method can be subsequently used to determine if this method has been successful.
How to extract text from the certain page's area of all pages in the PDF document to a text file.
Dim caption As String = "Example: GetPageTextArea"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim text_file As New System.IO.StreamWriter("text_area_from_pages.txt")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = Nothing
Dim page_text As String = Nothing
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
page_text = gdpicturePDF.GetPageTextArea(1, 1, 5, 2)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = "Page: " + i.ToString() + " Status: " + status.ToString()
MessageBox.Show(message, caption)
text_file.WriteLine(message)
text_file.WriteLine(page_text)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
Else
MessageBox.Show("The GetPageCount() has failed with the status: " + status.ToString(), caption)
End If
text_file.Close()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageTextArea";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.StreamWriter text_file = new System.IO.StreamWriter("text_area_from_pages.txt");
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = null;
string page_text = null;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
page_text = gdpicturePDF.GetPageTextArea(1,1,5,2);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = "Page: " + i.ToString() + " Status: " + status.ToString();
MessageBox.Show(message, caption);
text_file.WriteLine(message);
text_file.WriteLine(page_text);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The GetPageCount() has failed with the status: " + status.ToString(), caption);
}
text_file.Close();
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the prevailing text rotation in the clockwise direction, in degrees, based on all text presented on the currently selected page of the loaded PDF document.
The returned value will always be a multiple of 90.The resulting rotation value is measured considering all presented text on the page.
Each single text rotation is recognised and the most represented (prevailing) value is returned.
Be aware that the text rotation is calculated relative to the page, that said the current page rotation is not considered here.
You can use the method to eliminate the potential page rotation before computing the text rotation.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that the text rotation is calculated relative to the page and the current page rotation is not considered in the resulting value.
The prevailing clockwise rotation of the text on the currently selected page in degrees. The returned value can only be 0, 90, 180 or 270.
The method can be subsequently used to determine if this method has been successful.
How to rotate only those pages of your document, that contains some rotated text.
Dim caption As String = "Example: GuessPageTextRotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = Nothing
Dim page_text_rotation As Integer = 0
For i As Integer = 1 To pageCount
gdpicturePDF.SelectPage(i)
message = message + "The page nr. " + i + ": "
'Eliminating the possible page rotation.
status = gdpicturePDF.NormalizePage()
If status = GdPictureStatus.OK Then
page_text_rotation = gdpicturePDF.GuessPageTextRotation()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "text rotation: " + page_text_rotation.ToString()
If page_text_rotation > 0 Then
status = gdpicturePDF.RotatePage(page_text_rotation)
If status = GdPictureStatus.OK Then
message = message + " :page has been rotated" + vbCrLf
Else
message = message + " :page has NOT been rotated: " + status.ToString()
Exit For
End If
Else
message = message + " :page has not been rotated" + vbCrLf
End If
End If
Else
message = message + status.ToString()
Exit For
End If
Next
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_rotated.pdf")
If status = GdPictureStatus.OK Then
message = message + vbCrLf + "The pages have been rotated successfully and the file has been saved."
Else
message = message + vbCrLf + "The pages have been rotated successfully but the file can't be saved."
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GuessPageTextRotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = null;
int page_text_rotation = 0;
for (int i = 1; i <= pageCount; i++)
{
gdpicturePDF.SelectPage(i);
message = message + "The page nr. " + i + ": ";
//Eliminating the possible page rotation.
status = gdpicturePDF.NormalizePage();
if (status == GdPictureStatus.OK)
{
page_text_rotation = gdpicturePDF.GuessPageTextRotation();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "text rotation: " + page_text_rotation.ToString();
if (page_text_rotation > 0)
{
status = gdpicturePDF.RotatePage(page_text_rotation);
if (status == GdPictureStatus.OK)
{
message = message + " :page has been rotated\n";
}
else
{
message = message + " :page has NOT been rotated: " + status.ToString();
break;
}
}
else
{
message = message + " :page has not been rotated\n";
}
}
}
else
{
message = message + status.ToString();
break;
}
}
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_rotated.pdf");
if (status == GdPictureStatus.OK)
message = message + "\nThe pages have been rotated successfully and the file has been saved.";
else
message = message + "\nThe pages have been rotated successfully but the file can't be saved.";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the various settings of the text search/extraction engine for further use when searching or extracting text from the currently loaded PDF document.
Please note that you need to create or load the PDF document to allow these settings to work properly.
At the same, the settings are reset to an undefined value (TextExtractionOptions.Default), when creating or loading a new PDF document.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.
Likewise, the defined settings are only valid when processing (searching or extracting text) currently loaded PDF document.
They are reset to an undefined value, when creating or loading a new PDF document.
A bitwise combination of values of the TextExtractionOptions enumeration. Specifies required options for both text search and text extraction.
How to extract text of all pages in the PDF document to a text file using custom text extraction engine options.
Dim caption As String = "Example: SetTextExtractionOptions"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim text_file As New System.IO.StreamWriter("text_from_pages.txt")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim message As String = Nothing
Dim page_text As String = Nothing
oGDPicturePDF.SetTextExtractionOptions(TextExtractionOptions.ExactWordLineMatching)
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
page_text = gdpicturePDF.GetPageText()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = "Page: " + i.ToString() + " Status: " + status.ToString()
MessageBox.Show(message, caption)
text_file.WriteLine(message)
text_file.WriteLine(page_text)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
text_file.Close()
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetTextExtractionOptions";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
System.IO.StreamWriter text_file = new System.IO.StreamWriter("text_from_pages.txt");
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string message = null;
string page_text = null;
oGDPicturePDF.SetTextExtractionOptions(TextExtractionOptions.ExactWordLineMatching);
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
page_text = gdpicturePDF.GetPageText();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = "Page: " + i.ToString() + " Status: " + status.ToString();
MessageBox.Show(message, caption);
text_file.WriteLine(message);
text_file.WriteLine(page_text);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
text_file.Close();
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the status of the last executed operation with the current GdPicturePDF object.
Use this method in the combination with all those, which return a value instead of a status, such as the method in the example below.
A member of the GdPictureStatus enumeration. If the last executed GdPicturePDF method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to find out if the PDF document has been printed successfully.
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.PrintDialog() Then
MessageBox.Show("The PDF document has been successfully printed.", "Example: GetStat")
Else
'Use the GetStat() method here to find the reason for the failure.
MessageBox.Show("The PDF document has not been printed. Status: " + gdpicturePDF.GetStat().ToString(), "Example: GetStat")
End If
Else
MessageBox.Show("The file can't be opened.", "Example: GetStat")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintDialog())
{
MessageBox.Show("The PDF document has been successfully printed.", "Example: GetStat");
}
else
{
//Use the GetStat() method here to find the reason for the failure.
MessageBox.Show("The PDF document has not been printed. Status: " + gdpicturePDF.GetStat().ToString(), "Example: GetStat");
}
}
else
{
MessageBox.Show("The file can't be opened.", "Example: GetStat");
}
}
Returns the input file path of your source document, if it has been loaded using the method.
This method neither performs any security checks nor sets the error status.
The input file path of the source document loaded from that file, otherwise an empty string.
How to retrieve the file path of the currently loaded document.
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("D:\\documents\\my_document.pdf", False) = GdPictureStatus.OK Then
'Do your stuff here.
Dim filepath As String = gdpicturePDF.GetInputFilePath()
MessageBox.Show("The input file path is " + filepath, "Example: GetInputFilePath")
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), "Example: GetInputFilePath")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("D:\\documents\\my_document.pdf", false) == GdPictureStatus.OK)
{
//Do your stuff here.
string filepath = gdpicturePDF.GetInputFilePath();
MessageBox.Show("The input file path is " + filepath, "Example: GetInputFilePath");
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), "Example: GetInputFilePath");
}
gdpicturePDF.Dispose();
Returns if the currently selected page of the loaded PDF contains any kind of vector content, for example paths, lines, rectangles, Bezier curves, clipping paths, etc.
A vector-based PDF uses line segments to define all of the geometry on the page. The display of the geometry remains sharp when you zoom in to see details
of the drawing, and measurements and takeoffs (as well as their calibration) are more precise in a vector PDF.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the selected page contains vector content, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to find out if the current page of the PDF document contains vector content. The example shows you how to check all pages in the PDF document if they contain vector content.
Dim caption As String = "Example: PageHasShape"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("drawings.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim result As Boolean = False
Dim pagesWithShape As Integer = 0, pagesWithoutShape As Integer = 0
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
result = gdpicturePDF.PageHasShape()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If result Then
pagesWithShape += 1
MessageBox.Show("The page nr." + i.ToString() + " HAS vector content.", caption)
Else
pagesWithoutShape += 1
MessageBox.Show("The page nr." + i.ToString() + " HAS NO vector content.", caption)
End If
Else
MessageBox.Show("The PageHasShape() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
If (pagesWithShape + pagesWithoutShape) <> pageCount Then
MessageBox.Show("Something goes wrong: " + ((pagesWithShape + pagesWithoutShape).ToString() + "!=" + pageCount.ToString()), caption)
Else
MessageBox.Show("Finished successfully.", caption)
End If
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: PageHasShape";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("drawings.pdf", false);
if (status == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool result = false;
int pagesWithShape = 0, pagesWithoutShape = 0;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
result = gdpicturePDF.PageHasShape();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (result)
{
pagesWithShape++;
MessageBox.Show("The page nr." + i.ToString() + " HAS vector content.", caption);
}
else
{
pagesWithoutShape++;
MessageBox.Show("The page nr." + i.ToString() + " HAS NO vector content.", caption);
}
}
else
{
MessageBox.Show("The PageHasShape() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
if ((pagesWithShape + pagesWithoutShape) != pageCount)
{
MessageBox.Show("Something goes wrong: " + ((pagesWithShape + pagesWithoutShape).ToString() + "!=" + pageCount.ToString()), caption);
}
else
{
MessageBox.Show("Finished successfully.", caption);
}
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns if the currently selected page of the loaded PDF contains text, regardless if visible or hidden. It is the same as what the PageHasText(false) method does.
Please note that special characters like \r, \n, \l are always considered as text.
This method uses an internal algorithm which is faster than the full page text extraction.
These methods check up if the currently selected page of the loaded PDF contains text, regardless if visible or hidden.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the currently selected page contains text, both visible and hidden, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to find out if the current page in the PDF document contains text. The example shows you how to check all pages in the PDF document if they contain text or not (no matter if visible text or hidden).
Dim caption As String = "Example: PageHasText"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim result As Boolean = False
Dim pagesWithText As Integer = 0, pagesWithoutText As Integer = 0
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
result = gdpicturePDF.PageHasText()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If result Then
pagesWithText += 1
MessageBox.Show("The page nr." + i.ToString() + " HAS text.", caption)
Else
pagesWithoutText += 1
MessageBox.Show("The page nr." + i.ToString() + " HAS NO text.", caption)
End If
Else
MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
If (pagesWithText + pagesWithoutText) <> pageCount Then
MessageBox.Show("Something goes wrong: " + ((pagesWithText + pagesWithoutText).ToString() + "!=" + pageCount.ToString()), caption)
Else
MessageBox.Show("Finished successfully.", caption)
End If
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: PageHasText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool result = false;
int pagesWithText = 0, pagesWithoutText = 0;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
result = gdpicturePDF.PageHasText();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (result)
{
pagesWithText++;
MessageBox.Show("The page nr." + i.ToString() + " HAS text.", caption);
}
else
{
pagesWithoutText++;
MessageBox.Show("The page nr." + i.ToString() + " HAS NO text.", caption);
}
}
else
{
MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
if ((pagesWithText + pagesWithoutText) != pageCount)
{
MessageBox.Show("Something goes wrong: " + ((pagesWithText + pagesWithoutText).ToString() + "!=" + pageCount.ToString()), caption);
}
else
{
MessageBox.Show("Finished successfully.", caption);
}
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns if the currently selected page of the loaded PDF contains the visible text or also the hidden text according to the parameter you have specified.
Please note that special characters like \r, \n, \l are always considered as text.
This method uses an internal algorithm which is faster than the full page text extraction.
These methods check up if the currently selected page of the loaded PDF contains text, regardless if visible or hidden.
Specifies if the hidden text objects will be ignored. Hidden text is usually text with a text rendering mode which makes it invisible on the page.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the currently selected page contains text (visible and hidden according to your setting), otherwise false. The method can be subsequently used to determine if this method has been successful.
How to find out if the current page in the PDF document contains also hidden text. The example shows you how to check all pages in the PDF document if they contain text and if the text is visible or only hidden.
Dim caption As String = "Example: PageHasText"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim result As Boolean = False
Dim message As String = ""
For i As Integer = 1 To pageCount
result = False
message = ""
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
'Searching for both text - visible and hidden.
result = gdpicturePDF.PageHasText(False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = "The page nr." + i.ToString()
If result Then ' the current page has text (visible or hidden)
'The hidden text will be ignored.
result = gdpicturePDF.PageHasText(True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If result Then
'The current page has visible text.
message = message + " HAS text and HAS also VISIBLE text."
Else
'The current page has no visible text.
message = message + " HAS only HIDDEN text."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption)
End If
Else
'Neither visible nor hidden text.
message = message + " HAS NO text."
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
MessageBox.Show("Finished searching the document.", caption)
gdpicturePDF.Dispose()
string caption = "Example: PageHasText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool result = false;
string message = "";
for (int i = 1; i <= pageCount; i++)
{
result = false; message = "";
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
//Searching for both text - visible and hidden.
result = gdpicturePDF.PageHasText(false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = "The page nr." + i.ToString();
if (result)
{
//The current page has text (visible or hidden).
result = gdpicturePDF.PageHasText(true);
//The hidden text will be ignored.
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (result)
{
//The current page has visible text.
message = message + " HAS text and HAS also VISIBLE text.";
}
else
{
//The current page has no visible text.
message = message + " HAS only HIDDEN text.";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
//Neither visible nor hidden text.
message = message + " HAS NO text.";
MessageBox.Show(message, caption);
}
}
else
{
MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
MessageBox.Show("Finished searching the document.", caption);
gdpicturePDF.Dispose();
Returns if the currently selected page of the loaded PDF is entirely image-based.
Image-based pages are considered to contain nothing but one fully visible image covering the whole page area. This image must not be in any way rotated
and must not contain any other particular drawing operation such as a clipping path.
Be aware that this method does not ignore the hidden text if present. It is the same as what the IsPageImage(false) method does.
These methods check up if the currently selected page of the loaded PDF is entirely image-based.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the currently selected page is entirely image-based as defined above, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to find out if pages in the PDF document are image-based or not.
Dim caption As String = "Example: IsPageImage"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("image.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim result As Boolean = False
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
result = gdpicturePDF.IsPageImage()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If result Then
MessageBox.Show("The page nr." + i.ToString() + " IS image-based.", caption)
Else
MessageBox.Show("The page nr." + i.ToString() + " IS NOT image-based.", caption)
End If
Else
MessageBox.Show("The IsPageImage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
MessageBox.Show("Finished successfully.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: IsPageImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("image.pdf", false);
if (status == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool result = false;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
result = gdpicturePDF.IsPageImage();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (result)
{
MessageBox.Show("The page nr." + i.ToString() + " IS image-based.", caption);
}
else
{
MessageBox.Show("The page nr." + i.ToString() + " IS NOT image-based.", caption);
}
}
else
{
MessageBox.Show("The IsPageImage() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
MessageBox.Show("Finished successfully.", caption);
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns if the currently selected page of the loaded PDF is entirely image-based.
If yes, the method returns a unique image identifier referring to the newly created image object of the type GdPictureImage, that corresponds to the embedded image.
You can take advantages of the class and its methods for further manipulation with the resulting image.
Image-based pages are considered to contain nothing but one fully visible image covering the whole page area. This image must not be in any way rotated
and must not contain any other particular drawing operation such as a clipping path.
These methods check up if the currently selected page of the loaded PDF is entirely image-based.
Output parameter. If the currently selected page is an image-based page as defined above, this parameter returns a unique image identifier
of the newly created GdPictureImage object corresponding to the embedded image. If the page is not image-based, this parameter returns 0.
Be aware that you need to release the successfully created image after being used, for the suitable method please refer to the Remarks section below.
Set this parameter to true if you want to automatically rotate the created image representing by the GdPictureImage object
to get the same rendering orientation (for display or print) as is the viewing mode of the current page. Otherwise set it to false.
You can use the method to find out if the current page should be rotated when displayed or printed.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Likewise just to remind you that you need to release the image, if it has been created successfully, after being used using
either the method or the static method.
true if the currently selected page is entirely image-based as defined above, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to reuse an image from the image-based page in the PDF document.
The image is subsequently drawn onto a new page and saved into a new PDF document.
Dim caption As String = "Example: IsPageImage"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("drawing.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
Dim imageID As Integer = 0
Dim result As Boolean = gdpicturePDF.IsPageImage(imageID, True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If result Then
Dim name As String = gdpicturePDF.AddImageFromGdPictureImage(imageID, False, True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("drawing_duplicated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The image has been successfully duplicated.", caption)
End If
Else
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption)
End If
GdPictureDocumentUtilities.DisposeImage(imageID)
Else
MessageBox.Show("This page is not image-based.", caption)
End If
Else
MessageBox.Show("The IsPageImage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: IsPageImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("drawing.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
int imageID = 0;
bool result = gdpicturePDF.IsPageImage(ref imageID, true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (result)
{
string name = gdpicturePDF.AddImageFromGdPictureImage(imageID, false, true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("drawing_duplicated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The image has been successfully duplicated.", caption);
}
else
{
MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption);
}
GdPictureDocumentUtilities.DisposeImage(imageID);
}
else
MessageBox.Show("This page is not image-based.", caption);
}
else
MessageBox.Show("The IsPageImage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns if the currently selected page of the loaded PDF is entirely image-based ignoring or not the hidden text according to the parameter you have specified.
Image-based pages are considered to contain nothing but one fully visible image covering the whole page area. This image must not be in any way rotated
and must not contain any other particular drawing operation such as a clipping path.
These methods check up if the currently selected page of the loaded PDF is entirely image-based.
Specifies if the hidden text objects will be ignored. Hidden text is usually text with a text rendering mode which makes it invisible on the page.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the currently selected page is entirely image-based as defined above, otherwise false.
The method can be subsequently used to determine if this method has been successful.
How to find out if pages in the PDF document are image-based or not ignoring any hidden text if present.
Dim caption As String = "Example: IsPageImage"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("image.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim result As Boolean = False
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
result = gdpicturePDF.IsPageImage(True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If result Then
MessageBox.Show("The page nr." + i.ToString() + " IS image-based.", caption)
Else
MessageBox.Show("The page nr." + i.ToString() + " IS NOT image-based.", caption)
End If
Else
MessageBox.Show("The IsPageImage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
End If
Next
MessageBox.Show("Finished successfully.", caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: IsPageImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("image.pdf", false);
if (status == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool result = false;
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
result = gdpicturePDF.IsPageImage(true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (result)
{
MessageBox.Show("The page nr." + i.ToString() + " IS image-based.", caption);
}
else
{
MessageBox.Show("The page nr." + i.ToString() + " IS NOT image-based.", caption);
}
}
else
{
MessageBox.Show("The IsPageImage() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
}
MessageBox.Show("Finished successfully.", caption);
}
else
{
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Searches for all occurrences of a given regular expression pattern within the currently loaded PDF document and highlights every occurrence found usign Highlight text markup annotation.
The regular expression pattern to search for.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
The amount of red color to be used for the highlight annotation. Use the value between 0 and 255.
The amount of green color to be used for highlight annotation. Use the value between 0 and 255.
The amount of blue color to be used for the highlight annotation. Use the value between 0 and 255.
The transparency value of the highlight annotation. Use the value between 0 (full transparency) and 255 (full opacity).
Output parameter. If the method has been successfully followed, then the parameter will return number of occurrences found.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to highlight all occurrences of text string in PDF document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
Dim occurrences As Integer = 0
gdpicturePDF.SearchAndHighlight("Sensitive text string", True, 0, 0, 0, 255, occurrences)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
int occurrences = 0;
gdpicturePDF.SearchAndHighlight("Sensitive text string", true, 0, 0, 0, 255, ref occurrences);
gdpicturePDF.SaveToFile("output.pdf");
}
Sets the new origin's location of the currently used coordinate system defined in the loaded PDF document.
Please note that you need to create or load the PDF document properly to set the valid value, otherwise the value will remain undefined.
A member of the PdfOrigin enumeration. You can select one of these: bottom left, top left, bottom right and top right.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.
The location of the origin of a PDF document is defined by default to be at the lower left corner.
How to find out the position of the first page's media box in millimetres of the currently loaded PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = "NO document IS loaded." + vbCrLf + vbCrLf
'This is the incorrect usage - the values will remain undefined.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
message = message + "Status for SetOrigin(PdfOrigin.PdfOriginTopLeft): " + status.ToString()
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
status = gdpicturePDF.GetStat()
message = message + vbCrLf + "Status for SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter): " + status.ToString()
MessageBox.Show(message, "Example: SetOrigin")
'You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
message = "Your pdf document IS loaded." + vbCrLf + vbCrLf
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
'This is the correct usage.
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pLeft As Single = 0
Dim pTop As Single = 0
Dim pRight As Single = 0
Dim pBottom As Single = 0
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, pLeft, pTop, pRight, pBottom)
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") millimetres."
MessageBox.Show(message, "Example: SetOrigin")
End If
End If
Else
MessageBox.Show("This PDF has no pages.", "Example: SetOrigin")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetOrigin")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "NO document IS loaded.\n\n";
//This is the incorrect usage - the values will remain undefined.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
GdPictureStatus status = gdpicturePDF.GetStat();
message = message + "Status for SetOrigin(PdfOrigin.PdfOriginTopLeft): " + status.ToString();
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
status = gdpicturePDF.GetStat();
message = message + "\nStatus for SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter): " + status.ToString();
MessageBox.Show(message, "Example: SetOrigin");
//You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
message = "Your pdf document IS loaded.\n\n";
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
//This is the correct usage.
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float pLeft = 0;
float pTop = 0;
float pRight = 0;
float pBottom = 0;
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, ref pLeft, ref pTop, ref pRight, ref pBottom);
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") millimetres.";
MessageBox.Show(message, "Example: SetOrigin");
}
}
}
else
{
MessageBox.Show("This PDF has no pages.", "Example: SetOrigin");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: SetOrigin");
}
gdpicturePDF.Dispose();
Returns the origin's location of the currently used coordinate system defined in the loaded PDF document.
Please note that you need to create or load the PDF document properly to get the valid value, otherwise the value is undefined.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The location of the origin of a PDF document is defined by default to be at the lower left corner.
The standard location of the origin are: bottom left, top left, bottom right, top right.
A member of the PdfOrigin enumeration. The default value is PdfOrigin.PdfOriginBottomLeft.
The method can be subsequently used to determine if this method has been successful.
How to find out the currently set location of the origin of the used coordinate system.
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = "NO document IS loaded." + vbCrLf + vbCrLf
'The values obtained here are undefined.
Dim origin As PdfOrigin = gdpicturePDF.GetOrigin()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
message = message + "Origin: " + origin.ToString() + " status: " + status.ToString()
Dim units As PdfMeasurementUnit = gdpicturePDF.GetMeasurementUnit()
status = gdpicturePDF.GetStat()
message = message + vbCrLf + "Units: " + units.ToString() + " status: " + status.ToString()
MessageBox.Show(message, "Example: GetOrigin")
'You need to load the file here.
status = gdpicturePDF.LoadFromFile("testPDF.pdf", False)
If status = GdPictureStatus.OK Then
message = "Your pdf document IS loaded." + vbCrLf + vbCrLf
'The values obtained here are correctly defined.
origin = gdpicturePDF.GetOrigin()
status = gdpicturePDF.GetStat()
message = message + "Origin: " + origin.ToString() + " status: " + status.ToString()
units = gdpicturePDF.GetMeasurementUnit()
status = gdpicturePDF.GetStat()
message = message + vbCrLf + "Units: " + units.ToString() + " status: " + status.ToString()
MessageBox.Show(message, "Example: GetOrigin")
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOrigin")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "NO document IS loaded.\n\n";
//The values obtained here are undefined.
PdfOrigin origin = gdpicturePDF.GetOrigin();
GdPictureStatus status = gdpicturePDF.GetStat();
message = message + "Origin: " + origin.ToString() + " status: " + status.ToString();
PdfMeasurementUnit units = gdpicturePDF.GetMeasurementUnit();
status = gdpicturePDF.GetStat();
message = message + "\nUnits: " + units.ToString() + " status: " + status.ToString();
MessageBox.Show(message, "Example: GetOrigin");
//You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
message = "Your pdf document IS loaded.\n\n";
//The values obtained here are correctly defined.
origin = gdpicturePDF.GetOrigin();
status = gdpicturePDF.GetStat();
message = message + "Origin: " + origin.ToString() + " status: " + status.ToString();
units = gdpicturePDF.GetMeasurementUnit();
status = gdpicturePDF.GetStat();
message = message + "\nUnits: " + units.ToString() + " status: " + status.ToString();
MessageBox.Show(message, "Example: GetOrigin");
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOrigin");
}
gdpicturePDF.Dispose();
Sets the measurement units to be used for the currently loaded PDF document.
Please note that you need to create or load the PDF document properly to set the valid value, otherwise the value will remain undefined.
A member of the PdfMeasurementUnit enumeration. You can select one of these: point, millimeter, centimeter, inch.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.
All locations and sizes in PDF document are stored in a logical value called a PDF point. 1 point is equivalent to 1/72 of an inch.
Therefore the default PDF measurement units are points.
How to find out the position of the first page's media box in millimetres and in centimetres of the currently loaded PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = "NO document IS loaded." + vbCrLf + vbCrLf
'This is the incorrect usage - the values will remain undefined.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
message = message + "Status for SetOrigin(PdfOrigin.PdfOriginTopLeft): " + status.ToString()
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
status = gdpicturePDF.GetStat()
message = message + vbCrLf + "Status for SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter): " + status.ToString()
MessageBox.Show(message, "Example: SetMeasurementUnit")
'You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
message = "Your pdf document IS loaded." + vbCrLf + vbCrLf
status = gdpicturePDF.SelectPage(1)
If status = GdPictureStatus.OK Then
'This is the correct usage.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pLeft As Single = 0, pTop As Single = 0, pRight As Single = 0, pBottom As Single = 0
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, pLeft, pTop, pRight, pBottom)
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") millimetres." + vbCrLf + vbCrLf
End If
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pLeft As Single = 0, pTop As Single = 0, pRight As Single = 0, pBottom As Single = 0
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, pLeft, pTop, pRight, pBottom)
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") centimetres."
MessageBox.Show(message, "Example: SetMeasurementUnit")
End If
End If
Else
MessageBox.Show("This PDF has no pages.", "Example: SetMeasurementUnit")
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), "Example: SetMeasurementUnit")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "NO document IS loaded.\n\n";
//This is the incorrect usage - the values will remain undefined.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
GdPictureStatus status = gdpicturePDF.GetStat();
message = message + "Status for SetOrigin(PdfOrigin.PdfOriginTopLeft): " + status.ToString();
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
status = gdpicturePDF.GetStat();
message = message + "\nStatus for SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter): " + status.ToString();
MessageBox.Show(message, "Example: SetMeasurementUnit");
//You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
message = "Your pdf document IS loaded.\n\n";
status = gdpicturePDF.SelectPage(1);
if (status == GdPictureStatus.OK)
{
//This is the correct usage.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float pLeft = 0, pTop = 0, pRight = 0, pBottom = 0;
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, ref pLeft, ref pTop, ref pRight, ref pBottom);
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") millimetres.\n\n";
}
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float pLeft = 0, pTop = 0, pRight = 0, pBottom = 0;
gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, ref pLeft, ref pTop, ref pRight, ref pBottom);
message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") centimetres.";
MessageBox.Show(message, "Example: SetMeasurementUnit");
}
}
}
else
{
MessageBox.Show("This PDF has no pages.", "Example: SetMeasurementUnit");
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), "Example: SetMeasurementUnit");
}
gdpicturePDF.Dispose();
Returns the currently used measurement units defined in the loaded PDF document.
Please note that you need to create or load the PDF document properly to get the valid value, otherwise the value is undefined.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
All locations and sizes in PDF document are stored in a logical value called a PDF point. 1 point is equivalent to 1/72 of an inch.
The standard PDF measurement units are: point, milimeter, centimeter, inch. The default PDF measurement units are points.
A member of the PdfMeasurementUnit enumeration. The default value is PdfMeasurementUnit.PdfMeasurementUnitPoint.
The method can be subsequently used to determine if this method has been successful.
How to find out the currently set measurement units.
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = "NO document IS loaded." + vbCrLf + vbCrLf
'The values obtained here are undefined.
Dim origin As PdfOrigin = gdpicturePDF.GetOrigin()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
message = message + "Origin: " + origin.ToString() + " status: " + status.ToString()
Dim units As PdfMeasurementUnit = gdpicturePDF.GetMeasurementUnit()
status = gdpicturePDF.GetStat()
message = message + vbCrLf + "Units: " + units.ToString() + " status: " + status.ToString()
MessageBox.Show(message, "Example: GetMeasurementUnit")
'You need to load the file here.
status = gdpicturePDF.LoadFromFile("testPDF.pdf", False) ' you need to load the file here
If status = GdPictureStatus.OK Then
message = "Your pdf document IS loaded." + vbCrLf + vbCrLf
'The values obtained here are correctly defined.
origin = gdpicturePDF.GetOrigin()
status = gdpicturePDF.GetStat()
message = message + "Origin: " + origin.ToString() + " status: " + status.ToString()
units = gdpicturePDF.GetMeasurementUnit()
status = gdpicturePDF.GetStat()
message = message + vbCrLf + "Units: " + units.ToString() + " status: " + status.ToString()
MessageBox.Show(message, "Example: GetMeasurementUnit")
Else
MessageBox.Show("The file can't be loaded.", "Example: GetMeasurementUnit")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "NO document IS loaded.\n\n";
//The values obtained here are undefined.
PdfOrigin origin = gdpicturePDF.GetOrigin();
GdPictureStatus status = gdpicturePDF.GetStat();
message = message + "Origin: " + origin.ToString() + " status: " + status.ToString();
PdfMeasurementUnit units = gdpicturePDF.GetMeasurementUnit();
status = gdpicturePDF.GetStat();
message = message + "\nUnits: " + units.ToString() + " status: " + status.ToString();
MessageBox.Show(message, "Example: GetMeasurementUnit");
//You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
message = "Your pdf document IS loaded.\n\n";
//The values obtained here are correctly defined.
origin = gdpicturePDF.GetOrigin();
status = gdpicturePDF.GetStat();
message = message + "Origin: " + origin.ToString() + " status: " + status.ToString();
units = gdpicturePDF.GetMeasurementUnit();
status = gdpicturePDF.GetStat();
message = message + "\nUnits: " + units.ToString() + " status: " + status.ToString();
MessageBox.Show(message, "Example: GetMeasurementUnit");
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetMeasurementUnit");
}
gdpicturePDF.Dispose();
Determines if all subsequent modifications of the current page of the loaded PDF document are prepend or append.
The initial value is set to false, means the prepend mode is disabled.
This method can be particularly useful if you need to append content on the background of the page, for example drawing an image behind existing text.
Set this parameter to true, if you want to enable the prepend mode, otherwise set it to false to disable it. Initial value is false.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to rotate the first page of an existing PDF document by an angle of 20 degrees without altering the page's content.
Dim caption As String = "Example: SetPrependContentMode"
Dim gdpicturePDF As New GdPicturePDF()
'See the SetBlendMode() method how to create this file.
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test_BlendMode.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageWidth As Single = gdpicturePDF.GetPageWidth()
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The GetPageWidth() method has failed.", caption)
GoTo [error]
End If
Dim pageHeight As Single = gdpicturePDF.GetPageHeight()
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The GetPageHeight() method has failed.", caption)
GoTo [error]
End If
'The first page is selected implicitly.
'The current measurement units are set to points and the current origin is bottom left by default.
If (gdpicturePDF.SetPrependContentMode(True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, pageWidth / 2, pageHeight / 2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddRotationAt(20, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, -pageWidth / 2, -pageHeight / 2) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_PrependMode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The LoadFromFile() method has failed with the status: " + status.ToString(), caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: SetPrependContentMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//See the SetBlendMode() method how to create this file.
GdPictureStatus status = gdpicturePDF.LoadFromFile("test_BlendMode.pdf", false);
if (status == GdPictureStatus.OK)
{
float pageWidth = gdpicturePDF.GetPageWidth();
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The GetPageWidth() method has failed.", caption);
goto error;
}
float pageHeight = gdpicturePDF.GetPageHeight();
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The GetPageHeight() method has failed.", caption);
goto error;
}
//The first page is selected implicitly.
//The current measurement units are set to points and the current origin is bottom left by default.
if ((gdpicturePDF.SetPrependContentMode(true) == GdPictureStatus.OK) &&
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, pageWidth / 2, pageHeight / 2) == GdPictureStatus.OK) &&
(gdpicturePDF.AddRotationAt(20, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, -pageWidth / 2, -pageHeight / 2) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_PrependMode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The LoadFromFile() method has failed with the status: " + status.ToString(), caption);
error:
gdpicturePDF.Dispose();
Resets the graphics state parameters to their default configuration. For example, any specified transformation is canceled, the fill color and the stroke
color are set to their default values, etc. It's a good practice to call this method before adding new data to the currently loaded PDF document.
The graphics on a PDF page are described by a sequence of draw operators, graphics state operators, and marked-content operators. The graphics state
operators change the graphics state (set the line width, dash pattern, fill color, font size etc.) and the result of draw operators are affected by the
graphics state.According to the PDF Reference, Section "Graphics State", a PDF consumer application maintains an internal data structure
called the graphics state that holds current graphics control parameters. These parameters define the global framework within which the graphics operators execute.
For example, the fill operator implicitly uses the current color parameter, and the stroke operator additionally uses the current line width parameter from the graphics state.
The graphics state is initialized at the beginning of each page with the values specified in the PDF Reference, Section "Graphics State".
This method is only allowed for use with non-encrypted documents.
Be aware that graphics state parameters are initialized to their default values at the beginning of each page.
Therefore we recommend to call this method before adding new data to the existing PDF document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the graphics state to its default configuration.
Dim caption As String = "Example: ResetGraphicsState"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
'This is the font only used to describe the drawn rectangles.
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'Setting the default graphics state.
(gdpicturePDF.DrawRectangle(120, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 125, 15, "default state") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 15, "1. rectangle") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveGraphicsState() = GdPictureStatus.OK) AndAlso 'Saving the graphics state.
(gdpicturePDF.SaveGraphicsState() = GdPictureStatus.OK) AndAlso 'Save the graphics state again.
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, 150, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(128, 0, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 15, "2. rectangle") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.RestoreGraphicsState() = GdPictureStatus.OK) AndAlso 'Restoring the preceding graphics state.
(gdpicturePDF.AddTransformationMatrix(1, 0.1F, 0, 1, 150, -100) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 128, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(173, 255, 47) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 15, "3. rectangle") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.RestoreGraphicsState() = GdPictureStatus.OK) AndAlso 'Restoring the initial graphics state.
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 55, "4. rectangle") = GdPictureStatus.OK) AndAlso '1. and 4. rectangle use the same colors.
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'Resetting to the default state again.
(gdpicturePDF.DrawRectangle(120, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 125, 55, "default state") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_GraphicState.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ResetGraphicsState";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
//This is the font only used to describe the drawn rectangles.
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //Setting the default graphics state.
(gdpicturePDF.DrawRectangle(120, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 125, 15, "default state") == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 15, "1. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveGraphicsState() == GdPictureStatus.OK) && //Saving the graphics state.
(gdpicturePDF.SaveGraphicsState() == GdPictureStatus.OK) && //Saving the graphics state again.
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, 150, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(128, 0, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 15, "2. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.RestoreGraphicsState() == GdPictureStatus.OK) && //Restoring the preceding graphics state.
(gdpicturePDF.AddTransformationMatrix(1, 0.1f, 0, 1, 150, -100) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 128, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(173, 255, 47) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 15, "3. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.RestoreGraphicsState() == GdPictureStatus.OK) && //Restoring the initial graphics state.
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, true, true) == GdPictureStatus.OK) && //1. and 4. rectangle use the same colors.
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 55, "4. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //Resetting to the default state again.
(gdpicturePDF.DrawRectangle(120, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 125, 55, "default state") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_GraphicState.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Saves the current graphics state on the graphics state stack. You can use the method to reset the previously defined graphics state.
Please note that and following calls need to be applied on the same page,
in other words changing the current page between these two calls causes incorrect behavior of the graphics state.
The graphics on a PDF page are described by a sequence of draw operators, graphics state operators, and marked-content operators. The graphics state
operators change the graphics state (set the line width, dash pattern, fill color, font size etc) and the result of draw operators are affected by the graphics
state. Please see also the method for more details.
This method is only allowed for use with non-encrypted documents.
Be aware that changing the current page between calls to and methods causes incorrect behavior of the graphics
state. According to the PDF Reference, Section "Graphics State", the graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to correctly save and restore graphics state to draw various rectangles onto the newly created PDF document.
Dim caption As String = "Example: SaveGraphicsState"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
'This is the font only used to describe the drawn rectangles.
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0.5F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 15, "1. rectangle") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveGraphicsState() = GdPictureStatus.OK) AndAlso 'Saving the graphics state.
(gdpicturePDF.SaveGraphicsState() = GdPictureStatus.OK) AndAlso 'Saving the graphics state again.
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, 150, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(128, 0, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 15, "2. rectangle") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.RestoreGraphicsState() = GdPictureStatus.OK) AndAlso 'Restoring the preceding graphics state.
(gdpicturePDF.AddTransformationMatrix(1, 0.1F, 0, 1, 150, -100) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 128, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(173, 255, 47) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 15, "3. rectangle") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.RestoreGraphicsState() = GdPictureStatus.OK) AndAlso 'Restoring the initial graphics state.
(gdpicturePDF.DrawRectangle(10, 80, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 85, "4. rectangle") = GdPictureStatus.OK) AndAlso '1. and 4. rectangle use the same colors.
(gdpicturePDF.AddTransformationMatrix(1, 0.1F, 0.1F, 1, 100, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 80, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 85, "5. rectangle") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_GraphicState.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SaveGraphicsState";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
//This is the font only used to describe the drawn rectangles.
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0.5f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 15, "1. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveGraphicsState() == GdPictureStatus.OK) && //Saving the graphics state.
(gdpicturePDF.SaveGraphicsState() == GdPictureStatus.OK) && //Saving the graphics state again.
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, 150, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(128, 0, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 15, "2. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.RestoreGraphicsState() == GdPictureStatus.OK) && //Restoring the preceding graphics state.
(gdpicturePDF.AddTransformationMatrix(1, 0.1f, 0, 1, 150, -100) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 128, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(173, 255, 47) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 15, "3. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.RestoreGraphicsState() == GdPictureStatus.OK) && //Restoring the initial graphics state.
(gdpicturePDF.DrawRectangle(10, 80, 40, 20, true, true) == GdPictureStatus.OK) && //1. and 4. rectangle use the same colors.
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 85, "4. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.AddTransformationMatrix(1, 0.1f, 0.1f, 1, 100, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 80, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 85, "5. rectangle") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_GraphicState.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Restores the graphics state previously saved by the method. Restoring the graphics state means removing the most recently saved graphics
state from the graphics state stack and making it the current graphics state. Please note that and following calls
need to be applied on the same page, in other words changing the current page between these two calls causes incorrect behavior of the graphics state.
The graphics on a PDF page are described by a sequence of draw operators, graphics state operators, and marked-content operators. The graphics state
operators change the graphics state (set the line width, dash pattern, fill color, font size etc) and the result of draw operators are affected by the graphics
state. Please see also the method for more details.
This method is only allowed for use with non-encrypted documents.
Be aware that changing the current page between calls to and methods causes incorrect behavior of the graphics state.
According to the PDF Reference, Section "Graphics State", the graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to correctly save and restore graphics state to draw various rectangles onto the newly created PDF document.
Dim caption As String = "Example: RestoreGraphicsState"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
'This is the font only used to describe the drawn rectangles.
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0.5F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 15, "1. rectangle") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveGraphicsState() = GdPictureStatus.OK) AndAlso 'Saving the graphics state.
(gdpicturePDF.SaveGraphicsState() = GdPictureStatus.OK) AndAlso 'Saving the graphics state again.
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, 150, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(128, 0, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 15, "2. rectangle") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.RestoreGraphicsState() = GdPictureStatus.OK) AndAlso 'Restoring the preceding graphics state.
(gdpicturePDF.AddTransformationMatrix(1, 0.1F, 0, 1, 150, -100) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 128, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(173, 255, 47) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 15, "3. rectangle") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.RestoreGraphicsState() = GdPictureStatus.OK) AndAlso 'Restoring the initial graphics state.
(gdpicturePDF.DrawRectangle(10, 80, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 85, "4. rectangle") = GdPictureStatus.OK) AndAlso '1. and 4. rectangle use the same colors.
(gdpicturePDF.AddTransformationMatrix(1, 0.1F, 0.1F, 1, 100, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 80, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 15, 85, "5. rectangle") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_GraphicState.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RestoreGraphicsState";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
//This is the font only used to describe the drawn rectangles.
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0.5f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 15, "1. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveGraphicsState() == GdPictureStatus.OK) && //Saving the graphics state.
(gdpicturePDF.SaveGraphicsState() == GdPictureStatus.OK) && //Saving the graphics state again.
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, 150, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(128, 0, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 15, "2. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.RestoreGraphicsState() == GdPictureStatus.OK) && //Restoring the preceding graphics state.
(gdpicturePDF.AddTransformationMatrix(1, 0.1f, 0, 1, 150, -100) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 128, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(173, 255, 47) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 15, "3. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.RestoreGraphicsState() == GdPictureStatus.OK) && //Restoring the initial graphics state.
(gdpicturePDF.DrawRectangle(10, 80, 40, 20, true, true) == GdPictureStatus.OK) && //1. and 4. rectangle use the same colors.
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 85, "4. rectangle") == GdPictureStatus.OK) &&
(gdpicturePDF.AddTransformationMatrix(1, 0.1f, 0.1f, 1, 100, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 80, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 15, 85, "5. rectangle") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_GraphicState.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the line width (the line thickness, or in other words the pen size) used by all subsequent stroking operations,
like the method or the method. The specified value need to be expressed in the current units defined in the PDF document. The initial value is set to 1.0.
The line width parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
You can use the method to determine the currently defined units and you can use the method to reset the units according to your preference.
The thickness, expressed in the current units defined in the PDF document, of paths to be stroked. Initial value is 1.0.
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the different line width to draw various rectangles.
Dim caption As String = "Example: SetLineWidth"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineDash(5, 3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineNoDash() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineDash(New Single() {2, 1, 1, 1}) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 50, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_Lines.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineWidth";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineDash(5, 3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineNoDash() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineDash(new float[] {2, 1, 1, 1}) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 50, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_Lines.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the dash pattern to be used when paths are stroked, for example, when you use the method or the method.
The line dash pattern controls the pattern of dashes and gaps used to stroke paths. The specified values need to be expressed in the current units defined in the PDF document.
The initial value is a solid line. You can reset the dash pattern to its initial value simply by using the method.
The dash pattern parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
You can use the method to determine the currently defined units and you can use the method to reset the units according to your preference.
Sets the dash pattern to be used when paths are stroked.
The width of the dashes, expressed in the current units defined in the PDF document. Initial value is a solid line.
Zero DashOn parameter and zero DashOff parameter can be used to restore the dash pattern to a solid line, in the same way like using the method.
The width of the gaps between the dashes, expressed in the current units defined in the PDF document. Initial value is a solid line.
Zero DashOn parameter and zero DashOff parameter can be used to restore the dash pattern to a solid line in the same way like using the method.
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to define different dashed lines to draw various rectangles.
Dim caption As String = "Example: SetLineDash"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineDash(5, 3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineNoDash() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineDash(New Single() {2, 1, 1, 1}) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 50, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_Lines.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineDash";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineDash(5, 3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineNoDash() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineDash(new float[] {2, 1, 1, 1}) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 50, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_Lines.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the dash pattern to be used when paths are stroked, for example, when you use the method or the method.
The line dash pattern controls the pattern of dashes and gaps used to stroke paths. You are allowed to define dashes and gaps with the various length using this method. All
specified values need to be expressed in the current units defined in the PDF document. The initial value is set to be a solid line. You can reset the dash pattern to
its initial value simply by using the method.
The dash pattern parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
You can use the method to determine the currently defined units and you can use the method to reset the units according to your preference.
Sets the dash pattern to be used when paths are stroked.
Specifies the length of the custom dashes and gaps, expressed in the current units defined in the PDF document. The first element defined the length of a first
dash, the second element defines the length of a first gap, the third element defines the length of a next dash, and so forth. Initial value is a solid line.
Zero DashPattern parameter can be used to restore the dash pattern to a solid line in the same way like using the method.
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to define different dashed lines to draw various rectangles.
Dim caption As String = "Example: SetLineDash"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Cyan) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineDash(5, 3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineNoDash() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineDash(New Single() {2, 1, 1, 1}) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 50, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_Lines.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineDash";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Cyan) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineDash(5, 3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineNoDash() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineDash(new float[] {2, 1, 1, 1}) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 50, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_Lines.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the line join style. The line join style specifies the shape to be used at the corners of paths that are stroked,
for example, when you subsequently use the method. The initial value is set to miter join style (0).
The line join parameter is one of the graphics state parameters.
These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
A member of the PdfLineJoinStyle enumeration.
Specifies the shape of joints between connected segments of a stroked path. Initial value is PdfLineJoinStyle.PdfLineJoinStyleMiter.
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set different styles to join lines when drawing various rectangles.
Dim caption As String = "Example: SetLineJoinStyle"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso ' (gdpicturePDF.SetLineJoinStyle(PdfLineJoinStyle.PdfLineJoinStyleMiter) == GdPictureStatus.OK) AndAlso ' initial value
(gdpicturePDF.DrawRectangle(20, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineJoinStyle(PdfLineJoinStyle.PdfLineJoinStyleRound) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(20, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineJoinStyle(PdfLineJoinStyle.PdfLineJoinStyleBevel) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(20, 90, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_Lines.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineJoinStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
//(gdpicturePDF.SetLineJoinStyle(PdfLineJoinStyle.PdfLineJoinStyleMiter) == GdPictureStatus.OK) && // initial value
(gdpicturePDF.DrawRectangle(20, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineJoinStyle(PdfLineJoinStyle.PdfLineJoinStyleRound) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(20, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineJoinStyle(PdfLineJoinStyle.PdfLineJoinStyleBevel) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(20, 90, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_Lines.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the line cap style. The line cap style specifies the shape to be used at the ends of open subpaths (and dashes, if any) when they are stroked.
This style is subsequently used for example, when drawing a line with the DrawLine method(). The initial value is set to square butt cap (0).
The line cap parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
A member of the PdfLineCapStyle enumeration. Specifies the shape of the endpoints for any open path that is stroked. Initial value is PdfLineCapStyle.PdfLineCapStyleButt.
This method is only allowed for use with non-encrypted documents.
Just to remind you, that any open path, that is subsequently stroked, uses the defined endpoint shape (cap style).
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set different cap styles to draw various lines.
Dim caption As String = "Example: SetLineCapStyle"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso '(gdpicturePDF.SetLineCapStyle(PdfLineCapStyle.PdfLineCapStyleButt) == GdPictureStatus.OK) AndAlso ' initial value
(gdpicturePDF.DrawLine(20, 20, 60, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineCapStyle(PdfLineCapStyle.PdfLineCapStyleProjectingSquare) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(20, 50, 60, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineCapStyle(PdfLineCapStyle.PdfLineCapStyleRound) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(20, 80, 60, 80) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_Lines.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineCapStyle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(10) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
//(gdpicturePDF.SetLineCapStyle(PdfLineCapStyle.PdfLineCapStyleButt) == GdPictureStatus.OK) && // initial value
(gdpicturePDF.DrawLine(20, 20, 60, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineCapStyle(PdfLineCapStyle.PdfLineCapStyleProjectingSquare) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(20, 50, 60, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineCapStyle(PdfLineCapStyle.PdfLineCapStyleRound) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(20, 80, 60, 80) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_Lines.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Removes (resets) the currently defined dash pattern previously set by the method to the initial value, which is a solid line.
The dash pattern is used when paths are stroked, for example, when you use the method or the method.
The line dash pattern parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
This method is only allowed for use with non-encrypted documents.
Just to remind you that setting all parameters to zero when using the method restores the dash pattern to a solid line in the same way like using the method.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set and remove dash patterns to draw various rectangles.
Dim caption As String = "Example: SetLineNoDash"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineDash(5, 3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 10, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineNoDash() = GdPictureStatus.OK) AndAlso 'it is the same as (gdpicturePDF.SetLineDash(0, 0) = GdPictureStatus.OK)
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 50, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineDash(New Single() {2, 1, 1, 1}) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 50, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_Lines.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineNoDash";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineDash(5, 3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 10, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineNoDash() == GdPictureStatus.OK) && //it is the same as (gdpicturePDF.SetLineDash(0, 0) == GdPictureStatus.OK)
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 50, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineDash(new float[] {2, 1, 1, 1}) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 50, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_Lines.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the blending mode, that defines the function used in the compositing formula to customize the blending operation for all subsequent drawing operations. The initial value is set to normal.
Blending modes are used to determine how two layers are blended into each other (affect one another) through more complex methods.
Some blending modes exist to create special effects, some are used to give you more control when using adjustment layers to correct photographs.
The blend mode parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
A member of the PdfBlendMode enumeration. The current blend mode to be used in the transparent imaging model. Initial value is PdfBlendMode.PdfBlendModeNormal.
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set different blending modes to be used to draw text.
Dim caption As String = "Example: SetBlendMode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierBold)
status = gdpicturePDF.GetStat()
If (status <> GdPictureStatus.OK) OrElse (gdpicturePDF.SetTextSize(60) <> GdPictureStatus.OK) Then
MessageBox.Show("The standard font can't be add correctly.", caption)
GoTo [error]
End If
Dim text As String = "Mode = "
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 0, 130, 297, True, False) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(173, 216, 230) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetBlendMode(PdfBlendMode.PdfBlendModeNormal) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 10, 30, text + "normal") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetBlendMode(PdfBlendMode.PdfBlendModeScreen) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 10, 60, text + "screen") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetBlendMode(PdfBlendMode.PdfBlendModeMultiply) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 10, 90, text + "multiply") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_BlendMode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: SetBlendMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierBold);
status = gdpicturePDF.GetStat();
if ((status != GdPictureStatus.OK) ||
(gdpicturePDF.SetTextSize(60) != GdPictureStatus.OK))
{
MessageBox.Show("The standard font can't be add correctly.", caption);
goto error;
}
string text = "Mode = ";
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 0, 130, 297, true, false) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(173, 216, 230) == GdPictureStatus.OK) &&
(gdpicturePDF.SetBlendMode(PdfBlendMode.PdfBlendModeNormal) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 10, 30, text+"normal") == GdPictureStatus.OK) &&
(gdpicturePDF.SetBlendMode(PdfBlendMode.PdfBlendModeScreen) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 10, 60, text + "screen") == GdPictureStatus.OK) &&
(gdpicturePDF.SetBlendMode(PdfBlendMode.PdfBlendModeMultiply) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 10, 90, text + "multiply") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_BlendMode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
error:
gdpicturePDF.Dispose();
Sets the fill color used by all subsequent filling operations, like the method. The initial value is set to black.
This method uses the RGB color space for specifying the required color.
The fill color parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
Sets the fill color to be used by all subsequent filling operations.
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the initial fill color is black.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the different colors to be used to fill various drawn rectangles.
Dim caption As String = "Example: SetFillColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(210, 105, 30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_FillColor.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFillColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(210, 105, 30) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_FillColor.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the fill color used by all subsequent filling operations, like the method. The initial value is set to black.
This method uses the CMYK color space for specifying the required color.
The fill color parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
Sets the fill color to be used by all subsequent filling operations.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the resulting color. Use the value between 0 and 255.
The amount of black (key) color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the initial fill color is black.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the different colors to be used to fill various drawn rectangles.
Dim caption As String = "Example: SetFillColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 27, 59, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(45, 150, 225, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_FillColor.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFillColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 27, 59, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(45, 150, 225, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_FillColor.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the fill color used by all subsequent filling operations, like the method. The initial value is set to black.
The fill color parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
Sets the fill color to be used by all subsequent filling operations.
A color object that defines the new fill color. Initial value: black.
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the different colors to be used to fill various drawn rectangles.
Dim caption As String = "Example: SetFillColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Cyan) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Fuchsia) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_FillColor.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFillColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Cyan) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Fuchsia) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_FillColor.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the transparency level (the current non-stroking alpha constant) for all subsequent filling (non-stroking) operations, means those with the defined Fill
parameter, like the method or the method. This constant specifies the constant shape or constant opacity value. The initial value is set to 255.
The alpha constant parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
A new value for the transparency level. Use the value between 0 (full transparency) and 255 (full opacity).
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the transparency to be used when filling various drawn rectangles.
Dim caption As String = "Example: SetFillAlpha"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(70, 10, 60, 30, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(70, 80, 60, 30, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(70, 150, 60, 30, True, True) == GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 165, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(188, 143, 143) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(8) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 25, 180, 40, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineAlpha(200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillAlpha(200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 95, 180, 40, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineAlpha(100) == GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillAlpha(100) == GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 165, 180, 40, True, True) == GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_Lines.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFillAlpha";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(70, 10, 60, 30, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(70, 80, 60, 30, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(70, 150, 60, 30, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 165, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(188, 143, 143) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(8) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 25, 180, 40, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineAlpha(200) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillAlpha(200) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 95, 180, 40, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineAlpha(100) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillAlpha(100) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 165, 180, 40, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_Lines.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the line color used by all subsequent stroking operations, like the method or the method.
The initial value is set to black.This method uses the RGB color space for specifying the required color.
The line (stroke) color parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
Sets the line color to be used by all subsequent stroking operations.
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the initial line color is black.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the different line colors to draw various rectangles.
Dim caption As String = "Example: SetLineColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 228, 196) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(210, 105, 30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_LineColor.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 228, 196) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(210, 105, 30) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_LineColor.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the line color used by all subsequent stroking operations, like the method or the method.
The initial value is set to black.This method uses the CMYK color space for specifying the required color.
The line (stroke) color parameter is one of the graphics state parameters.
These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
Sets the line color to be used by all subsequent stroking operations.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the resulting color. Use the value between 0 and 255.
The amount of black (key) color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the initial line color is black.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the different line colors to draw various rectangles.
Dim caption As String = "Example: SetLineColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
f status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 27, 59, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(45, 150, 225, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_LineColor.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 27, 59, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(45, 150, 225, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_LineColor.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the line color used by all subsequent stroking operations, like the method or the method. The initial value is set to black.
The line (stroke) color parameter is one of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
Sets the line color to be used by all subsequent stroking operations.
A color object that defines the new line color. Initial value: black.
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the different line colors to draw various rectangles.
Dim caption As String = "Example: SetLineColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Cyan) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Bisque) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Fuchsia) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_LineColor.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(1) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Cyan) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Bisque) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(80, 20, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(5) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Fuchsia) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(150, 20, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_LineColor.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the transparency level (the current stroking alpha constant) for all subsequent stroking operations, means those with the defined Stroke parameter,
like the method or the method. This constant specifies the constant shape or constant opacity value. The initial value is set to 255.
The alpha constant parameter is one of the graphics state parameters.
These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
A new value for the transparency level. Use the value between 0 (full transparency) and 255 (full opacity).
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the transparency to be used when drawing various rectangles.
Dim caption As String = "Example: SetLineAlpha"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'The default graphics state is set.
(gdpicturePDF.SetLineWidth(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(70, 10, 60, 30, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(70, 80, 60, 30, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(70, 150, 60, 30, True, True) == GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 165, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(188, 143, 143) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(8) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 25, 180, 40, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineAlpha(200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillAlpha(200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 95, 180, 40, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineAlpha(100) == GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillAlpha(100) == GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 165, 180, 40, True, True) == GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_Lines.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetLineAlpha";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //The default graphics state is set.
(gdpicturePDF.SetLineWidth(3) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(70, 10, 60, 30, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(70, 80, 60, 30, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(70, 150, 60, 30, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 165, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(188, 143, 143) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(8) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 25, 180, 40, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineAlpha(200) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillAlpha(200) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 95, 180, 40, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineAlpha(100) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillAlpha(100) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 165, 180, 40, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_Lines.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Modifies the current transformation matrix (CTM) applying the concatenation with the transformation matrix you have specified. The
resulting transformation affects all subsequent drawing operations on the currently selected page of the loaded PDF document.
A transformation matrix is a part of the graphics state and it specifies the relationship between two coordinate spaces. By modifying a transformation
matrix, objects can be scaled, rotated, translated, or transformed in other ways. Although the transformation parameters specify a matrix, they are written as
six separate numbers. The matrix can represent any linear transformation from one coordinate system to another.
- Translations are specified as [ 1, 0, 0, 1, tx, ty ], where tx and ty are the distances to translate the origin of the coordinate system in the horizontal
and vertical dimensions, respectively.
- Scaling is obtained by [ sx, 0, 0, sy, 0, 0 ]. This scales the coordinates so that 1 unit in the horizontal and vertical dimensions of the new coordinate
system is the same size as sx and sy units, respectively, in the previous coordinate system.
- Rotations are produced by [ cos a, sin a, -sin a, cos a, 0, 0 ], which has the effect of rotating the coordinate system axes by an angle a counterclockwise.
- Skew is specified by [ 1, tan a, tan b, 1, 0, 0 ], which skews the x axis by an angle a and the y axis by an angle b.
For more details, please refer to the PDF Reference, Section "Common Transformations".
The first element of the transformation matrix. For more details please see the summary above.
The second element of the transformation matrix. For more details please see the summary above.
The third element of the transformation matrix. For more details please see the summary above.
The fourth element of the transformation matrix. For more details please see the summary above.
The distance, in points, from the left, to translate the origin of the coordinate system in the horizontal dimension.
The distance, in points, from the bottom, to translate the origin of the coordinate system in the vertical dimension.
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various rectangles without changing their coordinates using the different transformation matrices.
Dim caption As String = "Example: AddTransformationMatrix"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'Setting the default graphics state.
(gdpicturePDF.DrawRectangle(0, 0, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(10, 40, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveGraphicsState() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, 100, -100) = GdPictureStatus.OK) AndAlso 'translation
(gdpicturePDF.DrawRectangle(10, 40, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.RestoreGraphicsState() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddTransformationMatrix(1, 0.2F, 0, 1, 100, -200) = GdPictureStatus.OK) AndAlso 'vertical shear and translation
(gdpicturePDF.DrawRectangle(10, 40, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddTransformationMatrix(1, 0.2F, 0.1F, 1, 100, -150) = GdPictureStatus.OK) AndAlso 'vertical and horizontal shear and translation
(gdpicturePDF.DrawRectangle(10, 40, 40, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ResetGraphicsState() = GdPictureStatus.OK) AndAlso 'Resetting back to the default graphics state.
(gdpicturePDF.DrawRectangle(0, 180, 40, 20, True, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_TransformationMatrix.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddTransformationMatrix";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //Setting the default graphics state.
(gdpicturePDF.DrawRectangle(0, 0, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 40, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveGraphicsState() == GdPictureStatus.OK) &&
//translation
(gdpicturePDF.AddTransformationMatrix(1, 0, 0, 1, 100, -100) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 40, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.RestoreGraphicsState() == GdPictureStatus.OK) &&
//vertical shear and translation
(gdpicturePDF.AddTransformationMatrix(1, 0.2f, 0, 1, 100, -200) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 40, 40, 20, true, true) == GdPictureStatus.OK) &&
//vertical and horizontal shear and translation
(gdpicturePDF.AddTransformationMatrix(1, 0.2f, 0.1f, 1, 100, -150) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(10, 40, 40, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.ResetGraphicsState() == GdPictureStatus.OK) && //Resetting back to the default graphics state.
(gdpicturePDF.DrawRectangle(0, 180, 40, 20, true, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_TransformationMatrix.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Modifies the current transformation matrix (CTM) applying the clockwise rotation by a specified angle to the actual page. The applied rotation affects all
subsequent drawing operations on the currently selected page of the loaded PDF document. This method can be particularly useful when you need
to write text (or any other kind of page content) on a rotated page without applying the page rotation on the current content, as it is shown on the example below.
The CTM parameter is part of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
The rotation angle, in degrees, determining the clockwise rotation. This parameter can be only set to 90, -90, 180, -180, 270, -270, otherwise the method will fail.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
The applied page rotation does not affect the current page height and page width properties.
How to apply the rotation of the CTM on the current page to draw text without altering the page content.
Dim caption As String = "Example: AddPageRotation"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierBold)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim rotationAngle As Integer = 90
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 50, 50, "normal text") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRotatedText(fontName, 50, 50, "rotated text", rotationAngle) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.RotatePage(rotationAngle) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddPageRotation(360 - rotationAngle) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(165, 42, 42) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100, 500, "same as rotated text") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddPageRotation(rotationAngle) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 165, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 250, 20, "same as normal text") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddPageRotation.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddPageRotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierBold);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int rotationAngle = 90;
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(50) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 50, 50, "normal text") == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRotatedText(fontName, 50, 50, "rotated text", rotationAngle) == GdPictureStatus.OK) &&
(gdpicturePDF.RotatePage(rotationAngle) == GdPictureStatus.OK) &&
(gdpicturePDF.AddPageRotation(360 - rotationAngle) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(165, 42, 42) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100, 500, "same as rotated text") == GdPictureStatus.OK) &&
(gdpicturePDF.AddPageRotation(rotationAngle) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 165, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 250, 20, "same as normal text") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddPageRotation.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Modifies the current transformation matrix (CTM) applying a counterclockwise rotation by a required angle around a specified point, in other words
the current coordinate system axes are rotated by this angle counterclockwise. The rotation angle needs to be defined within the interval from 0 to 360.
The rotation's center point needs to be expressed in the current units defined in the PDF document, related to the actual page.
The applied rotation affects all subsequent drawing operations on the currently selected page of the loaded PDF document.
The CTM parameter is part of the graphics state parameters. These parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Graphics State").
You can use the method to determine the currently defined units and you can use the method to reset the units according to your preference.
The rotation angle, in degrees, determining the counterclockwise rotation. It must be an integer value from 0 to 360, otherwise the method will fail.
The horizontal (X) coordinate of the rotation's center point, expressed in the current units specified by the SetMeasurementUnit method, related to the currently selected page.
The vertical (Y) coordinate of the rotation's center point, expressed in the current units specified by the SetMeasurementUnit method, related to the currently selected page.
This method is only allowed for use with non-encrypted documents.
Be aware also that graphics state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw text onto a new page using the rotation of a current transformation matrix.
Dim caption As String = "Example: AddRotationAt"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(100) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddRotationAt(45, 50, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 50, 0, "GdPicturePDF") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddRotationAt.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddRotationAt";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(100) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.AddRotationAt(45, 50, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 50, 0, "GdPicturePDF") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddRotationAt.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws an image, specified by its resource name, onto the exactly defined area of the currently selected page of the loaded PDF document. The image already
needs to be included in the current document as a resource using one of the AddImage... methods().
The coordinates and the dimensions of the destination area need to be set in the current units defined in the PDF document, related to the actual page,
where the required image is to be drawn. You can use the method to determine the currently defined units and you can use the
method to reset the units according to your preference.
The image resource name of the required image as a string.
You can obtain this name using one of these methods:
, , or
any of the AddJpegImageFrom...() methods. For further assistance, please see the Images section of the GdPicturePDF class in the Reference Guide.
The horizontal (X) coordinate of the bottom left point of the destination area, where the image is to be drawn,
expressed in the current units specified by the SetMeasurementUnit method, related to the currently selected page.
The vertical (Y) coordinate of the bottom left point of the destination area, where the image is to be drawn,
expressed in the current units specified by the SetMeasurementUnit method, related to the currently selected page.
The width of the destination area, expressed in the current units specified by the SetMeasurementUnit method.
The height of the destination area, expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
Just to remind you that if the image to draw is a Mask Image, you should define the color for non-stroking operations by using the method.
Be aware that DstX and DstY parameters are fixly determined as the coordinates of the bottom left point of the destination area on the actual page.
We also recommend to take advantage of the class and its methods for further manipulation with images.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
These examples show you how to draw an image loaded from different resources using different methods
- the first image is loaded from the external file and the second image is loaded from the current PDF document.
Dim caption As String = "Example: DrawImage"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim width As Single = gdpicturePDF.GetPageWidth()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim height As Single = gdpicturePDF.GetPageHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'the new height of the destination area
height = height / 2
If (gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, 0, width, height) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, height, width, height) = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_DrawImage.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method or the NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float width = gdpicturePDF.GetPageWidth();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float height = gdpicturePDF.GetPageHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//the new height of the destination area
height = height / 2;
if ((gdpicturePDF.SelectPage(1) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, 0, width, height) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, height, width, height) == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_DrawImage.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method or the NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: DrawImage"
Dim message As String = ""
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test_images.pdf", True)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If gdpicturePDF.SelectPage(1) <> GdPictureStatus.OK Then
GoTo [error]
End If
Dim imageCount As Integer = gdpicturePDF.GetPageImageCount()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If imageCount > 0 Then
Dim imageName As String = gdpicturePDF.GetPageImageResName(0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim width As Single = gdpicturePDF.GetPageWidth()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
Dim height As Single = gdpicturePDF.GetPageHeight()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
GoTo [error]
End If
If (gdpicturePDF.InsertPage(width, height, pageCount + 1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(imageName, 0, 0, width, height) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFileInc("test_images.pdf")
If status = GdPictureStatus.OK Then
message = "The example has been followed successfully and the file has been saved."
Else
message = "The example has been followed successfully, but the SaveToFileInc() method has failed with the status: " + status.ToString()
End If
End If
Else
message = "The GetPageImageResName() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The first page of this document doesn't contain any image."
End If
Else
message = "The LoadFromFile() method has failed with the status: " + status.ToString()
End If
[error]:
If message.Equals("") Then
message = "The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: DrawImage";
string message = "";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test_images.pdf", true);
if (status == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if (gdpicturePDF.SelectPage(1) != GdPictureStatus.OK) goto error;
int imageCount = gdpicturePDF.GetPageImageCount();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if (imageCount > 0)
{
string imageName = gdpicturePDF.GetPageImageResName(0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float width = gdpicturePDF.GetPageWidth();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
float height = gdpicturePDF.GetPageHeight();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) goto error;
if ((gdpicturePDF.InsertPage(width, height, pageCount + 1) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(imageName, 0, 0, width, height) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFileInc("test_images.pdf");
if (status == GdPictureStatus.OK)
message = "The example has been followed successfully and the file has been saved.";
else
message = "The example has been followed successfully, but the SaveToFileInc() method has failed with the status: " + status.ToString();
}
}
else
message = "The GetPageImageResName() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
}
else
message = "The first page of this document doesn't contain any image.";
}
else
message = "The LoadFromFile() method has failed with the status: " + status.ToString();
error:
if (message.Equals(""))
message = "The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Draws a line on the currently selected page of the loaded PDF document according to what you have specified. All coordinates of the starting and ending points
of the line need to be set in the current units defined in the PDF document with respect to the currently located origin, related to the actual page. The line
is clearly defined by the its starting and ending points. The other line parameters, which you might prefer, for example, the line color or the line width, you
are allowed to set by using the method and the method.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
The horizontal (X) coordinate of the line's starting point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the line's starting point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The horizontal (X) coordinate of the line's ending point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the line's ending point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
This method is only allowed for use with non-encrypted documents.Be aware that the required line is drawn using the currently defined line attributes.
For further assistance, please see the Graphics State section of the GdPicturePDF class in the Reference Guide.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw lines with different attributes.
Dim caption As String = "Example: DrawLine"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'The color used to draw the line.
(gdpicturePDF.SetLineWidth(0.5F) = GdPictureStatus.OK) AndAlso 'the line width
(gdpicturePDF.DrawLine(2, 2, 18, 2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0.3F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(2, 4, 18, 4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(210, 105, 30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0.2F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineDash(2, 1) = GdPictureStatus.OK) AndAlso 'drawing a dash line
(gdpicturePDF.DrawLine(2, 6, 18, 6) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(2, 10, 18, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineNoDash() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(18, 6, 18, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(2, 6, 2, 10) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawLine.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawLine";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //The color used to draw the line.
(gdpicturePDF.SetLineWidth(0.5f) == GdPictureStatus.OK) && //the line width
(gdpicturePDF.DrawLine(2, 2, 18, 2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0.3f) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(2, 4, 18, 4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(210, 105, 30) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0.2f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineDash(2, 1) == GdPictureStatus.OK) && //drawing a dash line
(gdpicturePDF.DrawLine(2, 6, 18, 6) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(2, 10, 18, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineNoDash() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(18, 6, 18, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(2, 6, 2, 10) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawLine.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws an ellipse on the currently selected page of the loaded PDF document according to what you have specified. The center of the ellipse and the dimensions
of the ellipse's bounding box need to be set in the current units defined in the PDF document with respect to the currently located origin, related to the
actual page. The ellipse is clearly defined by the center and the dimensions of its bounding box.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
The horizontal (X) coordinate of the ellipse's center, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the ellipse's center, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The width of the ellipse's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the ellipse's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Set this parameter to true, if you want to fill the ellipse using the currently defined fill color, otherwise set it to false. You can set the fill
color using the method.
Set this parameter to true, if you want to stroke the ellipse (draw a boundary line along the rectangle) using the currently defined line color, otherwise
set it to false. You can set the line color using the method.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the center of the ellipse is the center of its bounding box.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw stroked and filled ellipses.
Dim caption As String = "Example: DrawEllipse"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'the color used to stroke the ellipses
(gdpicturePDF.SetLineWidth(0.2F) = GdPictureStatus.OK) AndAlso 'the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) = GdPictureStatus.OK) AndAlso 'the color used to fill the ellipses
(gdpicturePDF.DrawEllipse(10, 15, 16, 24, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawEllipse(10, 15, 12, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawEllipse(10, 15, 6, 12, True, False) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawEllipse1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawEllipse";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //the color used to stroke the ellipses
(gdpicturePDF.SetLineWidth(0.2f) == GdPictureStatus.OK) && //the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) == GdPictureStatus.OK) && //the color used to fill the ellipses
(gdpicturePDF.DrawEllipse(10, 15, 16, 24, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawEllipse(10, 15, 12, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawEllipse(10, 15, 6, 12, true, false) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawEllipse1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: DrawEllipse"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() <> GdPictureStatus.OK Then
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If gdpicturePDF.NewPage(210, 297) <> GdPictureStatus.OK Then
MessageBox.Show("The NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
If (gdpicturePDF.SetFillAlpha(180) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFillColor(255, 0, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawEllipse(100, 150, 180, 60, True, False) <> GdPictureStatus.OK) Then
MessageBox.Show("Drawing the first ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
If (gdpicturePDF.SetFillColor(0, 0, 255) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawEllipse(100, 150, 180, 60, True, False) <> GdPictureStatus.OK) Then
MessageBox.Show("Drawing the second ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopRight)
If (gdpicturePDF.SetFillColor(138, 43, 226) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawEllipse(100, 150, 180, 60, True, False) <> GdPictureStatus.OK) Then
MessageBox.Show("Drawing the third ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomRight)
If (gdpicturePDF.SetFillColor(255, 228, 196) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawEllipse(100, 150, 180, 60, True, False) <> GdPictureStatus.OK) Then
MessageBox.Show("Drawing the fourth ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_DrawEllipse2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: DrawEllipse";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() != GdPictureStatus.OK)
{
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if (gdpicturePDF.NewPage(210, 297) != GdPictureStatus.OK)
{
MessageBox.Show("The NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
if ((gdpicturePDF.SetFillAlpha(180) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFillColor(255, 0, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawEllipse(100, 150, 180, 60, true, false) != GdPictureStatus.OK))
{
MessageBox.Show("Drawing the first ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);
if ((gdpicturePDF.SetFillColor(0, 0, 255) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawEllipse(100, 150, 180, 60, true, false) != GdPictureStatus.OK))
{
MessageBox.Show("Drawing the second ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopRight);
if ((gdpicturePDF.SetFillColor(138, 43, 226) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawEllipse(100, 150, 180, 60, true, false) != GdPictureStatus.OK))
{
MessageBox.Show("Drawing the third ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomRight);
if ((gdpicturePDF.SetFillColor(255, 228, 196) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawEllipse(100, 150, 180, 60, true, false) != GdPictureStatus.OK))
{
MessageBox.Show("Drawing the fourth ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
GdPictureStatus status = gdpicturePDF.SaveToFile("test_DrawEllipse2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
error:
gdpicturePDF.Dispose();
Draws a circle on the currently selected page of the loaded PDF document according to what you have specified. The center of the circle and its radius need to
be set in the current units defined in the PDF document with respect to the currently located origin, related to the actual page. The circle is clearly defined
by the center and its radius.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
The horizontal (X) coordinate of the circle's center, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the circle's center, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The required radius of the circle, expressed in the current units specified by the SetMeasurementUnit method.
Set this parameter to true, if you want to fill the circle using the currently defined fill color, otherwise set it to false.
You can set the fill color using the method.
Set this parameter to true, if you want to stroke the circle (draw a boundary line along the circle) using the currently defined line color, otherwise set
it to false. You can set the line color using the method.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw stroked and filled circles. The example shows you reasonable combinations of the Fill and the Stroke parameters.
Dim caption As String = "Example: DrawCircle"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'the color used to stroke the circles
(gdpicturePDF.SetLineWidth(0.2F) = GdPictureStatus.OK) AndAlso 'the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) = GdPictureStatus.OK) AndAlso 'the color used to fill the circles
(gdpicturePDF.DrawCircle(10, 15, 8, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawCircle(10, 15, 6, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawCircle(10, 15, 4, True, False) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawCircle.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawCircle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //the color used to stroke the circles
(gdpicturePDF.SetLineWidth(0.2f) == GdPictureStatus.OK) && //the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) == GdPictureStatus.OK) && //the color used to fill the circles
(gdpicturePDF.DrawCircle(10, 15, 8, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawCircle(10, 15, 6, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawCircle(10, 15, 4, true, false) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawCircle.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a rectangle on the currently selected page of the loaded PDF document according to what you have specified. The starting point (the upper left corner)
of the rectangle and its dimensions need to be set in the current units defined in the PDF document with respect to the currently located origin,
related to the actual page. The rectangle is clearly defined by the starting point and its width and height.
You can simply use the method to determine the currently defined units and you can easily use
the method to reset the units according to your preference.
The horizontal (X) coordinate of the rectangle's starting point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the rectangle's starting point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The width of the rectangle, expressed in the current units specified by the SetMeasurementUnit method.
The height of the rectangle, expressed in the current units specified by the SetMeasurementUnit method.
Set this parameter to true, if you want to fill the rectangle using the currently defined fill color, otherwise set it to false.
You can set the fill color using the method.
Set this parameter to true, if you want to stroke the rectangle (draw a boundary line along the rectangle) using the currently defined line color, otherwise set
it to false. You can set the line color using the method.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw stroked and filled rectangles. The example shows you reasonable combinations of the Fill and the Stroke parameters.
Dim caption As String = "Example: DrawRectangle"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'the color used to stroke the rectangles
(gdpicturePDF.SetLineWidth(0.2F) = GdPictureStatus.OK) AndAlso 'the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) = GdPictureStatus.OK) AndAlso 'the color used to fill the rectangles
(gdpicturePDF.DrawRectangle(2, 2, 17, 25, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(4, 4, 12, 20, True, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(6, 6, 8, 12, True, False) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawRectangle.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawRectangle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(153, 50, 204) == GdPictureStatus.OK) && //the color used to stroke the rectangles
(gdpicturePDF.SetLineWidth(0.2f) == GdPictureStatus.OK) && //the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) == GdPictureStatus.OK) && //the color used to fill the rectangles
(gdpicturePDF.DrawRectangle(2, 2, 17, 25, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(4, 4, 12, 20, true, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(6, 6, 8, 12, true, false) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawRectangle.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a rounded rectangle (a rectangle with rounded corners) on the currently selected page of the loaded PDF document according to what you have specified.
The starting point (the upper left corner) of the rectangle and its dimensions need to be set in the current units defined in the PDF document with respect to
the currently located origin, related to the actual page. The rectangle is clearly defined by the starting point and its width and height.
You can simply use the method to determine the currently defined units and you can easily use
the method to reset the units according to your preference.
The horizontal (X) coordinate of the rectangle's starting point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the rectangle's starting point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The width of the rectangle, expressed in the current units specified by the SetMeasurementUnit method.
The height of the rectangle, expressed in the current units specified by the SetMeasurementUnit method.
The radius of the circle, of which the arc in the rectangle's corners is a part, expressed in the current units specified by the SetMeasurementUnit method.
The center of this circle is situated inside the rectangle's corners.
Set this parameter to true, if you want to fill the rectangle using the currently defined fill color, otherwise set it to false.
You can set the fill color using the method.
Set this parameter to true, if you want to stroke the rectangle (draw a boundary line along the rectangle) using the currently defined line color,
otherwise set it to false. You can set the line color using the method.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the centers of the four equal circles at the four rectangle's corners are situated inside the rectangle with respect to the Radius parameter.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw rounded rectangles. The example compares a typical rectangle with the rounded one.
Dim caption As String = "Example: DrawRoundedRectangle"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'the color used to stroke the rectangles
(gdpicturePDF.SetLineWidth(0.1F) = GdPictureStatus.OK) AndAlso 'the line width used to stroke
(gdpicturePDF.DrawRectangle(3, 3, 16, 24, False, True) = GdPictureStatus.OK) AndAlso 'the typical rectangle
(gdpicturePDF.DrawRoundedRectangle(3, 3, 16, 24, 5, False, True) = GdPictureStatus.OK) AndAlso 'the rounded rectangle
(gdpicturePDF.DrawRoundedRectangle(3, 3, 16, 24, 3, False, True) = GdPictureStatus.OK) AndAlso 'the rounded rectangle
(gdpicturePDF.DrawRoundedRectangle(3, 3, 16, 24, 1, False, True) = GdPictureStatus.OK) Then 'the rounded rectangle
status = gdpicturePDF.SaveToFile("test_DrawRoundedRectangle.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawRoundedRectangle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //the color used to stroke the rectangles
(gdpicturePDF.SetLineWidth(0.1f) == GdPictureStatus.OK) && //the line width used to stroke
(gdpicturePDF.DrawRectangle(3, 3, 16, 24, false, true) == GdPictureStatus.OK) && //the typical rectangle
(gdpicturePDF.DrawRoundedRectangle(3, 3, 16, 24, 5, false, true) == GdPictureStatus.OK) && //the rounded rectangle
(gdpicturePDF.DrawRoundedRectangle(3, 3, 16, 24, 3, false, true) == GdPictureStatus.OK) && //the rounded rectangle
(gdpicturePDF.DrawRoundedRectangle(3, 3, 16, 24, 1, false, true) == GdPictureStatus.OK)) //the rounded rectangle
{
status = gdpicturePDF.SaveToFile("test_DrawRoundedRectangle.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a circular arc on the currently selected page of the loaded PDF document according to what you have specified. The center point of the angle, that makes
the arc, and the radius of the circle, of which the arc is a part, need to be set in the current units defined in the PDF document with respect to the
currently located origin, related to the actual page. The arc is clearly defined by the StartAngle and the EndAngle parameters.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
The horizontal (X) coordinate of the center point of the angle, that makes the arc, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the center point of the angle, that makes the arc, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The required radius of the circle, of which the arc is a part, expressed in the current units specified by the SetMeasurementUnit method.
The starting angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative
ones in the opposite direction.
The ending angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones
in the opposite direction.
Set this parameter to true, if you want to close the arc, otherwise set it to false.
Please note that if you fill the arc, it will be always drawn as closed, as it is shown in the example below.
Set this parameter to true, if you want to fill the arc using the currently defined fill color, otherwise set it to false.
You can set the fill color using the method.
Set this parameter to true, if you want to stroke the arc (draw a boundary line along the arc) using the currently defined line color, otherwise set
it to false. You can set the line color using the method.
This method is only allowed for use with non-encrypted documents.
Just to remind you that angles are measured clockwise using this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw stroked and filled arcs. The example shows you reasonable combinations of the Close, the Fill and the Stroke parameters.
Dim caption As String = "Example: DrawArc"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'//This is the font only used to describe the drawn arcs.
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'the color used to stroke the arcs
(gdpicturePDF.SetLineWidth(0.1F) = GdPictureStatus.OK) AndAlso 'the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) = GdPictureStatus.OK) AndAlso 'the color used to fill the arcs
(gdpicturePDF.DrawArc(5, 6, 4, -45, 45, False, False, True) = GdPictureStatus.OK) AndAlso 'the first arc
(gdpicturePDF.DrawArc(15, 6, 4, -45, 45, False, True, True) = GdPictureStatus.OK) AndAlso 'the second arc
(gdpicturePDF.DrawArc(5, 12, 4, -45, 45, True, False, True) = GdPictureStatus.OK) AndAlso 'the third arc
(gdpicturePDF.DrawArc(15, 12, 4, -45, 45, True, True, True) = GdPictureStatus.OK) AndAlso 'the fourth arc
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso 'the color used to draw text + the code below is used to describe all arcs drawn above
(gdpicturePDF.DrawText(fontName, 5, 6, "1") = GdPictureStatus.OK) AndAlso 'starting point of the first arc
(gdpicturePDF.DrawText(fontName, 15, 6, "2") = GdPictureStatus.OK) AndAlso 'starting point of the second arc
(gdpicturePDF.DrawText(fontName, 5, 12, "3") = GdPictureStatus.OK) AndAlso 'starting point of the third arc
(gdpicturePDF.DrawText(fontName, 15, 12, "4") = GdPictureStatus.OK) AndAlso 'starting point of the four arc
(gdpicturePDF.DrawText(fontName, 3, 5, "only stroke") = GdPictureStatus.OK) AndAlso 'used attributes
(gdpicturePDF.DrawText(fontName, 13, 5, "fill & stroke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 3, 11, "close, not fill, but stroke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 13, 11, "close & fill & stroke") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawArc.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawArc";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//This is the font only used to describe the drawn arcs.
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //the color used to stroke the arcs
(gdpicturePDF.SetLineWidth(0.1f) == GdPictureStatus.OK) && //the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) == GdPictureStatus.OK) && //the color used to fill the arcs
(gdpicturePDF.DrawArc(5, 6, 4, -45, 45, false, false, true) == GdPictureStatus.OK) && //the first arc
(gdpicturePDF.DrawArc(15, 6, 4, -45, 45, false, true, true) == GdPictureStatus.OK) && //the second arc
(gdpicturePDF.DrawArc(5, 12, 4, -45, 45, true, false, true) == GdPictureStatus.OK) && //the third arc
(gdpicturePDF.DrawArc(15, 12, 4, -45, 45, true, true, true) == GdPictureStatus.OK) && //the fourth arc
//the code below is used to describe all arcs drawn above
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) && //the color used to draw text
(gdpicturePDF.DrawText(fontName, 5, 6, "1") == GdPictureStatus.OK) && //starting point of the first arc
(gdpicturePDF.DrawText(fontName, 15, 6, "2") == GdPictureStatus.OK) && //starting point of the second arc
(gdpicturePDF.DrawText(fontName, 5, 12, "3") == GdPictureStatus.OK) && //starting point of the third arc
(gdpicturePDF.DrawText(fontName, 15, 12, "4") == GdPictureStatus.OK) && //starting point of the four arc
(gdpicturePDF.DrawText(fontName, 3, 5, "only stroke") == GdPictureStatus.OK) && //used attributes
(gdpicturePDF.DrawText(fontName, 13, 5, "fill & stroke") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 3, 11, "close, not fill, but stroke") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 13, 11, "close & fill & stroke") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawArc.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a pie shape, means a sector of a circle, on the currently selected page of the loaded PDF document according to what you have specified. The center point
of the pie's circle and the circle's radius need to be set in the current units defined in the PDF document with respect to the currently located origin,
related to the actual page. The pie shape (sector) of the circle's area is clearly defined by the StartAngle and the EndAngle parameters.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
The horizontal (X) coordinate of the center of the pie's circle, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the center of the pie's circle, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The required radius of the circle, of which the pie shaped portion is a part, expressed in the current units specified by the SetMeasurementUnit method.
The starting angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative
ones in the opposite direction.
The ending angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones
in the opposite direction.
Set this parameter to true, if you want to fill the pie using the currently defined fill color, otherwise set it to false. You can set the fill
color using the method.
Set this parameter to true, if you want to stroke the pie (draw a boundary line along the pie shape) using the currently defined line color, otherwise set
it to false. You can set the line color using the method.
This method is only allowed for use with non-encrypted documents.
Just to remind you that angles are measured clockwise using this method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw stroked and filled pies. The example shows you reasonable combinations of the Fill and the Stroke parameters.
Dim caption As String = "Example: DrawPie"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'This is the font only used to describe the drawn pies.
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'the color used to stroke the pies
(gdpicturePDF.SetLineWidth(0.1F) = GdPictureStatus.OK) AndAlso 'the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) = GdPictureStatus.OK) AndAlso 'the color used to fill the pies
(gdpicturePDF.DrawPie(8, 6, 4, -45, 45, False, True) = GdPictureStatus.OK) AndAlso 'the first pie
(gdpicturePDF.DrawPie(5, 12, 4, -45, 45, True, False) = GdPictureStatus.OK) AndAlso 'the second pie
(gdpicturePDF.DrawPie(15, 12, 4, -45, 45, True, True) = GdPictureStatus.OK) AndAlso 'the third pie
(gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso 'the color used to draw text + the code below is used to describe all pies drawn above
(gdpicturePDF.DrawText(fontName, 8, 6, "1") = GdPictureStatus.OK) AndAlso 'the center of the circle of the first pie
(gdpicturePDF.DrawText(fontName, 5, 12, "2") = GdPictureStatus.OK) AndAlso 'the center of the circle of the second pie
(gdpicturePDF.DrawText(fontName, 15, 12, "3") = GdPictureStatus.OK) AndAlso 'the center of the circle of the third pie
(gdpicturePDF.DrawText(fontName, 7, 4, "only stroke") = GdPictureStatus.OK) AndAlso 'used attributes
(gdpicturePDF.DrawText(fontName, 4, 10, "only fill") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 14, 10, "fill & stroke") = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawPie.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawPie";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//This is the font only used to describe the drawn pies.
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //the color used to stroke the pies
(gdpicturePDF.SetLineWidth(0.1f) == GdPictureStatus.OK) && //the line width used to stroke
(gdpicturePDF.SetFillColor(153, 50, 204) == GdPictureStatus.OK) && //the color used to fill the pies
(gdpicturePDF.DrawPie(8, 6, 4, -45, 45, false, true) == GdPictureStatus.OK) && //the first pie
(gdpicturePDF.DrawPie(5, 12, 4, -45, 45, true, false) == GdPictureStatus.OK) && //the second pie
(gdpicturePDF.DrawPie(15, 12, 4, -45, 45, true, true) == GdPictureStatus.OK) && //the third pie
//the code below is used to describe all pies drawn above
(gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) && //the color used to draw text
(gdpicturePDF.DrawText(fontName, 8, 6, "1") == GdPictureStatus.OK) && //the center of the circle of the first pie
(gdpicturePDF.DrawText(fontName, 5, 12, "2") == GdPictureStatus.OK) && //the center of the circle of the second pie
(gdpicturePDF.DrawText(fontName, 15, 12, "3") == GdPictureStatus.OK) && //the center of the circle of the third pie
(gdpicturePDF.DrawText(fontName, 7, 4, "only stroke") == GdPictureStatus.OK) && //used attributes
(gdpicturePDF.DrawText(fontName, 4, 10, "only fill") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 14, 10, "fill & stroke") == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawPie.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required 1D barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for defining the barcode's desired color.
The coordinates and the dimensions of the specified barcode need to be set in the current units with respect to the currently located origin defined in the PDF document, related to the actual page,
where the barcode is to be drawn. You can use the method to determine the currently defined units and you can use the
method to reset the units according to your preference.
Draws a 1D (one-dimensional, or linear) barcode onto the currently selected page of the loaded PDF document.
A member of the Barcode1DWriterType enumeration. The type of the required barcode.
The data to encode using the required barcode.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The width of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The amount of red color to be used for the barcode's resulting color. Use the value between 0 and 255.
The amount of green color to be used for the barcode's resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the barcode's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw a 1-dimensional barcode onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcode1D"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "0123456789", 2, 2, 15, 10, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "9876543210", 2, 16, 15, 10, 255, 0, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcode1D.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcode1D() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcode1D";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "0123456789", 2, 2, 15, 10, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "9876543210", 2, 16, 15, 10, 255, 0, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcode1D.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcode1D() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required 1D barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for defining the barcode's desired color.The coordinates and the dimensions of the specified barcode need to be set in the current units with respect to the currently located origin defined in the PDF document, related to the actual page,
where the barcode is to be drawn. You can use the method to determine the currently defined units and you can use the
method to reset the units according to your preference.
Draws a 1D (one-dimensional, or linear) barcode onto the currently selected page of the loaded PDF document.
A member of the Barcode1DWriterType enumeration. The type of the required barcode.
The data to encode using the required barcode.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The width of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The amount of cyan color to be used for the barcode's resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the barcode's resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the barcode's resulting color. Use the value between 0 and 255.
The amount of black (key) color to be used for the barcode's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw a 1-dimensional barcode onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcode1D"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "0123456789", 2, 2, 15, 10, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "9876543210", 2, 16, 15, 10, 0, 255, 0, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcode1D.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcode1D() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcode1D";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "0123456789", 2, 2, 15, 10, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "9876543210", 2, 16, 15, 10, 0, 255, 0, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcode1D.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcode1D() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required 1D barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the barcode's color you have specified.The coordinates and the dimensions of the specified barcode need to be set in the current units with respect to the currently located origin defined in the PDF document,
related to the actual page, where the barcode is to be drawn. You can use the method to determine the currently defined units
and you can use the method to reset the units according to your preference.
Draws a 1D (one-dimensional, or linear) barcode onto the currently selected page of the loaded PDF document.
A member of the Barcode1DWriterType enumeration. The type of the required barcode.
The data to encode using the required barcode.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The width of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the barcode's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
A color object that defines the color to be used for drawing a required barcode.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw a 1-dimensional barcode onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcode1D"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "0123456789", 2, 2, 15, 10, Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "9876543210", 2, 16, 15, 10, Color.Red) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcode1D.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcode1D() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcode1D";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "0123456789", 2, 2, 15, 10, Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcode1D(Barcode1DWriterType.Barcode1DWriterCode128, "9876543210", 2, 16, 15, 10, Color.Red) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcode1D.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcode1D() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the symbol's fill color you have specified.The coordinates and the dimensions of the QR Code symbol need to be set in the current units with respect to the currently located origin defined in the PDF
document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined units and
you can use the method to reset the units according to your preference.
Draws a QR code (the trademark for a type of matrix barcode or two-dimensional barcode) onto the currently selected page of the loaded PDF document.
The data to encode using the required QR Code symbol.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged.
The higher the level, the greater the error correction, but also the larger the QR Code version.
The version of the QR Code, it specifies the overall dimensions of the symbol.
QR Codes can be generated in 40 different symbol versions, from 21 x 21 modules (version 1) to 177 x 177 modules (version 40), therefore the range for this
parameter is 0 - 40. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
Specifically for QR Codes, the larger the module is, the more stable and easier to read with a QR Code scanner it becomes. On the other hand, as the QR Code
symbol size gets larger, a larger printing area is required.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
A color object that defines the color to be used for drawing the required symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various QR barcodes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, Color.Orange) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 6, 2, Color.OrangeRed) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 8, 12, 2, Color.Orchid) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 10, Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 6, 10, Color.BlueViolet) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 8, 12, 10, Color.CadetBlue) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, Color.Orange) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 6, 2, Color.OrangeRed) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 8, 12, 2, Color.Orchid) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 10, Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 6, 10, Color.BlueViolet) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 8, 12, 10, Color.CadetBlue) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for specifying the desired color of the QR Code symbol.The coordinates and the dimensions of the QR Code symbol need to be set in the current units with respect to the currently located origin defined in the PDF
document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined units and
you can use the method to reset the units according to your preference.
Draws a QR code (the trademark for a type of matrix barcode or two-dimensional barcode) onto the currently selected page of the loaded PDF document.
The data to encode using the required QR Code symbol.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged.
The higher the level, the greater the error correction, but also the larger the QR Code version.
The version of the QR Code, it specifies the overall dimensions of the symbol.
QR Codes can be generated in 40 different symbol versions, from 21 x 21 modules (version 1) to 177 x 177 modules (version 40), therefore the range for this
parameter is 0 - 40. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
Specifically for QR Codes, the larger the module is, the more stable and easier to read with a QR Code scanner it becomes. On the other hand, as the QR Code symbol size gets larger, a larger printing area is required.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of red color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 255, 165, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 6, 2, 255, 69, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 8, 12, 2, 218, 112, 214) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 10, 0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 6, 10, 138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 8, 12, 10, 95, 158, 160) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 255, 165, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 6, 2, 255, 69, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 8, 12, 2, 218, 112, 214) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 10, 0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 6, 10, 138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 8, 12, 10, 95, 158, 160) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for specifying the desired color of the QR Code symbol.The coordinates and the dimensions of the code symbol need to be set in the current units with respect to the currently located origin defined in the PDF
document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined units and
you can use the method to reset the units according to your preference.
Draws a QR code (the trademark for a type of matrix barcode or two-dimensional barcode) onto the currently selected page of the loaded PDF document.
The data to encode using the required QR Code symbol.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged.
The higher the level, the greater the error correction, but also the larger the QR Code version.
The version of the QR Code, it specifies the overall dimensions of the symbol.
QR Codes can be generated in 40 different symbol versions, from 21 x 21 modules (version 1) to 177 x 177 modules (version 40), therefore the range for this
parameter is 0 - 40. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
Specifically for QR Codes, the larger the module is, the more stable and easier to read with a QR Code scanner it becomes. On the other hand, as the QR Code symbol size gets larger, a larger printing area is required.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of cyan color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of black (key) color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 6, 2, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 8, 12, 2, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 10, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 6, 10, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 8, 12, 10, 255, 0, 0, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 6, 2, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 8, 12, 2, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 10, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 6, 10, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 8, 12, 10, 255, 0, 0, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for specifying the desired colors (both fill and background) of the QR Code symbol.The coordinates and the dimensions of the code symbol need to be set in the current units with respect to the currently located origin defined in the PDF
document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined units and
you can use the method to reset the units according to your preference.
Draws a QR code (the trademark for a type of matrix barcode or two-dimensional barcode) onto the currently selected page of the loaded PDF document.
The data to encode using the required QR Code symbol.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged.
The higher the level, the greater the error correction, but also the larger the QR Code version.
The version of the QR Code, it specifies the overall dimensions of the symbol.
QR Codes can be generated in 40 different symbol versions, from 21 x 21 modules (version 1) to 177 x 177 modules (version 40), therefore the range for this
parameter is 0 - 40. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The number of modules composing the quiet zone.
The quiet zone is the margin area around the QR Code symbol, that does not contain any information. It separates the symbol from its surroundings.
Specifically, QR Code requires a four-module wide margin at all four sides of a symbol.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
Specifically for QR Codes, the larger the module is, the more stable and easier to read with a QR Code scanner it becomes. On the other hand, as the QR Code symbol size gets larger, a larger printing area is required.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of red color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of red color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, 255, 0, 0, 255, 128, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, 255, 0, 0, 255, 128, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, 255, 0, 0, 255, 128, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, 0, 0, 255, 255, 170, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, 0, 0, 255, 255, 170, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, 0, 0, 255, 255, 170, 80) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, 255, 0, 0, 255, 128, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, 255, 0, 0, 255, 128, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, 255, 0, 0, 255, 128, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, 0, 0, 255, 255, 170, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, 0, 0, 255, 255, 170, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, 0, 0, 255, 255, 170, 80) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for specifying the desired colors (both fill and background) of the QR Code symbol.The coordinates and the dimensions of the code symbol need to be set in the current units with respect to the currently located origin defined in the PDF
document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined units and
you can use the method to reset the units according to your preference.
Draws a QR code (the trademark for a type of matrix barcode or two-dimensional barcode) onto the currently selected page of the loaded PDF document.
The data to encode using the required QR Code symbol.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged.
The higher the level, the greater the error correction, but also the larger the QR Code version.
The number of modules composing the quiet zone.
The quiet zone is the margin area around the QR Code symbol, that does not contain any information. It separates the symbol from its surroundings.
Specifically, QR Code requires a four-module wide margin at all four sides of a symbol.
The version of the QR Code, it specifies the overall dimensions of the symbol.
QR Codes can be generated in 40 different symbol versions, from 21 x 21 modules (version 1) to 177 x 177 modules (version 40), therefore the range for this
parameter is 0 - 40. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
Specifically for QR Codes, the larger the module is, the more stable and easier to read with a QR Code scanner it becomes. On the other hand, as the QR Code
symbol size gets larger, a larger printing area is required.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of cyan color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of magenta color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of yellow color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of black color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of cyan color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of magenta color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of yellow color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of black color to be used for the symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, 0, 255, 0, 0, 0, 0, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, 0, 255, 0, 0, 0, 0, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, 0, 255, 0, 0, 0, 0, 255, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, 0, 255, 0, 0, 0, 0, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, 0, 255, 0, 0, 0, 0, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, 0, 255, 0, 0, 0, 0, 255, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the symbol's fill and background colors you have specified.The coordinates and the dimensions of the code symbol need to be set in the current units with respect to the currently located origin defined in the PDF
document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined units and
you can use the method to reset the units according to your preference.
Draws a QR code (the trademark for a type of matrix barcode or two-dimensional barcode) onto the currently selected page of the loaded PDF document.
The data to encode using the required QR Code symbol.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
A member of the BarcodeQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged.
The higher the level, the greater the error correction, but also the larger the QR Code version.
The version of the QR Code, it specifies the overall dimensions of the symbol.
QR Codes can be generated in 40 different symbol versions, from 21 x 21 modules (version 1) to 177 x 177 modules (version 40), therefore the range for this
parameter is 0 - 40. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The number of modules composing the quiet zone.
The quiet zone is the margin area around the QR Code symbol, that does not contain any information. It separates the symbol from its surroundings.
Specifically, QR Code requires a four-module wide margin at all four sides of a symbol.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
Specifically for QR Codes, the larger the module is, the more stable and easier to read with a QR Code scanner it becomes. On the other hand, as the QR Code symbol size gets larger, a larger printing area is required.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
A color object that defines the color to be used for drawing a required QR Code symbol.
A color object that defines the color to be used for drawing a background behind the QR Code symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelM,
0, 4, 8, 12, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 2, 2, 2, 12, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 3, 4, 6, 12, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeQRErrorCorrectionLevel.BarcodeQRErrorCorrectionLevelL,
0, 4, 8, 12, 12, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Micro QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the symbol's fill color you have specified.The coordinates and the dimensions of the Micro QR Code symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a Micro QR Code (a smaller version of standard QR Code) onto the currently selected page of the loaded PDF document.
The data to encode using the required Micro QR Code symbol. Specifically the amount of data that can be stored in a Micro QR Code is max. 35 numerals.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
Choosing the correct encoding mode and the lowest error correction (2) will help ensure the symbol is as small as possible.
A member of the BarcodeMicroQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged. The higher the error correction level, the less storage capacity.
The version of the Micro QR Code, it specifies the overall dimensions of the symbol.
Micro QR Codes can be generated in 4 different symbol versions, from 21 x 21 modules (version M1) to 17 x 17 modules (version M4), therefore the range for
this parameter is 0 - 4. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
A color object that defines the color to be used for drawing the required symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various Micro QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeMicroMicroQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, Color.Orange) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 2, Color.OrangeRed) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 6, 12, 2, Color.Orchid) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 8, Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 8, Color.BlueViolet) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 6, 12, 8, Color.CadetBlue) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeMicroMicroQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, Color.Orange) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 2, Color.OrangeRed) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 6, 12, 2, Color.Orchid) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 8, Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 8, Color.BlueViolet) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 6, 12, 8, Color.CadetBlue) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Micro QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for specifying the desired color of the Micro QR Code symbol.The coordinates and the dimensions of the Micro QR Code symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a Micro QR Code (a smaller version of standard QR Code) onto the currently selected page of the loaded PDF document.
The data to encode using the required Micro QR Code symbol. Specifically the amount of data that can be stored in a Micro QR Code is max. 35 numerals.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
Choosing the correct encoding mode and the lowest error correction (2) will help ensure the symbol is as small as possible.
A member of the BarcodeMicroQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged. The higher the error correction level, the less storage capacity.
The version of the Micro QR Code, it specifies the overall dimensions of the symbol.
Micro QR Codes can be generated in 4 different symbol versions, from 21 x 21 modules (version M1) to 17 x 17 modules (version M4), therefore the range for
this parameter is 0 - 4. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of red color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various Micro QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeMicroMicroQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 255, 165, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 2, 255, 69, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 6, 12, 2, 218, 112, 214) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 8, 0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 8, 138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 6, 12, 8, 95, 158, 160) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeMicroMicroQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 255, 165, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 2, 255, 69, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 6, 12, 2, 218, 112, 214) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 8, 0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 8, 138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 6, 12, 8, 95, 158, 160) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Micro QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for specifying the desired color of the Micro QR Code symbol.The coordinates and the dimensions of the Micro QR Code symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a Micro QR Code (a smaller version of standard QR Code) onto the currently selected page of the loaded PDF document.
The data to encode using the required Micro QR Code symbol. Specifically the amount of data that can be stored in a Micro QR Code is max. 35 numerals.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
Choosing the correct encoding mode and the lowest error correction (2) will help ensure the symbol is as small as possible.
A member of the BarcodeMicroQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged. The higher the error correction level, the less storage capacity.
The version of the Micro QR Code, it specifies the overall dimensions of the symbol.
Micro QR Codes can be generated in 4 different symbol versions, from 21 x 21 modules (version M1) to 17 x 17 modules (version M4), therefore the range for
this parameter is 0 - 4. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of cyan color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of black (key) color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various Micro QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeMicroMicroQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 2, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 6, 12, 2, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 8, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 8, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 6, 12, 8, 255, 0, 0, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeMicroMicroQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 2, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 6, 12, 2, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 8, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 8, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 6, 12, 8, 255, 0, 0, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Micro QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for specifying the desired colors (both fill and background) of the Micro QR Code symbol.The coordinates and the dimensions of the Micro QR Code symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a Micro QR Code (a smaller version of standard QR Code) onto the currently selected page of the loaded PDF document.
The data to encode using the required Micro QR Code symbol. Specifically the amount of data that can be stored in a Micro QR Code is max. 35 numerals.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
Choosing the correct encoding mode and the lowest error correction (2) will help ensure the symbol is as small as possible.
A member of the BarcodeMicroQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged. The higher the error correction level, the less storage capacity.
The version of the Micro QR Code, it specifies the overall dimensions of the symbol.
Micro QR Codes can be generated in 4 different symbol versions, from 21 x 21 modules (version M1) to 17 x 17 modules (version M4), therefore the range for
this parameter is 0 - 4. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The number of modules composing the quiet zone.
The quiet zone is the margin area around the Micro QR Code symbol, that does not contain any information. It separates the symbol from its surroundings.
Specifically, Micro QR Code requires only a two-module wide margin at all four sides of a symbol.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of red color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of red color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various Micro QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeMicroMicroQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, 255, 0, 0, 255, 128, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, 255, 0, 0, 255, 128, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 12, 2, 255, 0, 0, 255, 128, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 2, 8, 0, 0, 255, 255, 170, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 3, 4, 6, 8, 0, 0, 255, 255, 170, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 12, 8, 0, 0, 255, 255, 170, 80) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeMicroMicroQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, 255, 0, 0, 255, 128, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, 255, 0, 0, 255, 128, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 12, 2, 255, 0, 0, 255, 128, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 2, 8, 0, 0, 255, 255, 170, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 3, 4, 6, 8, 0, 0, 255, 255, 170, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 12, 8, 0, 0, 255, 255, 170, 80) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Micro QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for specifying the desired colors (both fill and background) of the Micro QR Code symbol.The coordinates and the dimensions of the Micro QR Code symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a Micro QR Code (a smaller version of standard QR Code) onto the currently selected page of the loaded PDF document.
The data to encode using the required Micro QR Code symbol. Specifically the amount of data that can be stored in a Micro QR Code is max. 35 numerals.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
Choosing the correct encoding mode and the lowest error correction (2) will help ensure the symbol is as small as possible.
A member of the BarcodeMicroQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged. The higher the error correction level, the less storage capacity.
The version of the Micro QR Code, it specifies the overall dimensions of the symbol.
Micro QR Codes can be generated in 4 different symbol versions, from 21 x 21 modules (version M1) to 17 x 17 modules (version M4), therefore the range for
this parameter is 0 - 4. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The number of modules composing the quiet zone.
The quiet zone is the margin area around the Micro QR Code symbol, that does not contain any information. It separates the symbol from its surroundings.
Specifically, Micro QR Code requires only a two-module wide margin at all four sides of a symbol.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of cyan color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of magenta color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of yellow color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of black color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of cyan color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of magenta color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of yellow color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of black color to be used for the symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various Micro QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeMicroMicroQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 12, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 2, 8, 0, 255, 0, 0, 0, 0, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 3, 4, 6, 8, 0, 255, 0, 0, 0, 0, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 12, 8, 0, 255, 0, 0, 0, 0, 255, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeMicroMicroQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 12, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 2, 8, 0, 255, 0, 0, 0, 0, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 3, 4, 6, 8, 0, 255, 0, 0, 0, 0, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 12, 8, 0, 255, 0, 0, 0, 0, 255, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Micro QR Code onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the symbol's fill and background colors you have specified.The coordinates and the dimensions of the Micro QR Code symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a Micro QR Code (a smaller version of standard QR Code) onto the currently selected page of the loaded PDF document.
The data to encode using the required Micro QR Code symbol. Specifically the amount of data that can be stored in a Micro QR Code is max. 35 numerals.
A member of the BarcodeQREncodingMode enumeration. The QR Code encoding mode.
Choosing the correct encoding mode and the lowest error correction (2) will help ensure the symbol is as small as possible.
A member of the BarcodeMicroQRErrorCorrectionLevel enumeration. The error correction level.
These levels are defined in terms of percentage of codewords in the barcode that can be corrected if damaged. The higher the error correction level, the less storage capacity.
The version of the Micro QR Code, it specifies the overall dimensions of the symbol.
Micro QR Codes can be generated in 4 different symbol versions, from 21 x 21 modules (version M1) to 17 x 17 modules (version M4), therefore the range for
this parameter is 0 - 4. You can use 0 to let the engine decide the minimum version required to encode all specified data.
The number of modules composing the quiet zone.
The quiet zone is the margin area around the Micro QR Code symbol, that does not contain any information. It separates the symbol from its surroundings.
Specifically, Micro QR Code requires only a two-module wide margin at all four sides of a symbol.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the symbol. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
A color object that defines the color to be used for drawing a required Micro QR Code symbol.
A color object that defines the color to be used for drawing a background behind the Micro QR Code symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various Micro QR Codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeMicroMicroQrCode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 12, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 2, 8, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 3, 4, 6, 8, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 12, 8, Color.Yellow, Color.Chocolate) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeMicroMicroQrCode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 2, 2, 2, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 3, 4, 6, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("0123456789", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelM,
0, 4, 6, 12, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 2, 2, 2, 8, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 3, 4, 6, 8, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeMicroMicroQrCode("9876543210", BarcodeQREncodingMode.BarcodeQREncodingModeAlphaNumeric, BarcodeMicroQRErrorCorrectionLevel.BarcodeMicroQRErrorCorrectionLevelL,
0, 4, 6, 12, 8, Color.Yellow, Color.Chocolate) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeMicroMicroQrCode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeMicroMicroQrCode() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required DataMatrix barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for defining the desired fill color of the barcode symbol.The coordinates and the dimensions of the DataMatrix barcode symbol need to be set in the current units with respect to the currently located origin
defined in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the
currently defined units and you can use the method to reset the units according to your preference.
Draws a DataMatrix barcode (a matrix 2D code) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodeDataMatrixEncodingMode enumeration. The DataMatrix barcode high level encoding mode.
A member of the BarcodeDataMatrixVersion enumeration. The version of the DataMatrix barcode.
You can use the BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the DataMatrix barcode. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of red color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various DataMatrix barcodes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeDataMatrix"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 2, 2, 2, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 4, 6, 2, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 8, 12, 2, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 2, 2, 10, 0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 4, 6, 10, 0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 8, 12, 10, 0, 0, 255) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeDataMatrix";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 2, 2, 2, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 4, 6, 2, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 8, 12, 2, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 2, 2, 10, 0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 4, 6, 10, 0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 8, 12, 10, 0, 0, 255) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required DataMatrix barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for defining the desired fill color of the barcode symbol.The coordinates and the dimensions of the DataMatrix barcode symbol need to be set in the current units with respect to the currently located origin defined
in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently
defined units and you can use the method to reset the units according to your preference.
Draws a DataMatrix barcode (a matrix 2D code) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodeDataMatrixEncodingMode enumeration. The DataMatrix barcode high level encoding mode.
A member of the BarcodeDataMatrixVersion enumeration. The version of the DataMatrix barcode.
You can use the BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the DataMatrix barcode. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of cyan color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of black (key) color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various DataMatrix barcodes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeDataMatrix"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 2, 2, 2, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 4, 6, 2, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 8, 12, 2, 0, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 2, 2, 10, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 4, 6, 10, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 8, 12, 10, 255, 0, 0, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeDataMatrix";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 2, 2, 2, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 4, 6, 2, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 8, 12, 2, 0, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 2, 2, 10, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 4, 6, 10, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 8, 12, 10, 255, 0, 0, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required DataMatrix barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the barcode symbol's fill color you have specified.The coordinates and the dimensions of the DataMatrix barcode symbol need to be set in the current units with respect to the currently located origin defined
in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently
defined units and you can use the method to reset the units according to your preference.
Draws a DataMatrix barcode (a matrix 2D code) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodeDataMatrixEncodingMode enumeration. The DataMatrix barcode high level encoding mode.
A member of the BarcodeDataMatrixVersion enumeration. The version of the DataMatrix barcode.
You can use the BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto to let the engine decide the minimum version required to encode all specified data.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the DataMatrix barcode. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
A color object that defines the color to be used for drawing a required barcode symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various DataMatrix barcodes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeDataMatrix"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 2, 2, 2, Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 4, 6, 2, Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 8, 12, 2, Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 2, 2, 10, Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 4, 6, 10, Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 8, 12, 10, Color.Blue) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeDataMatrix";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 2, 2, 2, Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 4, 6, 2, Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersion010x010, 8, 12, 2, Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 2, 2, 10, Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 4, 6, 10, Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII,
BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto, 8, 12, 10, Color.Blue) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required DataMatrix barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for defining the desired colors (both fill and background) of the barcode symbol.The coordinates and the dimensions of the DataMatrix barcode symbol need to be set in the current units with respect to the currently located origin defined
in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently
defined units and you can use the method to reset the units according to your preference.
Draws a DataMatrix barcode (a matrix 2D code) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodeDataMatrixEncodingMode enumeration. The DataMatrix barcode high level encoding mode.
A member of the BarcodeDataMatrixVersion enumeration. The version of the DataMatrix barcode.
You can use the BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto to let the engine decide the minimum version required to encode all specified data.
The number of modules composing the quiet zone.
A quiet zone is the margin area around the DataMatrix barcode, that does not contain any information. It separates the symbol from its surroundings and it should be at least one module wide.
Using width of two module sizes is a good practice.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the DataMatrix barcode. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of red color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of red color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various DataMatrix barcodes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeDataMatrix"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 2, 2, 2, 255, 0, 0, 255, 128, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 4, 6, 2, 255, 0, 0, 255, 128, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
6, 8, 12, 2, 255, 0, 0, 255, 128, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 2, 2, 10, 0, 0, 255, 255, 170, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 4, 6, 10, 0, 0, 255, 255, 170, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
6, 8, 12, 10, 0, 0, 255, 255, 170, 80) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeDataMatrix";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 2, 2, 2, 255, 0, 0, 255, 128, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 4, 6, 2, 255, 0, 0, 255, 128, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
6, 8, 12, 2, 255, 0, 0, 255, 128, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 2, 2, 10, 0, 0, 255, 255, 170, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 4, 6, 10, 0, 0, 255, 255, 170, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
6, 8, 12, 10, 0, 0, 255, 255, 170, 80) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required DataMatrix barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for defining the desired colors (both fill and background) of the barcode symbol.The coordinates and the dimensions of the DataMatrix barcode symbol need to be set in the current units with respect to the currently located origin defined
in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently
defined units and you can use the method to reset the units according to your preference.
Draws a DataMatrix barcode (a matrix 2D code) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodeDataMatrixEncodingMode enumeration. The DataMatrix barcode high level encoding mode.
A member of the BarcodeDataMatrixVersion enumeration. The version of the DataMatrix barcode.
You can use the BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto to let the engine decide the minimum version required to encode all specified data.
The number of modules composing the quiet zone.
A quiet zone is the margin area around the DataMatrix barcode, that does not contain any information. It separates the symbol from its surroundings and it
should be at least one module wide. Using width of two module sizes is a good practice.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the DataMatrix barcode. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of cyan color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of magenta color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of yellow color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of black color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of cyan color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of magenta color to be used for symbol's resulting background color. Use the value between 0 and 255.
The amount of yellow color to be used for symbol's resulting background color. Use the value between 0 and 255.
The amount of black color to be used for symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various DataMatrix barcodes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeDataMatrix"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 2, 2, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 4, 6, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
6, 8, 12, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 2, 2, 10, 0, 255, 0, 0, 0, 0, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 4, 6, 10, 0, 255, 0, 0, 0, 0, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
6, 8, 12, 10, 0, 255, 0, 0, 0, 0, 255, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeDataMatrix";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 2, 2, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 4, 6, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
6, 8, 12, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 2, 2, 10, 0, 255, 0, 0, 0, 0, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 4, 6, 10, 0, 255, 0, 0, 0, 0, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
6, 8, 12, 10, 0, 255, 0, 0, 0, 0, 255, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required DataMatrix barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the barcode symbol's fill and background colors you have specified.The coordinates and the dimensions of the DataMatrix barcode symbol need to be set in the current units with respect to the currently located origin defined
in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently
defined units and you can use the method to reset the units according to your preference.
Draws a DataMatrix barcode (a matrix 2D code) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodeDataMatrixEncodingMode enumeration. The DataMatrix barcode high level encoding mode.
A member of the BarcodeDataMatrixVersion enumeration. The version of the DataMatrix barcode.
You can use the BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto to let the engine decide the minimum version required to encode all specified data.
The number of modules composing the quiet zone.
A quiet zone is the margin area around the DataMatrix barcode, that does not contain any information. It separates the symbol from its surroundings and it
should be at least one module wide. Using width of two module sizes is a good practice.
The size of each module within the drawn symbol, in points.
The module is the smallest cell in the DataMatrix barcode. The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
A color object that defines the color to be used for drawing a required barcode symbol.
A color object that defines the color to be used for drawing a background behind the barcode symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various DataMatrix barcodes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeDataMatrix"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 2, 2, 2, Color.Red, Color.LightCoral) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 4, 6, 2, Color.Red, Color.LightCoral) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
6, 8, 12, 2, Color.Red, Color.LightCoral) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 2, 2, 10, Color.Blue, Color.Cyan) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 4, 6, 10, Color.Blue, Color.Cyan) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
6, 8, 12, 10, Color.Blue, Color.Cyan) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeDataMatrix";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 2, 2, 2, Color.Red, Color.LightCoral) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
4, 4, 6, 2, Color.Red, Color.LightCoral) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("0123456789", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersion012x012,
6, 8, 12, 2, Color.Red, Color.LightCoral) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 2, 2, 10, Color.Blue, Color.Cyan) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
4, 4, 6, 10, Color.Blue, Color.Cyan) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeDataMatrix("9876543210", BarcodeDataMatrixEncodingMode.BarcodeDataMatrixEncodingModeASCII, BarcodeDataMatrixVersion.BarcodeDataMatrixVersionAuto,
6, 8, 12, 10, Color.Blue, Color.Cyan) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeDataMatrix.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeDataMatrix() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
How to draw various DataMatrix barcodes on the newly created page of the new PDF document.
Draws a required PDF417 barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for defining the desired fill color of the barcode symbol.The coordinates and the dimensions of the PDF417 barcode symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a PDF417 barcode (a stacked linear barcode symbol format) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodePDF417EncodingMode enumeration. The barcode encoding mode.
You can use the BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined to let the engine analyze the input and to select the most appropriate encoding mode.
A member of the BarcodePDF417ErrorCorrectionLevel enumeration. The error correction level.
You can use the BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto to let the engine automatically determine the required level.
Specifies the number of rows constituting the barcode symbol.
A PDF417 symbol must have at least 3 rows and no more than 90. It is recommended to use 0 for automatic computation.
Specifies the number of columns constituting the barcode symbol.
A column refers to the set of codewords vertically. A PDF41 symbol may have 1 to 30 columns. It is recommended to use 0 for automatic computation.
The width of a module, in points.
Module is the smallest unit of a PDF417 symbol. The width of a module (width of the narrowest bar) is commonly referred as X dimension of the
symbol, for more details on this please read the Remarks section below.
The height of each row, in points.
For better decodability, height should be no less than 2, for more details on this please read the Remarks section below.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of red color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the PDF417 barcode is usually printed at an X to Y ratio of 1:2 to 1:5, with 1:3 being the most popular. By lowering the ratio, a
significant amount of space can be saved; however, some scanners cannot read X to Y ratios of less than 1:3.
Likewise, just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various PDF417 barcodes on the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodePDF417"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 4, 2, 2, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 4, 6, 2, 10, 255, 0, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("DrawBarcodePDF417.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodePDF417";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 4, 2, 2, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 4, 6, 2, 10, 255, 0, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodePDF417.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required PDF417 barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for defining the desired fill color of the barcode symbol.The coordinates and the dimensions of the PDF417 barcode symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a PDF417 barcode (a stacked linear barcode symbol format) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodePDF417EncodingMode enumeration. The barcode encoding mode.
You can use the BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined to let the engine analyze the input and to select the most appropriate encoding mode.
A member of the BarcodePDF417ErrorCorrectionLevel enumeration. The error correction level.
You can use the BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto to let the engine automatically determine the required level.
Specifies the number of rows constituting the barcode symbol.
A PDF417 symbol must have at least 3 rows and no more than 90. It is recommended to use 0 for automatic computation.
Specifies the number of columns constituting the barcode symbol.
A column refers to the set of codewords vertically. A PDF41 symbol may have 1 to 30 columns. It is recommended to use 0 for automatic computation.
The width of a module, in points.
Module is the smallest unit of a PDF417 symbol. The width of a module (width of the narrowest bar) is commonly referred as X dimension of the
symbol, for more details on this please read the Remarks section below.
The height of each row, in points.
For better decodability, height should be no less than 2, for more details on this please read the Remarks section below.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of cyan color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of black color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the PDF417 barcode is usually printed at an X to Y ratio of 1:2 to 1:5, with 1:3 being the most popular. By lowering the ratio, a
significant amount of space can be saved; however, some scanners cannot read X to Y ratios of less than 1:3.
Likewise, just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various PDF417 barcodes on the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodePDF417"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 4, 2, 2, 0, 0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 4, 6, 2, 10, 0, 0, 0, 255) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("DrawBarcodePDF417.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodePDF417";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 4, 2, 2, 0, 0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 4, 6, 2, 10, 0, 0, 0, 255) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodePDF417.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required PDF417 barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the barcode symbol's fill color you have specified.The coordinates and the dimensions of the PDF417 barcode symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a PDF417 barcode (a stacked linear barcode symbol format) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodePDF417EncodingMode enumeration. The barcode encoding mode.
You can use the BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined to let the engine analyze the input and to select the most appropriate encoding mode.
A member of the BarcodePDF417ErrorCorrectionLevel enumeration. The error correction level.
You can use the BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto to let the engine automatically determine the required level.
Specifies the number of rows constituting the barcode symbol.
A PDF417 symbol must have at least 3 rows and no more than 90. It is recommended to use 0 for automatic computation.
Specifies the number of columns constituting the barcode symbol.
A column refers to the set of codewords vertically. A PDF41 symbol may have 1 to 30 columns. It is recommended to use 0 for automatic computation.
The width of a module, in points.
Module is the smallest unit of a PDF417 symbol. The width of a module (width of the narrowest bar) is commonly referred as X dimension of the
symbol, for more details on this please read the Remarks section below.
The height of each row, in points.
For better decodability, height should be no less than 2, for more details on this please read the Remarks section below.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
A color object that defines the color to be used for drawing a required barcode symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the PDF417 barcode is usually printed at an X to Y ratio of 1:2 to 1:5, with 1:3 being the most popular. By lowering the ratio, a
significant amount of space can be saved; however, some scanners cannot read X to Y ratios of less than 1:3.
Likewise, just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various PDF417 barcodes on the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodePDF417"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 4, 2, 2, Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 4, 6, 2, 10, Color.Red) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("DrawBarcodePDF417.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodePDF417";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 4, 2, 2, Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 4, 6, 2, 10, Color.Red) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodePDF417.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required PDF417 barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for defining the desired colors (both fill and background) of the barcode symbol.The coordinates and the dimensions of the PDF417 barcode symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a PDF417 barcode (a stacked linear barcode symbol format) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodePDF417EncodingMode enumeration. The barcode encoding mode.
You can use the BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined to let the engine analyze the input and to select the most appropriate encoding mode.
A member of the BarcodePDF417ErrorCorrectionLevel enumeration. The error correction level.
You can use the BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto to let the engine automatically determine the required level.
Specifies the number of rows constituting the barcode symbol.
A PDF417 symbol must have at least 3 rows and no more than 90. It is recommended to use 0 for automatic computation.
Specifies the number of columns constituting the barcode symbol.
A column refers to the set of codewords vertically. A PDF41 symbol may have 1 to 30 columns. It is recommended to use 0 for automatic computation.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode, specifically for the PDF417 barcode it is a mandated
minimum amount of white space before the barcode begins and ends.
The width of a module, in points.
Module is the smallest unit of a PDF417 symbol. The width of a module (width of the narrowest bar) is commonly referred as X dimension of the
symbol, for more details on this please read the Remarks section below.
The height of each row, in points.
For better decodability, height should be no less than 2, for more details on this please read the Remarks section below.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of red color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of red color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the PDF417 barcode is usually printed at an X to Y ratio of 1:2 to 1:5, with 1:3 being the most popular. By lowering the ratio, a
significant amount of space can be saved; however, some scanners cannot read X to Y ratios of less than 1:3.
Likewise, just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various PDF417 barcodes on the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodePDF417"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 2, 4, 2, 2, 210, 105, 30, 255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 2, 4, 6, 2, 10, 210, 105, 30, 255, 255, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodePDF417.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodePDF417";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 2, 4, 2, 2, 210, 105, 30, 255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 2, 4, 6, 2, 10, 210, 105, 30, 255, 255, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodePDF417.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required PDF417 barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for defining the desired colors (both fill and background) of the barcode symbol.The coordinates and the dimensions of the PDF417 barcode symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a PDF417 barcode (a stacked linear barcode symbol format) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodePDF417EncodingMode enumeration. The barcode encoding mode.
You can use the BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined to let the engine analyze the input and to select the most appropriate encoding mode.
A member of the BarcodePDF417ErrorCorrectionLevel enumeration. The error correction level.
You can use the BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto to let the engine automatically determine the required level.
Specifies the number of rows constituting the barcode symbol.
A PDF417 symbol must have at least 3 rows and no more than 90. It is recommended to use 0 for automatic computation.
Specifies the number of columns constituting the barcode symbol.
A column refers to the set of codewords vertically. A PDF41 symbol may have 1 to 30 columns. It is recommended to use 0 for automatic computation.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode, specifically for the PDF417 barcode it is a mandated
minimum amount of white space before the barcode begins and ends.
The width of a module, in points.
Module is the smallest unit of a PDF417 symbol. The width of a module (width of the narrowest bar) is commonly referred as X dimension of the
symbol, for more details on this please read the Remarks section below.
The height of each row, in points.
For better decodability, height should be no less than 2, for more details on this please read the Remarks section below.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The amount of cyan color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of magenta color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of yellow color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of black color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of cyan color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of magenta color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of yellow color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of black color to be used for the symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the PDF417 barcode is usually printed at an X to Y ratio of 1:2 to 1:5, with 1:3 being the most popular. By lowering the ratio, a
significant amount of space can be saved; however, some scanners cannot read X to Y ratios of less than 1:3.
Likewise, just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various PDF417 barcodes on the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodePDF417"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 2, 4, 2, 2, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 2, 4, 6, 2, 10, 0, 255, 0, 0, 255, 0, 0, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodePDF417.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodePDF417";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 2, 4, 2, 2, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 2, 4, 6, 2, 10, 0, 255, 0, 0, 255, 0, 0, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodePDF417.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required PDF417 barcode onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space internally when manipulating with the barcode symbol's fill and background colors you have specified.The coordinates and the dimensions of the PDF417 barcode symbol need to be set in the current units with respect to the currently located origin defined in
the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the currently defined
units and you can use the method to reset the units according to your preference.
Draws a PDF417 barcode (a stacked linear barcode symbol format) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodePDF417EncodingMode enumeration. The barcode encoding mode.
You can use the BarcodePDF417EncodingMode.BarcodePDF417EncodingModeUndefined to let the engine analyze the input and to select the most appropriate encoding mode.
A member of the BarcodePDF417ErrorCorrectionLevel enumeration. The error correction level.
You can use the BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevelAuto to let the engine automatically determine the required level.
Specifies the number of rows constituting the barcode symbol.
A PDF417 symbol must have at least 3 rows and no more than 90. It is recommended to use 0 for automatic computation.
Specifies the number of columns constituting the barcode symbol.
A column refers to the set of codewords vertically. A PDF41 symbol may have 1 to 30 columns. It is recommended to use 0 for automatic computation.
The number of modules composing the quiet zone. The quiet zone defines the margin around the barcode, specifically for the PDF417 barcode it is a mandated
minimum amount of white space before the barcode begins and ends.
The width of a module, in points.
Module is the smallest unit of a PDF417 symbol. The width of a module (width of the narrowest bar) is commonly referred as X dimension of the
symbol, for more details on this please read the Remarks section below.
The height of each row, in points.
For better decodability, height should be no less than 2, for more details on this please read the Remarks section below.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related
to the currently selected page.
A color object that defines the color to be used for drawing a required barcode symbol.
A color object that defines the color to be used for drawing a background behind the barcode symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the PDF417 barcode is usually printed at an X to Y ratio of 1:2 to 1:5, with 1:3 being the most popular. By lowering the ratio, a
significant amount of space can be saved; however, some scanners cannot read X to Y ratios of less than 1:3.
Likewise, just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to draw various PDF417 barcodes on the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodePDF417"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 2, 4, 2, 2, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 2, 4, 6, 2, 10, Color.Chocolate, Color.Yellow) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodePDF417.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodePDF417";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodePDF417("0123456789", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
16, 5, 2, 2, 4, 2, 2, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodePDF417("9876543210", BarcodePDF417EncodingMode.BarcodePDF417EncodingModeText, BarcodePDF417ErrorCorrectionLevel.BarcodePDF417ErrorCorrectionLevel2,
32, 5, 2, 4, 6, 2, 10, Color.Chocolate, Color.Yellow) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodePDF417.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodePDF417() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Aztec Code (a type of 2D barcode) onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for defining the desired fill color of the barcode symbol.
The coordinates and the dimensions of the Aztec Code symbol need to be set in the current units with respect to the currently located origin
defined in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the
currently defined units and you can use the method to reset the units according to your preference.
The data to encode using the required barcode symbol.
A member of the BarcodeAztecCodeVersion enumeration. The version of the Aztec Code.
You can use the BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto to let the engine decide the minimum version required to encode all specified data.
The percentage of error correction level. These levels are defined in terms of percentage of codewords in the barcode symbol that can be corrected if damaged.
You can use the values between 5 and 95, otherwise the default value 23 is used.
The number of modules composing the quiet zone, although this barcode symbol does not require any mandatory quiet zone.
The size of each module within the drawn symbol, in points.The module is the smallest cell in the symbol.
The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The amount of red color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various Aztec codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeAztec"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, 255, 0, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeAztec";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, 255, 0, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Aztec Code (a type of 2D barcode) onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for defining the desired fill color of the barcode symbol.
The coordinates and the dimensions of the Aztec Code symbol need to be set in the current units with respect to the currently located origin
defined in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the
currently defined units and you can use the method to reset the units according to your preference.
The data to encode using the required barcode symbol.
A member of the BarcodeAztecCodeVersion enumeration. The version of the Aztec Code.
You can use the BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto to let the engine decide the minimum version required to encode all specified data.
The percentage of error correction level. These levels are defined in terms of percentage of codewords in the barcode symbol that can be corrected if damaged.
You can use the values between 5 and 95, otherwise the default value 23 is used.
The number of modules composing the quiet zone, although this barcode symbol does not require any mandatory quiet zone.
The size of each module within the drawn symbol, in points.The module is the smallest cell in the symbol.
The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The amount of cyan color to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the symbol's resulting color. Use the value between 0 and 255.
The amount of black (key) color to be used for the symbol's resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various Aztec codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeAztec"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, 0, 255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, 0, 255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, 0, 255, 255, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeAztec";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, 0, 255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, 0, 255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, 0, 255, 255, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Aztec Code (a type of 2D barcode) onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for defining the desired fill color of the barcode symbol.The coordinates and the dimensions of the Aztec Code symbol need to be set in the current units with respect to the currently located origin
defined in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the
currently defined units and you can use the method to reset the units according to your preference.
Draws a Aztec Code (a type of 2D barcode) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodeAztecCodeVersion enumeration. The version of the Aztec Code.
You can use the BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto to let the engine decide the minimum version required to encode all specified data.
The percentage of error correction level. These levels are defined in terms of percentage of codewords in the barcode symbol that can be corrected if damaged.
You can use the values between 5 and 95, otherwise the default value 23 is used.
The number of modules composing the quiet zone, although this barcode symbol does not require any mandatory quiet zone.
The size of each module within the drawn symbol, in points.The module is the smallest cell in the symbol.
The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
A color object that defines the color to be used for drawing a required barcode symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various Aztec codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeAztec"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, Color.Red) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeAztec";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, Color.Red) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Aztec Code (a type of 2D barcode) onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for defining the desired fill color of the barcode symbol.
The coordinates and the dimensions of the Aztec Code symbol need to be set in the current units with respect to the currently located origin
defined in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the
currently defined units and you can use the method to reset the units according to your preference.
The data to encode using the required barcode symbol.
A member of the BarcodeAztecCodeVersion enumeration. The version of the Aztec Code.
You can use the BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto to let the engine decide the minimum version required to encode all specified data.
The percentage of error correction level. These levels are defined in terms of percentage of codewords in the barcode symbol that can be corrected if damaged.
You can use the values between 5 and 95, otherwise the default value 23 is used.
The number of modules composing the quiet zone, although this barcode symbol does not require any mandatory quiet zone.
The size of each module within the drawn symbol, in points.The module is the smallest cell in the symbol.
The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The amount of red color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of red color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of green color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of blue color to be used for the symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various Aztec codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeAztec"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, 255, 0, 0, 0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, 255, 0, 0, 0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, 255, 0, 0, 0, 0, 255) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeAztec";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, 255, 0, 0, 0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, 255, 0, 0, 0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, 255, 0, 0, 0, 0, 255) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Aztec Code (a type of 2D barcode) onto the currently selected page of the loaded PDF document according to your preference.
This method uses the CMYK color space for defining the desired fill color of the barcode symbol.
The coordinates and the dimensions of the Aztec Code symbol need to be set in the current units with respect to the currently located origin
defined in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the
currently defined units and you can use the method to reset the units according to your preference.
The data to encode using the required barcode symbol.
A member of the BarcodeAztecCodeVersion enumeration. The version of the Aztec Code.
You can use the BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto to let the engine decide the minimum version required to encode all specified data.
The percentage of error correction level. These levels are defined in terms of percentage of codewords in the barcode symbol that can be corrected if damaged.
You can use the values between 5 and 95, otherwise the default value 23 is used.
The number of modules composing the quiet zone, although this barcode symbol does not require any mandatory quiet zone.
The size of each module within the drawn symbol, in points.The module is the smallest cell in the symbol.
The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The amount of cyan color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of magenta color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of yellow color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of black color to be used for the symbol's resulting fill color. Use the value between 0 and 255.
The amount of cyan color to be used for the symbol's resulting background color. Use the value between 0 and 255.
The amount of magenta color to be used for symbol's resulting background color. Use the value between 0 and 255.
The amount of yellow color to be used for symbol's resulting background color. Use the value between 0 and 255.
The amount of black color to be used for symbol's resulting background color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various Aztec codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeAztec"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, 0, 255, 255, 0, 255, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, 0, 255, 255, 0, 255, 255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, 0, 255, 255, 0, 255, 255, 0, 0) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeAztec";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, 0, 255, 255, 0, 255, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, 0, 255, 255, 0, 255, 255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, 0, 255, 255, 0, 255, 255, 0, 0) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws a required Aztec Code (a type of 2D barcode) onto the currently selected page of the loaded PDF document according to your preference.
This method uses the RGB color space for defining the desired fill color of the barcode symbol.
The coordinates and the dimensions of the Aztec Code symbol need to be set in the current units with respect to the currently located origin
defined in the PDF document, related to the actual page, where the symbol is to be drawn. You can use the method to determine the
currently defined units and you can use the method to reset the units according to your preference.
Draws a Aztec Code (a type of 2D barcode) onto the currently selected page of the loaded PDF document.
The data to encode using the required barcode symbol.
A member of the BarcodeAztecCodeVersion enumeration. The version of the Aztec Code.
You can use the BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto to let the engine decide the minimum version required to encode all specified data.
The percentage of error correction level. These levels are defined in terms of percentage of codewords in the barcode symbol that can be corrected if damaged.
You can use the values between 5 and 95, otherwise the default value 23 is used.
The number of modules composing the quiet zone, although this barcode symbol does not require any mandatory quiet zone.
The size of each module within the drawn symbol, in points.The module is the smallest cell in the symbol.
The module size has to be made out of at least 2×2 printed dots for bigger reliability, therefore the recommended value for this parameter is 4 and greater.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin,
related to the currently selected page.
A color object that defines the color to be used for drawing a required barcode symbol.
A color object that defines the color to be used for drawing a background behind the barcode symbol.
This method is only allowed for use with non-encrypted documents.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
This method requires the Barcode Reading & Writing component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw various Aztec codes onto the newly created page of the new PDF document.
Dim caption As String = "Example: DrawBarcodeAztec"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter)
If status = GdPictureStatus.OK Then
If (gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, Color.Red, Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, Color.Red, Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, Color.Red, Color.Blue) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawBarcodeAztec";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter);
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionAuto, 23, 0, 4, 2, 2, Color.Red, Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersion1, 23, 0, 6, 6, 2, Color.Red, Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawBarcodeAztec("0123456789", BarcodeAztecCodeVersion.BarcodeAztecCodeVersionCompact1, 23, 0, 8, 12, 2, Color.Red, Color.Blue) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawBarcodeAztec.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The one of the DrawBarcodeAztec() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the current text size (the font size, actually) to be used when drawing text onto the currently loaded PDF document. The initial value is set to 12.
The text size parameter is one of the text state parameters, that only affect text.
The text state parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Text State Parameters and Operators").
A new text (font) size, in points. Initial value is 12.
This value is defined for use with any font you choose.
This method is only allowed for use with non-encrypted documents.
As being noticed above, be aware that the text state parameters are initialized to their default values at the beginning of each page.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the required text size in the PDF document in order to be able to draw text with this size.
Dim caption As String = "Example: SetTextSize"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.DrawText(fontName, 150, 700, "GdPicture.NET default text size") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(25) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100, 600, "GdPicture.NET text size = 25") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(40) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 30, 500, "GdPicture.NET text size = 40") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) Then 'Reset to the initial value.
status = gdpicturePDF.SaveToFile("test_SetTextSize.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption)
Else
MessageBox.Show("The text has been successfully drawn," + vbCrLf + "but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetTextSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawText(fontName, 150, 700, "GdPicture.NET default text size") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(25) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100, 600, "GdPicture.NET text size = 25") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(40) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 30, 500, "GdPicture.NET text size = 40") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK)) //Resetting to the initial value.
{
status = gdpicturePDF.SaveToFile("test_SetTextSize.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption);
else
MessageBox.Show("The text has been successfully drawn,\nbut the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the text rendering mode to be used when drawing text onto the currently loaded PDF document. The text rendering mode specifies whether drawing text
causes glyph outlines to be stroked, filled, used as a clipping boundary, or some combination of the three. The initial value is set to fill mode.
The text rendering mode parameter is one of the text state parameters, that only affect text.
The text state parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Text State Parameters and Operators").
A member of the PdfTextMode enumeration. A new text rendering mode to set. Initial value is PdfTextMode.PdfTextModeFill.
This value is defined for use with any font you choose.
This method is only allowed for use with non-encrypted documents.
As being noticed above, be aware that the text state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the required text mode in the PDF document in order to be able to draw text using this mode.
Dim caption As String = "Example: SetTextMode"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100, 800, "Text mode = Fill (default)") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextMode(PdfTextMode.PdfTextModeStroke) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100, 750, "Text mode = Stroke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextMode(PdfTextMode.PdfTextModeFillStroke) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100, 700, "Text mode = Fill & Stroke") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextMode(PdfTextMode.PdfTextModeFill) Then 'Resetting to the initial value.
status = gdpicturePDF.SaveToFile("test_SetTextMode.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption)
Else
MessageBox.Show("The text has been successfully drawn," + vbCrLf + "but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetTextMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100, 800, "Text mode = Fill (default)") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextMode(PdfTextMode.PdfTextModeStroke) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100, 750, "Text mode = Stroke") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextMode(PdfTextMode.PdfTextModeFillStroke) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100, 700, "Text mode = Fill & Stroke") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextMode(PdfTextMode.PdfTextModeFill) == GdPictureStatus.OK)) //Resetting to the initial value.
{
status = gdpicturePDF.SaveToFile("test_SetTextMode.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption);
else
MessageBox.Show("The text has been successfully drawn,\nbut the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the word spacing to be used when drawing text on the currently loaded PDF document. This value defines a distance between adjacent words in a line of
text. It is a number expressed in unscaled text space units (points). The initial value is set to 0.
The word spacing parameter is one of the text state parameters, that only affect text.
The text state parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Text State Parameters and Operators").
A new word spacing to set. Initial value is 0.
This value is defined for use with any font you choose.
This method is only allowed for use with non-encrypted documents.
Word spacing is applied to every occurrence of the single-byte character code 32 (space character) in a string.
As being noticed above, be aware that the text state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the word spacing in the PDF document in order to be able to draw text using this parameter.
Dim caption As String = "Example: SetTextWordSpacing"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 50, 700, "Lorem ipsum dolor sit amet ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextWordSpacing(10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 50, 600, "Lorem ipsum dolor sit amet ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextWordSpacing(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 50, 500, "Lorem ipsum dolor sit amet ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextWordSpacing(0) = GdPictureStatus.OK) Then 'Resetting to the initial value.
status = gdpicturePDF.SaveToFile("test_SetTextWordSpacing.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption)
Else
MessageBox.Show("The text has been successfully drawn," + vbCrLf + "but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetTextWordSpacing";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 50, 700, "Lorem ipsum dolor sit amet ...") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextWordSpacing(10) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 50, 600, "Lorem ipsum dolor sit amet ...") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextWordSpacing(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 50, 500, "Lorem ipsum dolor sit amet ...") == GdPictureStatus.OK)&&
(gdpicturePDF.SetTextWordSpacing(0) == GdPictureStatus.OK)) //Resetting to the initial value.
{
status = gdpicturePDF.SaveToFile("test_SetTextWordSpacing.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption);
else
MessageBox.Show("The text has been successfully drawn,\nbut the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the character spacing to be used when drawing text onto the currently loaded PDF document. This value defines a distance between adjacent characters in
a line of text. It is a number expressed in unscaled text space units (points). The initial value is set to 0.
The character spacing parameter is one of the text state parameters, that only affect text.
The text state parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Text State Parameters and Operators").
A new char spacing to set. Initial value is 0.
This value is defined for use with any font you choose.
This method is only allowed for use with non-encrypted documents.
As being noticed above, be aware that the text state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the character spacing in the PDF document in order to be able to draw text using this parameter.
Dim caption As String = "Example: SetTextCharSpacing"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 50, 700, "Lorem ipsum dolor sit amet ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextCharSpacing(5) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 50, 600, "Lorem ipsum dolor sit amet ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextCharSpacing(10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 50, 500, "Lorem ipsum dolor sit amet ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextCharSpacing(0) = GdPictureStatus.OK) Then 'Resetting to the initial value.
status = gdpicturePDF.SaveToFile("test_SetTextCharSpacing.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption)
Else
MessageBox.Show("The text has been successfully drawn," + vbCrLf + "but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetTextCharSpacing";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 50, 700, "Lorem ipsum dolor sit amet ...") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextCharSpacing(5) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 50, 600, "Lorem ipsum dolor sit amet ...") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextCharSpacing(10) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 50, 500, "Lorem ipsum dolor sit amet ...") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextCharSpacing(0) == GdPictureStatus.OK)) //Resetting to the initial value.
{
status = gdpicturePDF.SaveToFile("test_SetTextCharSpacing.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption);
else
MessageBox.Show("The text has been successfully drawn,\nbut the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the horizontal scaling to be used when drawing text onto the currently loaded PDF document. This value adjusts the width of glyphs by stretching or
compressing them in the horizontal direction. It is specified as a percentage of the normal width of the glyphs. The initial value is set to 100 (the normal width).
The horizontal scaling parameter is one of the text state parameters, that only affect text.
The text state parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Text State Parameters and Operators").
A new value for the horizontal scaling, as a percentage of the normal width. Initial value is 100.
This value is defined for use with any font you choose.
This method is only allowed for use with non-encrypted documents.
As being noticed above, be aware that the text state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to reset the horizontal scaling in the PDF document in order to be able to draw text using this parameter.
Dim caption As String = "Example: SetTextScaling"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100, 700, "Hello world!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextScaling(50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100, 600, "Hello world!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextScaling(150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100, 500, "Hello world!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextScaling(100) = GdPictureStatus.OK) Then 'Resetting to the initial value.
status = gdpicturePDF.SaveToFile("test_SetTextScaling.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption)
Else
MessageBox.Show("The text has been successfully drawn," + vbCrLf + "but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetTextScaling";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100, 700, "Hello world!") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextScaling(50) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100, 600, "Hello world!") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextScaling(150) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100, 500, "Hello world!") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextScaling(100) == GdPictureStatus.OK)) //Resetting to the initial value.
{
status = gdpicturePDF.SaveToFile("test_SetTextScaling.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption);
else
MessageBox.Show("The text has been successfully drawn,\nbut the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Set the text rise to be used when drawing text onto the currently loaded PDF document. The text rise parameter specifies the distance, in unscaled text
space units (points), to move the baseline up (positive values) or down (negative values) from its default location. Adjustments to the baseline are useful for
drawing superscripts or subscripts. The initial value (the default location of the baseline) is set to 0.
The text rise parameter is one of the text state parameters, that only affect text.
The text state parameters are initialized to their default values at the beginning of each page (see PDF Reference, Section "Text State Parameters and Operators").
The new value for the text rise. Initial value is 0.
This value is defined for use with any font you choose.
This method is only allowed for use with non-encrypted documents.
The text rise always applies to the vertical coordinate in text space, regardless of the writing mode.
As being noticed above, be aware that the text state parameters are initialized to their default values at the beginning of each page.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to use the text rise parameter to draw superscripted and subscripted text within the PDF document.
Dim caption As String = "Example: SetTextRise"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim width As Single = gdpicturePDF.GetTextWidth(fontName, 20, "GdPicture.NET")
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100, 500, "GdPicture.NET") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(15) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextRise(20 * 2 / 3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100 + width, 500, "superscripted") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextRise(-20 * 1 / 3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 100 + width, 500, "subscripted") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextRise(0) = GdPictureStatus.OK) Then 'Resetting to the initial value.
status = gdpicturePDF.SaveToFile("test_SetTextRise.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption)
Else
MessageBox.Show("The text has been successfully drawn," + vbCrLf + "but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetTextRise";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float width = gdpicturePDF.GetTextWidth(fontName, 20, "GdPicture.NET");
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100, 500, "GdPicture.NET") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(15) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextRise(20 * 2/3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100 + width, 500, "superscripted") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextRise(-20 * 1/3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 100 + width, 500, "subscripted") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextRise(0) == GdPictureStatus.OK)) //Resetting to the initial value.
{
status = gdpicturePDF.SaveToFile("test_SetTextRise.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption);
else
MessageBox.Show("The text has been successfully drawn,\nbut the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws required text using the specified font on the currently selected page of the loaded PDF document. You also need to set the destination
point, expressed in the current units defined in the PDF document, related to the actual page, where the text is to be drawn.
You can simply use the method to determine the currently defined units and you can easily use
the method to reset the units according to your preference.
The resource name of the font you prefer for drawing your text.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods.
For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
The horizontal (X) coordinate of the destination point, where the text is to be drawn,
in the current units used in the PDF document with respect to the currently defined origin, related to the currently selected page.
The vertical (Y) coordinate of the destination point, where the text is to be drawn,
in the current units used in the PDF document with respect to the currently defined origin, related to the currently selected page.
The required text to draw.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw text with the specified attributes in the middle of a page of the loaded PDF document.
Dim caption As String = "Example: DrawText"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim text As String = "GdPicture.NET"
Dim textSize As Integer = 30
Dim textWidth As Single = gdpicturePDF.GetTextWidth(fontName, textSize, text)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SelectPage(1)
Dim pageWidth As Single = gdpicturePDF.GetPageWidth() 'Be careful: this function returns value in PDF points.
Dim pageHeight As Single = gdpicturePDF.GetPageHeight() 'Be careful: this function returns value in PDF points.
If (gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, pageWidth / 2 - textWidth / 2, pageHeight / 2, text) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawText.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption)
Else
MessageBox.Show("The text has been successfully drawn," + vbCrLf + "but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextWidth() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The LoadFromFile() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string text = "GdPicture.NET";
int textSize = 30;
float textWidth = gdpicturePDF.GetTextWidth(fontName, textSize, text);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SelectPage(1);
float pageWidth = gdpicturePDF.GetPageWidth(); //Be careful: this function returns value in PDF points.
float pageHeight = gdpicturePDF.GetPageHeight(); //Be careful: this function returns value in PDF points.
if ((gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, pageWidth / 2 - textWidth / 2, pageHeight / 2, text) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawText.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption);
else
MessageBox.Show("The text has been successfully drawn,\nbut the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextWidth() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The LoadFromFile() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Draws aligned text, supporting multiline text as well, using the specified font to fit the defined text box located on the currently selected page of
the loaded PDF document. You need to set the text box coordinates in the current units with respect to the currently located origin defined in the PDF
document, at the same all coordinates are related to the actual page, where the text is to be drawn. You are also allowed to specify both horizontal and
vertical text alignment within the text box. If the part of your text is not drawn, it may be because the text box is too small to hold entire text.
You can use the method to determine the currently defined units together with the method to determine the current origin
location and you can also use the method to reset the units together with the method to reset the origin location according to
your preference.
Draws aligned text, supporting multiline text as well, using the specified font to fit the defined text box located on the currently selected page of the
loaded PDF document according to other parameters you have specified.
The resource name of the font you prefer for drawing your text.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods. For further assistance, please see the
section Fonts of the GdPicturePDF class in the Reference Guide.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The horizontal (X) coordinate of the furthest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The vertical (Y) coordinate of the furthest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The required horizontal text alignment mode, that is used to draw text within the specified text box.
The required vertical text alignment mode, that is used to draw text within the specified text box.
The required text to draw. It can be multiline text as well.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw multiline text to fit the specified text box.
Dim caption As String = "Example: DrawTextBox"
Dim message As String = ""
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierOblique)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim multiText As String = "A friend is a need, a friend is indeed." + vbCrLf +
"Whether there is a thunderstorm or strong wind blowing," + vbCrLf +
"Friendship is like a tree that keeps glowing." + vbCrLf +
"A friend is ray of hope in darkness," + vbCrLf + "as no less than treasure of happiness."
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.DarkOrchid) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0.05F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(2, 2, 17, 6, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontName, 2, 2, 19, 8, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, multiText) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawTextBox.pdf")
If status = GdPictureStatus.OK Then
message = "The example has been followed successfully and the file has been saved."
Else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString()
End If
Else
message = "The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The AddStandardFont() method has failed with the status: " + status.ToString()
End If
Else
message = "The NewPDF() method has failed with the status: " + status.ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: DrawTextBox";
string message = "";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierOblique);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string multiText = "A friend is a need, a friend is indeed.\nWhether there is a thunderstorm or strong wind blowing,\nFriendship is like a tree that keeps glowing." +
"\nA friend is ray of hope in darkness,\nas no less than treasure of happiness.";
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.DarkOrchid) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0.05f) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(2, 2, 17, 6, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontName, 2, 2, 19, 8, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, multiText) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawTextBox.pdf");
if (status == GdPictureStatus.OK)
message = "The example has been followed successfully and the file has been saved.";
else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString();
}
else
message = "The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString();
}
else
message = "The AddStandardFont() method has failed with the status: " + status.ToString();
}
else
message = "The NewPDF() method has failed with the status: " + status.ToString();
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Draws an aligned text, supporting multiline text as well, using the specified font to fit the defined text box located on the currently selected page of the
loaded PDF document. You need to set the text box coordinates in the current units with respect to the currently located origin defined in the PDF document, at
the same all coordinates are related to the actual page, where the text is to be drawn. You are also allowed to specify both horizontal and vertical text
alignment within the text box, as well as use of the font boundary box attribute when drawing. If the part of your text is not drawn, it may be because the
text box is too small to hold entire text.
You can use the method to determine the currently defined units together with the method to determine the current origin
location and you can also use the method to reset the units together with the method to reset the origin location according to
your preference.
Draws aligned text, supporting multiline text as well, using the specified font to fit the defined text box located on the currently selected page of the
loaded PDF document according to other parameters you have specified.
The resource name of the font you prefer for drawing your text.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods. For further assistance, please see
the Fonts section of the GdPicturePDF class in the Reference Guide.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The horizontal (X) coordinate of the furthest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The vertical (Y) coordinate of the furthest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The required horizontal text alignment mode, that is used to draw text within the specified text box.
The required vertical text alignment mode, that is used to draw text within the specified text box.
The required text to draw. It can be multiline text as well.
Set this parameter to false (generally used as the default value) if you want to calculate the text height by using the font's ascent and descent
properties. The ascent property is the distance from the baseline to the highest grid coordinate used to place an outline point, the descent property to the lowest grid coordinate.
Set this parameter to true if you want to calculate the text height by using the font boundary box. It is an imaginary box that encloses all glyphs
from the font, usually as tightly as possible. This helps to increase the line spacing in drawn text.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw multiline text to fit the specified text box. The example shows you differences in drawing when using the font boundary box attribute.
Dim caption As String = "Example: DrawTextBox"
Dim message As String = ""
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierOblique)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim multiText As String = "A friend is a need, a friend is indeed." + vbCrLf +
"Whether there is a thunderstorm or strong wind blowing," + vbCrLf +
"Friendship is like a tree that keeps glowing." + vbCrLf +
"A friend is ray of hope in darkness," + vbCrLf + "as no less than treasure of happiness."
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.DarkOrchid) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0.05F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(2, 2, 17, 6, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontName, 2, 2, 19, 8, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, multiText, False) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(2, 10, 17, 6, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontName, 2, 10, 19, 16, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, multiText, True) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawTextBox.pdf")
If status = GdPictureStatus.OK Then
message = "The example has been followed successfully and the file has been saved."
Else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString()
End If
Else
message = "The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The AddStandardFont() method has failed with the status: " + status.ToString()
End If
Else
message = "The NewPDF() method has failed with the status: " + status.ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: DrawTextBox";
string message = "";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontCourierOblique);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string multiText = "A friend is a need, a friend is indeed.\nWhether there is a thunderstorm or strong wind blowing,\nFriendship is like a tree that keeps glowing." +
"\nA friend is ray of hope in darkness,\nas no less than treasure of happiness.";
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.DarkOrchid) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0.05f) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(2, 2, 17, 6, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontName, 2, 2, 19, 8, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, multiText, false) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(2, 10, 17, 6, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontName, 2, 10, 19, 16, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, multiText, true) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawTextBox.pdf");
if (status == GdPictureStatus.OK)
message = "The example has been followed successfully and the file has been saved.";
else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString();
}
else
message = "The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString();
}
else
message = "The AddStandardFont() method has failed with the status: " + status.ToString();
}
else
message = "The NewPDF() method has failed with the status: " + status.ToString();
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Draws, in other words, wraps, required text using the specified font to fit the defined rectangle located on the currently selected page of the loaded PDF
document. You need to set the rectangle coordinates in the current units with respect to the currently located origin defined in the PDF document, at the same
all coordinates are related to the actual page, where the text is to be drawn. You are also allowed to specify the text alignment within the defined rectangle
and the calculation of the height of the text line. The aim of this method is to respect the rectangle boundaries when drawing text, not to draw entire text.
You can use the method to determine the currently defined units together with the method to determine the current origin
location and you can also use the method to reset the units together with the method to reset the origin location according to
your preference.
The resource name of the font you prefer for drawing your text.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods. For further assistance, please see the
section Fonts of the GdPicturePDF class in the Reference Guide.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The horizontal (X) coordinate of the furthest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The vertical (Y) coordinate of the furthest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The required horizontal text alignment mode, that is used to draw text within the specified rectangle.
The required text to draw.
Set this parameter to true if you want to calculate the line height by using the font boundary box. It is an imaginary box that encloses all glyphs
from the font, usually as tightly as possible.
Set this parameter to false if you want to calculate the line height by using the font's ascent and descent properties. The ascent property is the
distance from the baseline to the highest grid coordinate used to place an outline point, the descent property to the lowest grid coordinate.
It is both the input and the output parameter.
As the input parameter it sets the position of the first character from the specified text you want to start with when drawing.
As the output parameter it returns the position of the character that has not been drawn because of the rectangle's boundaries or -1 if the whole text has
been wrapped successfully to fit the specified rectangle.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw required text to be centered within the specified rectangle. The example also shows you what the StartPos parameter actually indicates.
Dim caption As String = "Example: DrawWrappedText"
Dim message As String = "The example has not been followed successfully." + vbCrLf + "The last known status is "
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim startPosDraw As Integer = 0, startPosH As Integer = 0
Dim text As String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0.01F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(2, 2, 6, 6, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawWrappedText(fontName, 2, 2, 8, 8, TextAlignment.TextAlignmentCenter, text, False, startPosDraw) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 3, 9, "StartPos = " + startPosDraw.ToString()) = GdPictureStatus.OK) Then
Dim height As Single = gdpicturePDF.GetWrappedTextHeight(fontName, 2, 2, 8, 8, TextAlignment.TextAlignmentCenter, text, False, startPosH)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 3, 11, "Height = " + height.ToString()) = GdPictureStatus.OK) Then
startPosDraw = 0
If (gdpicturePDF.DrawRectangle(10, 2, 6, 6, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawWrappedText(fontName, 10, 2, 16, 8, TextAlignment.TextAlignmentCenter, text, True, startPosDraw) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 11, 9, "StartPos = " + startPosDraw.ToString()) = GdPictureStatus.OK) Then
height = gdpicturePDF.GetWrappedTextHeight(fontName, 2, 2, 8, 8, TextAlignment.TextAlignmentCenter, text, True, startPosH)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontName, 11, 11, "Height = " + height.ToString()) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawWrappedText.pdf")
If status = GdPictureStatus.OK Then
message = "The example has been followed successfully and the file has been saved."
Else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The AddStandardFont() method has failed with the status: " + status.ToString()
End If
Else
message = "The NewPDF() method has failed with the status: " + status.ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: DrawWrappedText";
string message = "The example has not been followed successfully.\nThe last known status is ";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int startPosDraw = 0, startPosH = 0;
string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0.01f) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(2, 2, 6, 6, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawWrappedText(fontName, 2, 2, 8, 8, TextAlignment.TextAlignmentCenter, text, false, ref startPosDraw) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 3, 9, "StartPos = " + startPosDraw.ToString()) == GdPictureStatus.OK))
{
float height = gdpicturePDF.GetWrappedTextHeight(fontName, 2, 2, 8, 8, TextAlignment.TextAlignmentCenter, text, false, ref startPosH);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 3, 11, "Height = " + height.ToString()) == GdPictureStatus.OK))
{
startPosDraw = 0;
if ((gdpicturePDF.DrawRectangle(10, 2, 6, 6, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawWrappedText(fontName, 10, 2, 16, 8, TextAlignment.TextAlignmentCenter, text, true, ref startPosDraw) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 11, 9, "StartPos = " + startPosDraw.ToString()) == GdPictureStatus.OK))
{
height = gdpicturePDF.GetWrappedTextHeight(fontName, 2, 2, 8, 8, TextAlignment.TextAlignmentCenter, text, true, ref startPosH);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontName, 11, 11, "Height = " + height.ToString()) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawWrappedText.pdf");
if (status == GdPictureStatus.OK)
message = "The example has been followed successfully and the file has been saved.";
else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = "The AddStandardFont() method has failed with the status: " + status.ToString();
}
else
message = "The NewPDF() method has failed with the status: " + status.ToString();
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Calculates the total height, expressed in the current units defined in the loaded PDF document, of the given text,
which will fit the defined rectangle when trying to wrap the text inside this rectangle, with respect to other parameters you have specified.
You can subsequently use the method to draw the text inside the required rectangle.
Please find more details in the documentation of the mentioned method.
The resource name of the font you prefer for drawing your text.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods. For further assistance, please see the
section Fonts of the GdPicturePDF class in the Reference Guide.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The horizontal (X) coordinate of the furthest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The vertical (Y) coordinate of the furthest point to the currently defined origin, where the text box is located,
in the current units used in the PDF document, related to the currently selected page.
The required horizontal text alignment mode, that is used to draw text within the specified rectangle.
The required text to draw.
Set this parameter to true if you want to calculate the text height by using the font boundary box. It is an imaginary box that encloses all glyphs from
the font, usually as tightly as possible.
Set this parameter to false if you want to calculate the text height by using the font's ascent and descent properties. The ascent property is the
distance from the baseline to the highest grid coordinate used to place an outline point, the descent property to the lowest grid coordinate.
It is both the input and the output parameter.
As the input parameter it sets the position of the first character from the specified text you want to start with when drawing.
As the output parameter it returns the position of the character that has not been drawn because of the rectangle's boundaries
or -1 if the whole text has been wrapped successfully to fit the specified rectangle.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The total height of the wrapped text within the whole specified rectangle, expressed in the current units specified by the SetMeasurementUnit method.
The method can be subsequently used to determine if this method has been successful.
How to calculate the height of the given text to determine the height of the rectangle which will border the text.
Dim caption As String = "Example: GetWrappedTextHeight"
Dim message As String = "The example has not been followed successfully." + vbCrLf + "The last known status is "
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
Dim text As String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. " +
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. " +
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Dim xp As Integer = 3, yp As Integer = 4 'This is the point where we start drawing.
Dim textsize As Integer = 20 'This is the size of the drawn text.
Dim rectwidth As Integer = 14 'This is the width of the rectangle, in which we want to write the whole text.
If gdpicturePDF.SetTextSize(textsize) = GdPictureStatus.OK Then 'It is important to set the size of the text before all drawing operations.
Dim startPos As Integer = 0
'Computing the total height of the wrapped text.
Dim rectheight As Single = gdpicturePDF.GetWrappedTextHeight(fontName, xp, yp, xp + 4, yp + 8, TextAlignment.TextAlignmentCenter, text, True, startPos)
'You can find out, if the whole text is drawn, by using the startPos parameter above.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
startPos = 0
If (gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0.04F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(xp, yp, rectwidth, rectheight, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawWrappedText(fontName, xp, yp, xp + rectwidth, yp + rectheight, TextAlignment.TextAlignmentCenter, text, False, startPos) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_GetWrappedTextHeight.pdf")
If status = GdPictureStatus.OK Then
message = "The example has been followed successfully and the file has been saved."
Else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The AddStandardFont() method has failed with the status: " + status.ToString()
End If
Else
message = "The NewPDF() method has failed with the status: " + status.ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: GetWrappedTextHeight";
string message = "The example has not been followed successfully.\nThe last known status is ";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. " +
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. " +
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
int xp = 3, yp = 4; //This is the point where we start drawing.
int textsize = 20; //This is the size of the drawn text.
int rectwidth = 14; //This is the width of the rectangle, in which we want to write the whole text.
if (gdpicturePDF.SetTextSize(textsize) == GdPictureStatus.OK) //It is important to set the size of the text before all drawing operations.
{
int startPos = 0;
//Computing the total height of the wrapped text.
float rectheight = gdpicturePDF.GetWrappedTextHeight(fontName, xp, yp, xp+4, yp+8, TextAlignment.TextAlignmentCenter, text, true, ref startPos);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//You can find out, if the whole text is drawn, by using the startPos parameter above.
startPos = 0;
if ((gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0.04f) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(xp, yp, rectwidth, rectheight, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawWrappedText(fontName, xp, yp, xp + rectwidth, yp + rectheight, TextAlignment.TextAlignmentCenter, text, false, ref startPos) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_GetWrappedTextHeight.pdf");
if (status == GdPictureStatus.OK)
message = "The example has been followed successfully and the file has been saved.";
else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = "The AddStandardFont() method has failed with the status: " + status.ToString();
}
else
message = "The NewPDF() method has failed with the status: " + status.ToString();
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Calculates the number of text lines of the given text, which will fit the rectangle with the defined width, when trying to wrap the text inside this rectangle,
with respect to other parameters you have specified. You can subsequently use the method to draw the text inside the required rectangle.
Please find more details in the documentation of the mentioned method.
The resource name of the font you prefer for drawing your text.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods. For further assistance, please see the
section Fonts of the GdPicturePDF class in the Reference Guide.
The required width of the rectangle, expressed in the current units specified by the SetMeasurementUnit method, related to the currently selected page.
The required horizontal text alignment mode, that is used to draw text within the specified rectangle.
The required text to draw.
Set this parameter to true if you want to calculate the line height by using the font boundary box. It is an imaginary box that encloses all glyphs from
the font, usually as tightly as possible.
Set this parameter to false if you want to calculate the line height by using the font's ascent and descent properties. The ascent property is the
distance from the baseline to the highest grid coordinate used to place an outline point, the descent property to the lowest grid coordinate.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of text lines of the wrapped text that fits within the rectangle with the specified width.
The method can be subsequently used to determine if this method has been successful.
How to find out the resulting number of text lines for the given text that will fit into a required rectangle.
Dim caption As String = "Example: GetWrappedTextLineCount"
Dim message As String = "The example has not been followed successfully." + vbCrLf + "The last known status is "
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK Then
Dim text As String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. " +
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. " +
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Dim xp As Integer = 3, yp As Integer = 4 'This is the point where we start drawing.
Dim textsize As Integer = 20 'This is the size of the drawn text.
Dim rectwidth As Integer = 14 'This is the width of the rectangle, in which we want to write the whole text.
Dim textheight As Single = gdpicturePDF.GetTextHeight(fontName, textsize) 'This is the height of the text = the height of one text line.
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textsize) = GdPictureStatus.OK) Then
'It is important to set the size of the text before all drawing operations.
'Computing the number of text lines for the whole text.
Dim textlines As Integer = gdpicturePDF.GetWrappedTextLineCount(fontName, rectwidth, TextAlignment.TextAlignmentCenter, text, False)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim startPos As Integer = 0
Dim rectheight As Integer = CInt(Math.Abs(textheight * textlines)) + 1 'This is the whole height of the rectangle for writing the text.
If (gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(0.04F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(xp, yp, rectwidth, rectheight, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawWrappedText(fontName, xp, yp, xp + rectwidth, yp + rectheight, TextAlignment.TextAlignmentCenter, text, False, startPos) = GdPictureStatus.OK) Then
'You can find out, if the whole text is drawn, by using the startPos parameter.
status = gdpicturePDF.SaveToFile("test_GetWrappedTextLineCount.pdf")
If status = GdPictureStatus.OK Then
message = "The example has been followed successfully and the file has been saved."
Else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The AddStandardFont() method has failed with the status: " + status.ToString()
End If
Else
message = "The NewPDF() method has failed with the status: " + status.ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: GetWrappedTextLineCount";
string message = "The example has not been followed successfully.\nThe last known status is ";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK)
{
string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. " +
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. " +
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. " +
"Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
int xp = 3, yp = 4; //This is the point where we start drawing.
int textsize = 20; //This is the size of the drawn text.
int rectwidth = 14; //This is the width of the rectangle, in which we want to write the whole text.
float textheight = gdpicturePDF.GetTextHeight(fontName, textsize); //This is the height of the text = the height of one text line.
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textsize) == GdPictureStatus.OK))
//It is important to set the size of the text before all drawing operations.
{
//Computing the number of text lines for the whole text.
int textlines = gdpicturePDF.GetWrappedTextLineCount(fontName, rectwidth, TextAlignment.TextAlignmentCenter, text, false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int startPos = 0;
int rectheight = (int)Math.Abs(textheight * textlines) + 1; //This is the whole height of the rectangle for writing the text.
if ((gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(0.04f) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(xp, yp, rectwidth, rectheight, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawWrappedText(fontName, xp, yp, xp + rectwidth, yp + rectheight, TextAlignment.TextAlignmentCenter, text, false, ref startPos) == GdPictureStatus.OK))
{
//You can find out, if the whole text is drawn, by using the startPos parameter.
status = gdpicturePDF.SaveToFile("test_GetWrappedTextLineCount.pdf");
if (status == GdPictureStatus.OK)
message = "The example has been followed successfully and the file has been saved.";
else
message = "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = "The AddStandardFont() method has failed with the status: " + status.ToString();
}
else
message = "The NewPDF() method has failed with the status: " + status.ToString();
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Draws required text, rotated by the defined angle counterclockwise, using the specified font on the currently selected page of the loaded PDF document. You
also need to set the destination point, expressed in the current units defined in the PDF document, related to the actual page, where the text is to be drawn.
You can simply use the method to determine the currently defined units and you can easily use the method to reset
the units according to your preference.
The resource name of the font you prefer for drawing your text.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods. For further assistance, please see the
section Fonts of the GdPicturePDF class in the Reference Guide.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method, related to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method, related to the currently selected page.
The required text to draw.
The rotation angle, in degrees, determining the counterclockwise rotation. This parameter is without any restrictions.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw rotated text with the specified attributes on the newly created page.
Dim caption As String = "Example: DrawRotatedText"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRotatedText(fontName, 10, 10, "GdPicture.NET", 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRotatedText(fontName, 10, 10, "GdPicture.NET", 90) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRotatedText(fontName, 10, 10, "GdPicture.NET", 180) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRotatedText(fontName, 10, 10, "GdPicture.NET", 270) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_DrawRotatedText.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption)
Else
MessageBox.Show("The text has been successfully drawn," + vbCrLf + "but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawRotatedText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRotatedText(fontName, 10, 10, "GdPicture.NET", 0) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRotatedText(fontName, 10, 10, "GdPicture.NET", 90) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRotatedText(fontName, 10, 10, "GdPicture.NET", 180) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRotatedText(fontName, 10, 10, "GdPicture.NET", 270) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_DrawRotatedText.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The text has been successfully drawn and the file has been saved.", caption);
else
MessageBox.Show("The text has been successfully drawn,\nbut the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets text decoration style for all subsequent text drawing operations.
A member of the PDFTextDecorationStyle enumeration.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw underline text on the newly created page.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
gdpicturePDF.NewPDF()
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline)
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single)
gdpicturePDF.SetTextUnderlineColor(255, 0, 0)
gdpicturePDF.SetTextUnderlineWidth(2)
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.NewPDF();
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline);
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single);
gdpicturePDF.SetTextUnderlineColor(255, 0, 0);
gdpicturePDF.SetTextUnderlineWidth(2);
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15);
gdpicturePDF.SaveToFile("output.pdf");
}
Sets text underline style for all subsequent text drawing operations if the PdfTextDecorationStyle.Underline is used.
A member of the PDFTextUnderlineStyle enumeration.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw underline text on the newly created page.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
gdpicturePDF.NewPDF()
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline)
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single)
gdpicturePDF.SetTextUnderlineColor(255, 0, 0)
gdpicturePDF.SetTextUnderlineWidth(2)
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.NewPDF();
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline);
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single);
gdpicturePDF.SetTextUnderlineColor(255, 0, 0);
gdpicturePDF.SetTextUnderlineWidth(2);
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15);
gdpicturePDF.SaveToFile("output.pdf");
}
Sets text underline width for all subsequent text drawing operations.
New value for the text decoration line width.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw underline text on the newly created page.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
gdpicturePDF.NewPDF()
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline)
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single)
gdpicturePDF.SetTextUnderlineColor(255, 0, 0)
gdpicturePDF.SetTextUnderlineWidth(2)
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.NewPDF();
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline);
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single);
gdpicturePDF.SetTextUnderlineColor(255, 0, 0);
gdpicturePDF.SetTextUnderlineWidth(2);
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15);
gdpicturePDF.SaveToFile("output.pdf");
}
Sets text underline color for all subsequent text drawing operations.
The amount of red color to be used for the resulting text decoration color. Use the value between 0 and 255.
The amount of green color to be used for the resulting text decoration color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting text decoration color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw underline text on the newly created page.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
gdpicturePDF.NewPDF()
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline)
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single)
gdpicturePDF.SetTextUnderlineColor(255, 0, 0)
gdpicturePDF.SetTextUnderlineWidth(2)
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.NewPDF();
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline);
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single);
gdpicturePDF.SetTextUnderlineColor(255, 0, 0);
gdpicturePDF.SetTextUnderlineWidth(2);
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15);
gdpicturePDF.SaveToFile("output.pdf");
}
Sets text underline distance from text for all subsequent text drawing operations.
New value for the text decoration line width.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw underline text on the newly created page.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
gdpicturePDF.NewPDF()
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline)
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single)
gdpicturePDF.SetTextUnderlineColor(255, 0, 0)
gdpicturePDF.SetTextUnderlineWidth(2)
gdpicturePDF.SetTextUnderlineDistance(2)
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.NewPDF();
gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
gdpicturePDF.SetTextDecorationStyle(PdfTextDecorationStyle.Underline);
gdpicturePDF.SetTextUnderlineStyle(PdfTextUnderlineStyle.Single);
gdpicturePDF.SetTextUnderlineColor(255, 0, 0);
gdpicturePDF.SetTextUnderlineWidth(2);
gdpicturePDF.SetTextUnderlineDistance(2);
gdpicturePDF.DrawRotatedText(fontResName, 100, 100, "This is rotated underlined text!", 15);
gdpicturePDF.SaveToFile("output.pdf");
}
Calculates the width of entered text, using the font you have specified, in the currently defined units within the loaded PDF document.
You can use the method to determine the currently defined units and you can also use the method to reset the units
according to your preference.
The resource name of the font you prefer.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods. For further assistance, please see the
section Fonts of the GdPicturePDF class in the Reference Guide.
The required text to measure.
The size of the text (the font size actually), in points.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
For example, if the currently loaded PDF document does not contain any page, this method will fail.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
The width of specified text, expressed in the current units specified by the SetMeasurementUnit method.
The method can be subsequently used to determine if this method has been successful.
How to determine the width of the specified text using the standard Times-Roman font.
Dim caption As String = "Example: GetTextWidth"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim width As Single = gdpicturePDF.GetTextWidth(fontName, 20, "I love GdPicture.NET")
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The width of your text ""I love GdPicture.NET"" using the Times-Roman font with the size 20 is " + width.ToString() + " centimeters.", caption)
Else
MessageBox.Show("The GetTextWidth() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Units can't be set correctly.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetTextWidth";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float width = gdpicturePDF.GetTextWidth(fontName, 20, "I love GdPicture.NET");
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The width of your text \"I love GdPicture.NET\" using the Times-Roman font with the size 20 is " + width.ToString() + " centimeters.", caption);
else
MessageBox.Show("The GetTextWidth() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("Units can't be set correctly.", caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Calculates the height of the font you have specified, expressed in the current units used in the loaded PDF document, without respecting the font boundary box.
You can use the method to determine the currently defined units and you can also use the method to reset the units
according to your preference.
Calculates the height of the specified font in the currently defined units within the loaded PDF document.
The resource name of the font you prefer.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods. For further assistance, please see the
section Fonts of the GdPicturePDF class in the Reference Guide.
The size of the text (the font size actually), in points.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
For example, if the currently loaded PDF document does not contain any page, this method will fail.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
The height of the specified font, expressed in the current units specified by the SetMeasurementUnit method, not respecting the font boundary box.
The method can be subsequently used to determine if this method has been successful.
How to determine the height of the standard Times-Roman font.
Dim caption As String = "Example: GetTextHeight"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim height As Single = gdpicturePDF.GetTextHeight(fontName, 20)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The height of the Times-Roman font with the size 20 is " + height.ToString() + " centimeters.", caption)
Else
MessageBox.Show("The GetTextHeight() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Units can't be set correctly.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetTextHeight";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float height = gdpicturePDF.GetTextHeight(fontName, 20);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The height of the Times-Roman font with the size 20 is " + height.ToString() + " centimeters.", caption);
else
MessageBox.Show("The GetTextHeight() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("Units can't be set correctly.", caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Calculates the height of the font you have specified, expressed in the current units used in the loaded PDF document.
You can use the method to determine the currently defined units and you can also use the method to reset the units
according to your preference.
Calculates the height of the specified font in the currently defined units within the loaded PDF document.
The resource name of the font you prefer.
You can easily obtain this name using the method or any of the AddTrueTypeFont...() methods. For further assistance, please see the
section Fonts of the GdPicturePDF class in the Reference Guide.
The size of the text (the font size actually), in points.
Set this parameter to true if you want to determine the font height by using the font boundary box. It is an imaginary box that encloses all glyphs
from the font, usually as tightly as possible. It is represented by four parameters.
Set this parameter to false if you want to determine the font height by using the font's ascent and descent properties. The ascent property is the
distance from the baseline to the highest grid coordinate used to place an outline point, the descent property to the lowest grid coordinate.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
For example, if the currently loaded PDF document does not contain any page, this method will fail.
Just to remind you that 1 point is equivalent to 1/72 of an inch.
The height of the specified font, expressed in the current units specified by the SetMeasurementUnit method.
The method can be subsequently used to determine if this method has been successful.
How to determine the height of the standard Times-Roman font with and without respect to the font boundary box.
Dim caption As String = "Example: GetTextHeight"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim height As Single = gdpicturePDF.GetTextHeight(fontName, 20, True)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "The height of the Times-Roman font with the size 20, with respect to the font boundary box, is " + height.ToString() + " centimeters."
Else
message = message + "The GetTextHeight() method has failed with the status: " + status.ToString()
End If
height = gdpicturePDF.GetTextHeight(fontName, 20, False)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + vbCrLf + "The height of the Times-Roman font with the size 20, without respecting the font boundary box, is " + height.ToString() + " centimeters."
Else
message = message + vbCrLf + "The GetTextHeight() method has failed with the status: " + status.ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Units can't be set correctly.", caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetTextHeight";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesRoman);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
float height = gdpicturePDF.GetTextHeight(fontName, 20, true);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + "The height of the Times-Roman font with the size 20, with respect to the font boundary box, is " + height.ToString() + " centimeters.";
else
message = message + "The GetTextHeight() method has failed with the status: " + status.ToString();
height = gdpicturePDF.GetTextHeight(fontName, 20, false);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + "\nThe height of the Times-Roman font with the size 20, without respecting the font boundary box, is " + height.ToString() + " centimeters.";
else
message = message + "\nThe GetTextHeight() method has failed with the status: " + status.ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("Units can't be set correctly.", caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Draws content of the page, specified by its page number, from a source PDF document, onto the exactly defined area of the currently selected page of the
destination PDF document. The coordinates and the dimensions of the destination area need to be set in the current units defined in the destination PDF
document, related to the actual page, where the content of the source page is to be drawn.
You can use the method to determine the currently defined units and you can use the method to reset the units
according to your preference.
The source PDF document, which contains the source page to draw.
The page number of the page, which content is to be drawn. This parameter is without any restrictions,
the source page is selected by use of the method, so all there mentioned details remain in effect.
The horizontal (X) coordinate of the bottom left point of the destination area, where the page content is to be drawn,
expressed in the current units used in the destination PDF document, related to the currently selected page.
The vertical (Y) coordinate of the bottom left point of the destination area, where the page content is to be drawn,
expressed in the current units used in the destination PDF document, related to the currently selected page.
The width of the destination area, expressed in the current units used in the destination PDF document.
The height of the destination area, expressed in the current units used in the destination PDF document.
This method is only allowed for use with non-encrypted documents, both the source and the destination one.
Be aware that DstX and DstY parameters are fixly determined as the coordinates of the bottom left point of the destination area on the actual page.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to draw content of the first page of the source PDF document onto the first page of the destination PDF document twice, side by side, within the two same-sized areas.
Dim caption As String = "Example: DrawPage"
Dim srcPDF As New GdPicturePDF()
Dim dstPDF As New GdPicturePDF()
Dim status As GdPictureStatus = srcPDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
If (dstPDF.NewPDF() = GdPictureStatus.OK) AndAlso
(dstPDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim width As Single = dstPDF.GetPageWidth()
If dstPDF.GetStat() = GdPictureStatus.OK Then
Dim height As Single = dstPDF.GetPageHeight()
If dstPDF.GetStat() = GdPictureStatus.OK Then
'the new width of the destination area
width = width / 2
If (dstPDF.SelectPage(1) = GdPictureStatus.OK) AndAlso
(dstPDF.DrawPage(srcPDF, 1, 0, 0, width, height) = GdPictureStatus.OK) AndAlso
(dstPDF.DrawPage(srcPDF, 1, width, 0, width, height) = GdPictureStatus.OK) Then
status = dstPDF.SaveToFile("test_DrawPage.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + dstPDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + dstPDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + dstPDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method or the NewPage() for the destination document has failed with the status: " + dstPDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The LoadFromFile() method for the source document has failed with the status: " + status.ToString(), caption)
End If
srcPDF.Dispose()
dstPDF.Dispose()
string caption = "Example: DrawPage";
GdPicturePDF srcPDF = new GdPicturePDF();
GdPicturePDF dstPDF = new GdPicturePDF();
GdPictureStatus status = srcPDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
if ((dstPDF.NewPDF() == GdPictureStatus.OK) &&
(dstPDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
float width = dstPDF.GetPageWidth();
if (dstPDF.GetStat() == GdPictureStatus.OK)
{
float height = dstPDF.GetPageHeight();
if (dstPDF.GetStat() == GdPictureStatus.OK)
{
//the new width of the destination area
width = width / 2;
if ((dstPDF.SelectPage(1) == GdPictureStatus.OK) &&
(dstPDF.DrawPage(srcPDF, 1, 0, 0, width, height) == GdPictureStatus.OK) &&
(dstPDF.DrawPage(srcPDF, 1, width, 0, width, height) == GdPictureStatus.OK))
{
status = dstPDF.SaveToFile("test_DrawPage.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + dstPDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + dstPDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + dstPDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method or the NewPage() for the destination document has failed with the status: " + dstPDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The LoadFromFile() method for the source document has failed with the status: " + status.ToString(), caption);
srcPDF.Dispose();
dstPDF.Dispose();
Creates and begins to define a new form XObject of the subtype Form, that includes all subsequently specified drawing operations
until the adjacent call. The resulting form XObject is identified by its resource name, which is meant to be used
for each further drawing within the currently loaded PDF document. The newly defined form XObject becomes a part of the currently loaded PDF document's content as well.
A form XObject is a structure within a PDF document, that describes objects (text, images, vectors, etc.) used repetitively in the document
to avoid multiple referencing of these objects in the document's content. So you can draw such a form XObject multiple times and it produces the same result on each specified location.
The width of the XObject's drawing canvas area, expressed in the current units specified by the SetMeasurementUnit method.
The height of the XObject's drawing canvas area, expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
Likewise, please avoid changing pages between calling both relevant and methods,
which causes loss of already specified drawing operations.
Returns a resource name of the newly created form XObject required for the next usage within the PDF document.
The method can be subsequently used to determine if this method has been successful.
This resource name you can subsequently pass to the method.
How to define a form XObject and how to use it further.
Dim caption As String = "Example: BeginXObjectForm"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SelectPage(1)
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, False)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim xObjResName As String = gdpicturePDF.BeginXObjectForm(120, 40)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFillColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 15, 20, "GdPicture SDK") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(8) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 15, 30, "used as reusable stamp") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(0, 0, 120, 40, False, True) = GdPictureStatus.OK) Then
If gdpicturePDF.EndXObjectForm() = GdPictureStatus.OK Then
If (gdpicturePDF.DrawXObjectForm(xObjResName, 50, 100, 1, 1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 300, 2, 2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 400, 0.5F, 0.5F) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("XObject_test.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Your PDF document with form XObject has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Drawing a newly created XObject has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The EndXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Drawing a stamp has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The BeginXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Adding font has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: BeginXObjectForm";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SelectPage(1);
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string xObjResName = gdpicturePDF.BeginXObjectForm(120, 40);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFillColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 15, 20, "GdPicture SDK") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(8) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 15, 30, "used as reusable stamp") == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(0, 0, 120, 40, false, true) == GdPictureStatus.OK))
{
if (gdpicturePDF.EndXObjectForm() == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawXObjectForm(xObjResName, 50, 100, 1, 1) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(2) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 300, 2, 2) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 400, 0.5F, 0.5F) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("XObject_test.pdf") == GdPictureStatus.OK)
MessageBox.Show("Your PDF document with form XObject has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Drawing a newly created XObject has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The EndXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Drawing a stamp has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The BeginXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Adding font has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Ends the current definition of a form XObject, that has been previously created using the method.
The newly defined form XObject becomes a part of the currently loaded PDF document's content.
You need to use the method to subsequently draw the required form XObject on the page.
This method is only allowed for use with non-encrypted documents.
Likewise, please avoid changing pages between calling both relevant and methods,
which causes loss of already specified drawing operations.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to define a form XObject and how to use it further.
Dim caption As String = "Example: EndXObjectForm"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SelectPage(1)
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, False)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim xObjResName As String = gdpicturePDF.BeginXObjectForm(120, 40)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFillColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 15, 20, "GdPicture SDK") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(8) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 15, 30, "used as reusable stamp") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(0, 0, 120, 40, False, True) = GdPictureStatus.OK) Then
If gdpicturePDF.EndXObjectForm() = GdPictureStatus.OK Then
If (gdpicturePDF.DrawXObjectForm(xObjResName, 50, 100, 1, 1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 300, 2, 2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 400, 0.5F, 0.5F) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("XObject_test.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Your PDF document with form XObject has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Drawing a newly created XObject has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The EndXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Drawing a stamp has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The BeginXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Adding font has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: EndXObjectForm";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SelectPage(1);
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string xObjResName = gdpicturePDF.BeginXObjectForm(120, 40);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFillColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 15, 20, "GdPicture SDK") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(8) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 15, 30, "used as reusable stamp") == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(0, 0, 120, 40, false, true) == GdPictureStatus.OK))
{
if (gdpicturePDF.EndXObjectForm() == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawXObjectForm(xObjResName, 50, 100, 1, 1) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(2) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 300, 2, 2) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 400, 0.5F, 0.5F) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("XObject_test.pdf") == GdPictureStatus.OK)
MessageBox.Show("Your PDF document with form XObject has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Drawing a newly created XObject has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The EndXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Drawing a stamp has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The BeginXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Adding font has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Draws an existing form XObject, identified by its resource name within the loaded PDF document, onto the currently selected page according to what you have specified.
A form XObject is a structure within a PDF document, that describes objects (text, images, vectors, etc.) used repetitively in the document to avoid
multiple referencing of these objects in the document's content. Each form XObject is identified by its unique resource name defined when creating the object.
The form XObject resource name as a string. You can obtain this name using the method.
The horizontal (X) coordinate of the bottom left point, where the required XObject is to be drawn,
expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin, related to the currently selected page.
The vertical (Y) coordinate of the bottom left point, where the required XObject is to be drawn,
expressed in the current units specified by the SetMeasurementUnit method with respect to the currently defined origin, related to the currently selected page.
The horizontal scale factor for drawing, it corresponds to the XObject's width.
For example, if this parameter is set to 2.0, it multiplies the width of the specified form XObject by 2, and if it is set to 0.5, it divides the width by 2.
The vertical scale factor for drawing, it corresponds to the XObject's height.
For example, if this parameter is set to 2.0, it multiplies the height of the specified form XObject by 2, and if it is set to 0.5, it divides the height by 2.
This method is only allowed for use with non-encrypted documents.
Be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to define a form XObject and how to use it further.
Dim caption As String = "Example: DrawXObjectForm"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SelectPage(1)
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, False)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim xObjResName As String = gdpicturePDF.BeginXObjectForm(120, 40)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.SetFillColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 15, 20, "GdPicture SDK") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(8) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 15, 30, "used as reusable stamp") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(0, 0, 120, 40, False, True) = GdPictureStatus.OK) Then
If gdpicturePDF.EndXObjectForm() = GdPictureStatus.OK Then
If (gdpicturePDF.DrawXObjectForm(xObjResName, 50, 100, 1, 1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 300, 2, 2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 400, 0.5F, 0.5F) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("XObject_test.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Your PDF document with form XObject has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Drawing a newly created XObject has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The EndXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Drawing a stamp has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The BeginXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Adding font has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: DrawXObjectForm";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SelectPage(1);
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, false);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string xObjResName = gdpicturePDF.BeginXObjectForm(120, 40);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetFillColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 15, 20, "GdPicture SDK") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(8) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 15, 30, "used as reusable stamp") == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(0, 0, 120, 40, false, true) == GdPictureStatus.OK))
{
if (gdpicturePDF.EndXObjectForm() == GdPictureStatus.OK)
{
if ((gdpicturePDF.DrawXObjectForm(xObjResName, 50, 100, 1, 1) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(2) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 300, 2, 2) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(3) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawXObjectForm(xObjResName, 50, 400, 0.5F, 0.5F) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("XObject_test.pdf") == GdPictureStatus.OK)
MessageBox.Show("Your PDF document with form XObject has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Drawing a newly created XObject has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The EndXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Drawing a stamp has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The BeginXObjectForm() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Adding font has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Appends a subpath, constructed from the specified GraphicsPath object, to a current path defined within a currently selected page of the loaded PDF document.
The newly added subpath is built up using the path construction and path-painting operators.
All coordinates within the defined GraphicsPath object need to be set in the current units defined in the PDF document with respect to the currently located origin,
related to the actual page. You can simply use the method to determine the currently defined units and you can easily use the method
to reset the units according to your preference.
A GraphicsPath object to be added to the current path.
This method is only allowed for use with non-encrypted documents.
It is recommended to set the origin's location to be the upper left corner simply by using the method to draw an expected image,
for further explanation please see the example below.For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class
in the Reference Guide, as well as the Path Construction and Painting section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert and add a GraphicsPath object to the current path.
Dim caption As String = "Example: AddGraphicsToPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim graphicsPath As New System.Drawing.Drawing2D.GraphicsPath()
Dim myPoints As Point() = {New Point(50, 50), New Point(100, 100), New Point(50, 100), New Point(50, 50)}
Dim myRect As New Rectangle(100, 100, 120, 120)
graphicsPath.AddLines(myPoints)
graphicsPath.AddRectangle(myRect)
graphicsPath.AddEllipse(200, 200, 100, 100)
graphicsPath.AddString("I Love GdPicture.NET", New FontFamily("Arial"), 0, 20, New Point(), New StringFormat())
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddGraphicsToPath(graphicsPath) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddGraphicsToPath.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
graphicsPath.Dispose()
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddGraphicsToPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
System.Drawing.Drawing2D.GraphicsPath graphicsPath = new System.Drawing.Drawing2D.GraphicsPath();
Point[] myPoints = { new Point(50, 50), new Point(100, 100), new Point(50, 100), new Point(50, 50) };
Rectangle myRect = new Rectangle(100, 100, 120, 120);
graphicsPath.AddLines(myPoints);
graphicsPath.AddRectangle(myRect);
graphicsPath.AddEllipse(200, 200, 100, 100);
graphicsPath.AddString("I Love GdPicture.NET", new FontFamily("Arial"), 0, 20, new Point(), new StringFormat());
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.AddGraphicsToPath(graphicsPath) == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddGraphicsToPath.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
{
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
graphicsPath.Dispose();
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Begins a new subpath, defined within a currently selected page of the loaded PDF document, by moving the current point to the newly specified
coordinates (DstX, DstY), omitting any connecting line segment. More precisely, this method sets the path construction operator "m".
The coordinates of the specified point need to be set in the current units defined in the PDF document with respect to the currently
located origin, related to the actual page. You can simply use the method to determine the currently defined units and you can easily use
the method to reset the units according to your preference.
The horizontal (X) coordinate of the new current point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the new current point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
This method is only allowed for use with non-encrypted documents.
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Path Construction Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to define a new current point for the current path, in other words how to begin a new path construction.
Dim caption As String = "Example: BeginPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_BeginPath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: BeginPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_BeginPath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: BeginPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_BeginPath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: BeginPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_BeginPath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Closes and terminates the current subpath, defined within a currently selected page of the loaded PDF document, by appending a straight line segment from
the current point to the starting point of the subpath. More precisely, this method sets the path construction operator "h".
If the current subpath is already closed, any other additional "h" operator does nothing (see PDF Reference, Section "Path Construction Operators").
This method is only allowed for use with non-encrypted documents.
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Path Construction Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to close the current path.
Dim caption As String = "Example: ClosePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_ClosePath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ClosePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_ClosePath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: ClosePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_ClosePath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ClosePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_ClosePath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Ends the current path object, that means empties the current path, defined within a currently selected page of the loaded PDF document, without filling or
stroking it. More precisely, this method sets the path-painting no-op operator "n". If the current sub-path is already closed, any other additional "n" operator
does nothing (see PDF Reference, Section "Path Construction Operators"). This operator is mostly used with a clipping path operator.
This method is only allowed for use with non-encrypted documents.
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Path-painting Operators and the Clipping Path Operators sections in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to end a currently defined path.
Dim caption As String = "Example: EndPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddEllipseToPath(300, 400, 400, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddEllipseToPath(300, 400, 400, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClipPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(128, 128, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(550, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 750) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_EndPath.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: EndPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.AddEllipseToPath(300, 400, 400, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.AddEllipseToPath(300, 400, 400, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.ClipPath() == GdPictureStatus.OK) &&
(gdpicturePDF.EndPath() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(128, 128, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(550, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 750) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_EndPath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Modifies the currently specified clipping path by intersecting it with the currently constructed path, defined within a currently selected page of the loaded PDF document. This method uses
the nonzero winding number rule to determine which regions lie inside the clipping path. In other words, this method sets the clipping path operator "W".
The clipping path is part of the graphics state and thus it is affected by the currently specified graphics state parameters (see PDF Reference, Section "Clipping Path Operators").
This method is only allowed for use with non-encrypted documents.
Just to remind you that the initial clipping path includes the entire page.
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Clipping Path Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize a clipping path to draw only some parts of your images.
Dim caption As String = "Example: ClipPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddEllipseToPath(300, 400, 400, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddEllipseToPath(300, 400, 400, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClipPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(128, 128, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(550, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 750) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_ClipPath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ClipPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.AddEllipseToPath(300, 400, 400, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.AddEllipseToPath(300, 400, 400, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.ClipPath() == GdPictureStatus.OK) &&
(gdpicturePDF.EndPath() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(128, 128, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(550, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 750) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_ClipPath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: ClipPath"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim width As Single = gdpicturePDF.GetPageWidth()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim height As Single = gdpicturePDF.GetPageHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'the new height of the destination area
height = height / 2
If (gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, height, width, height) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddEllipseToPath(width / 2, height / 2, width / 2, height / 2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClipPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, 0, width, height) = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_ClipPath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method or the NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ClipPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float width = gdpicturePDF.GetPageWidth();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float height = gdpicturePDF.GetPageHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//the new height of the destination area
height = height / 2;
if ((gdpicturePDF.SelectPage(1) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, height, width, height) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.AddEllipseToPath(width / 2, height / 2, width / 2, height / 2) == GdPictureStatus.OK) &&
(gdpicturePDF.ClipPath() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, 0, width, height) == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_ClipPath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method or the NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Modifies the currently specified clipping path by intersecting it with the currently constructed path, defined within a currently selected page of the loaded PDF document. This method uses
the even-odd rule to determine which regions lie inside the clipping path. In other words, this method sets the clipping path operator "W*".
The clipping path is part of the graphics state and thus it is affected by the currently specified graphics state parameters (see PDF Reference, Section "Clipping Path Operators").
This method is only allowed for use with non-encrypted documents.
Just to remind you that the initial clipping path includes the entire page.
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Clipping Path Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize a clipping path to draw your images. The examples below show you the difference between the nonzero winding number rule and the even-odd rule.
Dim caption As String = "Example: ClipPathOdd"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(250, 100) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(100, 350) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(390, 170) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(110, 170) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(400, 350) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClipPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(0, 0, 612, 400, True, False) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 128) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(250, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(100, 650) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(390, 470) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(110, 470) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(400, 650) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClipPathOdd() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRectangle(0, 400, 612, 800, True, False) = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_ClipPathOdd.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: ClipPathOdd";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(250, 100) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(100, 350) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(390, 170) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(110, 170) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(400, 350) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.ClipPath() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(0, 0, 612, 400, true, false) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 128) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(250, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(100, 650) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(390, 470) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(110, 470) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(400, 650) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.ClipPathOdd() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRectangle(0, 400, 612, 800, true, false) == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_ClipPathOdd.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Strokes the current path, in other words paints a line along the current path, defined within a currently selected page of the loaded PDF document. This
method sets the path-painting operator "S". Each straight or curved segment in the current path is painted and also be aware that each of the path's sub-paths
is handled separately (see PDF Reference, Section "Path-Painting Operators"). By the definition the results of the "S" operator depend on the current settings
of the graphics state parameters, for example the line width or the line color, as well as the line pattern or the line join style, etc.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that the path-painting operators end a path object, so once a path has been painted, means stroked, it is no longer defined. If
you want to stroke and fill the current path together, you need to use the method
instead of the sequence of methods and .
For further assistance, please see the Path Construction and Painting section and the Graphics State section of the GdPicturePDF class in the Reference Guide,
as well as the Path-Painting Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to stroke the current path. You can find more different approaches in the examples below.
Dim caption As String = "Example: StrokePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_StrokePath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: StrokePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_StrokePath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: StrokePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_StrokePath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: StrokePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_StrokePath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Closes, fills and then strokes the current path, using the nonzero winding number rule to determine the region to fill, defined within a currently selected
page of the loaded PDF document. More precisely, this method sets the path-painting operator "b". The use of this method has the same effect as the use of the
sequence of methods ClosePath() and FillAndStrokePath(), and therefore all details related to the method and
method remain in effect.
This method is only allowed for use with non-encrypted documents.
For further assistance, please see the Path Construction and Painting section and the Graphics State section of the GdPicturePDF class in the Reference Guide,
as well as the Path-Painting Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to close the current path with filling and stroking it at the same time.
Dim caption As String = "Example: CloseAndFillAndStrokePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 55) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 100) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 100) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndStrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 105) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 155) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 130) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 105) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 155) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_CloseAndFillAndStrokePath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: CloseAndFillAndStrokePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 55) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 100) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 100) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndStrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 105) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 155) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 130) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 105) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 155) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_CloseAndFillAndStrokePath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: CloseAndFillAndStrokePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(200, 40) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 90) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 70) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 40) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 90) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(200, 110) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 160) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 140) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 110) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 160) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePathOdd() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_CloseAndFillAndStrokePath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: CloseAndFillAndStrokePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(200, 40) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 90) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 70) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 40) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 90) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(200, 110) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 160) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 140) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 110) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 160) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePathOdd() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_CloseAndFillAndStrokePath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Closes, fills and then strokes the current path, using the even-odd rule (an alternative to the nonzero winding number rule) to determine the region to
fill, defined within a currently selected page of the loaded PDF document. More precisely, this method sets the path-painting operator "b*". The use of this
method has the same effect as the use of the sequence of methods ClosePath() and FillAndStrokePathOdd(), and therefore all details related to the
method and method remain in effect.
This method is only allowed for use with non-encrypted documents.
For further assistance, please see the Path Construction and Painting section and the Graphics State section of the GdPicturePDF class in the Reference Guide,
as well as the Path-Painting Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to close the current path with filling and stroking it at the same time using both rules to determine the region to fill.
Dim caption As String = "Example: CloseAndFillAndStrokePathOdd"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(200, 40) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 90) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 70) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 40) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 90) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(200, 110) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 160) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 140) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 110) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 160) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePathOdd() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_CloseAndFillAndStrokePathOdd.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: CloseAndFillAndStrokePathOdd";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(200, 40) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 90) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 70) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 40) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 90) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(200, 110) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 160) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 140) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 110) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 160) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePathOdd() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_CloseAndFillAndStrokePathOdd.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Fills and then strokes the current path, defined within a currently selected page of the loaded PDF document, using the nonzero winding number rule to determine the region to fill.
More precisely, this method sets the path-painting operator "B". Any sub-paths, that are open, are implicitly closed before being filled (see PDF Reference, Section "Path-Painting Operators").
The use of this method has the same effect as constructing two identical path objects, painting the first using the method and the second using
the method. Therefore all details related to the and the method remain in effect.
Be aware of your currently defined graphics state parameters, that both filling and stroking operations put into effect.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that the path-painting operators end a path object, so once a path has been painted (filled or stroked), it is no longer defined. In
other words, the sequence of the FillPath() and methods has not that effect as using the method.
For further assistance, please see the Path Construction and Painting section and the Graphics State section of the GdPicturePDF class in the Reference Guide,
as well as the Path-Painting Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to fill and stroke the current path at the same time.
Dim caption As String = "Example: FillAndStrokePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_FillAndStroke1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FillAndStrokePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.FillAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_FillAndStroke1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: FillAndStrokePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillAndStrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillAndStrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(180, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 205) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(180, 180) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(180, 205) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillAndStrokePathOdd() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_FillAndStrokePath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FillAndStrokePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.FillAndStrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.FillAndStrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(180, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 205) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(180, 180) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(180, 205) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.FillAndStrokePathOdd() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_FillAndStrokePath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Fills and then strokes the current path, defined within a currently selected page of the loaded PDF document, using the even-odd rule (an alternative to the
nonzero winding number rule) to determine the region to fill. More precisely, this method sets the path-painting operator "B*". According to the PDF
Reference, any sub-paths, that are open, are implicitly closed before being filled.
The use of this method has the same effect as the use of the method FillAndStrokePath(), except of the rule used to fill the path. Therefore all details
related to the method remain in effect. Be aware of your currently defined graphics state parameters, that both filling and
stroking operations put into effect.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that the path-painting operators end a path object, so once a path has been painted (filled or stroked), it is no longer defined. In
other words, the sequence of the and methods has not that effect as using the method.
For further assistance, please see the Path Construction and Painting section and the Graphics State section of the GdPicturePDF class in the Reference Guide,
as well as the Path-Painting Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to fill and stroke the current path at the same time using both rules to determine the region to fill.
Dim caption As String = "Example: FillAndStrokePathOdd"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillAndStrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillAndStrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(180, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 205) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(180, 180) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(180, 205) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillAndStrokePathOdd() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_FillAndStrokePathOdd.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FillAndStrokePathOdd";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.FillAndStrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.FillAndStrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(180, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 205) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(180, 180) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(180, 205) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.FillAndStrokePathOdd() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_FillAndStrokePathOdd.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Fills the current path, defined within a currently selected page of the loaded PDF document, using the nonzero winding number rule to determine the region to fill.
In other words, this method sets the path-painting operator "f". Any sub-paths, that are open, are implicitly closed before being filled (see PDF Reference, Section "Path-Painting Operators").
By the definition the "f" operator uses the current non-stroking color, previously defined by the method, to paint the entire region enclosed by the current path.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that the path-painting operators end a path object, so once a path has been painted, means filled, it is no longer defined.
If you want to fill and stroke the current path together, you need to use the method instead of
the sequence of the methods and .
For further assistance, please see the Path Construction and Painting section and the Graphics State section of the GdPicturePDF class in the Reference Guide,
as well as the Path-Painting Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to fill the current path.
Dim caption As String = "Example: FillPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_FillPath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FillPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_FillPath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: FillPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(200, 40) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 90) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 70) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 40) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 90) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(200, 110) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 160) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 140) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 110) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 160) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPathOdd() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_FillPath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FillPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(200, 40) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 90) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 70) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 40) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 90) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(200, 110) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 160) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 140) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 110) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 160) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPathOdd() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_FillPath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Fills the current path, defined within a currently selected page of the loaded PDF document, using the even-odd rule (an alternative to the nonzero winding number rule)
to determine the region to fill. In other words, this method sets the path-painting operator "f*". Any sub-paths, that are open, are implicitly closed before being filled
(see PDF Reference, Section "Path-Painting Operators").By the definition the "f*" Operator uses the current non-stroking color,
previously defined by the method, to paint the entire region enclosed by the current path.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that the path-painting operators end a path object, so once a path has been painted, means filled, it is no longer defined.
For further assistance, please see the Path Construction and Painting section and the Graphics State section of the GdPicturePDF class in the Reference Guide,
as well as the Path-Painting Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to fill the current path using both rules to determine the region to fill.
Dim caption As String = "Example: FillPathOdd"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(200, 40) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 90) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 70) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 40) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 90) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(200, 110) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 160) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 140) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 110) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(200, 160) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPathOdd() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_FillPathOdd.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: FillPathOdd";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(200, 40) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 90) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 70) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 40) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 90) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(200, 110) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 160) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 140) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 110) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(200, 160) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPathOdd() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_FillPathOdd.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Closes and strokes the current path, defined within a currently selected page of the loaded PDF document. More precisely, this method sets the path-painting
operator "s". The use of this method has the same effect as the use of the sequence of methods ClosePath() and StrokePath(), and therefore all details
related to the method remain in effect.
This method is only allowed for use with non-encrypted documents.
You also need to be aware that the path-painting operators end a path object, so once a path has been painted, it is no longer defined.
For further assistance, please see the Path Construction and Painting section and the Graphics State section of the GdPicturePDF class in the Reference Guide,
as well as the Path-Painting Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to close and stroke the current path using different approaches.
Dim caption As String = "Example: CloseAndStrokePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_CloseAndStrokePath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: CloseAndStrokePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_CloseAndStrokePath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: CloseAndStrokePath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndStrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(238, 130, 238) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_CloseAndStrokePath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: CloseAndStrokePath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndStrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(238, 130, 238) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_CloseAndStrokePath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Appends a straight line segment from the current point to the destination point (DstX, DstY) of the path currently under construction, that is defined
within a currently selected page of the loaded PDF document. More precisely, this method sets the path construction operator "l" (lowercase L). The new current
point of the constructed path is the destination point (DstX, DstY).
The coordinates of the specified point need to be set in the current units defined in the PDF document with respect to the currently located origin, related
to the actual page. You can simply use the method to determine the currently defined units and you can easily use the
method to reset the units according to your preference.
The horizontal (X) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the destination point, expressed in the current units specified by the SetMeasurementUnit method
with respect to the defined origin, related to the currently selected page.
This method is only allowed for use with non-encrypted documents.
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Path Construction Operators section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add a new line (a straight line segment) to the currently constructed path.
Dim caption As String = "Example: AddLineToPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndFillAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddLineToPath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLineToPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndFillAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddLineToPath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Dim caption As String = "Example: AddLineToPath"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
If (gdpicturePDF.NewPage(210, 297) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 10) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 50) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 80) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 120) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClosePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.StrokePath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(100, 150) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(20, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddLineToPath(190, 200) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.CloseAndStrokePath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddLineToPath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLineToPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
if ((gdpicturePDF.NewPage(210, 297) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 10) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 50) == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 80) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 120) == GdPictureStatus.OK) &&
(gdpicturePDF.ClosePath() == GdPictureStatus.OK) &&
(gdpicturePDF.StrokePath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(100, 150) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(20, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.AddLineToPath(190, 200) == GdPictureStatus.OK) &&
(gdpicturePDF.CloseAndStrokePath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddLineToPath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Appends an ellipse, using the sequence of cubic Bézier curves, to the currently constructed path, defined within a currently selected page of the loaded PDF
document. Be aware of your currently defined graphics state parameters, that subsequent filling and stroking operations applied onto the constructed path put into effect.
The ellipse is clearly defined by the center and the dimensions of its bounding box. All these coordinates need to be set in the current units defined in the
PDF document with respect to the currently located origin, related to the actual page. You can use the method to determine the
currently defined units and you can use the method to reset the units according to your preference.
The horizontal (X) coordinate of the ellipse's center, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the ellipse's center, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The width of the ellipse's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the ellipse's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
It is recommended to set the origin's location to be the upper left corner simply by using the method to draw an expected shape of an ellipse,
for further explanation please see the first example below.
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Path Construction and Painting section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add an ellipse to the currently constructed path.
Dim caption As String = "Example: AddEllipseToPath"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() <> GdPictureStatus.OK Then
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If gdpicturePDF.NewPage(210, 297) <> GdPictureStatus.OK Then
MessageBox.Show("The NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
If (gdpicturePDF.SetFillColor(255, 192, 203) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.FillPath() <> GdPictureStatus.OK) Then
MessageBox.Show("Painting the first ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
If (gdpicturePDF.SetFillColor(238, 130, 238) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.FillPath() <> GdPictureStatus.OK) Then
MessageBox.Show("Painting the second ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopRight)
If (gdpicturePDF.SetFillColor(255, 0, 0) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.FillPath() <> GdPictureStatus.OK) Then
MessageBox.Show("Painting the third ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomRight)
If (gdpicturePDF.SetFillColor(0, 0, 255) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.FillPath() <> GdPictureStatus.OK) Then
MessageBox.Show("Painting the fourth ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
GoTo [error]
End If
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_AddEllipseToPath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
[error]:
gdpicturePDF.Dispose()
string caption = "Example: AddEllipseToPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() != GdPictureStatus.OK)
{
MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if (gdpicturePDF.NewPage(210, 297) != GdPictureStatus.OK)
{
MessageBox.Show("The NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
if ((gdpicturePDF.SetFillColor(255, 192, 203) != GdPictureStatus.OK) ||
(gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) != GdPictureStatus.OK) ||
(gdpicturePDF.FillPath() != GdPictureStatus.OK))
{
MessageBox.Show("Painting the first ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft);
if ((gdpicturePDF.SetFillColor(238, 130, 238) != GdPictureStatus.OK) ||
(gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) != GdPictureStatus.OK) ||
(gdpicturePDF.FillPath() != GdPictureStatus.OK))
{
MessageBox.Show("Painting the second ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopRight);
if ((gdpicturePDF.SetFillColor(255, 0, 0) != GdPictureStatus.OK) ||
(gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) != GdPictureStatus.OK) ||
(gdpicturePDF.FillPath() != GdPictureStatus.OK))
{
MessageBox.Show("Painting the third ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomRight);
if ((gdpicturePDF.SetFillColor(0, 0, 255) != GdPictureStatus.OK) ||
(gdpicturePDF.AddEllipseToPath(100, 150, 180, 60) != GdPictureStatus.OK) ||
(gdpicturePDF.FillPath() != GdPictureStatus.OK))
{
MessageBox.Show("Painting the fourth ellipse has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
goto error;
}
GdPictureStatus status = gdpicturePDF.SaveToFile("test_AddEllipseToPath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
error:
gdpicturePDF.Dispose();
Dim caption As String = "Example: AddEllipseToPath"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim width As Single = gdpicturePDF.GetPageWidth()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim height As Single = gdpicturePDF.GetPageHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'the new height of the destination area
height = height / 2
If (gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, height, width, height) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddEllipseToPath(width / 2, height / 2, width / 2, height / 2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.ClipPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, 0, width, height) = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_AddEllipseToPath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method or the NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddEllipseToPath";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float width = gdpicturePDF.GetPageWidth();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float height = gdpicturePDF.GetPageHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//the new height of the destination area
height = height / 2;
if ((gdpicturePDF.SelectPage(1) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, height, width, height) == GdPictureStatus.OK) &&
(gdpicturePDF.AddEllipseToPath(width / 2, height / 2, width / 2, height / 2) == GdPictureStatus.OK) &&
(gdpicturePDF.ClipPath() == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, 0, width, height) == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_AddEllipseToPath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageHeight() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method or the NewPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Appends a cubic Bézier curve to the current path, defined within a currently selected page of the loaded PDF document.
More precisely, this method sets the path construction operator "c". The curve expands the current path from the current point to the end-point (X3, Y3), using (X1, Y1) and (X2, Y2) as the Bézier control points.
Be aware of your currently defined graphics state parameters, that subsequent filling and stroking operations applied onto the constructed path put into effect.
All specified coordinates need to be set in the current units defined in the PDF document with respect to the currently located origin, related to the actual page.
You can use the method to determine the currently defined units and you can use the method to reset the units according to your preference.
The horizontal (X) coordinate of the first Bézier control point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the first Bézier control point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The horizontal (X) coordinate of the second Bézier control point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the second Bézier control point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The horizontal (X) coordinate of the curve's end point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the curve's end point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the new current point in the constructed subpath is (X3, Y3).
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Cubic Bézier Curves section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add a cubic Bézier curve to the current path.
Dim caption As String = "Example: AddCurveToPath3"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(128, 128, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(550, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 750) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddCurveToPath3.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddCurveToPath3";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(128, 128, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(550, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 750) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddCurveToPath3.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Appends a cubic Bézier curve, using two control points, to the current path, defined within a currently selected page of the loaded PDF document.
More precisely, this method sets the path construction operator "v". The curve expands the current path from the current point to the end-point (X3, Y3), using the current point and (X2, Y2) as the Bézier control points.
Be aware of your currently defined graphics state parameters, that subsequent filling and stroking operations applied onto the constructed path put into effect.
All specified coordinates need to be set in the current units defined in the PDF document with respect to the currently located origin, related to the actual page.
You can use the method to determine the currently defined units and you can use the method to reset the units according to your preference.
The horizontal (X) coordinate of the second Bézier control point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the second Bézier control point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The horizontal (X) coordinate of the curve's end point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the curve's end point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the new current point in the constructed subpath is (X3, Y3).
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Cubic Bézier Curves section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add a cubic Bézier curve to the current path.
Dim caption As String = "Example: AddCurveToPath2"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(128, 128, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(550, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 750) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddCurveToPath2.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddCurveToPath2";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(128, 128, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(550, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 750) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddCurveToPath2.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Appends a cubic Bézier curve, using two control points, to the current path, defined within a currently selected page of the loaded PDF document.
More precisely, this method sets the path construction operator "y". The curve expands the current path from the current point to the end-point (X3, Y3), using (X1, Y1) and (X3, Y3) as the Bézier control points.
Be aware of your currently defined graphics state parameters, that subsequent filling and stroking operations applied onto the constructed path put into effect.
All specified coordinates need to be set in the current units defined in the PDF document with respect to the currently located origin, related to the actual page.
You can use the method to determine the currently defined units and you can use the method to reset the units according to your preference.
The horizontal (X) coordinate of the first Bézier control point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the first Bézier control point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The horizontal (X) coordinate of the curve's end point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the curve's end point, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
This method is only allowed for use with non-encrypted documents.
Just to remind you that the new current point in the constructed subpath is (X3, Y3).
For further assistance, please see the Path Construction and Painting section of the GdPicturePDF class in the Reference Guide,
as well as the Cubic Bézier Curves section in the PDF Reference.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add a cubic Bézier curve to the current path.
Dim caption As String = "Example: AddCurveToPath1"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(128, 128, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(550, 20) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginPath(50, 750) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.FillPath() = GdPictureStatus.OK) Then
status = gdpicturePDF.SaveToFile("test_AddCurveToPath1.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddCurveToPath1";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(128, 128, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath1(10, 500, 200, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(550, 20) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath2(510, 500, 300, 400) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginPath(50, 750) == GdPictureStatus.OK) &&
(gdpicturePDF.AddCurveToPath3(10, 550, 300, 480, 500, 600) == GdPictureStatus.OK) &&
(gdpicturePDF.FillPath() == GdPictureStatus.OK))
{
status = gdpicturePDF.SaveToFile("test_AddCurveToPath1.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Merges two PDF documents according to their file paths. The resulting PDF document is saved to a file path you have specified.
If the specified file already exists, it will be overwritten. Please see also the method for more details.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while merging large documents.
The feature is available in both 32-bit and 64-bit mode by default.
These methods allow you to merge two PDF documents according to the way they are currently stored.
Both documents are merged using the method and all mentioned details remain in effect.
The file path of the first PDF document to merge.
The file path of the second PDF document to merge.
The file path of the destination PDF document.
Please ensure that the destination file path differs from both source file paths.
You have to specify a full file path for the destination document with the correct file extension, which is "pdf".
Likewise it is required, that the destination file path differs from both source file paths.
You don't need to load any document within the GdPicturePDF object you are going to use. You can simply use it as an empty wrapper object, as it is shown in the example below.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to merge two PDF documents using their file paths into a PDF document specified by its file path.
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.Merge2Documents("test1.pdf", "test2.pdf", "test_merged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Both documents have been successfully merged.", "Example: Merge2Documents")
Else
MessageBox.Show("The Merge2Documents() method has failed with the status: " + status.ToString(), "Example: Merge2Documents")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.Merge2Documents("test1.pdf", "test2.pdf", "test_merged.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("Both documents have been successfully merged.", "Example: Merge2Documents");
}
else
{
MessageBox.Show("The Merge2Documents() method has failed with the status: " + status.ToString(), "Example: Merge2Documents");
}
}
Merges two PDF documents stored in the previously instantiated Stream objects according to what you have specified. The only supported
file format for these input streams is the PDF format. The resulting PDF document is also saved to a Stream object you have specified.
Please see also the method for more details.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while merging large documents.
The feature is available in both 32-bit and 64-bit mode by default.
These methods allow you to merge two PDF documents according to the way they are currently stored.
Both documents are merged using the method and all mentioned details remain in effect.
The stream object handling data of the first PDF document to merge. It must be initialized before it can be sent into this method and it should remain open for subsequent use.
The stream object handling data of the second PDF document to merge. It must be initialized before it can be sent into this method and it should remain open for subsequent use.
The destination stream. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Further the destination stream should be open for writing.
Please ensure that the destination stream file path differs from both source streams (file paths).
Please note that both source streams together with the destination stream should remain open and can only be closed/disposed of by the user.
Likewise it is required, that the destination stream (file path) differs from both source stream (file paths).
You don't need to load any document within the GdPicturePDF object you are going to use. You can simply use it as an empty wrapper object, as it is shown in the example below.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to merge two PDF documents stored in the instantiated streams into a destination stream and how to display the resulting PDF document in the GdViewer object.
Using gdpicturePDF As New GdPicturePDF()
Dim doc1 As System.IO.Stream = New System.IO.FileStream("test1.pdf", System.IO.FileMode.Open)
Dim doc2 As System.IO.Stream = New System.IO.FileStream("test2.pdf", System.IO.FileMode.Open)
Dim mergedDoc As System.IO.Stream = New System.IO.MemoryStream()
Dim status As GdPictureStatus = gdpicturePDF.Merge2Documents(doc1, doc2, mergedDoc)
If status = GdPictureStatus.OK Then
MessageBox.Show("Both documents have been successfully merged.", "Example: Merge2Documents")
Else
MessageBox.Show("The Merge2Documents() method has failed with the status: " + status.ToString(), "Example: Merge2Documents")
End If
Dim oViewer As New GdViewer()
oViewer.DisplayFromStream(mergedDoc)
oViewer.Dispose()
doc1.Dispose()
doc2.Dispose()
mergedDoc.Dispose()
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
System.IO.Stream doc1 = new System.IO.FileStream("test1.pdf", System.IO.FileMode.Open);
System.IO.Stream doc2 = new System.IO.FileStream("test2.pdf", System.IO.FileMode.Open);
System.IO.Stream mergedDoc = new System.IO.MemoryStream();
GdPictureStatus status = gdpicturePDF.Merge2Documents(doc1, doc2, mergedDoc);
if (status == GdPictureStatus.OK)
{
MessageBox.Show("Both documents have been successfully merged.", "Example: Merge2Documents");
}
else
{
MessageBox.Show("The Merge2Documents() method has failed with the status: " + status.ToString(), "Example: Merge2Documents");
}
GdViewer oViewer = new GdViewer();
oViewer.DisplayFromStream(mergedDoc);
oViewer.Dispose();
doc1.Dispose();
doc2.Dispose();
mergedDoc.Dispose();
}
Merges two PDF documents loaded within the two GdPicturePDF objects. The resulting PDF document is created and stored within the new GdPicturePDF object as well.
If both source documents are PDF/A compliant, the resulting document will also be PDF/A compliant. The conformance level and version of the merged document will be PDF/A-1b regardless of the original conformance of both source documents.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while merging large documents.
The feature is available in both 32-bit and 64-bit mode by default.
These methods allow you to merge two PDF documents according to the way they are currently stored.
Both documents are merged using the method and all mentioned details remain in effect.
A GdPicturePDF object. The first PDF document to merge.
A GdPicturePDF object. The second PDF document to merge.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The last page in each of used documents is set as the current document's page after the merging process.
This method requires the Document Editor component to run.
A newly created GdPicturePDF object which stores the merged PDF document. The method can be subsequently used to determine if this method has been successful.
All pages of the first source document are cloned to the destination document and then all pages of the second source document are cloned to the destination document as well.
How to merge two PDF documents from the two GdPicturePDF objects into a new GdPicturePDF object.
Dim gdpicturePDF1 As New GdPicturePDF()
Dim gdpicturePDF2 As New GdPicturePDF()
If (gdpicturePDF1.LoadFromFile("test1.pdf", False) = GdPictureStatus.OK) AndAlso (gdpicturePDF2.LoadFromFile("test2.pdf", False) = GdPictureStatus.OK) Then
Dim oNewGdPicturePDF As GdPicturePDF = gdpicturePDF1.Merge2Documents(gdpicturePDF1, gdpicturePDF2)
'You can use also gdpicturePDF2 object to call the Merge2Documents method.
Dim status As GdPictureStatus = gdpicturePDF1.GetStat()
If status = GdPictureStatus.OK Then
oNewGdPicturePDF.SetAuthor("I'm the author of the merged document.")
If oNewGdPicturePDF.GetStat() = GdPictureStatus.OK Then
If oNewGdPicturePDF.SaveToFile("test_merged.pdf") = GdPictureStatus.OK Then
oNewGdPicturePDF.CloseDocument()
MessageBox.Show("Both documents have been successfully merged.", "Example: Merge2Documents")
Else
MessageBox.Show("The SaveToFile() method has failed.", "Example: Merge2Documents")
End If
End If
Else
MessageBox.Show("The Merge2Documents() method has failed with the status: " + status.ToString(), "Example: Merge2Documents")
End If
oNewGdPicturePDF.Dispose()
gdpicturePDF1.CloseDocument()
gdpicturePDF2.CloseDocument()
Else
MessageBox.Show("Loading of the source documents has failed.", "Example: Merge2Documents")
End If
gdpicturePDF1.Dispose()
gdpicturePDF2.Dispose()
GdPicturePDF gdpicturePDF1 = new GdPicturePDF();
GdPicturePDF gdpicturePDF2 = new GdPicturePDF();
if ((gdpicturePDF1.LoadFromFile("test1.pdf", false) == GdPictureStatus.OK) &&
(gdpicturePDF2.LoadFromFile("test2.pdf", false) == GdPictureStatus.OK))
{
GdPicturePDF oNewGdPicturePDF = gdpicturePDF1.Merge2Documents(gdpicturePDF1, gdpicturePDF2);
//You can use also gdpicturePDF2 object to call the Merge2Documents method.
GdPictureStatus status = gdpicturePDF1.GetStat();
if (status == GdPictureStatus.OK)
{
oNewGdPicturePDF.SetAuthor("I'm the author of the merged document.");
if (oNewGdPicturePDF.GetStat() == GdPictureStatus.OK)
{
if (oNewGdPicturePDF.SaveToFile("test_merged.pdf") == GdPictureStatus.OK)
{
oNewGdPicturePDF.CloseDocument();
MessageBox.Show("Both documents have been successfully merged.", "Example: Merge2Documents");
}
else
{
MessageBox.Show("The SaveToFile() method has failed.", "Example: Merge2Documents");
}
}
}
else
{
MessageBox.Show("The Merge2Documents() method has failed with the status: " + status.ToString(), "Example: Merge2Documents");
}
oNewGdPicturePDF.Dispose();
gdpicturePDF1.CloseDocument();
gdpicturePDF2.CloseDocument();
}
else
{
MessageBox.Show("Loading of the source documents has failed.", "Example: Merge2Documents");
}
gdpicturePDF1.Dispose();
gdpicturePDF2.Dispose();
Merge several PDF documents according to their file paths stored in the input parameter.
All pages of the source documents are cloned one by one to the destination document in that order how they are stored in the input parameter.
The resulting PDF document is saved to a file path you have specified. If the specified file already exists, it will be overwritten.
If the first PDF document in the list (specified by the first object in the input parameter) is PDF/A compliant, the resulting document will also be PDF/A
compliant. The conformance level and version of the merged document will be PDF/A-1b regardless of the original conformance of the first source document.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while merging large documents.
The feature is available in both 32-bit and 64-bit mode by default.
These methods allow you to merge several PDF documents at once. Please read more details about the PDF/A compliance of the resulting document below.
An array of strings defining the file paths of all the PDF documents you want to merge.
The file path of the destination PDF document.
Please ensure that the destination file path differs from all source file paths.
This method is only allowed for use with non-encrypted documents.
Be aware that you have to specify a full file path for the destination document with the correct file extension, which is "pdf". Likewise it is required,
that the destination file path differs from all source file paths.
You don't need to load any document within the GdPicturePDF object you are going to use. You can simply use it as an empty wrapper object, as it is shown in the example below.
This method requires the Document Editor component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to merge 3 PDF documents using their file paths into a PDF document specified by its file path.
Dim arPDF As String() = New String(2) {}
arPDF(0) = "test1.pdf"
arPDF(1) = "test2.pdf"
arPDF(2) = "test3.pdf"
Using gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.MergeDocuments(arPDF, "test_merged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments")
Else
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments")
End If
End Using
string[] arPDF = new string[3];
arPDF[0] = "test1.pdf";
arPDF[1] = "test2.pdf";
arPDF[2] = "test3.pdf";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.MergeDocuments(arPDF, "test_merged.pdf");
if (status == GdPictureStatus.OK)
{
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments");
}
else
{
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments");
}
}
Merges several PDF documents loaded within the array of the GdPicturePDF objects. The resulting PDF document is created and stored within the new GdPicturePDF object as well.
If the first PDF document in the list (stored in the first GdPicturePDF object in the input parameter) is PDF/A compliant, the resulting
document will also be PDF/A compliant. The conformance level and version of the merged document will be PDF/A-1b regardless of the original conformance of the first source document.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while merging large documents.
The feature is available in both 32-bit and 64-bit mode by default.
These methods allow you to merge several PDF documents at once. Please read more details about the PDF/A compliance of the resulting document below.
An array of the GdPicturePDF objects keeping the PDF documents you want to merge.
You need to load PDF documents within the objects, as it is shown in the example below.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The last page in each of used documents and also in the resulting document is set as the current document's page after the merging process.
This method requires the Document Editor component to run.
A newly created GdPicturePDF object which keeps the merged PDF document. The method can be subsequently used to determine if this method has been successful.
All pages of the source documents are cloned one by one to the destination document in that order how they are stored in the input parameter.
How to merge 3 PDF documents from an array of GdPicturePDF objects into a new GdPicturePDF object.
Dim arPDF As GdPicturePDF() = New GdPicturePDF(2) {}
arPDF(0) = New GdPicturePDF()
arPDF(1) = New GdPicturePDF()
arPDF(2) = New GdPicturePDF()
If (arPDF(0).LoadFromFile("test1.pdf", False) = GdPictureStatus.OK) AndAlso
(arPDF(1).LoadFromFile("test2.pdf", False) = GdPictureStatus.OK) AndAlso
(arPDF(2).LoadFromFile("test3.pdf", False) = GdPictureStatus.OK) Then
Dim dstPDF As GdPicturePDF = arPDF(0).MergeDocuments(arPDF)
'You can use also arPDF[1] or arPDF[2] object to call the MergeDocuments method.
Dim status As GdPictureStatus = arPDF(0).GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments")
If dstPDF.SaveToFile("test_merged.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Merged document has been successfully saved.", "Example: MergeDocuments")
dstPDF.CloseDocument()
End If
Else
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments")
End If
dstPDF.Dispose()
arPDF(2).CloseDocument()
arPDF(1).CloseDocument()
arPDF(0).CloseDocument()
Else
MessageBox.Show("Loading of the source documents has failed.", "Example: MergeDocuments")
End If
arPDF(2).Dispose()
arPDF(1).Dispose()
arPDF(0).Dispose()
GdPicturePDF[] arPDF = new GdPicturePDF[3];
arPDF[0] = new GdPicturePDF();
arPDF[1] = new GdPicturePDF();
arPDF[2] = new GdPicturePDF();
if ((arPDF[0].LoadFromFile("test1.pdf", false) == GdPictureStatus.OK) &&
(arPDF[1].LoadFromFile("test2.pdf", false) == GdPictureStatus.OK) &&
(arPDF[2].LoadFromFile("test3.pdf", false) == GdPictureStatus.OK))
{
GdPicturePDF dstPDF = arPDF[0].MergeDocuments(arPDF);
//You can use also arPDF[1] or arPDF[2] object to call the MergeDocuments method.
GdPictureStatus status = arPDF[0].GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments");
if (dstPDF.SaveToFile("test_merged.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("Merged document has been successfully saved.", "Example: MergeDocuments");
dstPDF.CloseDocument();
}
}
else
{
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments");
}
dstPDF.Dispose();
arPDF[2].CloseDocument();
arPDF[1].CloseDocument();
arPDF[0].CloseDocument();
}
else
{
MessageBox.Show("Loading of the source documents has failed.", "Example: MergeDocuments");
}
arPDF[2].Dispose();
arPDF[1].Dispose();
arPDF[0].Dispose();
Merges several PDF documents loaded within the array of the GdPicturePDF objects. The resulting PDF document is created and stored within the new GdPicturePDF
object as well. Using this method you can additionally select preferred merging options.
If the first PDF document in the list (stored in the first GdPicturePDF object in the input parameter) is PDF/A compliant, the resulting document will also
be PDF/A compliant. The conformance level and version of the merged document will be PDF/A-1b regardless of the original conformance of the first source document.
Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while merging large documents.
The feature is available in both 32-bit and 64-bit mode by default.
These methods allow you to merge several PDF documents at once. Please read more details about the PDF/A compliance of the resulting document below.
An array of the GdPicturePDF objects keeping the PDF documents you want to merge.
You need to load PDF documents within the objects, as it is shown in the example below.
A member of the PdfDocumentMergingOptions enumeration. Specifies required merging options.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.The last page in each of used documents and also in the resulting document is set as the current document's page after the merging process.
This method requires the Document Editor component to run.
A newly created GdPicturePDF object which keeps the merged PDF document. The method can be subsequently used to determine if this method has been successful.
All pages of the source documents are cloned one by one to the destination document in that order how they are stored in the input parameter.
How to merge 3 PDF documents from an array of GdPicturePDF objects into a new GdPicturePDF object. In this example all attachments are excluded from the merging process.
Dim arPDF As GdPicturePDF() = New GdPicturePDF(2) {}
arPDF(0) = New GdPicturePDF()
arPDF(1) = New GdPicturePDF()
arPDF(2) = New GdPicturePDF()
If (arPDF(0).LoadFromFile("test1.pdf", False) = GdPictureStatus.OK) AndAlso
(arPDF(1).LoadFromFile("test2.pdf", False) = GdPictureStatus.OK) AndAlso
(arPDF(2).LoadFromFile("test3.pdf", False) = GdPictureStatus.OK) Then
Dim dstPDF As GdPicturePDF = arPDF(0).MergeDocuments(arPDF, PdfDocumentMergingOptions.ExcludeAttachments)
'You can use also arPDF[1] or arPDF[2] object to call the MergeDocuments method.
Dim status As GdPictureStatus = arPDF(0).GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments")
If dstPDF.SaveToFile("test_merged.pdf") = GdPictureStatus.OK Then
MessageBox.Show("Merged document has been successfully saved.", "Example: MergeDocuments")
dstPDF.CloseDocument()
End If
Else
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments")
End If
dstPDF.Dispose()
arPDF(2).CloseDocument()
arPDF(1).CloseDocument()
arPDF(0).CloseDocument()
Else
MessageBox.Show("Loading of the source documents has failed.", "Example: MergeDocuments")
End If
arPDF(2).Dispose()
arPDF(1).Dispose()
arPDF(0).Dispose()
GdPicturePDF[] arPDF = new GdPicturePDF[3];
arPDF[0] = new GdPicturePDF();
arPDF[1] = new GdPicturePDF();
arPDF[2] = new GdPicturePDF();
if ((arPDF[0].LoadFromFile("test1.pdf", false) == GdPictureStatus.OK) &&
(arPDF[1].LoadFromFile("test2.pdf", false) == GdPictureStatus.OK) &&
(arPDF[2].LoadFromFile("test3.pdf", false) == GdPictureStatus.OK))
{
GdPicturePDF dstPDF = arPDF[0].MergeDocuments(arPDF, PdfDocumentMergingOptions.ExcludeAttachments);
//You can use also arPDF[1] or arPDF[2] object to call the MergeDocuments method.
GdPictureStatus status = arPDF[0].GetStat();
if (status == GdPictureStatus.OK)
{
MessageBox.Show("All documents have been successfully merged.", "Example: MergeDocuments");
if (dstPDF.SaveToFile("test_merged.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("Merged document has been successfully saved.", "Example: MergeDocuments");
dstPDF.CloseDocument();
}
}
else
{
MessageBox.Show("The MergeDocuments() method has failed with the status: " + status.ToString(), "Example: MergeDocuments");
}
dstPDF.Dispose();
arPDF[2].CloseDocument();
arPDF[1].CloseDocument();
arPDF[0].CloseDocument();
}
else
{
MessageBox.Show("Loading of the source documents has failed.", "Example: MergeDocuments");
}
arPDF[2].Dispose();
arPDF[1].Dispose();
arPDF[0].Dispose();
Returns the action's unique identifier of the action associated with an annotation object, that is specified by its index related to the currently
selected page of the loaded PDF document. You can subsequently use the method to determine the kind of this action.
At this time it is supported by the toolkit to only associate one action within one annotation object.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
Be aware that at this time it is not supported by the toolkit to add multiple actions per one annotation object.
A unique action identifier of the action associated with a specified annotation object. The method can be subsequently used to determine if this method has been successful.
You can use the method to obtain the type of this action, as it is shown in the example below.
How to find out the types of actions associated with annotations on the first page of the PDF document.
Dim caption As String = "Example: GetAnnotationActionID"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of annotations on the 1st page is: " + annotCount.ToString() + vbCrLf
Dim actionID As Integer = -1
Dim actionType As PdfActionType = PdfActionType.ActionTypeUnknown
For annotID As Integer = 0 To annotCount - 1
message = message + "annotID: " + annotID.ToString() + " subtype: "
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + annotSubtype + " action: "
actionID = gdpicturePDF.GetAnnotationActionID(annotID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
actionType = gdpicturePDF.GetActionType(actionID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + actionType.ToString()
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message = message + vbCrLf
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationActionID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
{
int annotCount = gdpicturePDF.GetAnnotationCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "The number of annotations on the 1st page is: " + annotCount.ToString() + "\n";
int actionID = -1;
PdfActionType actionType = PdfActionType.ActionTypeUnknown;
for (int annotID = 0; annotID < annotCount; annotID++)
{
message = message + "annotID: " + annotID.ToString() + " subtype: ";
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
message = message + annotSubtype + " action: ";
actionID = gdpicturePDF.GetAnnotationActionID(annotID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
actionType = gdpicturePDF.GetActionType(actionID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + actionType.ToString();
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
}
else
message = message + gdpicturePDF.GetStat().ToString();
message = message + "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetAnnotationCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Associates a specified action (identified with a unique action identifier) with a required annotation object, that is specified by its index related to the currently
selected page of the loaded PDF document.
At this time it is supported by the toolkit to only associate one action within one annotation object.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
A unique action identifier specifying a required action object. You can obtain this identifier when creating an action, for example,
using the , , , , or methods.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
Also be aware that at this time it is not supported by the toolkit to add multiple actions per one annotation object.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to create a PDF document of 5 pages with 4 link annotations on each page, while these links are associated with the predefined named actions.
Dim failure As Boolean = True
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionFirstPageID As Integer = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedFirstPage)
status = gdpicturePDF.GetStat()
Dim actionPrevPageID As Integer = -1
If status = GdPictureStatus.OK Then
actionPrevPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedPrevPage)
status = gdpicturePDF.GetStat()
End If
Dim actionNextPageID As Integer = -1
If status = GdPictureStatus.OK Then
actionNextPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedNextPage)
status = gdpicturePDF.GetStat()
End If
Dim actionLastPageID As Integer = -1
If status = GdPictureStatus.OK Then
actionLastPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedLastPage)
status = gdpicturePDF.GetStat()
End If
If status = GdPictureStatus.OK Then
Dim i As Integer = 0, annotID As Integer = -1
Do
i += 1
failure = True
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(12) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 1, 0.5F, "This is the page " + i.ToString()) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, 4, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "First page") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 4, 1, 7, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Prev. page") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 7, 1, 10, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Next page") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 10, 1, 13, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Last page") = GdPictureStatus.OK) Then
annotID = gdpicturePDF.AddLinkAnnotation(1, 1, 3, 1, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionFirstPageID) = GdPictureStatus.OK) Then
annotID = gdpicturePDF.AddLinkAnnotation(4, 1, 3, 1, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionPrevPageID) = GdPictureStatus.OK) Then
annotID = gdpicturePDF.AddLinkAnnotation(7, 1, 3, 1, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetAnnotationAction(annotID, actionNextPageID) = GdPictureStatus.OK) Then
annotID = gdpicturePDF.AddLinkAnnotation(10, 1, 3, 1, True, 255, 0, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetAnnotationAction(annotID, actionLastPageID)
failure = (status <> GdPictureStatus.OK)
End If
End If
End If
End If
End If
Loop While (Not failure) AndAlso (i < 5)
If Not failure Then
failure = (gdpicturePDF.SaveToFile("annots_with_actions.pdf") <> GdPictureStatus.OK)
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been followed successfully. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: SetAnnotationAction")
Else
MessageBox.Show("The example HAS been followed successfully." + vbCrLf + "The PDF document has been saved.", "Example: SetAnnotationAction")
End If
gdpicturePDF.Dispose()
bool failure = true;
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionFirstPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedFirstPage);
status = gdpicturePDF.GetStat();
int actionPrevPageID = -1;
if (status == GdPictureStatus.OK)
{
actionPrevPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedPrevPage);
status = gdpicturePDF.GetStat();
}
int actionNextPageID = -1;
if (status == GdPictureStatus.OK)
{
actionNextPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedNextPage);
status = gdpicturePDF.GetStat();
}
int actionLastPageID = -1;
if (status == GdPictureStatus.OK)
{
actionLastPageID = gdpicturePDF.NewActionNamed(PdfActionNamed.ActionNamedLastPage);
status = gdpicturePDF.GetStat();
}
if (status == GdPictureStatus.OK)
{
int i = 0, annotID = -1;
do
{
i++; failure = true;
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(12) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 1, 0.5f, "This is the page " + i.ToString()) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, 4, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "First page") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 4, 1, 7, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Prev. page") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 7, 1, 10, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Next page") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 10, 1, 13, 2, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Last page") == GdPictureStatus.OK))
{
annotID = gdpicturePDF.AddLinkAnnotation(1, 1, 3, 1, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionFirstPageID) == GdPictureStatus.OK))
{
annotID = gdpicturePDF.AddLinkAnnotation(4, 1, 3, 1, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionPrevPageID) == GdPictureStatus.OK))
{
annotID = gdpicturePDF.AddLinkAnnotation(7, 1, 3, 1, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (gdpicturePDF.SetAnnotationAction(annotID, actionNextPageID) == GdPictureStatus.OK))
{
annotID = gdpicturePDF.AddLinkAnnotation(10, 1, 3, 1, true, 255, 0, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetAnnotationAction(annotID, actionLastPageID);
failure = (status != GdPictureStatus.OK);
}
}
}
}
}
} while ((!failure) && (i < 5));
if (!failure)
failure = (gdpicturePDF.SaveToFile("annots_with_actions.pdf") != GdPictureStatus.OK);
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been followed successfully. The presumed status: " + gdpicturePDF.GetStat().ToString(), "Example: SetAnnotationAction");
else
MessageBox.Show("The example HAS been followed successfully.\nThe PDF document has been saved.", "Example: SetAnnotationAction");
gdpicturePDF.Dispose();
Removes action from annotation object specified by its index on the currently selected page of the loaded PDF document.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Adds a text annotation object, so called "sticky note" annotation, on the currently selected page of the loaded PDF document. The subtype attribute of this
annotation is "Text". When opened, it displays a pop-up window with text, when closed, it appears as an icon according to what you have specified.
This method uses the RGB color space for specifying the required (background) color of the annotation object.Since each text annotation makes use of an associated pop-up window, adding a text annotation to your document includes at the same adding an annotation
object, that represents this pop-up window. The subtype attribute of this annotation is "Popup" and therefore the resulting count of all annotations in your
document increases by two. This pop-up annotation object is inscribed in the internal structure of the current document.
A member of the PdfStickyNoteAnnotationIcon enumeration. The name of the icon to be used when displaying the annotation.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The subject of the newly added annotation object.
The content of the newly added annotation object, that means the text displayed in the annotation's note and in its associated pop-up window.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
A flag specifying whether the annotation should initially be displayed open, means whether the annotation's pop-up window should be opened.
The initial value is false (closed).
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's pop-up window is to be located.
The value is expressed in the currently set units according to the currently used coordinate space.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's pop-up window is to be located.
The value is expressed in the currently set units according to the currently used coordinate space.
The width of the annotation's pop-up window, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's pop-up window, expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation. Likewise, just to remind you
that adding a text annotation increases the resulting count of all annotations in your document by two, as it is described above.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index (of the added annotation object of the subtype "Text") from 0 to -1 related to the currently
selected page. The method can be subsequently used to determine if this method has been successful.
How to create a yellow sticky note annotation on a new page of the PDF document.
Dim caption As String = "Example: AddStickyNoteAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
Dim annotID As Integer = gdpicturePDF.AddStickyNoteAnnotation(PdfStickyNoteAnnotationIcon.PdfAnnotationIconComment, 5, 5,
"GdPicture", "Important note!", "This is a sticky note annotation.",
0.75F, True, 255, 255, 0, 15, 5, 10, 10)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("stickynote.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddStickyNoteAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddStickyNoteAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
int annotID = gdpicturePDF.AddStickyNoteAnnotation(PdfStickyNoteAnnotationIcon.PdfAnnotationIconComment,
5, 5, "GdPicture", "Important note!", "This is a sticky note annotation.",
0.75f, true, 255, 255, 0, 15, 5, 10, 10);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
GdPictureStatus status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
GdPictureStatus status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("stickynote.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddStickyNoteAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a rubber stamp annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Stamp". This
annotation displays text or graphics in the way as if they were stamped on the page according to the defined parameters. When it is opened, it displays a
pop-up window with the content according to what you have specified.
This method uses the RGB color space for specifying the required color of the annotation object.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The content of the newly added annotation object, that means the text displayed in the annotation's note and in its associated pop-up window.
A member of the PdfRubberStampAnnotationIcon enumeration. The name of an icon, means the appearance of a stamp, to be used when displaying the annotation.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation. Likewise, just to inform you, that the
toolkit doesn't create (unlike other applications can) a standalone associated pop-up annotation object within the internal document structure when creating the new stamp annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a green stamp annotation on a new page of the PDF document.
Dim caption As String = "Example: AddStampAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
Dim annotID As Integer = gdpicturePDF.AddStampAnnotation(5, 10, 10, 7, "GdPicture", "This is a stamp annotation.",
PdfRubberStampAnnotationIcon.Approved, 0.75F, 0, 255, 0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("stamp.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddStampAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddStampAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
int annotID = gdpicturePDF.AddStampAnnotation(5, 10, 10, 7, "GdPicture", "This is a stamp annotation.",
PdfRubberStampAnnotationIcon.Approved, 0.75f, 0, 255, 0);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
GdPictureStatus status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
GdPictureStatus status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("stamp.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddStampAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a line annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Line". This annotation
displays a single straight line according to the defined parameters. When it is opened, it displays a pop-up window with the content according to what you have specified.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the color of the line.
The horizontal (X) coordinate of the starting point of the line to be drawn. The value of this coordinate is expressed in the currently set units
according to the currently used coordinate space, see the Remarks section below.
The vertical (Y) coordinate of the starting point of the line to be drawn. The value of this coordinate is expressed in the currently set units
according to the currently used coordinate space, see the Remarks section below.
The horizontal (X) coordinate of the ending point of the line to be drawn. The value of this coordinate is expressed in the currently set units
according to the currently used coordinate space, see the Remarks section below.
The vertical (Y) coordinate of the ending point of the line to be drawn. The value of this coordinate is expressed in the currently set units according
to the currently used coordinate space, see the Remarks section below.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The content of the newly added annotation object, that means the text displayed in the annotation's note and in its associated pop-up window.
A member of the PdfAnnotationLineEndingStyle enumeration. It is the line ending style used for the starting point when drawing a line.
A member of the PdfAnnotationLineEndingStyle enumeration. It is the line ending style used for the ending point when drawing a line.
Set this parameter to true, if you want to display the text specified by the Contents parameter as a caption in the appearance of the line,
otherwise set it to false. The text should be rendered in a manner appropriate to the content, taking into account factors such as writing direction.
The initial value is false.
The width of the line used to draw the line annotation, expressed in the current units specified by the SetMeasurementUnit method.
A member of the PdfAnnotationBorderStyle enumeration. The style of the line used to draw the line annotation.
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the dashes in the dash pattern used to draw the line.
Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the gaps in the dash pattern used to draw the line.
Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
The amount of red color to be used for the resulting color of the drawn line. Use the value between 0 and 255.
The amount of green color to be used for the resulting color of the drawn line. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color of the drawn line. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation. Likewise, just to inform you, that the
toolkit doesn't create (unlike other applications can) a standalone associated pop-up annotation object within the internal document structure when creating the new line annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a blue line annotation on a new page of the PDF document.
Dim caption As String = "Example: AddLineAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
Dim annotID As Integer = gdpicturePDF.AddLineAnnotation(5, 5, 10, 5, "GdPicture", "This is a line annotation.",
PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleDiamond, PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleDiamond,
True, 0.2F, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleInset, 0, 0, 0.75F, 0, 0, 255)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("line.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddLineAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLineAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
int annotID = gdpicturePDF.AddLineAnnotation(5, 5, 10, 5, "GdPicture", "This is a line annotation.",
PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleDiamond, PdfAnnotationLineEndingStyle.PdfAnnotationLineEndingStyleDiamond,
true, 0.2f, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleInset, 0, 0, 0.75f, 0, 0, 255);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
GdPictureStatus status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
GdPictureStatus status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("line.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddLineAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a circle or an ellipse annotation object to the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Circle".
The required shape is inscribed within the annotation's bounding box. When the annotation is opened, it displays a pop-up window with the content according to what you have specified.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the border color of the circle or ellipse.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The content of the newly added annotation object, that means the text displayed in the annotation's note and in its associated pop-up window.
The width of the line used to draw the required shape, expressed in the current units specified by the SetMeasurementUnit method.
A member of the PdfAnnotationBorderStyle enumeration. The style of the line used to draw the required shape.
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the dashes in the dash pattern used to draw
the required shape. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the gaps in the dash pattern used to draw
the required shape. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
The amount of red color to be used for the resulting border color. Use the value between 0 and 255.
The amount of green color to be used for the resulting border color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting border color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation. Likewise, just to inform you, that the
toolkit doesn't create (unlike other applications can) a standalone associated pop-up annotation object within the internal document structure when creating the new circle annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a blue circle annotation on a new page of the PDF document.
Dim caption As String = "Example: AddCircleAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
Dim annotID As Integer = gdpicturePDF.AddCircleAnnotation(5, 10, 10, 6, "GdPicture", "This is a circle annotation.",
0.5F, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, 0.4F, 0.2F,
0.5F, 0, 0, 255)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("circle.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddCircleAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddCircleAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
int annotID = gdpicturePDF.AddCircleAnnotation(5, 10, 10, 6, "GdPicture", "This is a circle annotation.",
0.5f, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, 0.4f, 0.2f,
0.5f, 0, 0, 255);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
GdPictureStatus status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
GdPictureStatus status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("circle.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddCircleAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a square or a rectangle annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Square".
The required shape is inscribed within the annotation's bounding box. When the annotation is opened, it displays a pop-up window with the content according to what you have specified.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the border color of the square or rectangle.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The content of the newly added annotation object, that means the text displayed in the annotation's note and in its associated pop-up window.
The width of the line used to draw the required shape, expressed in the current units specified by the SetMeasurementUnit method.
A member of the PdfAnnotationBorderStyle enumeration. The style of the line used to draw the required shape.
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the dashes in the dash pattern used to draw
the required shape. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
If the style of the line (the LineStyle parameter) is dashed, this value defines the width of the gaps in the dash pattern used to draw
the required shape. Otherwise, this parameter is ignored. The value is expressed in the current units specified by the SetMeasurementUnit method.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
The amount of red color to be used for the resulting border color. Use the value between 0 and 255.
The amount of green color to be used for the resulting border color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting border color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation. Likewise, just to inform you, that the
toolkit doesn't create (unlike other applications can) a standalone associated pop-up annotation object within the internal document structure when creating the new square annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a blue square annotation on a new page of the PDF document.
Dim caption As String = "Example: AddSquareAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
Dim annotID As Integer = gdpicturePDF.AddSquareAnnotation(5, 10, 10, 6, "GdPicture", "This is a square annotation.",
0.5F, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, 0.4F, 0.2F,
0.5F, 0, 0, 255)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("square.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddSquareAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddSquareAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
int annotID = gdpicturePDF.AddSquareAnnotation(5, 10, 10, 6, "GdPicture", "This is a square annotation.",
0.5f, PdfAnnotationBorderStyle.PdfAnnotationBorderStyleDashed, 0.4f, 0.2f,
0.5f, 0, 0, 255);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
GdPictureStatus status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
GdPictureStatus status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("square.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddSquareAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a free text annotation object to the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "FreeText". This
annotation displays text directly on the page according to what you have specified. This text is always visible, as this annotation doesn't have a pop-up
window and can't be opened or closed. This method uses the RGB color space for specifying the required colors.
Adds a free text annotation object to the currently selected page of the loaded PDF document.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Set this parameter to true, if you want to display borders around annotation's text, otherwise set it to false. These borders are inscribed
within the annotation's bounding box and they are drawn with the same color as it is specified for annotation's text.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The subject of the newly added annotation object.
The content of the newly added annotation object, that means annotation's text to be displayed.
The resource name of the font you prefer for drawing the annotation's content. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for drawing the annotation's content. Please note that 1 point = 1/72 inch.
The amount of red color to be used for the resulting color when displaying annotation's text. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying annotation's text. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying annotation's text. Use the value between 0 and 255.
The amount of red color to be used for the resulting color when displaying the annotation's background. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying the annotation's background. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying the annotation's background. Use the value between 0 and 255.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a free text annotation on a new page of the PDF document.
Dim caption As String = "Example: AddFreeTextAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim textSize As Single = 20
Dim text As String = "GdPicture freetext annot."
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim textW As Single = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim textH As Single = gdpicturePDF.GetTextHeight(fontResName, textSize, False)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
If (status1 = GdPictureStatus.OK) AndAlso (status2 = GdPictureStatus.OK) Then
Dim annotID As Integer = gdpicturePDF.AddFreeTextAnnotation(5, 5, textW, textH, False, "GdPicture", "Review", text,
fontResName, textSize, 165, 42, 42, 255, 165, 0, 0.75F)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
status1 = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
status2 = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("freetext.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddFreeTextAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddFreeTextAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
float textSize = 20;
string text = "GdPicture freetext annot.";
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float textW = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
GdPictureStatus status1 = gdpicturePDF.GetStat();
float textH = gdpicturePDF.GetTextHeight(fontResName, textSize, false);
GdPictureStatus status2 = gdpicturePDF.GetStat();
if ((status1 == GdPictureStatus.OK) && (status2 == GdPictureStatus.OK))
{
int annotID = gdpicturePDF.AddFreeTextAnnotation(5, 5, textW, textH, false, "GdPicture", "Review", text,
fontResName, textSize, 165, 42, 42, 255, 165, 0, 0.75f);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("freetext.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddFreeTextAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a free text annotation object to the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "FreeText". This
annotation displays text directly on the page according to what you have specified. This text is always visible, as this annotation doesn't have a pop-up
window and can't be opened or closed. This method uses the CMYK color space for specifying the required colors.
Adds a free text annotation object to the currently selected page of the loaded PDF document.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Set this parameter to true, if you want to display borders around annotation's text, otherwise set it to false. These borders are inscribed
within the annotation's bounding box and they are drawn with the same color as it is specified for annotation's text.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The subject of the newly added annotation object.
The content of the newly added annotation object, that means annotation's text to be displayed.
The resource name of the font you prefer for drawing the annotation's content. You can obtain this name using the method
or any of the AddTrueTypeFont...() methods. For further assistance, please see the Fonts section of the GdPicturePDF class in the Reference Guide.
A text (font) size, in points, for drawing the annotation's content. Please note that 1 point = 1/72 inch.
The amount of cyan color to be used for the resulting color when displaying annotation's text. Use the value between 0 and 255.
The amount of cyan color to be used for the resulting color when displaying annotation's text. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying annotation's text. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying annotation's text. Use the value between 0 and 255.
The amount of cyan color to be used for the resulting color when displaying the annotation's background. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color when displaying the annotation's background. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying the annotation's background. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying the annotation's background. Use the value between 0 and 255.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a free text annotation on a new page of the PDF document.
Dim caption As String = "Example: AddFreeTextAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim textSize As Single = 20
Dim text As String = "GdPicture freetext annot."
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim textW As Single = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim textH As Single = gdpicturePDF.GetTextHeight(fontResName, textSize, False)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
If (status1 = GdPictureStatus.OK) AndAlso (status2 = GdPictureStatus.OK) Then
Dim annotID As Integer = gdpicturePDF.AddFreeTextAnnotation(5, 5, textW, textH, False, "GdPicture", "Review", text,
fontResName, textSize, 90, 213, 213, 90, 0, 90, 255, 0, 0.75F)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
status1 = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
status2 = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("freetext.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddFreeTextAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddFreeTextAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
float textSize = 20;
string text = "GdPicture freetext annot.";
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float textW = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
GdPictureStatus status1 = gdpicturePDF.GetStat();
float textH = gdpicturePDF.GetTextHeight(fontResName, textSize, false);
GdPictureStatus status2 = gdpicturePDF.GetStat();
if ((status1 == GdPictureStatus.OK) && (status2 == GdPictureStatus.OK))
{
int annotID = gdpicturePDF.AddFreeTextAnnotation(5, 5, textW, textH, false, "GdPicture", "Review", text,
fontResName, textSize, 90, 213, 213, 90, 0, 90, 255, 0, 0.75f);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("freetext.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddFreeTextAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption);
}
else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a link annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Link". This annotation
represents an "action ready" link (hypertext link), in other words you can associate an action with this annotation object according to your preference.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the color of the annotation's borders.You
can subsequently assign an action to the created link using the method, as it is explained in the example below. For further assistance,
please see the Actions section of the GdPicturePDF class in the Reference Guide.
Adds an "action ready" link annotation object to the currently selected page of the loaded PDF document. It is a link annotation performing an associated action.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Set this parameter to true, if you want to display borders around the annotation's bounding box, otherwise set it to false. These borders are
inscribed within the annotation's bounding box and they are drawn with the required color.
The amount of red color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a link annotation and how to add an action to this link. The example creates two PDF documents,
which are linked together through the links associated with the GoToR action.
Dim caption As String = "Example: AddLinkAnnotation"
Dim gdpicturePDF As New GdPicturePDF()
Dim failure As Boolean = True
Dim textSize As Single = 12, textWidth As Single = 0, textHeight As Single = 0
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'Creating of the pdf1.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf2.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 0, 0, 255)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf1.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat().ToString(), caption)
Else
failure = True
status = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'Creating of the pdf2.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 0, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf1.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 0, 0, 255)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf2.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat(), caption)
Else
MessageBox.Show("The example HAS been successfully followed." + vbCrLf + "Both newly created PDF documents are linked together.", caption)
End If
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLinkAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
bool failure = true;
float textSize = 12, textWidth = 0, textHeight = 0;
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//Creating of the pdf1.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf2.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 0, 0, 255);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf1.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat().ToString(), caption);
else
{
failure = true;
status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//Creating of the pdf2.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 0, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf1.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 0, 0, 255);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf2.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat(), caption);
else
MessageBox.Show("The example HAS been successfully followed.\nBoth newly created PDF documents are linked together.", caption);
}
gdpicturePDF.Dispose();
Adds a link annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Link". This annotation
represents an "action ready" link (hypertext link), in other words you can associate an action with this annotation object according to your preference.
This method uses the CMYK color space for specifying the required color of the annotation object, here it is the color of the annotation's borders.You
can subsequently assign an action to the created link using the method, as it is explained in the example below. For further assistance,
please see the Actions section of the GdPicturePDF class in the Reference Guide.
Adds an "action ready" link annotation object to the currently selected page of the loaded PDF document. It is a link annotation performing an associated action.
The horizontal (X) coordinate of the closest point to the currently defined origin where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Set this parameter to true, if you want to display borders around the annotation's bounding box, otherwise set it to false.
These borders are inscribed within the annotation's bounding box and they are drawn with the required color.
The amount of cyan color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a link annotation and how to add an action to this link. The example creates two PDF documents,
which are linked together through the links associated with the GoToR action.
Dim caption As String = "Example: AddLinkAnnotation"
Dim gdpicturePDF As New GdPicturePDF()
Dim failure As Boolean = True
Dim textSize As Single = 12, textWidth As Single = 0, textHeight As Single = 0
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'Creating of the pdf1.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf2.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 255, 255, 0, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf1.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat().ToString(), caption)
Else
failure = True
status = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'Creating of the pdf2.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(0, 255, 255, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf1.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, 255, 255, 0, 0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf2.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat(), caption)
Else
MessageBox.Show("The example HAS been successfully followed." + vbCrLf + "Both newly created PDF documents are linked together.", caption)
End If
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLinkAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
bool failure = true;
float textSize = 12, textWidth = 0, textHeight = 0;
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//Creating of the pdf1.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf2.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 255, 255, 0, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf1.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat().ToString(), caption);
else
{
failure = true;
status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//Creating of the pdf2.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(0, 255, 255, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf1.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, 255, 255, 0, 0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf2.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat(), caption);
else
MessageBox.Show("The example HAS been successfully followed.\nBoth newly created PDF documents are linked together.", caption);
}
gdpicturePDF.Dispose();
Adds a link annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Link". This annotation
represents an "action ready" link (hypertext link), in other words you can associate an action with this annotation object according to your preference.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the color of the annotation's borders.You
can subsequently assign an action to the created link using the method, as it is explained in the example below. For further assistance,
please see the Actions section of the GdPicturePDF class in the Reference Guide.
Adds an "action ready" link annotation object to the currently selected page of the loaded PDF document. It is a link annotation performing an associated action.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Set this parameter to true, if you want to display borders around the annotation's bounding box, otherwise set it to false. These borders are
inscribed within the annotation's bounding box and they are drawn with the required color.
A color object that defines the required color to be used for displaying the link borders, if the Borders parameter is set to true.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a link annotation and how to add an action to this link. The example creates two PDF documents,
which are linked together through the links associated with the GoToR action.
Dim caption As String = "Example: AddLinkAnnotation"
Dim gdpicturePDF As New GdPicturePDF()
Dim failure As Boolean = True
Dim textSize As Single = 12, textWidth As Single = 0, textHeight As Single = 0
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'Creating of the pdf1.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf2.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, Color.Blue)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf1.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat().ToString(), caption)
Else
failure = True
status = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
'Creating of the pdf2.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.NewPage(21, 29.7F) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Red) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim text As String = "Navigate to pdf1.pdf"
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, True)
status = gdpicturePDF.GetStat()
End If
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) = GdPictureStatus.OK) Then
Dim linkIdx As Integer = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, True, Color.Blue)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim actionID As Integer = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", False, 1, 0, 0, 0, 0, 1)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetAnnotationAction(linkIdx, actionID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SaveToFile("pdf2.pdf") = GdPictureStatus.OK) AndAlso (gdpicturePDF.CloseDocument() = GdPictureStatus.OK) Then
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption)
failure = False
End If
End If
End If
End If
End If
End If
End If
If failure Then
MessageBox.Show("The example HAS NOT been successfully followed." + vbCrLf + "The last known error status is " + gdpicturePDF.GetStat(), caption)
Else
MessageBox.Show("The example HAS been successfully followed." + vbCrLf + "Both newly created PDF documents are linked together.", caption)
End If
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLinkAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
bool failure = true;
float textSize = 12, textWidth = 0, textHeight = 0;
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//Creating of the pdf1.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf2.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, Color.Blue);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf2.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf1.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf1.pdf has been successfully created with the link that guides to the pdf2.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat().ToString(), caption);
else
{
failure = true;
status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
//Creating of the pdf2.pdf.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.NewPage(21, 29.7f) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Red) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
string text = "Navigate to pdf1.pdf";
textWidth = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
textHeight = gdpicturePDF.GetTextHeight(fontResName, textSize, true);
status = gdpicturePDF.GetStat();
}
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 1, 1, textWidth + 1, textHeight + 1, TextAlignment.TextAlignmentNear, TextAlignment.TextAlignmentNear, text) == GdPictureStatus.OK))
{
int linkIdx = gdpicturePDF.AddLinkAnnotation(1, 1, textWidth, textHeight, true, Color.Blue);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int actionID = gdpicturePDF.NewActionGoToR(PdfDestinationType.DestinationTypeXYZ, "pdf1.pdf", false, 1, 0, 0, 0, 0, 1);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetAnnotationAction(linkIdx, actionID) == GdPictureStatus.OK) &&
(gdpicturePDF.SaveToFile("pdf2.pdf") == GdPictureStatus.OK) && (gdpicturePDF.CloseDocument() == GdPictureStatus.OK))
{
MessageBox.Show("The pdf2.pdf has been successfully created with the link that guides to the pdf1.pdf.", caption);
failure = false;
}
}
}
}
}
}
}
if (failure)
MessageBox.Show("The example HAS NOT been successfully followed.\nThe last known error status is " + gdpicturePDF.GetStat(), caption);
else
MessageBox.Show("The example HAS been successfully followed.\nBoth newly created PDF documents are linked together.", caption);
}
gdpicturePDF.Dispose();
Adds a link annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Link". This annotation
represents a hypertext link annotation, that has associated the action of the type URI. The destination of the assigned action is the URI (web destination) you have specified.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the color of the annotation's borders.
For further assistance, please see the Actions section of the GdPicturePDF class in the Reference Guide.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The uniform resource identifier to resolve, encoded in 7-bit ASCII. In other words, the web destination of this link annotation, for example "http://www.gdpicture.com".
Set this parameter to true, if you want to display borders around the annotation's bounding box, otherwise set it to false. These borders are
inscribed within the annotation's bounding box and they are drawn with the required color.
The amount of red color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true.
Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true.
Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true.
Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a link annotation on a new page in the PDF document, that points to a web page.
Dim caption As String = "Example: AddLinkToWebAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
gdpicturePDF.SelectPage(1)
Dim textSize As Single = 20
Dim text As String = "Navigate to www.gdpicture.com"
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 140, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim textW As Single = gdpicturePDF.GetTextWidth(fontResName, textSize, text)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim textH As Single = gdpicturePDF.GetTextHeight(fontResName, textSize, False)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
If (status1 = GdPictureStatus.OK) AndAlso (status2 = GdPictureStatus.OK) Then
If gdpicturePDF.DrawText(fontResName, 5, 10 + textH, text) = GdPictureStatus.OK Then
'Do not forget to select the required page before adding an annotation, the currently selected page is 1.
Dim annotID As Integer = gdpicturePDF.AddLinkToWebAnnotation(5, 10 - textH / 2, textW, 2 * textH, "www.gdpicture.com", True, 0, 0, 255)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
status1 = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
status2 = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("linkwebannot.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddLinkToWebAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption)
End If
Else
MessageBox.Show("Adding font and its properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLinkToWebAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
gdpicturePDF.SelectPage(1);
float textSize = 20;
string text = "Navigate to www.gdpicture.com";
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 140, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
float textW = gdpicturePDF.GetTextWidth(fontResName, textSize, text);
GdPictureStatus status1 = gdpicturePDF.GetStat();
float textH = gdpicturePDF.GetTextHeight(fontResName, textSize, false);
GdPictureStatus status2 = gdpicturePDF.GetStat();
if ((status1 == GdPictureStatus.OK) && (status2 == GdPictureStatus.OK))
{
if (gdpicturePDF.DrawText(fontResName, 5, 10 + textH, text) == GdPictureStatus.OK)
{
//Do not forget to select the required page before adding an annotation, the currently selected page is 1.
int annotID = gdpicturePDF.AddLinkToWebAnnotation(5, 10-textH/2, textW, 2*textH, "www.gdpicture.com", true, 0, 0, 255);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("linkwebannot.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddLinkToWebAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption);
}
else
MessageBox.Show("Adding font and its properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a link annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Link". This annotation
represents a hypertext link annotation, that has associated a go-to-page action (the action of the type GoTo). The destination of the assigned action is the
page in the current document according to your preference.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the color of the annotation's borders.
For further assistance, please see the Actions section of the GdPicturePDF class in the Reference Guide.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The page number of the destination's page in the current document. It must be a value from 1 to .
The horizontal (X) coordinate of the closest point to the currently defined origin on the destination's page, where the link jumps.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin on the destination's page, where the link jumps.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
Set this parameter to true, if you want to display borders around the annotation's bounding box, otherwise set it to false. These borders are
inscribed within the annotation's bounding box and they are drawn with the required color.
The amount of red color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true.
Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true.
Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying the link borders, if the Borders parameter is set to true.
Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create a link annotation on a new page in the PDF document, that points to a page in the same document. This example creates two pages in a
new PDF document with link annotation on each of them, so that these links point to the respective pages.
Dim caption As String = "Example: AddLinkToPageAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
gdpicturePDF.SelectPage(1)
Dim textSize As Single = 20
Dim fontResName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 140, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) Then
Dim textW As Single = gdpicturePDF.GetTextWidth(fontResName, textSize, "Goto Page 2")
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim textH As Single = gdpicturePDF.GetTextHeight(fontResName, textSize, False)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
If (status1 = GdPictureStatus.OK) AndAlso (status2 = GdPictureStatus.OK) Then
If gdpicturePDF.DrawText(fontResName, 0, textH, "Goto page 2") = GdPictureStatus.OK Then
'The currently selected page is 1.
Dim annotID As Integer = gdpicturePDF.AddLinkToPageAnnotation(0, 0, textW, textH, 2, 0, 0, True, 0, 0, 255)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Please always select the required page before adding an annotation.
If (gdpicturePDF.SelectPage(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(255, 140, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(textSize) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 0, textH, "Goto page 1") = GdPictureStatus.OK) Then
'The currently selected page is 2.
annotID = gdpicturePDF.AddLinkToPageAnnotation(0, 0, textW, textH, 1, 0, 0, True, 0, 0, 255)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("linkpageannot.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file has NOT been saved. Status: " + gdpicturePDF.GetStat(), caption)
End If
Else
MessageBox.Show("The AddLinkToPageAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddLinkToPageAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption)
End If
Else
MessageBox.Show("Adding font and its properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddLinkToPageAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
gdpicturePDF.SelectPage(1);
float textSize = 20;
string fontResName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontHelvetica);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 140, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK))
{
float textW = gdpicturePDF.GetTextWidth(fontResName, textSize, "Goto Page 2");
GdPictureStatus status1 = gdpicturePDF.GetStat();
float textH = gdpicturePDF.GetTextHeight(fontResName, textSize, false);
GdPictureStatus status2 = gdpicturePDF.GetStat();
if ((status1 == GdPictureStatus.OK) && (status2 == GdPictureStatus.OK))
{
if (gdpicturePDF.DrawText(fontResName, 0, textH, "Goto page 2") == GdPictureStatus.OK)
{
//The currently selected page is 1.
int annotID = gdpicturePDF.AddLinkToPageAnnotation(0, 0, textW, textH, 2, 0, 0, true, 0, 0, 255);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Please always select the required page before adding an annotation.
if ((gdpicturePDF.SelectPage(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(255, 140, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(textSize) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 0, textH, "Goto page 1") == GdPictureStatus.OK))
{
//The currently selected page is 2.
annotID = gdpicturePDF.AddLinkToPageAnnotation(0, 0, textW, textH, 1, 0, 0, true, 0, 0, 255);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("linkpageannot.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file has NOT been saved. Status: " + gdpicturePDF.GetStat(), caption);
}
else
MessageBox.Show("The AddLinkToPageAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddLinkToPageAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The DrawText() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTextWidth()/GetTextHeight() method has failed with the status: " + status1.ToString() + "/" + status2.ToString(), caption);
}
else
MessageBox.Show("Adding font and its properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a file attachment annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is
"FileAttachment". This annotation contains a reference to a file typically embedded in the current document. Opening this annotation you can extract, view or store the attached file.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the background color of the annotation's icon.
Adds a file attachment annotation object to the currently selected page of the loaded PDF document.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The binary content of the file associated with the annotation object.
The name of the file associated with the annotation object.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The description of the file associated with the annotation object.
The amount of red color to be used for the resulting color when displaying an annotation's icon. Use the value between 0 and 255.
The amount of green color to be used for the resulting color when displaying an annotation's icon. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color when displaying an annotation's icon. Use the value between 0 and 255.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
A member of the PdfFileAttachmentAnnotIcon enumeration. The name of the icon to be used when displaying the annotation.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create an annotation with the attached file on a new page of the PDF document.
Dim caption As String = "Example: AddFileAttachmentAnnot"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim status As GdPictureStatus = GdPictureStatus.OK
'Set the filename of the file you want to attach.
Dim filename As String = "your_file_attachment"
Dim data As Byte() = Nothing
Try
data = IO.File.ReadAllBytes(filename)
Catch e As Exception
status = GdPictureStatus.Aborted
MessageBox.Show("The file to be attached can't be read. Exception: " + e.Message, caption)
End Try
If status = GdPictureStatus.OK Then
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim annotID As Integer = gdpicturePDF.AddFileAttachmentAnnot(5, 5, 2, 4, data, filename, "GdPicture", "Attachment for review",
255, 165, 0, 0.75F, PdfFileAttachmentAnnotIcon.Paperclip)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("attachment.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddFileAttachmentAnnot() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddFileAttachmentAnnot";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
GdPictureStatus status = GdPictureStatus.OK;
//Set the filename of the file you want to attach.
string filename = "your_file_attachment";
byte[] data = null;
try
{
data = File.ReadAllBytes(filename);
}
catch (Exception e)
{
status = GdPictureStatus.Aborted;
MessageBox.Show("The file to be attached can't be read. Exception: " + e.Message, caption);
}
if (status == GdPictureStatus.OK)
{
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
int annotID = gdpicturePDF.AddFileAttachmentAnnot(5, 5, 2, 4, data, filename, "GdPicture", "Attachment for review",
255, 165, 0, 0.75f, PdfFileAttachmentAnnotIcon.Paperclip);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
GdPictureStatus status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
GdPictureStatus status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("attachment.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddFileAttachmentAnnot() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a file attachment annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is
"FileAttachment". This annotation contains a reference to a file typically embedded in the current document. Opening this annotation you can extract, view or store the attached file.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the background color of the annotation's icon.
Adds a file attachment annotation object to the currently selected page of the loaded PDF document.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The binary content of the file associated with the annotation object.
The name of the file associated with the annotation object.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The description of the file associated with the annotation object.
The amount of cyan color to be used for the resulting color when displaying an annotation's icon. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color when displaying an annotation's icon. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color when displaying an annotation's icon. Use the value between 0 and 255.
The amount of black color to be used for the resulting color when displaying an annotation's icon. Use the value between 0 and 255.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
A member of the PdfFileAttachmentAnnotIcon enumeration. The name of the icon to be used when displaying the annotation.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create an annotation with the attached file on a new page of the PDF document.
Dim caption As String = "Example: AddFileAttachmentAnnot"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim status As GdPictureStatus = GdPictureStatus.OK
'Set the filename of the file you want to attach.
Dim filename As String = "your_file_attachment"
Dim data As Byte() = Nothing
Try
data = IO.File.ReadAllBytes(filename)
Catch e As Exception
status = GdPictureStatus.Aborted
MessageBox.Show("The file to be attached can't be read. Exception: " + e.Message, caption)
End Try
If status = GdPictureStatus.OK Then
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim annotID As Integer = gdpicturePDF.AddFileAttachmentAnnot(5, 5, 2, 4, data, filename, "GdPicture", "Attachment for review",
0, 90, 255, 0, 0.75F, PdfFileAttachmentAnnotIcon.Paperclip)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("attachment.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddFileAttachmentAnnot() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddFileAttachmentAnnot";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
GdPictureStatus status = GdPictureStatus.OK;
//Set the filename of the file you want to attach.
string filename = "your_file_attachment";
byte[] data = null;
try
{
data = File.ReadAllBytes(filename);
}
catch (Exception e)
{
status = GdPictureStatus.Aborted;
MessageBox.Show("The file to be attached can't be read. Exception: " + e.Message, caption);
}
if (status == GdPictureStatus.OK)
{
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
int annotID = gdpicturePDF.AddFileAttachmentAnnot(5, 5, 2, 4, data, filename, "GdPicture", "Attachment for review",
0, 90, 255, 0, 0.75f, PdfFileAttachmentAnnotIcon.Paperclip);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
GdPictureStatus status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
GdPictureStatus status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("attachment.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddFileAttachmentAnnot() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Adds a file attachment annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is
"FileAttachment". This annotation contains a reference to a file typically embedded in the current document. Opening this annotation you can extract, view or store the attached file.
This method uses the RGB color space for specifying the required color of the annotation object, here it is the background color of the annotation's icon.
Adds a file attachment annotation object to the currently selected page of the loaded PDF document.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The binary content of the file associated with the annotation object.
The name of the file associated with the annotation object.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The description of the file associated with the annotation object.
A color object that defines the color to be used for displaying an annotation's icon.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
A member of the PdfFileAttachmentAnnotIcon enumeration. The name of the icon to be used when displaying the annotation.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before adding a required annotation.
You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the method
according to the current coordinate space defined by the method.
The unique annotation index from 0 to -1 related to the currently selected page.
The method can be subsequently used to determine if this method has been successful.
How to create an annotation with the attached file on a new page of the PDF document.
Dim caption As String = "Example: AddFileAttachmentAnnot"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
Dim status As GdPictureStatus = GdPictureStatus.OK
'Set the filename of the file you want to attach.
Dim filename As String = "your_file_attachment"
Dim data As Byte() = Nothing
Try
data = IO.File.ReadAllBytes(filename)
Catch e As Exception
status = GdPictureStatus.Aborted
MessageBox.Show("The file to be attached can't be read. Exception: " + e.Message, caption)
End Try
If status = GdPictureStatus.OK Then
'Please always select the required page before adding an annotation.
If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
Dim annotID As Integer = gdpicturePDF.AddFileAttachmentAnnot(5, 5, 2, 4, data, filename, "GdPicture", "Attachment for review",
Color.Chocolate, 0.75F, PdfFileAttachmentAnnotIcon.Paperclip)
'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
message = message + " subtype: "
If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
If gdpicturePDF.SaveToFile("attachment.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The AddFileAttachmentAnnot() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddFileAttachmentAnnot";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
GdPictureStatus status = GdPictureStatus.OK;
//Set the filename of the file you want to attach.
string filename = "your_file_attachment";
byte[] data = null;
try
{
data = File.ReadAllBytes(filename);
}
catch (Exception e)
{
status = GdPictureStatus.Aborted;
MessageBox.Show("The file to be attached can't be read. Exception: " + e.Message, caption);
}
if (status == GdPictureStatus.OK)
{
//Please always select the required page before adding an annotation.
if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
{
int annotID = gdpicturePDF.AddFileAttachmentAnnot(5, 5, 2, 4, data, filename, "GdPicture", "Attachment for review",
Color.Chocolate, 0.75f, PdfFileAttachmentAnnotIcon.Paperclip);
//Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string annotType = gdpicturePDF.GetAnnotationType(annotID);
GdPictureStatus status1 = gdpicturePDF.GetStat();
string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
GdPictureStatus status2 = gdpicturePDF.GetStat();
string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
message = message + " subtype: ";
if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
if (gdpicturePDF.SaveToFile("attachment.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The AddFileAttachmentAnnot() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Returns the number of all annotation objects contained within the currently selected page of the loaded PDF document.
The standard annotation types are described in the PDF Reference, Section "Annotation Types".
You can subsequently use the method to find out the correct subtype ("Popup", "Text", "FreeText", etc.) of the specific annotation object.
Please note that the final count of all annotation objects on the current page also includes all those Popup annotation objects, that are expressly
detected in the internal structure of the currently loaded PDF document.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method.
You also need to be aware that the final count of all annotations on the page also includes all Popup annotations as well.
You can use the method to determine the subtype ("Popup", "Text", "FreeText", etc.) of the specific annotation object.
The number of all annotation objects on the current page, that includes Popup annotation objects (expressly inscribed in the document's internal structure) as
well. The method can be subsequently used to determine if this method has been successful.
How to find out the number of all annotation objects within the current page of the PDF document.
Dim caption As String = "Example: GetAnnotationCount"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim annots As Integer = 0
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status <> GdPictureStatus.OK Then
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
Else
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString() + vbCrLf
Else
If annotCount = 0 Then
message = message + " does not contain any annotations." + vbCrLf
Else
message = message + " contains " + annotCount.ToString() + " annotations." + vbCrLf
annots = annots + annotCount
End If
End If
End If
Next
message = message + "The total number of annotations in this document is: " + annots.ToString()
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int annots = 0;
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status != GdPictureStatus.OK)
{
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
else
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
{
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString() + "\n";
}
else
{
if (annotCount == 0)
{
message = message + " does not contain any annotations." + "\n";
}
else
{
message = message + " contains " + annotCount.ToString() + " annotations." + "\n";
annots = annots + annotCount;
}
}
}
}
message = message + "The total number of annotations in this document is: " + annots.ToString();
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Removes the required annotation object specified by its index related to the currently selected page of the loaded PDF document.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
Just to remind you to always ensure that you have selected the correct page using the method before removing a required annotation.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove all annotation objects from the loaded PDF document.
Dim caption As String = "Example: RemoveAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString() + ": "
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
For annotID As Integer = annotCount - 1 To 0
status = gdpicturePDF.RemoveAnnotation(annotID)
If status <> GdPictureStatus.OK Then
message = message + "annotID: " + annotID.ToString() + " "
Exit For
End If
Next
message += status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("removed_annots.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString() + ": ";
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int annotID = annotCount - 1; annotID >= 0; annotID--)
{
status = gdpicturePDF.RemoveAnnotation(annotID);
if (status != GdPictureStatus.OK)
{
message = message + "annotID: " + annotID.ToString() + " ";
break;
}
}
message += status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("removed_annots.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the flags of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
These flags define various characteristics of the specified annotation.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
A bitwise combination of values of the PdfAnnotationFlag enumeration. The method can be subsequently used to determine if this method has been successful.
How to find out the annotation's flags of all underline annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationFlags"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = ""
Dim flags As PdfAnnotationFlag = PdfAnnotationFlag.PdfAnnotationFlagDefault
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Underline") Then
message = message + vbCrLf + "AnnotID: " + j.ToString() + " flags: "
flags = gdpicturePDF.GetAnnotationFlags(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim res As PdfAnnotationFlag = flags And PdfAnnotationFlag.PdfAnnotationFlagHidden
message = message + vbCrLf + " hidden: " + (res <> 0).ToString()
res = flags And PdfAnnotationFlag.PdfAnnotationFlagLocked
message = message + " locked: " + (res <> 0).ToString()
res = flags And PdfAnnotationFlag.PdfAnnotationFlagPrint
message = message + " print: " + (res <> 0).ToString()
'You can check out other flags in the same way.
Else
message = message + status.ToString()
End If
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationFlags";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "";
PdfAnnotationFlag flags = PdfAnnotationFlag.PdfAnnotationFlagDefault;
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Underline"))
{
message = message + "\nAnnotID: " + j.ToString() + " flags: ";
flags = gdpicturePDF.GetAnnotationFlags(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
PdfAnnotationFlag res = flags & PdfAnnotationFlag.PdfAnnotationFlagHidden;
message = message + "\n hidden: " + (res != 0).ToString();
res = flags & PdfAnnotationFlag.PdfAnnotationFlagLocked;
message = message + " locked: " + (res != 0).ToString();
res = flags & PdfAnnotationFlag.PdfAnnotationFlagPrint;
message = message + " print: " + (res != 0).ToString();
//You can check out other flags in the same way.
}
else
message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the flags of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
These flags define various characteristics of the specified annotation.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
A bitwise combination of values of the PdfAnnotationFlag enumeration.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to ensure that all annotations in the loaded PDF document will be printed. The example shows you how to set the annotation's flag for printing.
Dim caption As String = "Example: SetAnnotationFlags"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
Dim flags As PdfAnnotationFlag = gdpicturePDF.GetAnnotationFlags(annotID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetAnnotationFlags(annotID, flags Or PdfAnnotationFlag.PdfAnnotationFlagPrint)
End If
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_flags.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationFlags";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
PdfAnnotationFlag flags = gdpicturePDF.GetAnnotationFlags(annotID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.SetAnnotationFlags(annotID, flags | PdfAnnotationFlag.PdfAnnotationFlagPrint);
}
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_flags.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the content (text or description) of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
It can be displayed text for the annotations, that support displaying text (like free text annotations) or an additional description for the other
annotations in readable form. If the specified annotation is associated with an auxiliary pop-up window, it is the content of this pop-up window.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The content of the specified annotation object in a meaning described in the Summary section. The method can be subsequently used to determine if
this method has been successful.
How to retrieve the title, the subject and the content of all text annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationcontent"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = "", title As String = "", subject As String = "", content As String = ""
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Text") Then
message = message + vbCrLf + "AnnotID: " + j.ToString()
message = message + vbCrLf + " title: "
title = gdpicturePDF.GetAnnotationTitle(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + title Else message = message + status.ToString()
message = message + " subject: "
subject = gdpicturePDF.GetAnnotationSubject(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + subject Else message = message + status.ToString()
message = message + " content: "
content = gdpicturePDF.GetAnnotationContents(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + content Else message = message + status.ToString()
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationContents";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "", title = "", subject = "", content = "";
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Text"))
{
message = message + "\nAnnotID: " + j.ToString();
message = message + "\n title: ";
title = gdpicturePDF.GetAnnotationTitle(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + title;
else message = message + status.ToString();
message = message + " subject: ";
subject = gdpicturePDF.GetAnnotationSubject(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + subject;
else message = message + status.ToString();
message = message + " content: ";
content = gdpicturePDF.GetAnnotationContents(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + content;
else message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the content (text or description) of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
It can be displayed text for the annotations, that support displaying text (like free text annotations) or an additional description for the other
annotations in readable form. If the specified annotation is associated with an auxiliary pop-up window, it is the content of this pop-up window.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The new content of the specified annotation object in a meaning described in the Summary section.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the content of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationContents"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
Dim content As String = ""
For annotID As Integer = 0 To annotCount - 1
content = gdpicturePDF.GetAnnotationContents(annotID)
status = gdpicturePDF.SetAnnotationContents(annotID, content + vbCrLf + "Added by GdPicture/Orpalis.")
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_content.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationContents";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
string content = "";
for (int annotID = 0; annotID < annotCount; annotID++)
{
content = gdpicturePDF.GetAnnotationContents(annotID);
status = gdpicturePDF.SetAnnotationContents(annotID, content + "\nAdded by GdPicture/Orpalis.");
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_content.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the type of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
It is always "Annot" for properly defined annotation object. Please use the method to find out the specific subtype of
the required annotation object, as it is shown in the example below.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
Just to remind you, that you need to use the method to find out the specific subtype of the required annotation object, as it is shown in the example below.
The type of the specified annotation object, if defined properly, must be "Annot". Specifically, the correct return value should be always "Annot".
The method can be subsequently used to determine if this method has been successful.
How to find out the type and the subtype of all annotations included in the PDF document.
Dim caption As String = "Example: GetAnnotationType"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status <> GdPictureStatus.OK Then
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
Else
message = message + "Page nr." + i.ToString() + ":" + vbCrLf
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
message = message + "The GetAnnotationCount() method has failed with the status: " + status.ToString() + vbCrLf
Else
If annotCount = 0 Then
message = message + "This page does not contain any annotations." + vbCrLf
Else
Dim annotType As String = ""
Dim annotSubType As String = ""
For j As Integer = 0 To annotCount - 1
annotType = gdpicturePDF.GetAnnotationType(j)
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
message = message + "Annot nr." + j.ToString() + ": Type = " + annotType + " Subtype = " + annotSubType + vbCrLf
Next
End If
End If
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationType";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status != GdPictureStatus.OK)
{
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
else
{
message = message + "Page nr." + i.ToString() + ":\n";
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
{
message = message + "The GetAnnotationCount() method has failed with the status: " + status.ToString() + "\n";
}
else
{
if (annotCount == 0)
{
message = message + "This page does not contain any annotations." + "\n";
}
else
{
string annotType = "";
string annotSubType = "";
for (int j = 0; j < annotCount; j++)
{
annotType = gdpicturePDF.GetAnnotationType(j);
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
message = message + "Annot nr." + j.ToString() + ": Type = " + annotType + " Subtype = " + annotSubType + "\n";
}
}
}
}
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the subtype of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
Please note that the returned subtype values correspond to the Annotation Types naming convention (see PDF Reference, Section "Annotation Types").
The subtype of the specified annotation object as a string, for example "Popup", "Stamp", "Text" and others.
Please refer to the Annotation Types naming convention in PDF Reference, Section "Annotation Types" for the proper subtype values.
The method can be subsequently used to determine if this method has been successful.
How to find out the type and the subtype of all annotations included in the PDF document.
Dim caption As String = "Example: GetAnnotationSubType"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status <> GdPictureStatus.OK Then
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
Else
message = message + "Page nr." + i.ToString() + ":" + vbCrLf
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
message = message + "The GetAnnotationCount() method has failed with the status: " + status.ToString() + vbCrLf
Else
If annotCount = 0 Then
message = message + "This page does not contain any annotations." + vbCrLf
Else
Dim annotType As String = ""
Dim annotSubType As String = ""
For j As Integer = 0 To annotCount - 1
annotType = gdpicturePDF.GetAnnotationType(j)
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
message = message + "Annot nr." + j.ToString() + ": Type = " + annotType + " Subtype = " + annotSubType + vbCrLf
Next
End If
End If
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationSubType";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status != GdPictureStatus.OK)
{
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
else
{
message = message + "Page nr." + i.ToString() + ":\n";
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
{
message = message + "The GetAnnotationCount() method has failed with the status: " + status.ToString() + "\n";
}
else
{
if (annotCount == 0)
{
message = message + "This page does not contain any annotations." + "\n";
}
else
{
string annotType = "";
string annotSubType = "";
for (int j = 0; j < annotCount; j++)
{
annotType = gdpicturePDF.GetAnnotationType(j);
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
message = message + "Annot nr." + j.ToString() + ": Type = " + annotType + " Subtype = " + annotSubType + "\n";
}
}
}
}
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the rectangle (the bounding box) of a required annotation object specified by its index related to the currently selected page of the loaded PDF
document. This rectangle defines the location of the annotation on the page expressed in the current units used in this document with respect to the currently defined origin.
You can use the method to reset the units and the method to reset the origin's location according to your preference.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
Output parameter. The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is located.
The returned value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page.
Output parameter. The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is located.
The returned value expressed is in the current units used in the PDF document and it is related to the current page.
Output parameter. The width of the annotation's bounding box. The returned value is expressed in the current units specified by the SetMeasurementUnit method.
Output parameter. The height of the annotation's bounding box. The returned value is expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
Be aware that the values of the coordinates and dimensions are expressed in the current units defined by the method according to the
current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve the bounding box attributes and some other properties of all stamp annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationRect"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = ""
Dim color As Color = Color.Black, fillColor As Color = Color.Black
Dim opacity As Byte = 0
Dim l As Single = 0, t As Single = 0, w As Single = 0, h As Single = 0
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Stamp") Then
message = message + vbCrLf + "AnnotID: " + j.ToString()
message = message + vbCrLf + " color: "
color = gdpicturePDF.GetAnnotationColor(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + color.ToString() Else message = message + status.ToString()
message = message + " fill color: "
fillColor = gdpicturePDF.GetAnnotationFillColor(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + fillColor.ToString() Else message = message + status.ToString()
message = message + " opacity: "
opacity = gdpicturePDF.GetAnnotationOpacity(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + opacity.ToString() Else message = message + status.ToString()
message = message + " rectangle: "
status = gdpicturePDF.GetAnnotationRect(j, l, t, w, h)
If status = GdPictureStatus.OK Then message = message + "[" + l.ToString() + "," + t.ToString() + " ; w:" + w.ToString() + " h:" + h.ToString() + "]" Else message = message + status.ToString()
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationRect";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "";
Color color = Color.Black, fillColor = Color.Black;
byte opacity = 0;
float l = 0, t = 0, w = 0, h = 0;
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Stamp"))
{
message = message + "\nAnnotID: " + j.ToString();
message = message + "\n color: ";
color = gdpicturePDF.GetAnnotationColor(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + color;
else message = message + status.ToString();
message = message + " fill color: ";
fillColor = gdpicturePDF.GetAnnotationFillColor(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + fillColor;
else message = message + status.ToString();
message = message + " opacity: ";
opacity = gdpicturePDF.GetAnnotationOpacity(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + opacity.ToString();
else message = message + status.ToString();
message = message + " rectangle: ";
status = gdpicturePDF.GetAnnotationRect(j, ref l, ref t, ref w, ref h);
if (status == GdPictureStatus.OK) message = message + "[" + l.ToString() + "," + t.ToString() + " ; w:" + w.ToString() + " h:" + h.ToString() + "]";
else message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the QuadPoints of annotation specified by its index related to the currently selected page of the loaded PDF
document.
You can use the method to reset the units and the method to reset the origin's location according to your preference.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
Output parameter. Array of 8 × n numbers specifying the coordinates of n quadrilaterals in PDF user space.
This method is only allowed for use with non-encrypted documents.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
Be aware that the values of the coordinates and dimensions are expressed in the current units defined by the method according to the
current coordinate space defined by the method.
This method is applicable only for "Link", "Highlight", "Underline", "Squiggly" and "StrikeOut" annotation types.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. If the annotation does not contain any QuadPoints information the return value is GdPictureStatus.PropertyNotFound.
We strongly recommend always checking this status first.
How to retrieve the quad points of text markup annotation.
Using pdf = New GdPicturePDF
pdf.LoadFromFile("input.pdf")
Dim quadpoints = New Single() { }
pdf.GetAnnotationQuadPoints(0, quadpoints)
pdf.DrawRectangle(quadpoints(0), quadpoints(1), quadpoints(6) - quadpoints(0), quadpoints(7) - quadpoints(1), False, True)
pdf.SaveToFile("output.pdf")
End Using
using pdf = new GdPicturePDF();
{
pdf.LoadFromFile("input.pdf");
float[] quadpoints = new float[0];
pdf.GetAnnotationQuadPoints(0, ref quadpoints);
pdf.DrawRectangle(quadpoints[0], quadpoints[1], quadpoints[6] - quadpoints[0], quadpoints[7] - quadpoints[1], false, true);
pdf.SaveToFile("output.pdf");
}
Sets the rectangle (the bounding box) of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This rectangle defines the location of the annotation on the page expressed in the current units used in this document with respect to the currently defined origin.
You can use the method to reset the units and the method to reset the origin's location according to your preference.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The new width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The new height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
Be aware that the values of the coordinates and dimensions are expressed in the current units defined by the method according to the
current coordinate space defined by the method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change (to double in this example) the bounding box of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationRect"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
Dim l As Single = 0, t As Single = 0, w As Single = 0, h As Single = 0
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.GetAnnotationRect(annotID, l, t, w, h)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.SetAnnotationRect(annotID, l, t, 2 * w, 2 * h)
End If
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_rectangle.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationRect";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
float l = 0, t = 0, w = 0, h = 0;
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.GetAnnotationRect(annotID, ref l, ref t, ref w, ref h);
if (status == GdPictureStatus.OK)
status = gdpicturePDF.SetAnnotationRect(annotID, l, t, 2*w, 2*h);
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_rectangle.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This color is used for the following purposes:- The background of the annotation's icon when closed.
- The title bar of the annotation's pop-up window.
- The border of a link annotation.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The color of the specified annotation object. The method can be subsequently used to determine if this method has been successful.
How to retrieve the color and some other properties of all stamp annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = ""
Dim color As Color = Color.Black, fillColor As Color = Color.Black
Dim opacity As Byte = 0
Dim l As Single = 0, t As Single = 0, w As Single = 0, h As Single = 0
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Stamp") Then
message = message + vbCrLf + "AnnotID: " + j.ToString()
message = message + vbCrLf + " color: "
color = gdpicturePDF.GetAnnotationColor(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + color.ToString() Else message = message + status.ToString()
message = message + " fill color: "
fillColor = gdpicturePDF.GetAnnotationFillColor(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + fillColor.ToString() Else message = message + status.ToString()
message = message + " opacity: "
opacity = gdpicturePDF.GetAnnotationOpacity(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + opacity.ToString() Else message = message + status.ToString()
message = message + " rectangle: "
status = gdpicturePDF.GetAnnotationRect(j, l, t, w, h)
If status = GdPictureStatus.OK Then message = message + "[" + l.ToString() + "," + t.ToString() + " ; w:" + w.ToString() + " h:" + h.ToString() + "]" Else message = message + status.ToString()
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "";
Color color = Color.Black, fillColor = Color.Black;
byte opacity = 0;
float l = 0, t = 0, w = 0, h = 0;
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Stamp"))
{
message = message + "\nAnnotID: " + j.ToString();
message = message + "\n color: ";
color = gdpicturePDF.GetAnnotationColor(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + color;
else message = message + status.ToString();
message = message + " fill color: ";
fillColor = gdpicturePDF.GetAnnotationFillColor(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + fillColor;
else message = message + status.ToString();
message = message + " opacity: ";
opacity = gdpicturePDF.GetAnnotationOpacity(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + opacity.ToString();
else message = message + status.ToString();
message = message + " rectangle: ";
status = gdpicturePDF.GetAnnotationRect(j, ref l, ref t, ref w, ref h);
if (status == GdPictureStatus.OK) message = message + "[" + l.ToString() + "," + t.ToString() + " ; w:" + w.ToString() + " h:" + h.ToString() + "]";
else message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the interior color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This color is used for the following purposes:- To specify the interior color with which to fill the annotation’s rectangle or ellipse (for Square or Circle annotation types).
- To specify the interior color with which to fill the annotation’s line endings (for Line, Polygon or PolyLine annotation types).
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
Just to inform you, that this parameter is only meaningful to use for specific annotation types described in the Summary section above.
The interior color of the specified annotation object. The method can be subsequently used to determine if this method has been successful.
How to retrieve the fill color and some other properties of all stamp annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationFillColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = ""
Dim color As Color = Color.Black, fillColor As Color = Color.Black
Dim opacity As Byte = 0
Dim l As Single = 0, t As Single = 0, w As Single = 0, h As Single = 0
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Stamp") Then
message = message + vbCrLf + "AnnotID: " + j.ToString()
message = message + vbCrLf + " color: "
color = gdpicturePDF.GetAnnotationColor(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + color.ToString() Else message = message + status.ToString()
message = message + " fill color: "
fillColor = gdpicturePDF.GetAnnotationFillColor(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + fillColor.ToString() Else message = message + status.ToString()
message = message + " opacity: "
opacity = gdpicturePDF.GetAnnotationOpacity(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + opacity.ToString() Else message = message + status.ToString()
message = message + " rectangle: "
status = gdpicturePDF.GetAnnotationRect(j, l, t, w, h)
If status = GdPictureStatus.OK Then message = message + "[" + l.ToString() + "," + t.ToString() + " ; w:" + w.ToString() + " h:" + h.ToString() + "]" Else message = message + status.ToString()
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationFillColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "";
Color color = Color.Black, fillColor = Color.Black;
byte opacity = 0;
float l = 0, t = 0, w = 0, h = 0;
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Stamp"))
{
message = message + "\nAnnotID: " + j.ToString();
message = message + "\n color: ";
color = gdpicturePDF.GetAnnotationColor(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + color;
else message = message + status.ToString();
message = message + " fill color: ";
fillColor = gdpicturePDF.GetAnnotationFillColor(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + fillColor;
else message = message + status.ToString();
message = message + " opacity: ";
opacity = gdpicturePDF.GetAnnotationOpacity(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + opacity.ToString();
else message = message + status.ToString();
message = message + " rectangle: ";
status = gdpicturePDF.GetAnnotationRect(j, ref l, ref t, ref w, ref h);
if (status == GdPictureStatus.OK) message = message + "[" + l.ToString() + "," + t.ToString() + " ; w:" + w.ToString() + " h:" + h.ToString() + "]";
else message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This color is used for the following purposes:- The background of the annotation's icon when closed.
- The title bar of the annotation's pop-up window.
- The border of a link annotation.
This method uses the RGB color space for specifying the required color.
Sets the (background) color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the (background) color of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.SetAnnotationColor(annotID, 255, 69, 0)
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_color.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.SetAnnotationColor(annotID, 255, 169, 0);
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_color.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This color is used for the following purposes:- The background of the annotation's icon when closed.
- The title bar of the annotation's pop-up window.
- The border of a link annotation.
This method uses the CMYK color space for specifying the required color.
Sets the (background) color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting color. Use the value between 0 and 255.
The amount of black color to be used for the resulting color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the (background) color of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.SetAnnotationColor(annotID, 0, 186, 255, 0)
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_color.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.SetAnnotationColor(annotID, 0, 186, 255, 0);
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_color.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This color is used for the following purposes:- The background of the annotation's icon when closed.
- The title bar of the annotation's pop-up window.
- The border of a link annotation.
Sets the (background) color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
A color object that defines the new color to be used for displaying a specified annotation, as it is explained in the Summary section.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the (background) color of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.SetAnnotationColor(annotID, Color.OrangeRed)
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_color.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.SetAnnotationColor(annotID, Color.OrangeRed);
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_color.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the interior color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This color is used for the following purposes:- To specify the interior color with which to fill the annotation’s rectangle or ellipse (for Square or Circle annotation types).
- To specify the interior color with which to fill the annotation’s line endings (for Line, Polygon or PolyLine annotation types).
This method uses the RGB color space for specifying the required color.
Sets the fill (interior) color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The amount of red color to be used for the resulting interior color. Use the value between 0 and 255.
The amount of green color to be used for the resulting interior color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting interior color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to change the fill (interior) color of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationFillColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.SetAnnotationFillColor(annotID, 255, 69, 0)
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_fillcolor.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationFillColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.SetAnnotationFillColor(annotID, 255, 69, 0);
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_fillcolor.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the interior color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This color is used for the following purposes:- To specify the interior color with which to fill the annotation’s rectangle or ellipse (for Square or Circle annotation types).
- To specify the interior color with which to fill the annotation’s line endings (for Line, Polygon or PolyLine annotation types).
This method uses the CMYK color space for specifying the required color.
Sets the fill (interior) color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The amount of cyan color to be used for the resulting interior color. Use the value between 0 and 255.
The amount of magenta color to be used for the resulting interior color. Use the value between 0 and 255.
The amount of yellow color to be used for the resulting interior color. Use the value between 0 and 255.
The amount of black color to be used for the resulting interior color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the fill (interior) color of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationFillColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.SetAnnotationFillColor(annotID, 0, 186, 255, 0)
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_fillcolor.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationFillColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.SetAnnotationFillColor(annotID, 0, 186, 255, 0);
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_fillcolor.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Sets the interior color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This color is used for the following purposes:
- To specify the interior color with which to fill the annotation’s rectangle or ellipse (for Square or Circle annotation types).
- To specify the interior color with which to fill the annotation’s line endings (for Line, Polygon or PolyLine annotation types).
Sets the fill (interior) color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The annotation intertior color.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to change the fill (interior) color of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationFillColor"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.SetAnnotationFillColor(annotID, Color.OrangeRed)
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_fillcolor.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationFillColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.SetAnnotationFillColor(annotID, Color.OrangeRed);
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_fillcolor.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the title of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
It is the text label that is displayed in the title bar of the annotation's pop-up window, mostly it represents the author of the annotation.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The title of the specified annotation object. The method can be subsequently used to determine if this method has been successful.
How to retrieve the title, the subject and the content of all text annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationTitle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = "", title As String = "", subject As String = "", content As String = ""
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Text") Then
message = message + vbCrLf + "AnnotID: " + j.ToString()
message = message + vbCrLf + " title: "
title = gdpicturePDF.GetAnnotationTitle(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + title Else message = message + status.ToString()
message = message + " subject: "
subject = gdpicturePDF.GetAnnotationSubject(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + subject Else message = message + status.ToString()
message = message + " content: "
content = gdpicturePDF.GetAnnotationContents(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + content Else message = message + status.ToString()
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "", title = "", subject = "", content = "";
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Text"))
{
message = message + "\nAnnotID: " + j.ToString();
message = message + "\n title: ";
title = gdpicturePDF.GetAnnotationTitle(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + title;
else message = message + status.ToString();
message = message + " subject: ";
subject = gdpicturePDF.GetAnnotationSubject(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + subject;
else message = message + status.ToString();
message = message + " content: ";
content = gdpicturePDF.GetAnnotationContents(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + content;
else message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the title of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
It is the text label that is displayed in the title bar of the annotation's pop-up window, mostly it represents the author of the annotation.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The new title of the specified annotation object.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.We strongly recommend always checking this status first.
How to change the title of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationTitle"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.SetAnnotationTitle(annotID, "GdPicture by Orpalis")
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_titles.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.SetAnnotationTitle(annotID, "GdPicture by Orpalis");
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_titles.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the opacity value of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This value is used when painting the annotation and it applies to all visible elements of the annotation in its closed state except of the pop-up window.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The opacity value from 0 (full transparency) to 255 (full opacity) of the specified annotation object.
The method can be subsequently used to determine if this method has been successful.
How to retrieve the opacity and some other properties of all stamp annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationOpacity"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = ""
Dim color As Color = Color.Black, fillColor As Color = Color.Black
Dim opacity As Byte = 0
Dim l As Single = 0, t As Single = 0, w As Single = 0, h As Single = 0
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Stamp") Then
message = message + vbCrLf + "AnnotID: " + j.ToString()
message = message + vbCrLf + " color: "
color = gdpicturePDF.GetAnnotationColor(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + color.ToString() Else message = message + status.ToString()
message = message + " fill color: "
fillColor = gdpicturePDF.GetAnnotationFillColor(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + fillColor.ToString() Else message = message + status.ToString()
message = message + " opacity: "
opacity = gdpicturePDF.GetAnnotationOpacity(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + opacity.ToString() Else message = message + status.ToString()
message = message + " rectangle: "
status = gdpicturePDF.GetAnnotationRect(j, l, t, w, h)
If status = GdPictureStatus.OK Then message = message + "[" + l.ToString() + "," + t.ToString() + " ; w:" + w.ToString() + " h:" + h.ToString() + "]" Else message = message + status.ToString()
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationOpacity";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "";
Color color = Color.Black, fillColor = Color.Black;
byte opacity = 0;
float l = 0, t = 0, w = 0, h = 0;
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Stamp"))
{
message = message + "\nAnnotID: " + j.ToString();
message = message + "\n color: ";
color = gdpicturePDF.GetAnnotationColor(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + color;
else message = message + status.ToString();
message = message + " fill color: ";
fillColor = gdpicturePDF.GetAnnotationFillColor(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + fillColor;
else message = message + status.ToString();
message = message + " opacity: ";
opacity = gdpicturePDF.GetAnnotationOpacity(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + opacity.ToString();
else message = message + status.ToString();
message = message + " rectangle: ";
status = gdpicturePDF.GetAnnotationRect(j, ref l, ref t, ref w, ref h);
if (status == GdPictureStatus.OK) message = message + "[" + l.ToString() + "," + t.ToString() + " ; w:" + w.ToString() + " h:" + h.ToString() + "]";
else message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the opacity value of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
This value is used when painting the annotation and it applies to all visible elements of the annotation in its closed state except of the pop-up window.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The new opacity value from 0 (full transparency) to 255 (full opacity) of the specified annotation object.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the opacity of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationOpacity"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.SetAnnotationOpacity(annotID, 128)
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_opacity.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationOpacity";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.SetAnnotationOpacity(annotID, 128);
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_opacity.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the subject of a required annotation object specified by its index related to the currently selected page of the loaded PDF document. It is a short
text description of the subject being addressed by the specified annotation.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The subject of the specified annotation object. The method can be subsequently used to determine if this method has been successful.
How to retrieve the title, the subject and the content of all text annotation objects within the PDF document.
Dim caption As String = "Example: GetAnnotationSubject"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim message As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
message = message + "The page nr." + i.ToString()
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If annotCount = 0 Then
message = message + " does not contain any annotations."
Else
Dim annotSubType As String = "", title As String = "", subject As String = "", content As String = ""
For j As Integer = 0 To annotCount - 1
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotSubType.Equals("Text") Then
message = message + vbCrLf + "AnnotID: " + j.ToString()
message = message + vbCrLf + " title: "
title = gdpicturePDF.GetAnnotationTitle(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + title Else message = message + status.ToString()
message = message + " subject: "
subject = gdpicturePDF.GetAnnotationSubject(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + subject Else message = message + status.ToString()
message = message + " content: "
content = gdpicturePDF.GetAnnotationContents(j)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then message = message + content Else message = message + status.ToString()
End If
Else
message = message + vbCrLf + "The GetAnnotationSubType() method has failed with the status: " + status.ToString()
End If
Next
End If
Else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString()
End If
message = message + vbCrLf
Else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationSubject";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string message = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
message = message + "The page nr." + i.ToString();
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (annotCount == 0)
{
message = message + " does not contain any annotations.";
}
else
{
string annotSubType = "", title = "", subject = "", content = "";
for (int j = 0; j < annotCount; j++)
{
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotSubType.Equals("Text"))
{
message = message + "\nAnnotID: " + j.ToString();
message = message + "\n title: ";
title = gdpicturePDF.GetAnnotationTitle(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + title;
else message = message + status.ToString();
message = message + " subject: ";
subject = gdpicturePDF.GetAnnotationSubject(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + subject;
else message = message + status.ToString();
message = message + " content: ";
content = gdpicturePDF.GetAnnotationContents(j);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) message = message + content;
else message = message + status.ToString();
}
}
else
{
message = message + "\nThe GetAnnotationSubType() method has failed with the status: " + status.ToString();
}
}
}
}
else
message = message + ": the GetAnnotationCount() method has failed with the status: " + status.ToString();
message = message + "\n";
}
else
message = message + "The SelectPage(" + i.ToString() + ") method has failed with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Sets the subject of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
It is a short text description of the subject being addressed by the specified annotation.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The new subject of the specified annotation object.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the subject of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationSubject"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + " Annots: " + annotCount.ToString()
For annotID As Integer = 0 To annotCount - 1
status = gdpicturePDF.SetAnnotationSubject(annotID, "Reviewed by Orpalis")
If status <> GdPictureStatus.OK Then Exit For
Next
message = message + " status: " + status.ToString()
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
If gdpicturePDF.SaveToFile("test_subjects.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationSubject";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + " Annots: " + annotCount.ToString();
for (int annotID = 0; annotID < annotCount; annotID++)
{
status = gdpicturePDF.SetAnnotationSubject(annotID, "Reviewed by Orpalis");
if (status != GdPictureStatus.OK) break;
}
message = message + " status: " + status.ToString();
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
if (gdpicturePDF.SaveToFile("test_subjects.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Returns the annotation name of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
It is a text string, corresponding to the NM entry in the annotation dictionary (see PDF Reference, Section "Annotation Dictionaries"), uniquely identifying
the annotation among all the annotations on its page. You can use this attribute, for example, to precisely identify the annotation in third-party software.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
Be aware that this attribute is optional, for more details please refer to the NM entry in the annotation dictionary in the PDF Reference.
The annotation name of the specified annotation object. The method can be subsequently used to determine if this method has been successful.
How to get the value of the annotation name attribute for further use.
Dim caption As String = "Example: GetAnnotationName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim annotname As String = Nothing
Dim annotCount As Integer = 0
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
If gdpicturePDF.SelectPage(i) <> GdPictureStatus.OK Then Exit For
annotCount = gdpicturePDF.GetAnnotationCount()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If annotCount = 0 Then Continue For
For j As Integer = 0 To annotCount - 1
annotname = gdpicturePDF.GetAnnotationName(j)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If annotname.Equals("required_annotation_name") Then status = gdpicturePDF.SetAnnotationOpacity(j, 0)
If status <> GdPictureStatus.OK Then Exit For
ElseIf gdpicturePDF.GetStat() <> GdPictureStatus.PropertyNotFound Then
'The annotation name attribut is optional.
Exit For
End If
Next
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) AndAlso (gdpicturePDF.GetStat() <> GdPictureStatus.PropertyNotFound) Then Exit For
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_annotnames.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetAnnotationName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string annotname = null;
int annotCount = 0;
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
if (gdpicturePDF.SelectPage(i) != GdPictureStatus.OK) break;
annotCount = gdpicturePDF.GetAnnotationCount();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (annotCount == 0) continue;
for (int j = 0; j < annotCount; j++)
{
annotname = gdpicturePDF.GetAnnotationName(j);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (annotname.Equals("required_annotation_name"))
status = gdpicturePDF.SetAnnotationOpacity(j, 0);
if (status != GdPictureStatus.OK) break;
}
else
//The annotation name attribut is optional.
if (gdpicturePDF.GetStat() != GdPictureStatus.PropertyNotFound) break;
}
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) &&
(gdpicturePDF.GetStat() != GdPictureStatus.PropertyNotFound))
break;
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_annotnames.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Sets the annotation name of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.
It is a text string, corresponding to the NM entry in the annotation dictionary (see PDF Reference, Section "Annotation Dictionaries"), uniquely identifying
the annotation among all the annotations on its page. You can use this attribute, for example, to precisely identify the annotation in third-party software.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
The new annotation name of the specified annotation object.
This method is only allowed for use with non-encrypted documents.
Likewise always ensure that you have selected the correct page using the method before applying an annotation index.
Be aware that this attribute is optional, for more details please refer to the NM entry in the annotation dictionary in the PDF Reference..
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the annotation name for all sticky notes in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = 0
Dim annotType As String = "", annotSubType As String = ""
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
If gdpicturePDF.SelectPage(i) <> GdPictureStatus.OK Then Exit For
annotCount = gdpicturePDF.GetAnnotationCount()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If annotCount = 0 Then Continue For
For j As Integer = 0 To annotCount - 1
annotType = gdpicturePDF.GetAnnotationType(j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
annotSubType = gdpicturePDF.GetAnnotationSubType(j)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If annotType.Equals("Annot") AndAlso annotSubType.Equals("Text") Then
If gdpicturePDF.SetAnnotationName(j, "Text_p" + i.ToString() + "_idx" + j.ToString()) <> GdPictureStatus.OK Then Exit For
End If
Next
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
status = gdpicturePDF.SaveToFile("test_annotnames.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
int annotCount = 0;
string annotType = "", annotSubType = "";
int pageCount = gdpicturePDF.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
if (gdpicturePDF.SelectPage(i) != GdPictureStatus.OK) break;
annotCount = gdpicturePDF.GetAnnotationCount();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (annotCount == 0) continue;
for (int j = 0; j < annotCount; j++)
{
annotType = gdpicturePDF.GetAnnotationType(j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
annotSubType = gdpicturePDF.GetAnnotationSubType(j);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (annotType.Equals("Annot") && annotSubType.Equals("Text"))
{
if (gdpicturePDF.SetAnnotationName(j, "Text_p" + i.ToString() + "_idx" + j.ToString()) != GdPictureStatus.OK) break;
}
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
status = gdpicturePDF.SaveToFile("test_annotnames.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
Gets the content of the embedded (attached) file associated with the specified annotation related to the currently selected page of the loaded PDF
document. You need to identify the annotation object by its 0-based index, that is always related to the currently selected page.
Be aware that PDF documents can also contain embedded files as a whole. Such files are called File Attachments and they are attached directly to a PDF document.
You can refer to our examples
how to extract embedded files in both ways.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
Output parameter. An array of bytes containing the data of the embedded file associated with the specified annotation.
This method is only allowed for use with non-encrypted documents.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to retrieve all files associated with all file attachment annotations in the loaded PDF document.
Dim caption As String = "Example: GetFileAttachmentAnnotEmbeddedFile"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim subtype As String = ""
For annotID As Integer = 0 To annotCount - 1
subtype = gdpicturePDF.GetAnnotationSubType(annotID)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (subtype.Equals("FileAttachment")) Then
message = message + vbCrLf + "AnnotID: " + annotID.ToString()
Dim filedata As Byte() = Nothing
Dim filesize As Integer = 0
Dim fileDesc As String = "", crDate As String = "", modDate As String = ""
Dim filename As String = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, filedata) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Using file As System.IO.Stream = System.IO.File.OpenWrite(filename)
file.Write(filedata, 0, filesize)
End Using
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate
End If
End If
message = message + " status: " + status.ToString()
Next
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFileAttachmentAnnotEmbeddedFile";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string subtype = "";
for (int annotID = 0; annotID < annotCount; annotID++)
{
subtype = gdpicturePDF.GetAnnotationSubType(annotID);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (subtype.Equals("FileAttachment")))
{
message = message + "\nAnnotID: " + annotID.ToString();
byte[] filedata = null;
int filesize = 0;
string fileDesc = "", crDate = "", modDate = "";
string filename = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, ref filedata);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
using (System.IO.Stream file = File.OpenWrite(filename))
{
file.Write(filedata, 0, filesize);
}
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate;
}
}
message = message + " status: " + status.ToString();
}
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Gets the creation date of the embedded file (the attachment's creation date) associated with the specified annotation related to the currently selected page of
the loaded PDF document. You need to identify the annotation object by its 0-based index, that is always related to the currently selected page.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The creation date of the embedded file associated with the specified annotation. The method can be subsequently used to determine if this method has been successful.
How to retrieve all files and their properties associated with all file attachment annotations in the loaded PDF document.
Dim caption As String = "Example: GetFileAttachmentAnnotCreationDate"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim subtype As String = ""
For annotID As Integer = 0 To annotCount - 1
subtype = gdpicturePDF.GetAnnotationSubType(annotID)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (subtype.Equals("FileAttachment")) Then
message = message + vbCrLf + "AnnotID: " + annotID.ToString()
Dim filedata As Byte() = Nothing
Dim filesize As Integer = 0
Dim fileDesc As String = "", crDate As String = "", modDate As String = ""
Dim filename As String = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, filedata) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Using file As System.IO.Stream = System.IO.File.OpenWrite(filename)
file.Write(filedata, 0, filesize)
End Using
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate
End If
End If
message = message + " status: " + status.ToString()
Next
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFileAttachmentAnnotCreationDate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string subtype = "";
for (int annotID = 0; annotID < annotCount; annotID++)
{
subtype = gdpicturePDF.GetAnnotationSubType(annotID);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (subtype.Equals("FileAttachment")))
{
message = message + "\nAnnotID: " + annotID.ToString();
byte[] filedata = null;
int filesize = 0;
string fileDesc = "", crDate = "", modDate = "";
string filename = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, ref filedata);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
using (System.IO.Stream file = File.OpenWrite(filename))
{
file.Write(filedata, 0, filesize);
}
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate;
}
}
message = message + " status: " + status.ToString();
}
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Gets the description of the embedded file (the attachment's description) associated with the specified annotation related to the currently selected page of the
loaded PDF document. You need to identify the annotation object by its 0-based index, that is always related to the currently selected page.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The description of the embedded file associated with the specified annotation. The method can be subsequently used to determine if this method has been successful.
How to retrieve all files and their properties associated with all file attachment annotations in the loaded PDF document.
Dim caption As String = "Example: GetFileAttachmentAnnotFileDescription"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim subtype As String = ""
For annotID As Integer = 0 To annotCount - 1
subtype = gdpicturePDF.GetAnnotationSubType(annotID)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (subtype.Equals("FileAttachment")) Then
message = message + vbCrLf + "AnnotID: " + annotID.ToString()
Dim filedata As Byte() = Nothing
Dim filesize As Integer = 0
Dim fileDesc As String = "", crDate As String = "", modDate As String = ""
Dim filename As String = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, filedata) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Using file As System.IO.Stream = System.IO.File.OpenWrite(filename)
file.Write(filedata, 0, filesize)
End Using
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate
End If
End If
message = message + " status: " + status.ToString()
Next
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFileAttachmentAnnotFileDescription";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string subtype = "";
for (int annotID = 0; annotID < annotCount; annotID++)
{
subtype = gdpicturePDF.GetAnnotationSubType(annotID);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (subtype.Equals("FileAttachment")))
{
message = message + "\nAnnotID: " + annotID.ToString();
byte[] filedata = null;
int filesize = 0;
string fileDesc = "", crDate = "", modDate = "";
string filename = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, ref filedata);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
using (System.IO.Stream file = File.OpenWrite(filename))
{
file.Write(filedata, 0, filesize);
}
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate;
}
}
message = message + " status: " + status.ToString();
}
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Gets the modification date of the embedded file (the attachment's modification date) associated with the specified annotation related to the currently selected
page of the loaded PDF document. You need to identify the annotation object by its 0-based index, that is always related to the currently selected page.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The modification date of the embedded file associated with the specified annotation. The method can be subsequently used to determine if this method has been successful.
How to retrieve all files and their properties associated with all file attachment annotations in the loaded PDF document.
Dim caption As String = "Example: GetFileAttachmentAnnotModificationDate"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim subtype As String = ""
For annotID As Integer = 0 To annotCount - 1
subtype = gdpicturePDF.GetAnnotationSubType(annotID)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (subtype.Equals("FileAttachment")) Then
message = message + vbCrLf + "AnnotID: " + annotID.ToString()
Dim filedata As Byte() = Nothing
Dim filesize As Integer = 0
Dim fileDesc As String = "", crDate As String = "", modDate As String = ""
Dim filename As String = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, filedata) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Using file As System.IO.Stream = System.IO.File.OpenWrite(filename)
file.Write(filedata, 0, filesize)
End Using
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate
End If
End If
message = message + " status: " + status.ToString()
Next
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFileAttachmentAnnotModificationDate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string subtype = "";
for (int annotID = 0; annotID < annotCount; annotID++)
{
subtype = gdpicturePDF.GetAnnotationSubType(annotID);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (subtype.Equals("FileAttachment")))
{
message = message + "\nAnnotID: " + annotID.ToString();
byte[] filedata = null;
int filesize = 0;
string fileDesc = "", crDate = "", modDate = "";
string filename = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, ref filedata);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
using (System.IO.Stream file = File.OpenWrite(filename))
{
file.Write(filedata, 0, filesize);
}
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate;
}
}
message = message + " status: " + status.ToString();
}
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Gets the file name of the embedded file (the attachment's file name) associated with the specified annotation related to the currently selected page of the
loaded PDF document. You need to identify the annotation object by its 0-based index, that is always related to the currently selected page.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The file name of the embedded file associated with the specified annotation. The method can be subsequently used to determine if this method has been successful.
How to retrieve all files associated with all file attachment annotations in the loaded PDF document.
Dim caption As String = "Example: GetFileAttachmentAnnotFileName"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim subtype As String = ""
For annotID As Integer = 0 To annotCount - 1
subtype = gdpicturePDF.GetAnnotationSubType(annotID)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (subtype.Equals("FileAttachment")) Then
message = message + vbCrLf + "AnnotID: " + annotID.ToString()
Dim filedata As Byte() = Nothing
Dim filesize As Integer = 0
Dim fileDesc As String = "", crDate As String = "", modDate As String = ""
Dim filename As String = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, filedata) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Using file As System.IO.Stream = System.IO.File.OpenWrite(filename)
file.Write(filedata, 0, filesize)
End Using
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate
End If
End If
message = message + " status: " + status.ToString()
Next
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFileAttachmentAnnotFileName";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string subtype = "";
for (int annotID = 0; annotID < annotCount; annotID++)
{
subtype = gdpicturePDF.GetAnnotationSubType(annotID);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (subtype.Equals("FileAttachment")))
{
message = message + "\nAnnotID: " + annotID.ToString();
byte[] filedata = null;
int filesize = 0;
string fileDesc = "", crDate = "", modDate = "";
string filename = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, ref filedata);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
using (System.IO.Stream file = File.OpenWrite(filename))
{
file.Write(filedata, 0, filesize);
}
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate;
}
}
message = message + " status: " + status.ToString();
}
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Gets the file size of the embedded file (the attachment's file size) associated with the specified annotation related to the currently selected page of the
loaded PDF document. You need to identify the annotation object by its 0-based index, that is always related to the currently selected page.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
The file size, in bytes, of the embedded file associated with the specified annotation. The method can be subsequently used to determine if this method has been successful.
How to retrieve all files associated with all file attachment annotations in the loaded PDF document.
Dim caption As String = "Example: GetFileAttachmentAnnotFileSize"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
Dim status As GdPictureStatus = GdPictureStatus.OK
For page As Integer = 1 To pageCount
message = message + "Page nr." + page.ToString()
status = gdpicturePDF.SelectPage(page)
If status = GdPictureStatus.OK Then
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim subtype As String = ""
For annotID As Integer = 0 To annotCount - 1
subtype = gdpicturePDF.GetAnnotationSubType(annotID)
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (subtype.Equals("FileAttachment")) Then
message = message + vbCrLf + "AnnotID: " + annotID.ToString()
Dim filedata As Byte() = Nothing
Dim filesize As Integer = 0
Dim fileDesc As String = "", crDate As String = "", modDate As String = ""
Dim filename As String = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, filedata) Else status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Using file As System.IO.Stream = System.IO.File.OpenWrite(filename)
file.Write(filedata, 0, filesize)
End Using
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate
End If
End If
message = message + " status: " + status.ToString()
Next
Else
message = message + "GetAnnotationCount - status: " + status.ToString()
End If
Else
message = message + "SelectPage - status: " + status.ToString()
End If
message += vbCrLf
Next
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetFileAttachmentAnnotFileSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "";
GdPictureStatus status = GdPictureStatus.OK;
for (int page = 1; page <= pageCount; page++)
{
message = message + "Page nr." + page.ToString();
status = gdpicturePDF.SelectPage(page);
if (status == GdPictureStatus.OK)
{
int annotCount = gdpicturePDF.GetAnnotationCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string subtype = "";
for (int annotID = 0; annotID < annotCount; annotID++)
{
subtype = gdpicturePDF.GetAnnotationSubType(annotID);
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (subtype.Equals("FileAttachment")))
{
message = message + "\nAnnotID: " + annotID.ToString();
byte[] filedata = null;
int filesize = 0;
string fileDesc = "", crDate = "", modDate = "";
string filename = gdpicturePDF.GetFileAttachmentAnnotFileName(annotID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) filesize = gdpicturePDF.GetFileAttachmentAnnotFileSize(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) fileDesc = gdpicturePDF.GetFileAttachmentAnnotFileDescription(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) crDate = gdpicturePDF.GetFileAttachmentAnnotCreationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) modDate = gdpicturePDF.GetFileAttachmentAnnotModificationDate(annotID);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK) status = gdpicturePDF.GetFileAttachmentAnnotEmbeddedFile(annotID, ref filedata);
else status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
using (System.IO.Stream file = File.OpenWrite(filename))
{
file.Write(filedata, 0, filesize);
}
message = message + " file: " + filename + " desc: " + fileDesc + " size: " + filesize.ToString() +
" creation: " + crDate + " modif: " + modDate;
}
}
message = message + " status: " + status.ToString();
}
}
else
message = message + "GetAnnotationCount - status: " + status.ToString();
}
else
message = message + "SelectPage - status: " + status.ToString();
message += "\n";
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Flattens the required annotation specified by its index related to the currently selected page of the loaded PDF document.
Flattening an annotation means removing the annotation object from the document's internal structure and placing its data within the PDF document as regular item,
so the previously defined annotation is no longer available for user's interaction.
The 0-based index of the required annotation within the current page. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
Please always ensure that you have selected the correct page using the method before applying an annotation index.
To flatten all annotations included in the current document please follow the attached example.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Flattening all annotations in the loaded PDF document.
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
gdpicturePDF.LoadFromFile("input.pdf", False)
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For page As Integer = 1 To pageCount
gdpicturePDF.SelectPage(page)
Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
For i As Integer = 0 To annotCount - 1
gdpicturePDF.FlattenAnnotation(0)
Next
Next
gdpicturePDF.SaveToFile("output.pdf", True)
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf", false);
int pageCount = gdpicturePDF.GetPageCount();
for (int page = 1; page <= pageCount; page++)
{
gdpicturePDF.SelectPage(page);
int annotCount = gdpicturePDF.GetAnnotationCount();
for (int i = 0; i < annotCount; i++)
{
gdpicturePDF.FlattenAnnotation(0);
}
}
gdpicturePDF.SaveToFile("output.pdf", true);
}
Returns the printer color mode setting of the active printer. This property determines whether the output will print in color or in monochrome.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method
and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the PrinterColorMode enumeration. The value of the active printer color mode setting.
The method can be subsequently used or the method to determine if this method has been successful.
How to find out some properties of the active printer.
Dim caption As String = "Example: PrintGetColorMode"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If (gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK) Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnAlign As PrintAlignment = gdpicturePDF.PrintGetAlignment()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: " + prnAlign.ToString() + vbCrLf
Else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnCollate As Boolean = gdpicturePDF.PrintGetCollate()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: " + prnCollate.ToString() + vbCrLf
Else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnColorMode As PrinterColorMode = gdpicturePDF.PrintGetColorMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: " + prnColorMode.ToString() + vbCrLf
Else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnDuplex As System.Drawing.Printing.Duplex = gdpicturePDF.PrintGetDuplexMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: " + prnDuplex.ToString() + vbCrLf
Else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnOrientation As PrinterOrientation = gdpicturePDF.PrintGetOrientation()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: " + prnOrientation.ToString() + vbCrLf
Else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnQuality As PrintQuality = gdpicturePDF.PrintGetQuality()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: " + prnQuality.ToString() + vbCrLf
Else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetColorMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintAlignment prnAlign = gdpicturePDF.PrintGetAlignment();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: " + prnAlign.ToString() + "\n";
else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool prnCollate = gdpicturePDF.PrintGetCollate();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: " + prnCollate.ToString() + "\n";
else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterColorMode prnColorMode = gdpicturePDF.PrintGetColorMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: " + prnColorMode.ToString() + "\n";
else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.Duplex prnDuplex = gdpicturePDF.PrintGetDuplexMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: " + prnDuplex.ToString() + "\n";
else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterOrientation prnOrientation = gdpicturePDF.PrintGetOrientation();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: " + prnOrientation.ToString() + "\n";
else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintQuality prnQuality = gdpicturePDF.PrintGetQuality();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: " + prnQuality.ToString() + "\n";
else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up the printer color mode setting of the active printer. This property determines whether the output will print in color or in monochrome.
A member of the PrinterColorMode enumeration. The new value of the active printer color mode setting.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method
and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetColorMode"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: MiddleCenter" + vbCrLf
Else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAutoRotation(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " auto-rotation: True" + vbCrLf
Else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetCollate(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: True" + vbCrLf
Else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: Color" + vbCrLf
Else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: Simplex" + vbCrLf
Else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: Portrait" + vbCrLf
Else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: High" + vbCrLf
Else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetColorMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: MiddleCenter\n";
else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAutoRotation(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " auto-rotation: true\n";
else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetCollate(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: true\n";
else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: Color\n";
else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: Simplex\n";
else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: Portrait\n";
else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: High\n";
else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the printer document name setting of the active printer. You can use it to display during the next print process (for example, in a print
status dialog box or printer queue) while printing the document.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to inform you that the default value specified by the toolkit is "GdPicture Print Process".
Likewise to remind you that the active printer is the printer identified by the method or set by the method
and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The value of the active printer document name setting. The method can be subsequently used or the method to determine if this method has been successful.
How to find out the document name property of the active printer and how to use it further.
Dim caption As String = "Example: PrintGetDocumentName"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim docName As String = gdpicturePDF.PrintGetDocumentName()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim curName As String = gdpicturePDF.GetTitle()
If String.IsNullOrEmpty(curName) = False Then
'We only change the document name if the document title is not empty.
gdpicturePDF.PrintSetDocumentName(curName)
status = gdpicturePDF.GetStat()
End If
If status = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file " + curName + " has been printed successfully.", caption)
Else
Dim message As String = "The file " + curName + " can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, caption)
End If
Else
MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintGetDocumentName";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string docName = gdpicturePDF.PrintGetDocumentName();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string curName = gdpicturePDF.GetTitle();
if (String.IsNullOrEmpty(curName) == false)
{
//We only change the document name if the document title is not empty.
status = gdpicturePDF.PrintSetDocumentName(curName);
if (status == GdPictureStatus.OK)
docName = curName;
}
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file " + docName + " has been printed successfully.", caption);
}
else
{
string message = "The file " + docName + " can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
}
else
{
MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, caption);
}
}
else
{
MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Sets up the printer document name setting of the active printer. You can use it to display during the next print process
(for example, in a print status dialog box or printer queue) while printing the document.
The new value of the printer document name setting.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to inform you that the default value specified by the toolkit is "GdPicture Print Process".
Likewise to remind you that the active printer is the printer identified by the method or set by the method
and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up the document name property of the active printer.
Dim caption As String = "Example: PrintSetDocumentName"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim docName As String = gdpicturePDF.PrintGetDocumentName()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim curName As String = gdpicturePDF.GetTitle()
If String.IsNullOrEmpty(curName) = False Then
'We only change the document name if the document title is not empty.
status = gdpicturePDF.PrintSetDocumentName(curName)
If status = GdPictureStatus.OK Then
docName = curName
End If
End If
If status = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file " + docName + " has been printed successfully.", caption)
Else
Dim message As String = "The file " + docName + " can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, caption)
End If
Else
MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintSetDocumentName";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string docName = gdpicturePDF.PrintGetDocumentName();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
GdPictureStatus status = GdPictureStatus.OK;
string curName = gdpicturePDF.GetTitle();
if (String.IsNullOrEmpty(curName) == false)
{
//We only change the document name if the document title is not empty.
gdpicturePDF.PrintSetDocumentName(curName);
status = gdpicturePDF.GetStat();
}
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file " + curName + " has been printed successfully.", caption);
}
else
{
string message = "The file " + curName + " can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
}
else
{
MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, caption);
}
}
else
{
MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Enables or disables showing the progress indicator during the print process. The printing progress bar is displayed by default.
Set this parameter to true if you want to show the progress bar during the print process, otherwise set it to false. The
true.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to disable displaying the printing progress bar.
Dim caption As String = "Example: PrintSetShowPrintingProgress"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
'Printing progress bar will not display.
gdpicturePDF.PrintSetShowPrintingProgress(False)
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintSetShowPrintingProgress";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
//Printing progress bar will not display.
gdpicturePDF.PrintSetShowPrintingProgress(false);
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Sets up the paper source, means the paper tray, from which the printer gets paper, used by the active printer.
The value matches up to the PaperSource.Kind property of the default paper settings.
Sets up the paper source, from which the active printer gets paper.
The constant that represents the paper source to be used. Please refer to the System.Drawing.Printing.PaperSourceKind enumeration for correct values.
The standard values are listed below (please see the corresponding ordering number):
- Upper
- Lower
- Middle
- Manual
- Enveloper
- ManualFeed
- AutomaticFeed
- TractorFeed
- SmallFormat
- LargeFormat
- LargeCapacity
14. Cassette15. FormSource257. or greater: Custom
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
true if the method has been followed successfully, otherwise false.
Please use the method or the method to determine the specific reason for the method's failure.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetPaperBin"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.PrintSetPaperBin(7) Then
message = message + " paper bin: 7 (automatic feed)" + vbCrLf
Else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pSize As System.Drawing.Printing.PaperSize = New System.Drawing.Printing.PaperSize("My custom size", 120, 250)
gdpicturePDF.PrintSetPaperSize(pSize)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: 120, 250" + vbCrLf
Else
message = "The PrintSetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetFromToPage(2, 4)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " page range: 2-4" + vbCrLf
Else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetPaperBin";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintSetPaperBin(7))
message = message + " paper bin: 7 (automatic feed)\n";
else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.PaperSize pSize = new System.Drawing.Printing.PaperSize("My custom size", 120, 250);
gdpicturePDF.PrintSetPaperSize(pSize);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: 120, 250\n";
else
message = "The PrintSetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetFromToPage(2,4);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " page range: 2-4\n";
else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up the paper source property of the active printer.
Sets up the paper source, from which the active printer gets paper.
A PaperSource object that defines the new value of the paper source property to be used.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
true if the method has been followed successfully, otherwise false.
Please use the method or the method to determine the specific reason for the method's failure.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetPaperBin"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pSource As System.Drawing.Printing.PaperSource = new System.Drawing.Printing.PaperSource()
pSource.RawKind = 7
If gdpicturePDF.PrintSetPaperBin(pSource) Then
message = message + " paper bin: 7 (automatic feed)" + vbCrLf
Else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pSize As System.Drawing.Printing.PaperSize = New System.Drawing.Printing.PaperSize("My custom size", 120, 250)
gdpicturePDF.PrintSetPaperSize(pSize)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: 120, 250" + vbCrLf
Else
message = "The PrintSetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetFromToPage(2, 4)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " page range: 2-4" + vbCrLf
Else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetPaperBin";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.PaperSource pSource = new System.Drawing.Printing.PaperSource();
pSource.RawKind = 7;
if (gdpicturePDF.PrintSetPaperBin(pSource))
message = message + " paper bin: 7 (automatic feed)\n";
else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.PaperSize pSize = new System.Drawing.Printing.PaperSize("My custom size", 120, 250);
gdpicturePDF.PrintSetPaperSize(pSize);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: 120, 250\n";
else
message = "The PrintSetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetFromToPage(2,4);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " page range: 2-4\n";
else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the paper source, means the paper tray, from which the printer gets paper, used by the active printer. The value is determined through the
PaperSource.Kind property of the default page settings.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The constant that represents the current paper source. Please refer to the System.Drawing.Printing.PaperSourceKind enumeration for correct values. The standard
values are listed below (please see the corresponding ordering number):
- Upper
- Lower
- Middle
- Manual
- Enveloper
- ManualFeed
- AutomaticFeed
- TractorFeed
- SmallFormat
- LargeFormat
- LargeCapacity
14. Cassette15. FormSource257. or greater: Custom
The method can be subsequently used or the method to determine if this method has been successful.
How to find out some page properties of the active printer.
Dim caption As String = "Example: PrintGetPaperBin"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim leftMargin As Single = 0, rightMargin As Single = 0
gdpicturePDF.PrintGetMargins(leftMargin, rightMargin)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + vbCrLf
Else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnBin As Integer = gdpicturePDF.PrintGetPaperBin()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper bin: " + prnBin.ToString() + vbCrLf
Else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnSize As Integer = gdpicturePDF.PrintGetPaperSize()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: " + prnSize.ToString() + vbCrLf
Else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnHeight As Single = gdpicturePDF.PrintGetPaperHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper height: " + prnHeight.ToString()
Else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnWidth As Single = gdpicturePDF.PrintGetPaperWidth()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper width: " + prnWidth.ToString() + vbCrLf
Else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetPaperBin";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float leftMargin = 0, rightMargin = 0;
gdpicturePDF.PrintGetMargins(ref leftMargin, ref rightMargin);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + "\n";
else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnBin = gdpicturePDF.PrintGetPaperBin();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper bin: " + prnBin.ToString() + "\n";
else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnSize = gdpicturePDF.PrintGetPaperSize();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: " + prnSize.ToString() + "\n";
else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnHeight = gdpicturePDF.PrintGetPaperHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper height: " + prnHeight.ToString();
else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnWidth = gdpicturePDF.PrintGetPaperWidth();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper width: " + prnWidth.ToString() + "\n";
else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up the required range of pages you want to print during the next print process using the active printer.
The first page from the required range of pages.
The last page from the required range of pages.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetFromToPage"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.PrintSetPaperBin(7) Then
message = message + " paper bin: 7 (automatic feed)" + vbCrLf
Else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pSize As System.Drawing.Printing.PaperSize = New System.Drawing.Printing.PaperSize("My custom size", 120, 250)
gdpicturePDF.PrintSetPaperSize(pSize)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: 120, 250" + vbCrLf
Else
message = "The PrintSetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetFromToPage(2, 4)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " page range: 2-4" + vbCrLf
Else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetFromToPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintSetPaperBin(7))
message = message + " paper bin: 7 (automatic feed)\n";
else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.PaperSize pSize = new System.Drawing.Printing.PaperSize("My custom size", 120, 250);
gdpicturePDF.PrintSetPaperSize(pSize);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: 120, 250\n";
else
message = "The PrintSetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetFromToPage(2,4);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " page range: 2-4\n";
else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up the required selection of pages you want to print during the next print process using the active printer.
The specified pages selection will not take into account if you will print using the or the methods.
The custom page range to be set for printing, for example, "1;4;5" to process pages 1, 4 and 5 or "1-5;10" to process pages from 1 to 5 and page 10. Set this
parameter to "*" to process all pages of the current document.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Be aware that the defined pages selection will not take into account if you will use the or the methods.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to specify the required selection of pages to print.
Dim caption As String = "Example: PrintSetPageSelection"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
gdpicturePDF.PrintSetPageSelection("2;6-8;10")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.GetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintSetPageSelection";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetPageSelection("2;6-8;10");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.GetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Returns the printer quality setting of the active printer. This setting matches the PrinterResolutionKind property included in the
PrinterSettings.PrinterResolutions parameter of the active printer.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
Likewise to inform you, that you can also use the method to retrieve currently defined printer settings
of the active printer with all its relevant properties.
A member of the PrintQuality enumeration. The value of the active printer quality setting.
The method can be subsequently used or the method to determine if this method has been successful.
How to find out some properties of the active printer.
Dim caption As String = "Example: PrintGetQuality"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If (gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK) Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnAlign As PrintAlignment = gdpicturePDF.PrintGetAlignment()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: " + prnAlign.ToString() + vbCrLf
Else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnCollate As Boolean = gdpicturePDF.PrintGetCollate()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: " + prnCollate.ToString() + vbCrLf
Else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnColorMode As PrinterColorMode = gdpicturePDF.PrintGetColorMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: " + prnColorMode.ToString() + vbCrLf
Else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnDuplex As System.Drawing.Printing.Duplex = gdpicturePDF.PrintGetDuplexMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: " + prnDuplex.ToString() + vbCrLf
Else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnOrientation As PrinterOrientation = gdpicturePDF.PrintGetOrientation()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: " + prnOrientation.ToString() + vbCrLf
Else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnQuality As PrintQuality = gdpicturePDF.PrintGetQuality()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: " + prnQuality.ToString() + vbCrLf
Else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetQuality";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintAlignment prnAlign = gdpicturePDF.PrintGetAlignment();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: " + prnAlign.ToString() + "\n";
else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool prnCollate = gdpicturePDF.PrintGetCollate();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: " + prnCollate.ToString() + "\n";
else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterColorMode prnColorMode = gdpicturePDF.PrintGetColorMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: " + prnColorMode.ToString() + "\n";
else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.Duplex prnDuplex = gdpicturePDF.PrintGetDuplexMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: " + prnDuplex.ToString() + "\n";
else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterOrientation prnOrientation = gdpicturePDF.PrintGetOrientation();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: " + prnOrientation.ToString() + "\n";
else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintQuality prnQuality = gdpicturePDF.PrintGetQuality();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: " + prnQuality.ToString() + "\n";
else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up the printer quality setting of the active printer. This setting matches the PrinterResolutionKind property included in the
PrinterSettings.PrinterResolutions parameter of the active printer.
If the required Quality parameter is identified within the set of PrinterSettings.PrinterResolutions property items of the active printer, then
the currently defined active printer resolution is filled up with the specified resolution attributes provided by the corresponding printer resolution item.
A member of the PrintQuality enumeration. The new value of the active printer quality setting.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
Likewise to inform you, that you can also use the method to specify all relevant printer settings for the active printer
according to your preference and printer possibilities.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetQuality"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: MiddleCenter" + vbCrLf
Else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAutoRotation(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " auto-rotation: True" + vbCrLf
Else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetCollate(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: True" + vbCrLf
Else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: Color" + vbCrLf
Else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: Simplex" + vbCrLf
Else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: Portrait" + vbCrLf
Else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: High" + vbCrLf
Else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetQuality";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: MiddleCenter\n";
else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAutoRotation(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " auto-rotation: true\n";
else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetCollate(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: true\n";
else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: Color\n";
else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: Simplex\n";
else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: Portrait\n";
else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: High\n";
else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the status of the last executed print operation with the current GdPicturePDF object.
If the returned status is specifically GdPictureStatus.PrintingException, you can use the method to find out more details.
You can use the method to find out more details.
A member of the GdPictureStatus enumeration. If the last executed print method has been successfully followed, then the return value is GdPictureStatus.OK.
How to properly check the returned status when printing the current document.
Dim caption As String = "Example: PrintGetStat"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintGetStat";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Returns the error description of the last executed print operation, that has failed specifically with the GdPictureStatus.PrintingException error.
The value resets to its default (an empty string) starting each new print job.
The description of the last printing error.
How to properly check the returned status when printing the current document.
Dim caption As String = "Example: PrintGetLastError"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintGetLastError";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Sets up the printer copies setting of the active printer, that means the number of copies to be printed.
The number of copies to be printed. The new value of the active printer copies setting.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to increase the number of copies to be printed using the active printer.
Dim caption As String = "Example: PrintSetCopies"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim prnCopies As Short = gdpicturePDF.PrintGetCopies()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetCopies(prnCopies + 2)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully. Number of copies: " + (prnCopies+2).ToString(), caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The PrintSetCopies() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetCopies() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintSetCopies";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
short prnCopies = gdpicturePDF.PrintGetCopies();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetCopies((short)(prnCopies + 2));
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully. Number of copies: " + (prnCopies+2).ToString(), caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
}
else
{
MessageBox.Show("The PrintSetCopies() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
}
else
{
MessageBox.Show("The PrintGetCopies() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Returns the printer copies setting of the active printer, that means the number of copies to be printed.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The number of copies to be printed. The value of the active printer copies setting.
The method can be subsequently used or the method to determine if this method has been successful.
How to increase the number of copies to be printed using the active printer.
Dim caption As String = "Example: PrintGetCopies"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim prnCopies As Short = gdpicturePDF.PrintGetCopies()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetCopies(prnCopies + 2)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully. Number of copies: " + (prnCopies+2).ToString(), caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The PrintSetCopies() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetCopies() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintGetCopies";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
short prnCopies = gdpicturePDF.PrintGetCopies();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetCopies((short)(prnCopies + 2));
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully. Number of copies: " + (prnCopies+2).ToString(), caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
}
else
{
MessageBox.Show("The PrintSetCopies() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
}
else
{
MessageBox.Show("The PrintGetCopies() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Sets up the printer duplex mode setting of the active printer. This property determines whether a page is printed on both sides
(if the printer supports this feature).
A member of the Duplex enumeration. The new value of the active printer duplex mode setting.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetDuplexMode"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: MiddleCenter" + vbCrLf
Else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAutoRotation(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " auto-rotation: True" + vbCrLf
Else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetCollate(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: True" + vbCrLf
Else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: Color" + vbCrLf
Else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: Simplex" + vbCrLf
Else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: Portrait" + vbCrLf
Else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: High" + vbCrLf
Else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetDuplexMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: MiddleCenter\n";
else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAutoRotation(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " auto-rotation: true\n";
else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetCollate(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: true\n";
else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: Color\n";
else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: Simplex\n";
else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: Portrait\n";
else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: High\n";
else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up the printer collate setting of the active printer. This property determines, whether the printed document is collated.
Setting it to true will print a complete copy of the document before the first page of the next copy is printed.
Setting it to false will print each page by the number of copies specified before printing the next page.
The new value of the printer collate setting.
Set this parameter to true if you want the document to be collated when printing, otherwise set it to false.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Please note that collating is only performed when the number of copies is greater than 1.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetCollate"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: MiddleCenter" + vbCrLf
Else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAutoRotation(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " auto-rotation: True" + vbCrLf
Else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetCollate(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: True" + vbCrLf
Else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: Color" + vbCrLf
Else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: Simplex" + vbCrLf
Else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: Portrait" + vbCrLf
Else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: High" + vbCrLf
Else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetCollate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: MiddleCenter\n";
else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAutoRotation(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " auto-rotation: true\n";
else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetCollate(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: true\n";
else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: Color\n";
else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: Simplex\n";
else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: Portrait\n";
else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: High\n";
else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the printer collate setting of the active printer. This property determines, whether the printed document is collated.
true will print a complete copy of the document before the first page of the next copy is printed. false will print each page by the number of
copies specified before printing the next page.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Please note that collating is only performed when the number of copies is greater than 1.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The value of the printer collate setting. true if the printed document is collated when printing, otherwise false.
The method can be subsequently used or the method to determine if this method has been successful.
How to find out some properties of the active printer.
Dim caption As String = "Example: PrintGetCollate"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If (gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK) Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnAlign As PrintAlignment = gdpicturePDF.PrintGetAlignment()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: " + prnAlign.ToString() + vbCrLf
Else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnCollate As Boolean = gdpicturePDF.PrintGetCollate()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: " + prnCollate.ToString() + vbCrLf
Else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnColorMode As PrinterColorMode = gdpicturePDF.PrintGetColorMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: " + prnColorMode.ToString() + vbCrLf
Else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnDuplex As System.Drawing.Printing.Duplex = gdpicturePDF.PrintGetDuplexMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: " + prnDuplex.ToString() + vbCrLf
Else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnOrientation As PrinterOrientation = gdpicturePDF.PrintGetOrientation()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: " + prnOrientation.ToString() + vbCrLf
Else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnQuality As PrintQuality = gdpicturePDF.PrintGetQuality()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: " + prnQuality.ToString() + vbCrLf
Else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetCollate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintAlignment prnAlign = gdpicturePDF.PrintGetAlignment();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: " + prnAlign.ToString() + "\n";
else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool prnCollate = gdpicturePDF.PrintGetCollate();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: " + prnCollate.ToString() + "\n";
else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterColorMode prnColorMode = gdpicturePDF.PrintGetColorMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: " + prnColorMode.ToString() + "\n";
else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.Duplex prnDuplex = gdpicturePDF.PrintGetDuplexMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: " + prnDuplex.ToString() + "\n";
else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterOrientation prnOrientation = gdpicturePDF.PrintGetOrientation();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: " + prnOrientation.ToString() + "\n";
else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintQuality prnQuality = gdpicturePDF.PrintGetQuality();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: " + prnQuality.ToString() + "\n";
else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Prompts the printer driver to show the printer settings dialog box of the active printer.
A handle to the parent window of the active printer configuration property sheet.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to display the printer's standard settings dialog box.
Dim caption As String = "Example: PrintShowPrinterSettingsDialog"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
'Displaying the printer settings dialog box.
If gdpicturePDF.PrintShowPrinterSettingsDialog(Me.Handle) = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.GetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintShowPrinterSettingsDialog";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
//Displaying the printer settings dialog box.
if (gdpicturePDF.PrintShowPrinterSettingsDialog(this.Handle) == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.GetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Returns the printer duplex mode setting of the active printer. This property determines whether a page is printed on both sides
(if the printer supports this feature).
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the Duplex enumeration. The value of the active printer duplex mode setting.
The method can be subsequently used or the method to determine if this method has been successful.
How to find out some properties of the active printer.
Dim caption As String = "Example: PrintGetDuplexMode"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If (gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK) Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnAlign As PrintAlignment = gdpicturePDF.PrintGetAlignment()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: " + prnAlign.ToString() + vbCrLf
Else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnCollate As Boolean = gdpicturePDF.PrintGetCollate()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: " + prnCollate.ToString() + vbCrLf
Else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnColorMode As PrinterColorMode = gdpicturePDF.PrintGetColorMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: " + prnColorMode.ToString() + vbCrLf
Else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnDuplex As System.Drawing.Printing.Duplex = gdpicturePDF.PrintGetDuplexMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: " + prnDuplex.ToString() + vbCrLf
Else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnOrientation As PrinterOrientation = gdpicturePDF.PrintGetOrientation()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: " + prnOrientation.ToString() + vbCrLf
Else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnQuality As PrintQuality = gdpicturePDF.PrintGetQuality()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: " + prnQuality.ToString() + vbCrLf
Else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetDuplexMode";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintAlignment prnAlign = gdpicturePDF.PrintGetAlignment();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: " + prnAlign.ToString() + "\n";
else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool prnCollate = gdpicturePDF.PrintGetCollate();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: " + prnCollate.ToString() + "\n";
else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterColorMode prnColorMode = gdpicturePDF.PrintGetColorMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: " + prnColorMode.ToString() + "\n";
else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.Duplex prnDuplex = gdpicturePDF.PrintGetDuplexMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: " + prnDuplex.ToString() + "\n";
else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterOrientation prnOrientation = gdpicturePDF.PrintGetOrientation();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: " + prnOrientation.ToString() + "\n";
else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintQuality prnQuality = gdpicturePDF.PrintGetQuality();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: " + prnQuality.ToString() + "\n";
else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up the printer orientation setting of the active printer. This property determines the page orientation when printing.
A member of the PrinterOrientation enumeration. The new value of the active printer orientation setting.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetOrientation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: MiddleCenter" + vbCrLf
Else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAutoRotation(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " auto-rotation: True" + vbCrLf
Else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetCollate(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: True" + vbCrLf
Else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: Color" + vbCrLf
Else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: Simplex" + vbCrLf
Else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: Portrait" + vbCrLf
Else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: High" + vbCrLf
Else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetOrientation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: MiddleCenter\n";
else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAutoRotation(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " auto-rotation: true\n";
else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetCollate(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: true\n";
else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: Color\n";
else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: Simplex\n";
else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: Portrait\n";
else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: High\n";
else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the printer orientation setting of the active printer. This property determines the page orientation when printing.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the PrinterOrientation enumeration. The value of the active printer orientation setting.
The method can be subsequently used or the method to determine if this method has been successful.
How to find out some properties of the active printer.
Dim caption As String = "Example: PrintGetOrientation"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If (gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK) Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnAlign As PrintAlignment = gdpicturePDF.PrintGetAlignment()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: " + prnAlign.ToString() + vbCrLf
Else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnCollate As Boolean = gdpicturePDF.PrintGetCollate()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: " + prnCollate.ToString() + vbCrLf
Else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnColorMode As PrinterColorMode = gdpicturePDF.PrintGetColorMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: " + prnColorMode.ToString() + vbCrLf
Else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnDuplex As System.Drawing.Printing.Duplex = gdpicturePDF.PrintGetDuplexMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: " + prnDuplex.ToString() + vbCrLf
Else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnOrientation As PrinterOrientation = gdpicturePDF.PrintGetOrientation()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: " + prnOrientation.ToString() + vbCrLf
Else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnQuality As PrintQuality = gdpicturePDF.PrintGetQuality()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: " + prnQuality.ToString() + vbCrLf
Else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetOrientation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintAlignment prnAlign = gdpicturePDF.PrintGetAlignment();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: " + prnAlign.ToString() + "\n";
else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool prnCollate = gdpicturePDF.PrintGetCollate();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: " + prnCollate.ToString() + "\n";
else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterColorMode prnColorMode = gdpicturePDF.PrintGetColorMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: " + prnColorMode.ToString() + "\n";
else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.Duplex prnDuplex = gdpicturePDF.PrintGetDuplexMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: " + prnDuplex.ToString() + "\n";
else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterOrientation prnOrientation = gdpicturePDF.PrintGetOrientation();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: " + prnOrientation.ToString() + "\n";
else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintQuality prnQuality = gdpicturePDF.PrintGetQuality();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: " + prnQuality.ToString() + "\n";
else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the name of the printer, that is currently selected as the active printer, means the printer,
which is subsequently used when printing the loaded PDF document.
It is mostly the default printer, if not set otherwise. However, you can use the method to select your preferred printer for next
print jobs without affecting any other installed printers.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to inform you, that the printer, which name is returned by this method, is used to execute all subsequent print jobs and all subsequently altered
printer settings are related to this printer. Likewise, none of the available printers or their properties are affected using any of the print
methods of this class.
The name of the active printer to be used for subsequent printing. The method can be subsequently used or the method
to determine if this method has been successful.
How to find out the name of the currently selected printer on your computer.
Dim caption As String = "Example: PrintGetActivePrinter"
Using gdpicturePDF As New GdPicturePDF()
Dim PrintersCount As Integer = gdpicturePDF.PrintGetPrintersCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim CurPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The number of available printers: " + PrintersCount.ToString() + vbCrLf +
"The currently selected printer is: " + CurPrinter, caption)
Else
MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
End Using
string caption = "Example: PrintGetActivePrinter";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
int PrintersCount = gdpicturePDF.PrintGetPrintersCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string CurPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The number of available printers: " + PrintersCount.ToString() +
"\nThe currently selected printer is: " + CurPrinter, caption);
else
MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
else
MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
Sets the printer, identified by its name, as the active printer, that means makes it the currently selected printer, which is subsequently used when printing the
loaded PDF document. The specified printer is used to execute all next print jobs using the print methods of this class, if not set otherwise, without
affecting any other installed printers.
You can use the method to retrieve the currently selected printer, denoted as the active printer for print methods of this class. At
the same this printer utilizes all by you altered printer settings without affecting the installed printers.
The name of the printer you want to set up as an active printer to be used for subsequent printing.
Just to inform you, that the printer selected by this method is used to execute all subsequent print jobs and all subsequently altered printer settings are
related to this printer. Likewise, none of the available printers or their properties are affected using any of the print methods of this class.
true if the method has been followed successfully, otherwise false.
Please use the method or the method to determine the specific reason for the method's failure.
How to find out printer settings for all available printers.
Dim caption As String = "Example: PrintSetActivePrinter"
Using gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
Dim CurPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim PrintersCount As Integer = gdpicturePDF.PrintGetPrintersCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For i As Integer = 1 To PrintersCount
Dim PrinterName As String = gdpicturePDF.PrintGetPrinterName(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.PrintSetActivePrinter(PrinterName) = True Then
Dim prnSettings As System.Drawing.Printing.PrinterSettings
prnSettings = gdpicturePDF.PrintGetPrinterSettings()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "Printer: " + PrinterName + vbCrLf + "Settings: " + prnSettings.ToString() + vbCrLf + vbCrLf
Else
message = message + "Printer: " + PrinterName + " Error getting settings: " + gdpicturePDF.PrintGetStat().ToString() + vbCrLf
End If
Else
Exit For
End If
Else
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show(message, caption)
Else
MessageBox.Show("The example has NOT been followed successfully. The last status: " + gdpicturePDF.PrintGetStat(), caption)
End If
If gdpicturePDF.PrintSetActivePrinter(CurPrinter) = False Then
MessageBox.Show("The PrintSetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
End Using
string caption = "Example: PrintSetActivePrinter";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
string message = "";
string CurPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int PrintersCount = gdpicturePDF.PrintGetPrintersCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int i = 1; i <= PrintersCount; i++)
{
string PrinterName = gdpicturePDF.PrintGetPrinterName(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintSetActivePrinter(PrinterName) == true)
{
System.Drawing.Printing.PrinterSettings prnSettings;
prnSettings = gdpicturePDF.PrintGetPrinterSettings();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + "Printer: " + PrinterName + "\nSettings: " + prnSettings.ToString() + "\n\n";
else
message = message + "Printer: " + PrinterName + " Error getting settings: " + gdpicturePDF.PrintGetStat().ToString() + "\n";
}
else
break;
}
else
break;
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show(message, caption);
else
MessageBox.Show("The example has NOT been followed successfully. The last status: " + gdpicturePDF.PrintGetStat(), caption);
if (gdpicturePDF.PrintSetActivePrinter(CurPrinter) == false)
MessageBox.Show("The PrintSetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
else
MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
else
MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
Returns the number of all available (installed) printers on the computer.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
The number of available printers. The method can be subsequently used or the method to determine if this method has been successful.
How to find out the number of currently installed printers on your computer.
Dim caption As String = "Example: PrintGetPrintersCount"
Using gdpicturePDF As New GdPicturePDF()
Dim PrintersCount As Integer = gdpicturePDF.PrintGetPrintersCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim CurPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The number of available printers: " + PrintersCount.ToString() + vbCrLf +
"The currently active printer is: " + CurPrinter, caption)
Else
MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
End Using
string caption = "Example: PrintGetPrintersCount";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
int PrintersCount = gdpicturePDF.PrintGetPrintersCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string CurPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The number of available printers: " + PrintersCount.ToString() +
"\nThe currently active printer is: " + CurPrinter, caption);
else
MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
else
MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
Returns the name of the printer according to the index you have specified.
You can use the method to determine the number of all available printers.
The printer index is simply an integer value from 1 to .
The printer index. It must be a value from 1 to .
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
The name of the specified printer. The method can be subsequently used or the method to determine if this method has been successful.
How to find out the printer's name and how to use it further.
Dim caption As String = "Example: PrintGetPrinterName"
Using gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
Dim CurPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim PrintersCount As Integer = gdpicturePDF.PrintGetPrintersCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
For i As Integer = 1 To PrintersCount
Dim PrinterName As String = gdpicturePDF.PrintGetPrinterName(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.PrintSetActivePrinter(PrinterName) = True Then
Dim prnSettings As System.Drawing.Printing.PrinterSettings
prnSettings = gdpicturePDF.PrintGetPrinterSettings()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + "Printer: " + PrinterName + vbCrLf + "Settings: " + prnSettings.ToString() + vbCrLf + vbCrLf
Else
message = message + "Printer: " + PrinterName + " Error getting settings: " + gdpicturePDF.PrintGetStat().ToString() + vbCrLf
End If
Else
Exit For
End If
Else
Exit For
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show(message, caption)
Else
MessageBox.Show("The example has NOT been followed successfully. The last status: " + gdpicturePDF.PrintGetStat(), caption)
End If
If gdpicturePDF.PrintSetActivePrinter(CurPrinter) = False Then
MessageBox.Show("The PrintSetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
End If
End Using
string caption = "Example: PrintGetPrinterName";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
string message = "";
string CurPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int PrintersCount = gdpicturePDF.PrintGetPrintersCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
for (int i = 1; i <= PrintersCount; i++)
{
string PrinterName = gdpicturePDF.PrintGetPrinterName(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintSetActivePrinter(PrinterName) == true)
{
System.Drawing.Printing.PrinterSettings prnSettings;
prnSettings = gdpicturePDF.PrintGetPrinterSettings();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + "Printer: " + PrinterName + "\nSettings: " + prnSettings.ToString() + "\n\n";
else
message = message + "Printer: " + PrinterName + " Error getting settings: " + gdpicturePDF.PrintGetStat().ToString() + "\n";
}
else
break;
}
else
break;
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show(message, caption);
else
MessageBox.Show("The example has NOT been followed successfully. The last status: " + gdpicturePDF.PrintGetStat(), caption);
if (gdpicturePDF.PrintSetActivePrinter(CurPrinter) == false)
MessageBox.Show("The PrintSetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
else
MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
else
MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings and then to print the currently loaded PDF document.
Invokes the standard Windows Print dialog box allowing you to print the current document by choosing additional settings.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
You also need to be aware that annotations and form fields included in the document are rendered by default using this method when printing.
Just to inform you, that sometimes pages in the PDF document may have defined their internal rotation, which causes them to be unexpectedly rotated when printing.
Then you need to use the method for each such page to remove that rotation. You can also use the method
to find out if the page should be rotated when printed.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
How to print the current document using the standard Windows Print dialog box.
Dim caption As String = "Example: PrintDialog"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.PrintDialog() = True Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintDialog";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintDialog() == true)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Sets up the printer settings of the active printer.
As explained in the or the methods, none of the available printers
or their properties are affected using any of the print methods of this class.
A System.Drawing.Printing.PrinterSettings object. The newly specified printer settings of the active printer.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the printer settings for the active printer. This example shows you how to change the number of copies.
Dim caption As String = "Example: PrintSetPrinterSettings"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim prnSettings As System.Drawing.Printing.PrinterSettings
prnSettings = gdpicturePDF.PrintGetPrinterSettings()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
prnSettings.Copies = 2
gdpicturePDF.PrintSetPrinterSettings(prnSettings)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The PrintSetPrinterSettings() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetPrinterSettings() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
End Sub
string caption = "Example: PrintSetPrinterSettings";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
System.Drawing.Printing.PrinterSettings prnSettings;
prnSettings = gdpicturePDF.PrintGetPrinterSettings();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
prnSettings.Copies = 2;
gdpicturePDF.PrintSetPrinterSettings(prnSettings);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
}
else
{
MessageBox.Show("The PrintSetPrinterSettings() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
}
else
{
MessageBox.Show("The PrintGetPrinterSettings() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Returns the printer settings of the active printer.
As explained in the or the methods, none of the available printers
or their properties are affected using any of the print methods of this class.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A System.Drawing.Printing.PrinterSettings object. The printer settings of the active printer.
The method can be subsequently used or the method to determine if this method has been successful.
How to get the printer settings for the active printer and how to use them further.
Dim caption As String = "Example: PrintGetPrinterSettings"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim prnSettings As System.Drawing.Printing.PrinterSettings
prnSettings = gdpicturePDF.PrintGetPrinterSettings()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
prnSettings.Copies = 2
gdpicturePDF.PrintSetPrinterSettings(prnSettings)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The PrintSetPrinterSettings() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
Else
MessageBox.Show("The PrintGetPrinterSettings() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
End Sub
string caption = "Example: PrintGetPrinterSettings";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
System.Drawing.Printing.PrinterSettings prnSettings;
prnSettings = gdpicturePDF.PrintGetPrinterSettings();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
prnSettings.Copies = 2;
gdpicturePDF.PrintSetPrinterSettings(prnSettings);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
}
else
{
MessageBox.Show("The PrintSetPrinterSettings() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
}
else
{
MessageBox.Show("The PrintGetPrinterSettings() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings and then to print the currently loaded PDF document.
Using this method you can specify the top-level window that will own the modal dialog box.
Invokes the standard Windows Print dialog box allowing you to print the current document by choosing additional settings.
Represents the top-level window that will own the modal dialog box.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
You also need to be aware that annotations and form fields included in the document are rendered by default using this method when printing.
Just to inform you, that sometimes pages in the PDF document may have defined their internal rotation, which causes them to be unexpectedly rotated when printing.
Then you need to use the method for each such page to remove that rotation. You can also use the method
to find out if the page should be rotated when printed.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
How to print the current document using the standard Windows Print dialog box.
Dim caption As String = "Example: PrintDialog"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.PrintDialog(Me) = True Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintDialog";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintDialog(this) == true)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings and then to print the currently loaded PDF document. The
size of the document's pages is automatically adjusted to the actual paper size.
Invokes the standard Windows Print dialog box allowing you to print the current document by choosing additional settings, while document's page size is
automatically adjusted to the actual paper size.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
You also need to be aware that annotations and form fields included in the document are rendered by default using this method when printing.
Just to inform you, that sometimes pages in the PDF document may have defined their internal rotation, which causes them to be unexpectedly rotated when printing.
Then you need to use the method for each such page to remove that rotation. You can also use the method
to find out if the page should be rotated when printed.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
How to print the current document using the standard Windows Print dialog box so the document's pages are adjusted to the specified paper size automatically.
Dim caption As String = "Example: PrintDialogFit"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim ps As New System.Drawing.Printing.PaperSize("My Custom Size", 850, 1100)
gdpicturePDF.PrintSetPaperSize(ps)
If gdpicturePDF.PrintDialogFit() = True Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintDialogFit";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
System.Drawing.Printing.PaperSize ps = new System.Drawing.Printing.PaperSize("My Custom Size", 850, 1100);
gdpicturePDF.PrintSetPaperSize(ps);
if (gdpicturePDF.PrintDialogFit() == true)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Invokes the standard Windows Print dialog box, which allows you to select additional options or settings and then to print the currently loaded PDF document. The
size of the document's pages is automatically adjusted to the actual paper size. Using this method you can specify the top-level window that will own the modal dialog box.
Invokes the standard Windows Print dialog box allowing you to print the current document by choosing additional settings, while document's page size is
automatically adjusted to the actual paper size.
Represents the top-level window that will own the modal dialog box.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
You also need to be aware that annotations and form fields included in the document are rendered by default using this method when printing.
Just to inform you, that sometimes pages in the PDF document may have defined their internal rotation, which causes them to be unexpectedly rotated when printing.
Then you need to use the method for each such page to remove that rotation. You can also use the method
to find out if the page should be rotated when printed.
true if the method has been followed successfully, otherwise false. Please use the method to determine the reason for the printing failure.
How to print the current document using the standard Windows Print dialog box so the document's pages are adjusted to the specified paper size automatically.
Dim caption As String = "Example: PrintDialogFit"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim ps As New System.Drawing.Printing.PaperSize("My Custom Size", 850, 1100)
gdpicturePDF.PrintSetPaperSize(ps)
If gdpicturePDF.PrintDialogFit(Me) = True Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintDialogFit";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
System.Drawing.Printing.PaperSize ps = new System.Drawing.Printing.PaperSize("My Custom Size", 850, 1100);
gdpicturePDF.PrintSetPaperSize(ps);
if (gdpicturePDF.PrintDialogFit(this) == true)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Prints the currently loaded PDF document to the active printer using the actual paper size.
Please note that you can use the method to identify the specific reason for the printing failure.
You also need to be aware that annotations and form fields included in the document are rendered by default using this method when printing.
Just to inform you, that sometimes pages in the PDF document may have defined their internal rotation, which causes them to be unexpectedly rotated when printing.
Then you need to use the method for each such page to remove that rotation. You can also use the method
to find out if the page should be rotated when printed.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to print the current document using the default printer.
Dim caption As String = "Example: Print"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: Print";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Prints the currently loaded PDF document to the active printer. The size of the document's pages is automatically adjusted to the actual paper size.
Please note that you can use the method to identify the specific reason for the printing failure.
You also need to be aware that annotations and form fields included in the document are rendered by default using this method when printing.
Just to inform you, that sometimes pages in the PDF document may have defined their internal rotation, which causes them to be unexpectedly rotated when printing.
Then you need to use the method for each such page to remove that rotation. You can also use the method
to find out if the page should be rotated when printed.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to print the current document so the document's pages are adjusted to the specified paper size.
Dim caption As String = "Example: PrintFit"
Using gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim ps As New System.Drawing.Printing.PaperSize("My Custom Size", 850, 1100)
gdpicturePDF.PrintSetPaperSize(ps)
If gdpicturePDF.PrintFit() = GdPictureStatus.OK Then
MessageBox.Show("The file has been printed successfully.", caption)
Else
Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
MessageBox.Show(message, caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PrintFit";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
System.Drawing.Printing.PaperSize ps = new System.Drawing.Printing.PaperSize("My Custom Size", 850, 1100);
gdpicturePDF.PrintSetPaperSize(ps);
if (gdpicturePDF.PrintFit() == GdPictureStatus.OK)
{
MessageBox.Show("The file has been printed successfully.", caption);
}
else
{
string message = "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
MessageBox.Show(message, caption);
}
gdpicturePDF.CloseDocument();
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Sets up the standard paper size, means the type of the paper, to be used by the active printer.
The constant that represents the required standard paper size to be used. Please refer to the System.Drawing.Printing.PaperKind enumeration for correct values.
Some of them are listed below (please see the corresponding ordering number):
- Letter, 8.5 x 11 in.
- Letter Small, 8.5 x 11 in.
- Tabloid, 11 x 17 in.
- Ledger, 17 x 11 in.
- Legal, 8.5 x 14 in.
- Statement, 5 1/2 x 8 1/2 in.
- Executive, 7 1/2 x 10 1/2 in.
- A3, 297 x 420 mm
- A4, 210 x 297 mm
- A4 Small, 210 x 297 mm
- A5, 148 x 210 mm
- B4, 250 x 354 mm
- B5, 182 x 257 mm
- Folio, 8.5 x 13 in.
- Quarto, 215 x 275 mm
- Standard 10 x 14 in.
- Standard 11 x 17 in.
- Note, 8.5 x 11 in.
- Envelope #9, 3 7/8 x 8 7/8 in.
- Envelope #10, 4 1/8 x 9.5 in.
- Envelope #11, 4.5 x 10 3/8 in.
- Envelope #12, 4.5 x 11 in.
- Envelope #14, 5 x 11.5 in.
- C size sheet
- D size sheet
- E size sheet
- Envelope DL, 110 x 220 mm
- Envelope C5, 162 x 229 mm
- Envelope C3, 324 x 458 mm
- Envelope C4, 229 x 324 mm
- Envelope C6, 114 x 162 mm
- Envelope C65, 114 x 229 mm
- Envelope B4, 250 x 353 mm
- Envelope B5, 176 x 250 mm
- Envelope B6, 176 x 125 mm
- Envelope Italy, 110 x 230 mm
- Envelope Monarch, 3 7/8 x 7.5 in.
- Envelope, 3 5/8 x 6.5 in.
- U.S. Standard Fanfold, 14 7/8 x 11 in.
- German Standard Fanfold, 8.5 x 12 in.
- German Legal Fanfold, 8 1/2 x 13 in.
42. and more Less-common international sizes.118. and more Custom paper sizes.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetStdPaperSize"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.PrintSetPaperBin(7) Then
message = message + " paper bin: 7 (automatic feed)" + vbCrLf
Else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetStdPaperSize(5)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: (5) Legal" + vbCrLf
Else
message = "The PrintSetStdPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetFromToPage(2, 4)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " page range: 2-4" + vbCrLf
Else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetStdPaperSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintSetPaperBin(7))
message = message + " paper bin: 7 (automatic feed)\n";
else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetStdPaperSize(5);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: (5) Legal\n";
else
message = "The PrintSetStdPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetFromToPage(2,4);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " page range: 2-4\n";
else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets the paper size, means the type of the paper, to be used by the active printer.
A PaperSize object that defines the new value of the paper size to be used.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetPaperSize"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.PrintSetPaperBin(7) Then
message = message + " paper bin: 7 (automatic feed)" + vbCrLf
Else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim pSize As System.Drawing.Printing.PaperSize = New System.Drawing.Printing.PaperSize("My custom size", 120, 250)
gdpicturePDF.PrintSetPaperSize(pSize)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: 120, 250" + vbCrLf
Else
message = "The PrintSetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetFromToPage(2, 4)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " page range: 2-4" + vbCrLf
Else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetPaperSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintSetPaperBin(7))
message = message + " paper bin: 7 (automatic feed)\n";
else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.PaperSize pSize = new System.Drawing.Printing.PaperSize("My custom size", 120, 250);
gdpicturePDF.PrintSetPaperSize(pSize);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: 120, 250\n";
else
message = "The PrintSetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetFromToPage(2,4);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " page range: 2-4\n";
else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up a custom paper size to be used by the active printer.
The custom paper width to be used, in inches.
The custom paper height to be used, in inches.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetUserPaperSize"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.PrintSetPaperBin(7) Then
message = message + " paper bin: 7 (automatic feed)" + vbCrLf
Else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetUserPaperSize(120, 250)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: 120, 250" + vbCrLf
Else
message = "The PrintSetUserPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetFromToPage(2, 4)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " page range: 2-4" + vbCrLf
Else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetUserPaperSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.PrintSetPaperBin(7))
message = message + " paper bin: 7 (automatic feed)\n";
else
message = "The PrintSetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetUserPaperSize(120, 250);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: 120, 250\n";
else
message = "The PrintSetUserPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetFromToPage(2,4);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " page range: 2-4\n";
else
message = "The PrintSetFromToPage() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the height of the paper to be used by the active printer.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The paper height, in inches. The method can be subsequently used or the method to determine if this method has been successful.
How to find out some page properties of the active printer.
Dim caption As String = "Example: PrintGetPaperHeight"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim leftMargin As Single = 0, rightMargin As Single = 0
gdpicturePDF.PrintGetMargins(leftMargin, rightMargin)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + vbCrLf
Else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnBin As Integer = gdpicturePDF.PrintGetPaperBin()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper bin: " + prnBin.ToString() + vbCrLf
Else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnSize As Integer = gdpicturePDF.PrintGetPaperSize()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: " + prnSize.ToString() + vbCrLf
Else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnHeight As Single = gdpicturePDF.PrintGetPaperHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper height: " + prnHeight.ToString()
Else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnWidth As Single = gdpicturePDF.PrintGetPaperWidth()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper width: " + prnWidth.ToString() + vbCrLf
Else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetPaperHeight";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float leftMargin = 0, rightMargin = 0;
gdpicturePDF.PrintGetMargins(ref leftMargin, ref rightMargin);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + "\n";
else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnBin = gdpicturePDF.PrintGetPaperBin();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper bin: " + prnBin.ToString() + "\n";
else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnSize = gdpicturePDF.PrintGetPaperSize();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: " + prnSize.ToString() + "\n";
else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnHeight = gdpicturePDF.PrintGetPaperHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper height: " + prnHeight.ToString();
else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnWidth = gdpicturePDF.PrintGetPaperWidth();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper width: " + prnWidth.ToString() + "\n";
else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the width of the paper to be used by the active printer.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The paper width, in inches. The method can be subsequently used or the method to determine if this method has been successful.
How to find out some page properties of the active printer.
Dim caption As String = "Example: PrintGetPaperWidth"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim leftMargin As Single = 0, rightMargin As Single = 0
gdpicturePDF.PrintGetMargins(leftMargin, rightMargin)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + vbCrLf
Else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnBin As Integer = gdpicturePDF.PrintGetPaperBin()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper bin: " + prnBin.ToString() + vbCrLf
Else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnSize As Integer = gdpicturePDF.PrintGetPaperSize()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: " + prnSize.ToString() + vbCrLf
Else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnHeight As Single = gdpicturePDF.PrintGetPaperHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper height: " + prnHeight.ToString()
Else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnWidth As Single = gdpicturePDF.PrintGetPaperWidth()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper width: " + prnWidth.ToString() + vbCrLf
Else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetPaperWidth";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float leftMargin = 0, rightMargin = 0;
gdpicturePDF.PrintGetMargins(ref leftMargin, ref rightMargin);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + "\n";
else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnBin = gdpicturePDF.PrintGetPaperBin();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper bin: " + prnBin.ToString() + "\n";
else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnSize = gdpicturePDF.PrintGetPaperSize();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: " + prnSize.ToString() + "\n";
else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnHeight = gdpicturePDF.PrintGetPaperHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper height: " + prnHeight.ToString();
else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnWidth = gdpicturePDF.PrintGetPaperWidth();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper width: " + prnWidth.ToString() + "\n";
else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the value of an image alignment setting of the active printer. This value determines how the image is aligned when printing.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the PrintAlignment enumeration. The value of the image alignment property.
The method can be subsequently used or the method to determine if this method has been successful.
How to find out some properties of the currently selected (active) printer.
Dim caption As String = "Example: PrintGetAlignment"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If (gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK) Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnAlign As PrintAlignment = gdpicturePDF.PrintGetAlignment()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: " + prnAlign.ToString() + vbCrLf
Else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnCollate As Boolean = gdpicturePDF.PrintGetCollate()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: " + prnCollate.ToString() + vbCrLf
Else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnColorMode As PrinterColorMode = gdpicturePDF.PrintGetColorMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: " + prnColorMode.ToString() + vbCrLf
Else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnDuplex As System.Drawing.Printing.Duplex = gdpicturePDF.PrintGetDuplexMode()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: " + prnDuplex.ToString() + vbCrLf
Else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnOrientation As PrinterOrientation = gdpicturePDF.PrintGetOrientation()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: " + prnOrientation.ToString() + vbCrLf
Else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnQuality As PrintQuality = gdpicturePDF.PrintGetQuality()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: " + prnQuality.ToString() + vbCrLf
Else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetAlignment";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintAlignment prnAlign = gdpicturePDF.PrintGetAlignment();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: " + prnAlign.ToString() + "\n";
else
message = "The PrintGetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
bool prnCollate = gdpicturePDF.PrintGetCollate();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: " + prnCollate.ToString() + "\n";
else
message = "The PrintGetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterColorMode prnColorMode = gdpicturePDF.PrintGetColorMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: " + prnColorMode.ToString() + "\n";
else
message = "The PrintGetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
System.Drawing.Printing.Duplex prnDuplex = gdpicturePDF.PrintGetDuplexMode();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: " + prnDuplex.ToString() + "\n";
else
message = "The PrintGetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrinterOrientation prnOrientation = gdpicturePDF.PrintGetOrientation();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: " + prnOrientation.ToString() + "\n";
else
message = "The PrintGetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
PrintQuality prnQuality = gdpicturePDF.PrintGetQuality();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: " + prnQuality.ToString() + "\n";
else
message = "The PrintGetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up the value of an image alignment setting of the active printer. This value determines how the image is aligned when printing.
A member of the PrintAlignment enumeration. The new value of the image alignment property.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetAlignment"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: MiddleCenter" + vbCrLf
Else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAutoRotation(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " auto-rotation: True" + vbCrLf
Else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetCollate(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: True" + vbCrLf
Else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: Color" + vbCrLf
Else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: Simplex" + vbCrLf
Else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: Portrait" + vbCrLf
Else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: High" + vbCrLf
Else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetAlignment";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: MiddleCenter\n";
else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAutoRotation(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " auto-rotation: true\n";
else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetCollate(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: true\n";
else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: Color\n";
else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: Simplex\n";
else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: Portrait\n";
else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: High\n";
else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Sets up the auto-rotation property of the active printer, that determines, if the pages are automatically rotated to fit on the output medium when printing.
Defines the auto-rotation property. Set this parameter to true if you want to select the page orientation automatically,
otherwise set it to false.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up some printer properties to be used for printing the current document.
Dim caption As String = "Example: PrintSetAutoRotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " alignment: MiddleCenter" + vbCrLf
Else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetAutoRotation(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " auto-rotation: True" + vbCrLf
Else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetCollate(True)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " collate: True" + vbCrLf
Else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " color mode: Color" + vbCrLf
Else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " duplex: Simplex" + vbCrLf
Else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " orientation: Portrait" + vbCrLf
Else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " quality: High" + vbCrLf
Else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.Print() = GdPictureStatus.OK Then
message = message + "The file has been printed successfully using new settings."
Else
message = message + "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
message = message + " Error: " + gdpicturePDF.PrintGetLastError()
End If
End If
Else
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintSetAutoRotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAlignment(PrintAlignment.PrintAlignmentMiddleCenter);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " alignment: MiddleCenter\n";
else
message = "The PrintSetAlignment() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetAutoRotation(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " auto-rotation: true\n";
else
message = "The PrintSetAutoRotation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetCollate(true);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " collate: true\n";
else
message = "The PrintSetCollate() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetColorMode(PrinterColorMode.PrinterColorModeColor);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " color mode: Color\n";
else
message = "The PrintSetColorMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetDuplexMode(System.Drawing.Printing.Duplex.Simplex);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " duplex: Simplex\n";
else
message = "The PrintSetDuplexMode() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetOrientation(PrinterOrientation.PrinterOrientationPortrait);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " orientation: Portrait\n";
else
message = "The PrintSetOrientation() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.PrintSetQuality(PrintQuality.PrintQualityHighResolution);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " quality: High\n";
else
message = "The PrintSetQuality() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.Print() == GdPictureStatus.OK)
{
message = message + "The file has been printed successfully using new settings.";
}
else
{
message = message + "The file can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
message = message + " Error: " + gdpicturePDF.PrintGetLastError();
}
}
else
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Enables or disables the pre-rasterization parameter which specifies whether the pages of the currently loaded PDF document must be pre-rasterized before being printed using the active printer.
Enabling the pre-rasterization can dramatically improve the performance with printer drivers non-optimized for vector graphics rendering.
You can also define the rendering resolution using the method when pre-rasterization is enabled.
Set this parameter to true if you want to enable the pre-rasterization, otherwise set it to false. The default value is false.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Enabling the pre-rasterization option to speed up the print process.
Using gdpicturePDF As New GdPicturePDF()
gdpicturePDF.LoadFromFile("document_to_print.pdf", False)
'Enabling the pre-rasterization option.
gdpicturePDF.PrintSetPreRasterization(True)
'Setting the pre-rasterization DPI.
gdpicturePDF.PrintSetPreRasterizationDPI(300)
gdpicturePDF.Print()
gdpicturePDF.CloseDocument()
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("document_to_print.pdf", false);
//Enabling the pre-rasterization option.
gdpicturePDF.PrintSetPreRasterization(true);
//Setting the pre-rasterization DPI.
gdpicturePDF.PrintSetPreRasterizationDPI(300);
gdpicturePDF.Print();
gdpicturePDF.CloseDocument();
}
Specifies the rendering resolution to be used when pre-rasterization is enabled using the method.
Enabling the pre-rasterization and setting the proper DPI can dramatically improve the performance with printer drivers non-optimized for vector graphics rendering.
The rendering resolution to be used for pre-rasterization. The default value is -1, which means automatic computation based on printing quality.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Setting the pre-rasterization DPI to speed up the print process.
Using gdpicturePDF As New GdPicturePDF()
gdpicturePDF.LoadFromFile("document_to_print.pdf", False)
'Enabling the pre-rasterization option.
gdpicturePDF.PrintSetPreRasterization(True)
'Setting the pre-rasterization DPI.
gdpicturePDF.PrintSetPreRasterizationDPI(300)
gdpicturePDF.Print()
gdpicturePDF.CloseDocument()
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("document_to_print.pdf", false);
//Enabling the pre-rasterization option.
gdpicturePDF.PrintSetPreRasterization(true);
//Setting the pre-rasterization DPI.
gdpicturePDF.PrintSetPreRasterizationDPI(300);
gdpicturePDF.Print();
gdpicturePDF.CloseDocument();
}
Returns the current paper size, means the type of the paper, to be used by the active printer.
The value is determined through the PaperSize.Kind property of the default page settings.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
The constant that represents the current paper size. Please refer to the System.Drawing.Printing.PaperKind enumeration for correct values. Some of them are
listed below (please see the corresponding ordering number):
- Letter, 8.5 x 11 in.
- Letter Small, 8.5 x 11 in.
- Tabloid, 11 x 17 in.
- Ledger, 17 x 11 in.
- Legal, 8.5 x 14 in.
- Statement, 5 1/2 x 8 1/2 in.
- Executive, 7 1/2 x 10 1/2 in.
- A3, 297 x 420 mm
- A4, 210 x 297 mm
- A4 Small, 210 x 297 mm
- A5, 148 x 210 mm
- B4, 250 x 354 mm
- B5, 182 x 257 mm
- Folio, 8.5 x 13 in.
- Quarto, 215 x 275 mm
- Standard 10 x 14 in.
- Standard 11 x 17 in.
- Note, 8.5 x 11 in.
- Envelope #9, 3 7/8 x 8 7/8 in.
- Envelope #10, 4 1/8 x 9.5 in.
- Envelope #11, 4.5 x 10 3/8 in.
- Envelope #12, 4.5 x 11 in.
- Envelope #14, 5 x 11.5 in.
- C size sheet
- D size sheet
- E size sheet
- Envelope DL, 110 x 220 mm
- Envelope C5, 162 x 229 mm
- Envelope C3, 324 x 458 mm
- Envelope C4, 229 x 324 mm
- Envelope C6, 114 x 162 mm
- Envelope C65, 114 x 229 mm
- Envelope B4, 250 x 353 mm
- Envelope B5, 176 x 250 mm
- Envelope B6, 176 x 125 mm
- Envelope Italy, 110 x 230 mm
- Envelope Monarch, 3 7/8 x 7.5 in.
- Envelope, 3 5/8 x 6.5 in.
- U.S. Standard Fanfold, 14 7/8 x 11 in.
- German Standard Fanfold, 8.5 x 12 in.
- German Legal Fanfold, 8 1/2 x 13 in.
42. and more Less-common international sizes.118. and more Custom paper sizes.
The method can be subsequently used or the method to determine if this method has been successful.
How to find out some page properties of the active printer.
Dim caption As String = "Example: PrintGetPaperSize"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim leftMargin As Single = 0, rightMargin As Single = 0
gdpicturePDF.PrintGetMargins(leftMargin, rightMargin)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + vbCrLf
Else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnBin As Integer = gdpicturePDF.PrintGetPaperBin()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper bin: " + prnBin.ToString() + vbCrLf
Else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnSize As Integer = gdpicturePDF.PrintGetPaperSize()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: " + prnSize.ToString() + vbCrLf
Else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnHeight As Single = gdpicturePDF.PrintGetPaperHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper height: " + prnHeight.ToString()
Else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnWidth As Single = gdpicturePDF.PrintGetPaperWidth()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper width: " + prnWidth.ToString() + vbCrLf
Else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetPaperSize";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float leftMargin = 0, rightMargin = 0;
gdpicturePDF.PrintGetMargins(ref leftMargin, ref rightMargin);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + "\n";
else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnBin = gdpicturePDF.PrintGetPaperBin();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper bin: " + prnBin.ToString() + "\n";
else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnSize = gdpicturePDF.PrintGetPaperSize();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: " + prnSize.ToString() + "\n";
else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnHeight = gdpicturePDF.PrintGetPaperHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper height: " + prnHeight.ToString();
else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnWidth = gdpicturePDF.PrintGetPaperWidth();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper width: " + prnWidth.ToString() + "\n";
else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the physical margins (x and y coordinates), that are part of the default page settings property of the active printer.
Both margins are used as defaults for all pages to be printed.
Output parameter. The physical margin (x-coordinate) at the left of the page, in inches.
Output parameter. The physical margin (y-coordinate) at the top of the page, in inches.
It is recommend to use the method or the method to identify the specific reason for the method's failure, if any.
Just to remind you that the active printer is the printer identified by the method or set by the method and
it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.
How to find out some page properties of the active printer.
Dim caption As String = "Example: PrintGetMargins"
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = ""
If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
Dim curPrinter As String = gdpicturePDF.PrintGetActivePrinter()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = "Active printer: " + curPrinter + vbCrLf
Else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat()
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim leftMargin As Single = 0, rightMargin As Single = 0
gdpicturePDF.PrintGetMargins(leftMargin, rightMargin)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + vbCrLf
Else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnBin As Integer = gdpicturePDF.PrintGetPaperBin()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper bin: " + prnBin.ToString() + vbCrLf
Else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnSize As Integer = gdpicturePDF.PrintGetPaperSize()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper size: " + prnSize.ToString() + vbCrLf
Else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnHeight As Single = gdpicturePDF.PrintGetPaperHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper height: " + prnHeight.ToString()
Else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim prnWidth As Single = gdpicturePDF.PrintGetPaperWidth()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + " paper width: " + prnWidth.ToString() + vbCrLf
Else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat()
End If
End If
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString()
End If
Else
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
gdpicturePDF.Dispose()
string caption = "Example: PrintGetMargins";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "";
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string curPrinter = gdpicturePDF.PrintGetActivePrinter();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = "Active printer: " + curPrinter + "\n";
else
message = "The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.GetStat();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float leftMargin = 0, rightMargin = 0;
gdpicturePDF.PrintGetMargins(ref leftMargin, ref rightMargin);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " margins: left = " + leftMargin.ToString() + ", right = " + rightMargin.ToString() + "\n";
else
message = "The PrintGetMargins() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnBin = gdpicturePDF.PrintGetPaperBin();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper bin: " + prnBin.ToString() + "\n";
else
message = "The PrintGetPaperBin() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int prnSize = gdpicturePDF.PrintGetPaperSize();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper size: " + prnSize.ToString() + "\n";
else
message = "The PrintGetPaperSize() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnHeight = gdpicturePDF.PrintGetPaperHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper height: " + prnHeight.ToString();
else
message = "The PrintGetPaperHeight() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float prnWidth = gdpicturePDF.PrintGetPaperWidth();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + " paper width: " + prnWidth.ToString() + "\n";
else
message = "The PrintGetPaperWidth() method has failed with the status: " + gdpicturePDF.GetStat();
}
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The example has NOT been followed successfully. Status: " + gdpicturePDF.GetStat().ToString();
}
}
else
{
message = "The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString();
}
MessageBox.Show(message, caption);
gdpicturePDF.Dispose();
Returns the number of the optional content group (OCG) entries defined in the currently loaded PDF document.
Optional Content Groups, also knows as Layers, are a very effective tool to control the visibility of the page content,
that can be selectively viewed or hidden, by users or viewers.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of OCG entries (layers) defined in the document. The method can be subsequently used to determine if this method has been successful.
How to find out the number of layers defined in the PDF document and enumerate them subsequently.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim state As PdfOcgState = PdfOcgState.Undefined
Dim onOff As Boolean = False
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGViewState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; View = " + state.ToString()
Else
output = output + " ; View = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGExportState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Export = " + state.ToString()
Else
output = output + " ; Export = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGPrintState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Print = " + state.ToString()
Else
output = output + " ; Print = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGLockedState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Locked = " + onOff.ToString()
Else
output = output + " ; Locked = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCGCount")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGCount")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCGCount")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
PdfOcgState state = PdfOcgState.Undefined;
bool onOff = false;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nNr." + (i + 1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGViewState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; View = " + state.ToString();
else
output = output + " ; View = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGExportState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Export = " + state.ToString();
else
output = output + " ; Export = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGPrintState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Print = " + state.ToString();
else
output = output + " ; Print = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGLockedState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Locked = " + onOff.ToString();
else
output = output + " ; Locked = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCGCount");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGCount");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCGCount");
}
gdpicturePDF.Dispose();
Returns a unique identifier of an optional content group according to the index you have specified.
You can use the method to determine the number of all OCG entries (layers) used in the PDF document.
The index of the required optional content group. It must be a value from 0 to -1.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The unique identifier of the specified OCG entry. The method can be subsequently used to determine if this method has been successful.
How to find out the proper layer identifier and some of the corresponding layer's properties.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim state As PdfOcgState = PdfOcgState.Undefined
Dim onOff As Boolean = False
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGViewState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; View = " + state.ToString()
Else
output = output + " ; View = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGExportState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Export = " + state.ToString()
Else
output = output + " ; Export = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGPrintState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Print = " + state.ToString()
Else
output = output + " ; Print = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGLockedState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Locked = " + onOff.ToString()
Else
output = output + " ; Locked = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCG")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCG")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCG")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
PdfOcgState state = PdfOcgState.Undefined;
bool onOff = false;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nNr." + (i + 1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGViewState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; View = " + state.ToString();
else
output = output + " ; View = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGExportState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Export = " + state.ToString();
else
output = output + " ; Export = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGPrintState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Print = " + state.ToString();
else
output = output + " ; Print = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGLockedState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Locked = " + onOff.ToString();
else
output = output + " ; Locked = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCG");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCG");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCG");
}
gdpicturePDF.Dispose();
Returns the title of an optional content group, in other words the name of a layer, specified by its unique identifier.
This name is presented in the viewer's user interface.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The title of the specifed optional content group. The method can be subsequently used to determine if this method has been successful.
How to find out the title of the specified layer and some other layer's properties.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim state As PdfOcgState = PdfOcgState.Undefined
Dim onOff As Boolean = False
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGViewState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; View = " + state.ToString()
Else
output = output + " ; View = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGExportState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Export = " + state.ToString()
Else
output = output + " ; Export = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGPrintState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Print = " + state.ToString()
Else
output = output + " ; Print = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGLockedState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Locked = " + onOff.ToString()
Else
output = output + " ; Locked = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCGTitle")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGTitle")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCGTitle")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
PdfOcgState state = PdfOcgState.Undefined;
bool onOff = false;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nNr." + (i + 1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGViewState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; View = " + state.ToString();
else
output = output + " ; View = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGExportState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Export = " + state.ToString();
else
output = output + " ; Export = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGPrintState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Print = " + state.ToString();
else
output = output + " ; Print = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGLockedState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Locked = " + onOff.ToString();
else
output = output + " ; Locked = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCGTitle");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGTitle");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCGTitle");
}
gdpicturePDF.Dispose();
Sets up the title of an optional content group, in other words the name of a layer, specified by its unique identifier.
This name is presented in the viewer's user interface.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
The new title to be used for the specified optional content group.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the title of the specified layer in the PDF document.
Dim caption As String = "Example: SetOCGTitle"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
If gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", False) = GdPictureStatus.OK Then
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (ocgCount > 0) Then
Dim ocgID As Integer = gdpicturePDF.GetOCG(0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetOCGTitle(ocgID, "Updated layer") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, False) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGZoomMin(ocgID, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGZoomMax(ocgID, 1) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_UpdatedLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetOCG() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetOCGTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
if (gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", false) == GdPictureStatus.OK)
{
int ocgCount = gdpicturePDF.GetOCGCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (ocgCount > 0))
{
int ocgID = gdpicturePDF.GetOCG(0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetOCGTitle(ocgID, "Updated layer") == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, false) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGZoomMin(ocgID, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGZoomMax(ocgID, 1) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_UpdatedLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCG() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the value of the Locked state setting of an optional content group specified by its unique identifier.
The Locked state indicates, if this group is for information only. Producers can use this state to prevent the visibility of this group
from being changed by users.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The value of the Locked state setting. The method can be subsequently used to determine if this method has been successful.
How to find out the Locked state of the specified layer and some other layer's properties.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim state As PdfOcgState = PdfOcgState.Undefined
Dim onOff As Boolean = False
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGViewState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; View = " + state.ToString()
Else
output = output + " ; View = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGExportState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Export = " + state.ToString()
Else
output = output + " ; Export = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGPrintState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Print = " + state.ToString()
Else
output = output + " ; Print = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGLockedState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Locked = " + onOff.ToString()
Else
output = output + " ; Locked = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCGLockedState")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGLockedState")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCGLockedState")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
PdfOcgState state = PdfOcgState.Undefined;
bool onOff = false;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nNr." + (i + 1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGViewState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; View = " + state.ToString();
else
output = output + " ; View = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGExportState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Export = " + state.ToString();
else
output = output + " ; Export = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGPrintState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Print = " + state.ToString();
else
output = output + " ; Print = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGLockedState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Locked = " + onOff.ToString();
else
output = output + " ; Locked = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCGLockedState");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGLockedState");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCGLockedState");
}
gdpicturePDF.Dispose();
Sets up the value of the Locked state setting of an optional content group specified by its unique identifier.
The Locked state indicates, if this group is for information only. Producers can use this state to prevent the visibility
of this group from being changed by users.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
The new value of the Locked state setting to be used for the specified optional content group.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to enable the Locked state setting for the specified layer in the PDF document.
Dim caption As String = "Example: SetOCGLockedState"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim image_res_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim ocgID As Integer = gdpicturePDF.NewOCG("Image layer")
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) = GdPictureStatus.OK) Then
If (gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_ImageLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetOCGLockedState";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
string image_res_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int ocgID = gdpicturePDF.NewOCG("Image layer");
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) == GdPictureStatus.OK))
{
if ((gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_ImageLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
Returns the value of the View state setting of an optional content group specified by its unique identifier.
The View state indicates the onscreen visibility, that means if the content of this group is viewable.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfOcgState enumeration. The value of the View state setting.
The method can be subsequently used to determine if this method has been successful.
How to find out the View state of the specified layer and some other layer's properties.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim state As PdfOcgState = PdfOcgState.Undefined
Dim onOff As Boolean = False
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGViewState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; View = " + state.ToString()
Else
output = output + " ; View = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGExportState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Export = " + state.ToString()
Else
output = output + " ; Export = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGPrintState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Print = " + state.ToString()
Else
output = output + " ; Print = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGLockedState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Locked = " + onOff.ToString()
Else
output = output + " ; Locked = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCGViewState")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGViewState")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCGViewState")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
PdfOcgState state = PdfOcgState.Undefined;
bool onOff = false;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nNr." + (i + 1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGViewState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; View = " + state.ToString();
else
output = output + " ; View = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGExportState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Export = " + state.ToString();
else
output = output + " ; Export = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGPrintState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Print = " + state.ToString();
else
output = output + " ; Print = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGLockedState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Locked = " + onOff.ToString();
else
output = output + " ; Locked = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCGViewState");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGViewState");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCGViewState");
}
gdpicturePDF.Dispose();
Sets up the value of the View state setting of an optional content group specified by its unique identifier.
The View state indicates the onscreen visibility, that means if the content of this group is viewable.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
A member of the PdfOcgState enumeration. The new value of the View state setting to be used for the specified optional content group.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to enable the View state setting for the specified layer in the PDF document.
Dim caption As String = "Example: SetOCGViewState"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim image_res_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim ocgID As Integer = gdpicturePDF.NewOCG("Image layer")
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) = GdPictureStatus.OK) Then
If (gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_ImageLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetOCGViewState";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
string image_res_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int ocgID = gdpicturePDF.NewOCG("Image layer");
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) == GdPictureStatus.OK))
{
if ((gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_ImageLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
Returns the value of the Print state setting of an optional content group specified by its unique identifier.
The Print state indicates, if the content of this group is printable.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfOcgState enumeration. The value of the Print state setting.
The method can be subsequently used to determine if this method has been successful.
How to find out the Print state of the specified layer and some other layer's properties.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim state As PdfOcgState = PdfOcgState.Undefined
Dim onOff As Boolean = False
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGViewState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; View = " + state.ToString()
Else
output = output + " ; View = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGExportState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Export = " + state.ToString()
Else
output = output + " ; Export = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGPrintState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Print = " + state.ToString()
Else
output = output + " ; Print = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGLockedState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Locked = " + onOff.ToString()
Else
output = output + " ; Locked = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCGPrintState")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGPrintState")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCGPrintState")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
PdfOcgState state = PdfOcgState.Undefined;
bool onOff = false;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nNr." + (i + 1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGViewState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; View = " + state.ToString();
else
output = output + " ; View = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGExportState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Export = " + state.ToString();
else
output = output + " ; Export = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGPrintState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Print = " + state.ToString();
else
output = output + " ; Print = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGLockedState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Locked = " + onOff.ToString();
else
output = output + " ; Locked = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCGPrintState");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGPrintState");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCGPrintState");
}
gdpicturePDF.Dispose();
Sets up the value of the Print state setting of an optional content group specified by its unique identifier.
The Print state indicates, if the content of this group is printable.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
A member of the PdfOcgState enumeration. The new value of the Print state setting to be used for the specified optional content group.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to disable the Print state setting for the specified layer in the PDF document.
Dim caption As String = "Example: SetOCGPrintState"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim image_res_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim ocgID As Integer = gdpicturePDF.NewOCG("Image layer")
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) = GdPictureStatus.OK) Then
If (gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOff) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_ImageLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetOCGPrintState";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
string image_res_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int ocgID = gdpicturePDF.NewOCG("Image layer");
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) == GdPictureStatus.OK))
{
if ((gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOff) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_ImageLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
Returns the value of the Export state setting of an optional content group specified by its unique identifier.
The Export state indicates, if the content in this group is exported, when the document (or part of it) is saved by a viewer application to a format, that
does not support optional content (for example, an earlier version of PDF or a raster image format).
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
A member of the PdfOcgState enumeration. The value of the Export state setting.
The method can be subsequently used to determine if this method has been successful.
How to find out the Export state of the specified layer and some other layer's properties.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim state As PdfOcgState = PdfOcgState.Undefined
Dim onOff As Boolean = False
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGViewState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; View = " + state.ToString()
Else
output = output + " ; View = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGExportState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Export = " + state.ToString()
Else
output = output + " ; Export = Error (" + status.ToString() + ")"
End If
state = gdpicturePDF.GetOCGPrintState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Print = " + state.ToString()
Else
output = output + " ; Print = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGLockedState(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " ; Locked = " + onOff.ToString()
Else
output = output + " ; Locked = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCGExportState")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGExportState")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCGExportState")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
PdfOcgState state = PdfOcgState.Undefined;
bool onOff = false;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nNr." + (i + 1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGViewState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; View = " + state.ToString();
else
output = output + " ; View = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGExportState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Export = " + state.ToString();
else
output = output + " ; Export = Error (" + status.ToString() + ")";
state = gdpicturePDF.GetOCGPrintState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Print = " + state.ToString();
else
output = output + " ; Print = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGLockedState(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " ; Locked = " + onOff.ToString();
else
output = output + " ; Locked = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCGExportState");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGExportState");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCGExportState");
}
gdpicturePDF.Dispose();
Sets up the value of the Export state setting of an optional content group specified by its unique identifier.
The Export state indicates, if the content in this group is exported, when the document (or part of it) is saved by a viewer application to a format,
that does not support optional content (for example, an earlier version of PDF or a raster image format).
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
A member of the PdfOcgState enumeration. The new value of the Export state setting to be used for the specified optional content group.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to disable the Export state setting for the specified layer in the PDF document.
Dim caption As String = "Example: SetOCGExportState"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim image_res_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim ocgID As Integer = gdpicturePDF.NewOCG("Image layer")
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) = GdPictureStatus.OK) Then
If (gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_ImageLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetOCGExportState";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
string image_res_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int ocgID = gdpicturePDF.NewOCG("Image layer");
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) == GdPictureStatus.OK))
{
if ((gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_ImageLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
Returns the minimum magnification factor of an optional content group, specified by its unique identifier.
It is the minimum value of a defined range of magnifications at which the content of this optional content group is best viewed.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that some viewers can interpret this value as the minimum value of a defined range of magnifications below which the content
of this optional content group is viewed, meaning that when zooming lower the content will not display.
The minimum recommended magnification factor at which the content of the specified OCG is best viewed.
The method can be subsequently used to determine if this method has been successful.
How to find out the range of magnifications of the specified layer in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim onOff As Boolean = False
Dim zoom As Double = 0
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Layer nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGIntentView(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If onOff Then
output = output + " Intent = View"
Else
output = output + " Intent = Design"
End If
Else
output = output + " Intent = Error (" + status.ToString() + ")"
End If
zoom = gdpicturePDF.GetOCGZoomMin(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + vbCrLf + " zoomMin = " + String.Format("{0:0.00}", zoom)
Else
output = output + vbCrLf + " zoomMin = Error (" + status.ToString() + ")"
End If
zoom = gdpicturePDF.GetOCGZoomMax(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " zoomMax = " + String.Format("{0:0.00}", zoom)
Else
output = output + " zoomMax = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCGZoomMin")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGZoomMin")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCGZoomMin")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
bool onOff = false;
double zoom = 0;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nLayer nr." + (i+1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGIntentView(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (onOff)
output = output + " Intent = View";
else
output = output + " Intent = Design";
}
else
output = output + " Intent = Error (" + status.ToString() + ")";
zoom = gdpicturePDF.GetOCGZoomMin(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "\n zoomMin = " + string.Format("{0:0.00}", zoom);
else
output = output + "\n zoomMin = Error (" + status.ToString() + ")";
zoom = gdpicturePDF.GetOCGZoomMax(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " zoomMax = " + string.Format("{0:0.00}", zoom);
else
output = output + " zoomMax = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCGZoomMin");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGZoomMin");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCGZoomMin");
}
gdpicturePDF.Dispose();
Sets up the minimum magnification factor of an optional content group, specified by its unique identifier.
It is the minimum value of a defined range of magnifications at which the content of this optional content group is best viewed.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
The new value of the minimum magnification factor to be set. Please use the value 0.1 to define the 10% or 1 to define the 100% zoom factor.
This method is only allowed for use with non-encrypted documents.
To define the 10% to 200% zoom range, please set the ZoomMin parameter to 0.1 using the method
and the ZoomMax parameter to 2 using the method.
Be aware that some viewers can interpret this value as the minimum value of a defined range of magnifications below which the content
of this optional content group is viewed, meaning that when zooming lower the content will not display.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the range of magnifications for the specified layer in the PDF document.
The layer in this example is best viewed (in some viewers it is only viewed) when zooming between 0% and 100%.
Dim caption As String = "Example: SetOCGZoomMin"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
If gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", False) = GdPictureStatus.OK Then
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (ocgCount > 0) Then
Dim ocgID As Integer = gdpicturePDF.GetOCG(0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetOCGTitle(ocgID, "Updated layer") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, False) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGZoomMin(ocgID, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGZoomMax(ocgID, 1) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_UpdatedLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetOCG() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetOCGZoomMin";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
if (gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", false) == GdPictureStatus.OK)
{
int ocgCount = gdpicturePDF.GetOCGCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (ocgCount > 0))
{
int ocgID = gdpicturePDF.GetOCG(0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetOCGTitle(ocgID, "Updated layer") == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, false) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGZoomMin(ocgID, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGZoomMax(ocgID, 1) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_UpdatedLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCG() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns the maximum magnification factor of an optional content group, specified by its unique identifier.
It is the maximum value of a defined range of magnifications below which the content of this optional content group is best viewed.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that some viewers can interpret this value as the maximum value of a defined range of magnifications below which the content
of this optional content group is viewed, meaning that when zooming greater the content will not display.
The maximum magnification factor below which the content of the specified OCG is best viewed.
The method can be subsequently used to determine if this method has been successful.
How to find out the range of magnifications of the specified layer in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim onOff As Boolean = False
Dim zoom As Double = 0
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Layer nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGIntentView(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If onOff Then
output = output + " Intent = View"
Else
output = output + " Intent = Design"
End If
Else
output = output + " Intent = Error (" + status.ToString() + ")"
End If
zoom = gdpicturePDF.GetOCGZoomMin(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + vbCrLf + " zoomMin = " + String.Format("{0:0.00}", zoom)
Else
output = output + vbCrLf + " zoomMin = Error (" + status.ToString() + ")"
End If
zoom = gdpicturePDF.GetOCGZoomMax(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + " zoomMax = " + String.Format("{0:0.00}", zoom)
Else
output = output + " zoomMax = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCGZoomMax")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGZoomMax")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCGZoomMax")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
bool onOff = false;
double zoom = 0;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nLayer nr." + (i+1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGIntentView(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (onOff)
output = output + " Intent = View";
else
output = output + " Intent = Design";
}
else
output = output + " Intent = Error (" + status.ToString() + ")";
zoom = gdpicturePDF.GetOCGZoomMin(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "\n zoomMin = " + string.Format("{0:0.00}", zoom);
else
output = output + "\n zoomMin = Error (" + status.ToString() + ")";
zoom = gdpicturePDF.GetOCGZoomMax(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + " zoomMax = " + string.Format("{0:0.00}", zoom);
else
output = output + " zoomMax = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCGZoomMax");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGZoomMax");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCGZoomMax");
}
gdpicturePDF.Dispose();
Sets up the maximum magnification factor of an optional content group, specified by its unique identifier.
It is the maximum value of a defined range of magnifications below which the content of this optional content group is best viewed.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
The new value of the maximum magnification factor to be set. Please use the value 0.1 to define the 10% or 1 to define the 100% zoom factor.
This method is only allowed for use with non-encrypted documents.
To define the 10% to 200% zoom range, please set the ZoomMin parameter to 0.1 using the method
and the ZoomMax parameter to 2 using the method.
Be aware that some viewers can interpret this value as the maximum value of a defined range of magnifications below which the content
of this optional content group is viewed, meaning that when zooming greater the content will not display.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to change the range of magnifications for the specified layer in the PDF document.
The layer in this example is best viewed (in some viewers it is only viewed) when zooming between 0% and 100%.
Dim caption As String = "Example: SetOCGZoomMax"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
If gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", False) = GdPictureStatus.OK Then
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso (ocgCount > 0) Then
Dim ocgID As Integer = gdpicturePDF.GetOCG(0)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If (gdpicturePDF.SetOCGTitle(ocgID, "Updated layer") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, False) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGZoomMin(ocgID, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGZoomMax(ocgID, 1) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_UpdatedLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetOCG() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetOCGZoomMax";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
if (gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", false) == GdPictureStatus.OK)
{
int ocgCount = gdpicturePDF.GetOCGCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) && (ocgCount > 0))
{
int ocgID = gdpicturePDF.GetOCG(0);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if ((gdpicturePDF.SetOCGTitle(ocgID, "Updated layer") == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, false) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGZoomMin(ocgID, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGZoomMax(ocgID, 1) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_UpdatedLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCG() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Returns, if the value of the Intent setting of an optional content group, specified by its unique identifier, is View.
The Intent setting provides a way to distinguish between different intended uses of optional content.
PDF 1.5 defines two names, View and Design, to indicate the intended use of the graphics in the optional content group.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the value of the Intent setting is View, otherwise returns false, means if the Intent setting is Design.
The method can be subsequently used to determine if this method has been successful.
How to find out the Intent option of the specified layer in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim output As String = ""
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = "The number of OCG layers: " + ocgCount.ToString()
Dim OcgId As Integer = 0
Dim title As String = ""
Dim onOff As Boolean = False
For i As Integer = 0 To ocgCount - 1
output = output + vbCrLf + "Nr." + (i + 1).ToString() + ": "
OcgId = gdpicturePDF.GetOCG(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
title = gdpicturePDF.GetOCGTitle(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
output = output + "Title = " + title.ToString()
Else
output = output + "Title = Error (" + status.ToString() + ")"
End If
onOff = gdpicturePDF.GetOCGIntentView(OcgId)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If onOff Then
output = output + " Intent = View"
Else
output = output + " Intent = Design"
End If
Else
output = output + " Intent = Error (" + status.ToString() + ")"
End If
Else
output = output + "The GetOCG() method has failed with the status: " + status.ToString()
End If
Next
MessageBox.Show(output, "Example: GetOCGIntentView")
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGIntentView")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetOCGIntentView")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string output = "";
int ocgCount = gdpicturePDF.GetOCGCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
output = "The number of OCG layers: " + ocgCount.ToString();
int OcgId = 0;
string title = "";
bool onOff = false;
for (int i = 0; i < ocgCount; i++)
{
output = output + "\nNr." + (i + 1).ToString() + ": ";
OcgId = gdpicturePDF.GetOCG(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
title = gdpicturePDF.GetOCGTitle(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
output = output + "Title = " + title.ToString();
else
output = output + "Title = Error (" + status.ToString() + ")";
onOff = gdpicturePDF.GetOCGIntentView(OcgId);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (onOff)
output = output + " Intent = View";
else
output = output + " Intent = Design";
}
else
output = output + " Intent = Error (" + status.ToString() + ")";
}
else
output = output + "The GetOCG() method has failed with the status: " + status.ToString();
}
MessageBox.Show(output, "Example: GetOCGIntentView");
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGIntentView");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: GetOCGIntentView");
}
gdpicturePDF.Dispose();
Adds a required image resource to be the content of an optional content group, specified by its unique identifier.
The resource name of the image you want to add to be the OCG's (layer's) content.
You can obtain this identifier using these methods: AddImageFrom...(), AddJpegImageFrom...() or . You can also take
advantages of the class and its methods to load the image file of your favourite format.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add an image to be the content of the specified layer in the PDF document.
Dim caption As String = "Example: SetImageOptional"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim image_res_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim ocgID As Integer = gdpicturePDF.NewOCG("Image layer")
status = gdpicturePDF.GetStat()
If (status = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) = GdPictureStatus.OK) Then
If (gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_ImageLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetImageOptional";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
string image_res_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int ocgID = gdpicturePDF.NewOCG("Image layer");
status = gdpicturePDF.GetStat();
if ((status == GdPictureStatus.OK) &&
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) == GdPictureStatus.OK))
{
if ((gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_ImageLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
Adds a required form field to be the content of an optional content group, specified by its unique identifier.
The form field identifier you want to add to be the OCG's (layer's) content. You can obtain this identifier using methods
like , or methods intended to add form fields.
The unique identifier of the required OCG entry. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to add a form field to be the content of the specified layer in the PDF document.
Dim caption As String = "Example: SetFormFieldOptional"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim fieldID As Integer = gdpicturePDF.AddTextFormField(50, 700, 200, 30, "Name", "GdPicture", False, fontName, 12, 165, 42, 42)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBorderColor(fieldID, 0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldBackgroundColor(fieldID, 255, 228, 196) = GdPictureStatus.OK) Then
Dim ocgID As Integer = gdpicturePDF.NewOCG("Form field layer")
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFormFieldOptional(fieldID, ocgID) = GdPictureStatus.OK) Then
If (gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_FormFieldLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewOCG() or SetFormFieldOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Adding the form field has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldOptional";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int fieldID = gdpicturePDF.AddTextFormField(50, 700, 200, 30, "Name", "GdPicture", false, fontName, 12, 165, 42, 42);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBorderColor(fieldID, 0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldBackgroundColor(fieldID, 255, 228, 196) == GdPictureStatus.OK))
{
int ocgID = gdpicturePDF.NewOCG("Form field layer");
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFormFieldOptional(fieldID, ocgID) == GdPictureStatus.OK))
{
if ((gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_FormFieldLayer.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The NewOCG() or SetFormFieldOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Adding the form field has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The AddStandardFont() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
Begins a marked content sequence of operations associated to an optional content group specified by its unique identifier.
The unique identifier of the required OCG entry, that you want to associate the marked-content with.
You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to associate a graphical marked content with an optional content group.
Dim caption As String = "Example: BeginOCGMarkedContent"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim ocgID As Integer = gdpicturePDF.NewOCG("Marked Content Layer")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginOCGMarkedContent(ocgID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRoundedRectangle(20, 20, 100, 50, 5, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontName, 20, 20, 120, 72, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "GdPicture.NET", True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndOCGMarkedContent() = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_MarkedContentLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Error occurred when creating the marked content. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: BeginOCGMarkedContent";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
int ocgID = gdpicturePDF.NewOCG("Marked Content Layer");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginOCGMarkedContent(ocgID) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRoundedRectangle(20, 20, 100, 50, 5, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontName, 20, 20, 120, 72, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "GdPicture.NET", true) == GdPictureStatus.OK) &&
(gdpicturePDF.EndOCGMarkedContent() == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_MarkedContentLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Error occurred when creating the marked content. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The NewOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
Ends the marked content, that has been previously defined by using the method.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to associate a graphical marked content with an optional content group.
Dim caption As String = "Example: EndOCGMarkedContent"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
Dim ocgID As Integer = gdpicturePDF.NewOCG("Marked Content Layer")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginOCGMarkedContent(ocgID) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawRoundedRectangle(20, 20, 100, 50, 5, False, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontName, 20, 20, 120, 72, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "GdPicture.NET", True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndOCGMarkedContent() = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_MarkedContentLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Error occurred when creating the marked content. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: EndOCGMarkedContent";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
int ocgID = gdpicturePDF.NewOCG("Marked Content Layer");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
(gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
(gdpicturePDF.BeginOCGMarkedContent(ocgID) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawRoundedRectangle(20, 20, 100, 50, 5, false, true) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontName, 20, 20, 120, 72, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "GdPicture.NET", true) == GdPictureStatus.OK) &&
(gdpicturePDF.EndOCGMarkedContent() == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_MarkedContentLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Error occurred when creating the marked content. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The NewOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
Creates a new optional content group (OCG) entry, means a layer, in the currently loaded PDF document.
Optional Content Groups, also knows as Layers, are a very effective tool to control the visibility of the page content,
that can be selectively viewed or hidden, by users or viewers.
The title of the newly created optional content group.
The unique identifier of the newly created OCG entry. The method can be subsequently used to determine if this method has been successful.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
How to create a new layer (OCG entry) with the image-based content in the PDF document.
The layer in this example is best viewed (in some viewers it is only viewed) when zooming between 0% and 100%.
Dim caption As String = "Example: NewOCG"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
'Creating content of a new layer.
Dim image_res_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim width As Single = gdpicturePDF.GetPageWidth()
Dim height As Single = gdpicturePDF.GetPageHeight()
'Drawing the layer's content on the current page.
If gdpicturePDF.DrawImage(image_res_name, 0, 0, width, height) = GdPictureStatus.OK Then
'Creating the layer and setting its properties.
Dim ocgID As Integer = gdpicturePDF.NewOCG("Image layer")
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) = GdPictureStatus.OK) Then
If (gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGLockedState(ocgID, True) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGZoomMin(ocgID, 0) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetOCGZoomMax(ocgID, 1) = GdPictureStatus.OK) Then
If gdpicturePDF.SaveToFile("test_NewOCG.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The DrawImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NewOCG";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
//Creating content of a new layer.
string image_res_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
float width = gdpicturePDF.GetPageWidth();
float height = gdpicturePDF.GetPageHeight();
//Drawing the layer's content on the current page.
if (gdpicturePDF.DrawImage(image_res_name, 0, 0, width, height) == GdPictureStatus.OK)
{
//Creating the layer and setting its properties.
int ocgID = gdpicturePDF.NewOCG("Image layer");
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetImageOptional(image_res_name, ocgID) == GdPictureStatus.OK))
{
if ((gdpicturePDF.SetOCGExportState(ocgID, PdfOcgState.StateOff) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGLockedState(ocgID, true) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGPrintState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGViewState(ocgID, PdfOcgState.StateOn) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGZoomMin(ocgID, 0) == GdPictureStatus.OK) &&
(gdpicturePDF.SetOCGZoomMax(ocgID, 1) == GdPictureStatus.OK))
{
if (gdpicturePDF.SaveToFile("test_NewOCG.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The NewOCG() or SetImageOptional() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The DrawImage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The AddJpegImageFromFile() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
Deletes an optional content group (OCG) entry, specified by its unique identifier, from the currently loaded PDF document.
This method only removes the specified OCG entry in the OCG entries dictionary, which subsequently makes the content of that layer visible within the document.
The unique identifier of the required OCG entry that you want to delete. You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
Be aware that this method only deletes the specified OCG entry in the OCGs dictionary, which means, that the content itself of the specified layer
is not removed and stay visible within the document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to delete the specified OCG entry in the PDF document.
Dim caption As String = "Example: DeleteOCG"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
If gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", False) = GdPictureStatus.OK Then
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (ocgCount > 0) Then
Dim ocgID As Integer = gdpicturePDF.GetOCG(0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.DeleteOCG(ocgID) = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_DeletedLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The DeleteOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DeleteOCG";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
if (gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", false) == GdPictureStatus.OK)
{
int ocgCount = gdpicturePDF.GetOCGCount();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) && (ocgCount > 0))
{
int ocgID = gdpicturePDF.GetOCG(0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.DeleteOCG(ocgID) == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_DeletedLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The DeleteOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Deletes an optional content group (OCG) entry, specified by its unique identifier, from the currently loaded PDF document.
This method removes the specified OCG entry in the OCG entries dictionary and optionally removes the content of this layer from the document itself.
Deletes an optional content group (OCG) entry, specified by its unique identifier, from the currently loaded PDF document.
You can also specify if the content of the given layer should be removed or not from the document itself.
The unique identifier of the required OCG entry that you want to delete. You can obtain this identifier using the method.
Set this parameter to true if you want to remove all content of the layer from the document.
This method is only allowed for use with non-encrypted documents.
If the RemoveContent parameter is set to false, this method only deletes the specified OCG entry in the OCGs dictionary,
which means, that the content itself of the specified layer is not removed and stay visible within the document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to delete the specified OCG entry and its content in the PDF document.
Dim caption As String = "Example: DeleteOCG"
Dim gdpicturePDF As New GdPicturePDF()
'Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
If gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", False) = GdPictureStatus.OK Then
Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (ocgCount > 0) Then
Dim ocgID As Integer = gdpicturePDF.GetOCG(0)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.DeleteOCG(ocgID, True) = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_DeletedLayer.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The DeleteOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetOCGCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DeleteOCG";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.
if (gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", false) == GdPictureStatus.OK)
{
int ocgCount = gdpicturePDF.GetOCGCount();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) && (ocgCount > 0))
{
int ocgID = gdpicturePDF.GetOCG(0);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.DeleteOCG(ocgID, true) == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_DeletedLayer.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
}
else
{
MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The DeleteOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The GetOCGCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
Flattens all visible optional content group entries and removes content of all hidden ones in the currently loaded PDF document.
That means content of all visible layers is flattened into the document and content of all hidden layers is removed.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Flattening all visible layers and removing all hidden ones included in the current document.
Using gdpicturePdf As GdPicturePDF = New GdPicturePDF()
gdpicturePDF.LoadFromFile("document.pdf", False)
gdpicturePDF.FlattenVisibleOCGs()
MessageBox.Show("The number of layers available: " + gdpicturePDF.GetOCGCount(), "Flattening visible layers", MessageBoxButtons.OK, MessageBoxIcon.Information)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePdf = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("document.pdf", false);
gdpicturePDF.FlattenVisibleOCGs();
MessageBox.Show("The number of layers available: " + gdpicturePDF.GetOCGCount(), "Flattening visible layers", MessageBoxButtons.OK, MessageBoxIcon.Information);
gdpicturePDF.SaveToFile("output.pdf");
}
Returns a unique identifier of the root (top-level element) in the the document's logical structure hierarchy, so-called tag's structure tree, in the currently loaded PDF document.
If the root element does not exist yet, the toolkit will create a new structure element at the very top of the forming structure tree.
At this time, the toolkit only identifies and supports the standard structure type, so-called tag type, named Document as the root element of the document's tag structure tree.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Be aware that currently the toolkit only supports the tag type Document as the root of the document's tag structure tree.
The unique tag identifier of the existing or the newly created tag's tree root element, that is of the standard structure type Document.
The method can be subsequently used to determine if this method has been successful.
How to create the root element of the document's tag tree to produce the new tagged PDF document.
Dim caption As String = "Example: GetTagRootID"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 200, 250, "Hello Word") = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'You can continue to build the tagged content here.
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your tagged PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: GetTagRootID";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 200, 250, "Hello World") == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//You can continue to build the tagged content here.
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your tagged PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Creates a new structure element of the defined structure type in the document's tag structure tree as a child of the specified parent element, that is a part
of the document's logical structure hierarchy in the currently loaded PDF document.
A unique tag identifier specifying the parent element in the document's tag structure tree.
A name of the structure type for the newly created structure element.
Please refer to the PDF Reference, Section "Standard Structure Types", for the names of the standard structure types.
This method is only allowed for use with non-encrypted documents.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The unique tag identifier of the newly created tag's tree element. The method can be subsequently used to determine if this method has been successful.
How to create a proper structure element of the Paragraph like category (tag type "P") for the simple text in the paragraph.
Dim caption As String = "Example: NewTag"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your tagged PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: NewTag";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your tagged PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Begins a marked content sequence of operations in the page content associated to a structure element (tag),
that is specified by its unique tag's identifier related to the document's tag structure tree of the currently loaded PDF document.
A unique tag identifier of the tag's tree element to be associated with the specified marked content sequence element.
A name of the structure type for the newly created marked content sequence element.
Please refer to the PDF Reference, Section "Standard Structure Types", for the names of the standard structure types.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to create a marked content sequence structure element of the Paragraph like category (tag type "P") for the simple text in the paragraph.
Dim caption As String = "Example: BeginMarkedContentSequence"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your tagged PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: BeginMarkedContentSequence";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your tagged PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Begins a marked content of operations in the page content associated to a structure element of the required structure type
related to the document's tag structure tree of the currently loaded PDF document.
A name of the structure type for the newly created marked content element.
Please refer to the PDF Reference, Section "Standard Structure Types", for the names of the standard structure types.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to create a marked content structure element of the Artifact category containing some graphics.
Dim caption As String = "Example: BeginMarkedContent"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginMarkedContent("Artifact") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(50, 55, 330, 55) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your tagged PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: BeginMarkedContent";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginMarkedContent("Artifact") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(50, 55, 330, 55) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your tagged PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Ends a marked content or a marked content sequence of operations in the page content, that have been previously defined using
the or the methods.
Both specified marked content and marked content sequence structure elements are related to the document's tag structure tree of the currently loaded PDF document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to properly end both newly created marked content and marked content sequence structure elements in the page content.
Dim caption As String = "Example: EndMarkedContent"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginMarkedContent("Artifact") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(50, 55, 330, 55) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your tagged PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: EndMarkedContent";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginMarkedContent("Artifact") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(50, 55, 330, 55) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your tagged PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Attaches the defined structure element (tag), that is identified by its unique tag's identifier, to the specified annotation object,
that is identified by its index related to the currently selected page of the loaded PDF document.
The required structure element (tag) should be a part of the document's tag structure tree.
A unique tag identifier of the tag's tree element to be attached to the specified annotation object.
You can obtain this identifier using the method.
The 0-based index of the required annotation within the current page. It must be a value from 0 to GetAnnotationCount-1.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to attach a newly created tag element to a link annotation.
Dim caption As String = "Example: AttachTagToAnnotation"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim linkTagID As Integer = gdpicturePDF.NewTag(tagRootID, "Link")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim linkAnnotIdx As Integer = gdpicturePDF.AddLinkToWebAnnotation(100, 100, 100, 20, "http://www.gdpicture.com/", False, 0, 0, 255)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If gdpicturePDF.AttachTagToAnnotation(linkTagID, linkAnnotIdx) = GdPictureStatus.OK Then
If (gdpicturePDF.BeginMarkedContentSequence(linkTagID, "Span") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextBox(fontResName, 100, 100, 200, 120, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "GdPicture") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your tagged document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The creation of the marked content sequence has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AttachTagToAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddLinkToWebAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: AttachTagToAnnotation";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int linkTagID = gdpicturePDF.NewTag(tagRootID, "Link");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int linkAnnotIdx = gdpicturePDF.AddLinkToWebAnnotation(100, 100, 100, 20, "http://www.gdpicture.com/", false, 0, 0, 255);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (gdpicturePDF.AttachTagToAnnotation(linkTagID, linkAnnotIdx) == GdPictureStatus.OK)
{
if ((gdpicturePDF.BeginMarkedContentSequence(linkTagID, "Span") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextBox(fontResName, 100, 100, 200, 120, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "GdPicture") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your tagged document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The creation of the marked content sequence has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AttachTagToAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddLinkToWebAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Attaches the defined structure element (tag), that is identified by its unique tag's identifier, to the specified form field object,
that is identified by its unique form field's identifier related to the currently loaded PDF document.
The required structure element (tag) should be a part of the document's tag structure tree.
A unique form field's identifier specifying a required form field object.
You can obtain this identifier using methods like , or methods intended to add form fields.
A unique tag identifier of the tag's tree element to be attached to the specified form field object.
You can obtain this identifier using the method.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to attach a newly created tag element to a text form field.
Dim caption As String = "Example: AttachTagToFormField"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, False)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetTagRootID() method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Creating a parent tag of the type 'Div' that will hold both the form field and its caption.
Dim divTag As Integer = gdpicturePDF.NewTag(tagRootID, "Div")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(Div) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Creating a tag of the type 'Caption'.
Dim captionTag As Integer = gdpicturePDF.NewTag(divTag, "Caption")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(Caption) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Drawing a caption for the text form field.
If (gdpicturePDF.BeginMarkedContentSequence(captionTag, "Span") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 100, 70, "Your toolkit is: ") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.EndMarkedContent() <> GdPictureStatus.OK) Then
message = "The creation of the marked content sequence has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Creating a tag of the type 'Form'.
Dim formTag As Integer = gdpicturePDF.NewTag(divTag, "Form")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(Form) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Creating a text form field.
Dim formID As Integer = gdpicturePDF.AddTextFormField(220, 50, 150, 30, "TextField_Name", "GdPicture14", False, fontResName, 20, Color.Brown)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.White) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) Then
message = "The NewTag(Caption) method has failed. status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Attaching the prepared tag to the new text form field.
If (gdpicturePDF.AttachTagToFormField(formTag, formID) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetTagTitle(formTag, "Name Field") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldAlternateTitle(formID, "Name Field") <> GdPictureStatus.OK) Then
message = "Attaching the tag to the form field has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If gdpicturePDF.SaveToFile("test_tagged.pdf") = GdPictureStatus.OK Then
message = "Your tagged document has been successfully created."
Else
message = "The example has been successfully followed, but the SaveToFile() method has failed. Status: " + gdpicturePDF.GetStat().ToString()
End If
[error]:
MessageBox.Show(message, caption)
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: AttachTagToFormField";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
string message = "";
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, false);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetTagRootID() method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Creating a parent tag of the type 'Div' that will hold both the form field and its caption.
int divTag = gdpicturePDF.NewTag(tagRootID, "Div");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(Div) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Creating a tag of the type 'Caption'.
int captionTag = gdpicturePDF.NewTag(divTag, "Caption");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(Caption) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Drawing a caption for the text form field.
if ((gdpicturePDF.BeginMarkedContentSequence(captionTag, "Span") != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 100, 70, "Your toolkit is: ") != GdPictureStatus.OK) ||
(gdpicturePDF.EndMarkedContent() != GdPictureStatus.OK))
{
message = "The creation of the marked content sequence has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Creating a tag of the type 'Form'.
int formTag = gdpicturePDF.NewTag(divTag, "Form");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(Form) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Creating a text form field.
int formID = gdpicturePDF.AddTextFormField(220, 50, 150, 30, "TextField_Name", "GdPicture14", false, fontResName, 20, Color.Brown);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.White) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK))
{
message = "The NewTag(Caption) method has failed. status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Attaching the prepared tag to the new text form field.
if ((gdpicturePDF.AttachTagToFormField(formTag, formID) != GdPictureStatus.OK) ||
(gdpicturePDF.SetTagTitle(formTag, "Name Field") != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldAlternateTitle(formID, "Name Field") != GdPictureStatus.OK))
{
message = "Attaching the tag to the form field has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if (gdpicturePDF.SaveToFile("test_tagged.pdf") == GdPictureStatus.OK)
message = "Your tagged document has been successfully created.";
else
message = "The example has been successfully followed, but the SaveToFile() method has failed. Status: " + gdpicturePDF.GetStat().ToString();
error:
MessageBox.Show(message, caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Maps your custom (newly defined) structure type name to the already existing structure type name.
Structure type names are identified and mapped through the so-called RoleMap entry in the structure tree root element,
that should be a part of the document's tag structure tree related to the currently loaded PDF document.
All standard structure type names (tag's names) (see PDF Reference, Section "Standard Structure Types") may be used in the PDF/UA-1 conformed documents.
If other names are used, a mapping of those custom names to the standard type names must be provided in the document's RoleMap entry.
This way a structure tree element (tag) name is always mapped to its corresponding name in the role map, if there is one defined.
The new name of the structure type, that will be mapped to the existing structure type.
The name of the already existing structure type, to which the new one is to be mapped.
This name must be either one of the standard structure type names (see PDF Reference, Section "Standard Structure Types"), or other previously defined structure type name.
This method is only allowed for use with non-encrypted documents.
Be aware that you can only map the new custom structure type name to already existing structure type name in the document's RoleMap entry.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to map the standard structure type to your custom type.
Dim caption As String = "Example: MapStructureType"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Mapping the standard structure type named P to your custom type named TextElement.
If gdpicturePDF.MapStructureType("TextElement", "P") = GdPictureStatus.OK Then
Dim tagTextElement As Integer = gdpicturePDF.NewTag(tagRootID, "TextElement")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.BeginMarkedContentSequence(tagTextElement, "TextElement") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as TextElement!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your tagged PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Mapping structure type has failed with the status:" + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: MapStructureType";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
// This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Mapping the standard structure type named P to your custom type named TextElement.
if (gdpicturePDF.MapStructureType("TextElement", "P") == GdPictureStatus.OK)
{
int tagTextElement = gdpicturePDF.NewTag(tagRootID, "TextElement");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagTextElement, "TextElement") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as TextElement!") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your tagged PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Mapping structure type has failed with the status:" + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Sets up the natural language used for text or for optional content in the currently loaded PDF document.
This language serves to support the accessibility of documents to users with disabilities, specifically to enable proper vocalization, for example,
through a screen reader or other text-to-speech engines. For further assistance, please refer to the PDF Reference, Section "Natural Language Specification".
A new value of the language identifier as a string. The empty string indicates that the language is unknown.
Please refer to the PDF Reference, Section "Language Identifiers" for the proper syntax of language codes.
This method is only allowed for use with non-encrypted documents.
Be aware that you need to respect the proper syntax described in the PDF Reference, Section "Language Identifiers" to specify the required language.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up a natural language to be used with the newly created tagged PDF document.
Dim caption As String = "Example: SetLanguage"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLanguage("en-US") = GdPictureStatus.OK) Then
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text in english that is tagged as paragraph!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Getting the root or setting the language has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetLanguage";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLanguage("en-US") == GdPictureStatus.OK))
{
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text in english that is tagged as paragraph!") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Getting the root or setting the language has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Sets the title of the structure element (tag) specified by its unique (tag's) identifier, that is a part of the document's tag structure tree related
to the currently loaded PDF document.
It is a text string in the readable form representing the specific structure element (tag), for example, Section 1 or Volume 1, etc.
A unique tag identifier of the tag's tree element
The new title of the specified tag's tree element.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize a title property of a newly created tag element.
Dim caption As String = "Example: SetTagTitle"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, False)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetTagRootID() method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Creating a parent tag of the type 'Div' that will hold both the form field and its caption.
Dim divTag As Integer = gdpicturePDF.NewTag(tagRootID, "Div")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(Div) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Creating a tag of the type 'Caption'.
Dim captionTag As Integer = gdpicturePDF.NewTag(divTag, "Caption")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(Caption) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Drawing a caption for the text form field.
If (gdpicturePDF.BeginMarkedContentSequence(captionTag, "Span") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawText(fontResName, 100, 70, "Your toolkit is: ") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.EndMarkedContent() <> GdPictureStatus.OK) Then
message = "The creation of the marked content sequence has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Creating a tag of the type 'Form'.
Dim formTag As Integer = gdpicturePDF.NewTag(divTag, "Form")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(Form) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Creating a text form field.
Dim formID As Integer = gdpicturePDF.AddTextFormField(220, 50, 150, 30, "TextField_Name", "GdPicture14", False, fontResName, 20, Color.Brown)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.White) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) <> GdPictureStatus.OK) Then
message = "The NewTag(Caption) method has failed. status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
'Attaching the prepared tag to the new text form field.
If (gdpicturePDF.AttachTagToFormField(formTag, formID) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetTagTitle(formTag, "Name Field") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFormFieldAlternateTitle(formID, "Name Field") <> GdPictureStatus.OK) Then
message = "Attaching the tag to the form field has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If gdpicturePDF.SaveToFile("test_tagged.pdf") = GdPictureStatus.OK Then
message = "Your tagged document has been successfully created."
Else
message = "The example has been successfully followed, but the SaveToFile() method has failed. Status: " + gdpicturePDF.GetStat().ToString()
End If
[error]:
MessageBox.Show(message, caption)
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagTitle";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
string message = "";
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, false);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetTagRootID() method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Creating a parent tag of the type 'Div' that will hold both the form field and its caption.
int divTag = gdpicturePDF.NewTag(tagRootID, "Div");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(Div) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Creating a tag of the type 'Caption'.
int captionTag = gdpicturePDF.NewTag(divTag, "Caption");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(Caption) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Drawing a caption for the text form field.
if ((gdpicturePDF.BeginMarkedContentSequence(captionTag, "Span") != GdPictureStatus.OK) ||
(gdpicturePDF.DrawText(fontResName, 100, 70, "Your toolkit is: ") != GdPictureStatus.OK) ||
(gdpicturePDF.EndMarkedContent() != GdPictureStatus.OK))
{
message = "The creation of the marked content sequence has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Creating a tag of the type 'Form'.
int formTag = gdpicturePDF.NewTag(divTag, "Form");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(Form) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Creating a text form field.
int formID = gdpicturePDF.AddTextFormField(220, 50, 150, 30, "TextField_Name", "GdPicture14", false, fontResName, 20, Color.Brown);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBackgroundColor(formID, Color.White) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldBorderColor(formID, Color.Brown) != GdPictureStatus.OK))
{
message = "The NewTag(Caption) method has failed. status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
//Attaching the prepared tag to the new text form field.
if ((gdpicturePDF.AttachTagToFormField(formTag, formID) != GdPictureStatus.OK) ||
(gdpicturePDF.SetTagTitle(formTag, "Name Field") != GdPictureStatus.OK) ||
(gdpicturePDF.SetFormFieldAlternateTitle(formID, "Name Field") != GdPictureStatus.OK))
{
message = "Attaching the tag to the form field has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if (gdpicturePDF.SaveToFile("test_tagged.pdf") == GdPictureStatus.OK)
message = "Your tagged document has been successfully created.";
else
message = "The example has been successfully followed, but the SaveToFile() method has failed. Status: " + gdpicturePDF.GetStat().ToString();
error:
MessageBox.Show(message, caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Sets the alternate description of the structure element (tag) specified by its unique (tag's) identifier, that is a part of the document's tag structure tree
related to the currently loaded PDF document.
It is a text string in the readable form providing for items, located in the PDF document, that do not translate naturally
into the text, such as images, formulas, actual form field names or annotations displaying text and others.
A unique tag identifier of the tag's tree element.
The new alternate description of the specified tag's tree element.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize an alternate description property of a newly created tag element.
Dim caption As String = "Example: SetTagAlternateDescription"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagImage As Integer = gdpicturePDF.NewTag(tagRootID, "Figure")
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAlternateDescription(tagImage, "This is a picture of ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAttribute(tagImage, "BBox", New Double() {0, 0, 612, 792}) = GdPictureStatus.OK) Then
If (gdpicturePDF.BeginMarkedContentSequence(tagImage, "Figure") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, 0, 612, 792) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagAlternateDescription";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagRootID = gdpicturePDF.GetTagRootID();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLanguage("en-US") == GdPictureStatus.OK))
{
int tagImage = gdpicturePDF.NewTag(tagRootID, "Figure");
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAlternateDescription(tagImage, "This is a picture of ...") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAttribute(tagImage, "BBox", new double[] { 0, 0, 612, 792 }) == GdPictureStatus.OK))
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagImage, "Figure") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, 0, 612, 792) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Creating a tag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddJpegImageFromFile has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Sets the actual text of a structure element (tag) specified by its unique (tag's) identifier, that is a part of the document's tag structure tree
related to the currently loaded PDF document.
It is an exact replacement text for such content, that is represented in a nonstandard way. Generally, it should apply to as small piece of content as possible.
A unique tag identifier of the tag's tree element.
The new actual text of the specified tag's tree element.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to utilize an actual text property of a newly created tag element.
Dim caption As String = "Example: SetTagLanguage"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Setting the natural language for the whole document.
gdpicturePDF.SetLanguage("en-US")
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Setting the language for the drawn text in the paragraph tag.
If (gdpicturePDF.SetTagLanguage(tagParagraph, "es-MX") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagActualText(tagParagraph, "Hasta la vista.") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "Hasta la vista.") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagLanguage";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Setting the natural language for the whole document.
gdpicturePDF.SetLanguage("en-US");
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Setting the language for the drawn text in the paragraph tag.
if ((gdpicturePDF.SetTagLanguage(tagParagraph, "es-MX") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagActualText(tagParagraph, "Hasta la vista.") == GdPictureStatus.OK) &&
(gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "Hasta la vista.") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Sets the natural language for all text in the structure element (tag) specified by its unique (tag's) identifier, that is a part of the document's tag structure tree
related to the currently loaded PDF document. You can override the document's natural language by setting this property for the single structure element if needed.
For further assistance, please refer to the PDF Reference, Section "Language Specification Hierarchy".
A unique tag identifier of the tag's tree element.
A new value of the language identifier for a specified tag's tree element as a string.
Please refer to the PDF Reference, Section "Language Identifiers" for the proper syntax of language codes.
This method is only allowed for use with non-encrypted documents.
Be aware that you need to respect the proper syntax described in the PDF Reference, Section "Language Identifiers" to specify the required language.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set up a natural language to be used with a newly created tag element.
Dim caption As String = "Example: SetTagLanguage"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Setting the natural language for the whole document.
gdpicturePDF.SetLanguage("en-US")
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Setting the language for the drawn text in the paragraph tag.
If (gdpicturePDF.SetTagLanguage(tagParagraph, "es-MX") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagActualText(tagParagraph, "Hasta la vista.") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "Hasta la vista.") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagLanguage";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Setting the natural language for the whole document.
gdpicturePDF.SetLanguage("en-US");
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Setting the language for the drawn text in the paragraph tag.
if ((gdpicturePDF.SetTagLanguage(tagParagraph, "es-MX") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagActualText(tagParagraph, "Hasta la vista.") == GdPictureStatus.OK) &&
(gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "Hasta la vista.") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Creates a new attribute for a structure element (tag) specified by its unique (tag's) identifier, that is a part of
the document's tag structure tree related to the currently loaded PDF document.
This attribute consists of a key-value pair: the key is the attribute's name and the value is the attribute's corresponding value.
You are allowed to set the attribute's value as a string using this method.
Creates a new attribute for a structure element (tag) specified by its unique (tag's) identifier, that is a part of
the document's tag structure tree related to the currently loaded PDF document.
A unique tag identifier of the tag's tree element to which the new attribute will be attached.
A name of the newly defined attribute to be attached to the specified tag's tree element.
A value of the newly defined attribute as a string, that is to be attached to the specified tag's tree element.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set attributes to a newly created tag attached to the underlined text.
Dim caption As String = "Example: SetTagAttribute"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLanguage("en-US") = GdPictureStatus.OK) Then
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAttribute(tagParagraph, "TextDecorationType", "Underline") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAttribute(tagParagraph, "LineHeight", 20) = GdPictureStatus.OK) Then
If (gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextUnderline(fontResName, 20, 700, "This is underlined text in english that is tagged as paragraph!", Color.Aquamarine, 3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() or SetTagAttribute() methods have failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Getting the root or setting the language has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagAttribute";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLanguage("en-US") == GdPictureStatus.OK))
{
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAttribute(tagParagraph, "TextDecorationType", "Underline") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAttribute(tagParagraph, "LineHeight", 20) == GdPictureStatus.OK))
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextUnderline(fontResName, 20, 700, "This is underlined text in english that is tagged as paragraph!", Color.Aquamarine, 3) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() or SetTagAttribute() methods have failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Getting the root or setting the language has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Creates a new attribute for a structure element (tag) specified by its unique (tag's) identifier, that is a part of
the document's tag structure tree related to the currently loaded PDF document.
This attribute consists of a key-value pair: the key is the attribute's name and the value is the attribute's corresponding value.
You are allowed to set the attribute's value as an array of strings using this method.
Creates a new attribute for a structure element (tag) specified by its unique (tag's) identifier, that is a part of
the document's tag structure tree related to the currently loaded PDF document.
A unique tag identifier of the tag's tree element to which the new attribute will be attached.
A name of the newly defined attribute to be attached to the specified tag's tree element.
A value of the newly defined attribute as an array of strings, that is to be attached to the specified tag's tree element.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the border style attribute to a newly created tag attached to the table cell.
Dim caption As String = "Example: SetTagAttribute"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetTextSize(16) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetLineColor(Color.Black) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetLineWidth(3) <> GdPictureStatus.OK) Then
message = "Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The GetTagRootID() method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim tagTable As Integer = gdpicturePDF.NewTag(tagRootID, "Table")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(Table) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim tagTableHeader As Integer = gdpicturePDF.NewTag(tagTable, "THead")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(THead) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim tagTableBody As Integer = gdpicturePDF.NewTag(tagTable, "TBody")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(TBody) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim tagTableRow As Integer = gdpicturePDF.NewTag(tagTableHeader, "TR")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(TR) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If (gdpicturePDF.BeginMarkedContent("Artifact") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawLine(100, 100, 300, 100) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFillColor(Color.LightGray) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawRectangle(100, 100, 200, 30, True, False) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.EndMarkedContent() <> GdPictureStatus.OK) Then
message = "Creating the line/artifact has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim borderStyle As String() = {"None", "Solid", "None", "None"}
Dim tagTableHeaderData As Integer = gdpicturePDF.NewTag(tagTableRow, "TH")
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetTagAttribute(tagTableHeaderData, "TBorderStyle", borderStyle) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.BeginMarkedContentSequence(tagTableHeaderData, "TH") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFillColor(Color.Black) <> GdPictureStatus.OK) Or
(gdpicturePDF.DrawTextBox(fontResName, 100, 100, 200, 130, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Header1") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.EndMarkedContent() <> GdPictureStatus.OK) Then
message = "Creating the first table header cell has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
tagTableHeaderData = gdpicturePDF.NewTag(tagTableRow, "TH")
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetTagAttribute(tagTableHeaderData, "TBorderStyle", borderStyle) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.BeginMarkedContentSequence(tagTableHeaderData, "TH") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFillColor(Color.Black) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawTextBox(fontResName, 200, 100, 300, 130, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Header2") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.EndMarkedContent() <> GdPictureStatus.OK) Then
message = "Creating the second table header cell has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
tagTableRow = gdpicturePDF.NewTag(tagTableBody, "TR")
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then
message = "The NewTag(TR) method has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If (gdpicturePDF.BeginMarkedContent("Artifact") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawLine(100, 130, 300, 130) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFillColor(Color.LightGray) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawRectangle(100, 130, 200, 30, True, False) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.EndMarkedContent() <> GdPictureStatus.OK) Then
message = "Creating the line/artifact has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
Dim tagTableData As Integer = gdpicturePDF.NewTag(tagTableRow, "TD")
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetTagAttribute(tagTableData, "TBorderStyle", borderStyle) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.BeginMarkedContentSequence(tagTableData, "TD") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFillColor(Color.Black) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawTextBox(fontResName, 100, 130, 200, 160, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Data1") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.EndMarkedContent() <> GdPictureStatus.OK) Then
message = "Creating the first table data cell has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
tagTableData = gdpicturePDF.NewTag(tagTableRow, "TD")
If (gdpicturePDF.GetStat() <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetTagAttribute(tagTableData, "TBorderStyle", borderStyle) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.BeginMarkedContentSequence(tagTableData, "TD") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.SetFillColor(Color.Black) <> GdPictureStatus.OK) OrElse
(gdpicturePDF.DrawTextBox(fontResName, 200, 130, 300, 160, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Data2") <> GdPictureStatus.OK) OrElse
(gdpicturePDF.EndMarkedContent() <> GdPictureStatus.OK) Then
message = "Creating the second table data cell has failed. Status: " + gdpicturePDF.GetStat().ToString()
GoTo [error]
End If
If gdpicturePDF.SaveToFile("test_tagged.pdf") = GdPictureStatus.OK Then
message = "The example has been followed successfully and the file has been saved."
Else
message = "The example has been followed successfully, but the file can't be saved. Status:" + gdpicturePDF.GetStat().ToString()
End If
[error]:
MessageBox.Show(message, caption)
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagAttribute";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
string message = "";
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
// This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetTextSize(16) != GdPictureStatus.OK) ||
(gdpicturePDF.SetLineColor(Color.Black) != GdPictureStatus.OK) ||
(gdpicturePDF.SetLineWidth(3) != GdPictureStatus.OK))
{
message = "Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The GetTagRootID() method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int tagTable = gdpicturePDF.NewTag(tagRootID, "Table");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(Table) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int tagTableHeader = gdpicturePDF.NewTag(tagTable, "THead");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(THead) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int tagTableBody = gdpicturePDF.NewTag(tagTable, "TBody");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(TBody) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int tagTableRow = gdpicturePDF.NewTag(tagTableHeader, "TR");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(TR) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if ((gdpicturePDF.BeginMarkedContent("Artifact") != GdPictureStatus.OK) ||
(gdpicturePDF.DrawLine(100, 100, 300, 100) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFillColor(Color.LightGray) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawRectangle(100, 100, 200, 30, true, false) != GdPictureStatus.OK) ||
(gdpicturePDF.EndMarkedContent() != GdPictureStatus.OK))
{
message = "Creating the line/artifact has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
string[] borderStyle = new[] { "None", "Solid", "None", "None" };
int tagTableHeaderData = gdpicturePDF.NewTag(tagTableRow, "TH");
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetTagAttribute(tagTableHeaderData, "TBorderStyle", borderStyle) != GdPictureStatus.OK) ||
(gdpicturePDF.BeginMarkedContentSequence(tagTableHeaderData, "TH") != GdPictureStatus.OK) ||
(gdpicturePDF.SetFillColor(Color.Black) != GdPictureStatus.OK) |
(gdpicturePDF.DrawTextBox(fontResName, 100, 100, 200, 130, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Header1") != GdPictureStatus.OK) ||
(gdpicturePDF.EndMarkedContent() != GdPictureStatus.OK))
{
message = "Creating the first table header cell has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
tagTableHeaderData = gdpicturePDF.NewTag(tagTableRow, "TH");
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetTagAttribute(tagTableHeaderData, "TBorderStyle", borderStyle) != GdPictureStatus.OK) ||
(gdpicturePDF.BeginMarkedContentSequence(tagTableHeaderData, "TH") != GdPictureStatus.OK) ||
(gdpicturePDF.SetFillColor(Color.Black) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawTextBox(fontResName, 200, 100, 300, 130, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Header2") != GdPictureStatus.OK) ||
(gdpicturePDF.EndMarkedContent() != GdPictureStatus.OK))
{
message = "Creating the second table header cell has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
tagTableRow = gdpicturePDF.NewTag(tagTableBody, "TR");
if (gdpicturePDF.GetStat() != GdPictureStatus.OK)
{
message = "The NewTag(TR) method has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if ((gdpicturePDF.BeginMarkedContent("Artifact") != GdPictureStatus.OK) ||
(gdpicturePDF.DrawLine(100, 130, 300, 130) != GdPictureStatus.OK) ||
(gdpicturePDF.SetFillColor(Color.LightGray) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawRectangle(100, 130, 200, 30, true, false) != GdPictureStatus.OK) ||
(gdpicturePDF.EndMarkedContent() != GdPictureStatus.OK))
{
message = "Creating the line/artifact has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
int tagTableData = gdpicturePDF.NewTag(tagTableRow, "TD");
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetTagAttribute(tagTableData, "TBorderStyle", borderStyle) != GdPictureStatus.OK) ||
(gdpicturePDF.BeginMarkedContentSequence(tagTableData, "TD") != GdPictureStatus.OK) ||
(gdpicturePDF.SetFillColor(Color.Black) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawTextBox(fontResName, 100, 130, 200, 160, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Data1") != GdPictureStatus.OK) ||
(gdpicturePDF.EndMarkedContent() != GdPictureStatus.OK))
{
message = "Creating the first table data cell has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
tagTableData = gdpicturePDF.NewTag(tagTableRow, "TD");
if ((gdpicturePDF.GetStat() != GdPictureStatus.OK) ||
(gdpicturePDF.SetTagAttribute(tagTableData, "TBorderStyle", borderStyle) != GdPictureStatus.OK) ||
(gdpicturePDF.BeginMarkedContentSequence(tagTableData, "TD") != GdPictureStatus.OK) ||
(gdpicturePDF.SetFillColor(Color.Black) != GdPictureStatus.OK) ||
(gdpicturePDF.DrawTextBox(fontResName, 200, 130, 300, 160, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "Data2") != GdPictureStatus.OK) ||
(gdpicturePDF.EndMarkedContent() != GdPictureStatus.OK))
{
message = "Creating the second table data cell has failed. Status: " + gdpicturePDF.GetStat().ToString();
goto error;
}
if (gdpicturePDF.SaveToFile("test_tagged.pdf") == GdPictureStatus.OK)
message = "The example has been followed successfully and the file has been saved.";
else
message = "The example has been followed successfully, but the file can't be saved. Status:" + gdpicturePDF.GetStat().ToString();
error:
MessageBox.Show(message, caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Creates a new attribute for a structure element (tag) specified by its unique (tag's) identifier, that is a part of
the document's tag structure tree related to the currently loaded PDF document.
This attribute consists of a key-value pair: the key is the attribute's name and the value is the attribute's corresponding value.
You are allowed to set the attribute's value as a number using this method.
Creates a new attribute for a structure element (tag) specified by its unique (tag's) identifier, that is a part of
the document's tag structure tree related to the currently loaded PDF document.
A unique tag identifier of the tag's tree element to which the new attribute will be attached.
A name of the newly defined attribute to be attached to the specified tag's tree element.
A value of the newly defined attribute as a number, that is to be attached to the specified tag's tree element.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set attributes to a newly created tag attached to the underlined text.
Dim caption As String = "Example: SetTagAttribute"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(20) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetLanguage("en-US") = GdPictureStatus.OK) Then
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAttribute(tagParagraph, "TextDecorationType", "Underline") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAttribute(tagParagraph, "LineHeight", 20) = GdPictureStatus.OK) Then
If (gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawTextUnderline(fontResName, 20, 700, "This is underlined text in english that is tagged as paragraph!", Color.Aquamarine, 3) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() or SetTagAttribute() methods have failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Getting the root or setting the language has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagAttribute";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(20) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLanguage("en-US") == GdPictureStatus.OK))
{
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAttribute(tagParagraph, "TextDecorationType", "Underline") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAttribute(tagParagraph, "LineHeight", 20) == GdPictureStatus.OK))
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawTextUnderline(fontResName, 20, 700, "This is underlined text in english that is tagged as paragraph!", Color.Aquamarine, 3) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() or SetTagAttribute() methods have failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Getting the root or setting the language has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Creates a new attribute for a structure element (tag) specified by its unique (tag's) identifier, that is a part of
the document's tag structure tree related to the currently loaded PDF document.
This attribute consists of a key-value pair: the key is the attribute's name and the value is the attribute's corresponding value.
You are allowed to set the attribute's value as an array of numbers using this method.
Creates a new attribute for a structure element (tag) specified by its unique (tag's) identifier, that is a part of
the document's tag structure tree related to the currently loaded PDF document.
A unique tag identifier of the tag's tree element to which the new attribute will be attached.
A name of the newly defined attribute to be attached to the specified tag's tree element.
A value of the newly defined attribute as an array of numbers, that is to be attached to the specified tag's tree element.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to set the BBox attribute, which is necessary here, to a newly created tag attached to the image.
Dim caption As String = "Example: SetTagAttribute"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagImage As Integer = gdpicturePDF.NewTag(tagRootID, "Figure")
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAlternateDescription(tagImage, "This is a picture of ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAttribute(tagImage, "BBox", New Double() {0, 0, 612, 792}) = GdPictureStatus.OK) Then
If (gdpicturePDF.BeginMarkedContentSequence(tagImage, "Figure") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, 0, 612, 792) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagAttribute";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagRootID = gdpicturePDF.GetTagRootID();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLanguage("en-US") == GdPictureStatus.OK))
{
int tagImage = gdpicturePDF.NewTag(tagRootID, "Figure");
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAlternateDescription(tagImage, "This is a picture of ...") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAttribute(tagImage, "BBox", new double[] { 0, 0, 612, 792 }) == GdPictureStatus.OK))
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagImage, "Figure") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, 0, 612, 792) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Creating a tag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddJpegImageFromFile has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Checks whether the currently loaded PDF document conforms to Tagged PDF conventions.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
true if the current PDF conforms to Tagged PDF conventions based on the information in MarkInfo dictionary, otherwise false. The method can be subsequently used to determine if this method has been successful.
How to determine if the PDF document is a tagged PDF file.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim isTagged As Boolean = gdpicturePDF.IsTagged()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If isTagged Then
MessageBox.Show("Your PDF document is tagged.", "Example: IsTagged")
Else
MessageBox.Show("Your PDF document is not tagged.", "Example: IsTagged")
End If
Else
MessageBox.Show("The IsTagged() method has failed with the status: " + status.ToString(), "Example: IsTagged")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: IsTagged")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
bool isTagged = gdpicturePDF.IsTagged();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (isTagged)
{
MessageBox.Show("Your PDF document is tagged.", "Example: IsTagged");
}
else
{
MessageBox.Show("Your PDF document is not tagged.", "Example: IsTagged");
}
}
else
{
MessageBox.Show("The IsTagged() method has failed with the status: " + status.ToString(), "Example: IsTagged");
}
}
else
{
MessageBox.Show("The file can't be loaded.", "Example: IsTagged");
}
gdpicturePDF.Dispose();
Optimizes fonts used in the currently loaded PDF document in order to minimize its file size for archiving.
This method is useful primarily for PDF documents intended for storing or archiving to reduce its file size.
The toolkit replaces the fully embedded fonts included in the document with their corresponding subsets and removes all other
unnecessary data found in the existing font files as well. Be aware that subsequent editing of such optimized document may lead to insufficient rendering.
This method is only allowed for use with non-encrypted documents.
Just to inform you, that embedded font programs used in the document are subsetted and any unnecessary duplicity in font resources structure is removed.
This method is mainly useful when you need to reduce the file size of the final stage of the PDF document. It is not suitable when you need to edit this document further.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to simply optimize fonts in the PDF document.
Dim caption As String = "Example: PackFonts"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.PackFonts() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_optimized.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurs when optimizing fonts. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be opened. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: PackFonts";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.PackFonts() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_optimized.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example has been followed successfully.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The error occurs when optimizing fonts. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be opened. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Removes all unused resources from the currently loaded PDF document in order to minimize its file size mostly after splitting or removing pages.
This method is particularly useful when you remove pages or split large PDF documents to smaller ones. Sometimes it happens that shared document resources
are transferred to single pages when splitting, or they have been left unused after removing their source pages. You can simply use this method
to eliminate such redundant resources and to reduce the file size if necessary.
This method is only allowed for use with non-encrypted documents.
You can find an example of usage for this method here.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to simply remove unused resources from the PDF document.
Dim caption As String = "Example: RemoveUnusedResources"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.GetPageCount() > 2) Then
'Removing some pages.
If (gdpicturePDF.DeletePage(pageCount) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DeletePage(1) = GdPictureStatus.OK) Then
If gdpicturePDF.RemoveUnusedResources() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_optimized.pdf", True) = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurs when reducing resources. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("No pages have been removed, the example has not been followed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("No pages have been removed, the example has not been followed. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be opened. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: RemoveUnusedResources";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF.GetPageCount();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.GetPageCount() > 2))
{
//Removing some pages.
if ((gdpicturePDF.DeletePage(pageCount) == GdPictureStatus.OK) &&
(gdpicturePDF.DeletePage(1) == GdPictureStatus.OK))
{
if (gdpicturePDF.RemoveUnusedResources() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_optimized.pdf", true) == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The error occurs when reducing resources. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("No pages have been removed, the example has not been followed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("No pages have been removed, the example has not been followed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be opened. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Attempts to repair malformed PDF document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to repair the PDF document.
Dim caption As String = "Example: Repair"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF.Repair() = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_repaired.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The error occurs when repairing document. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be opened. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: Repair";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF.Repair() == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_repaired.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The example has been followed successfully.", caption);
}
else
{
MessageBox.Show("The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The error occurs when repairing document. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be opened. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
}
Converts the currently loaded PDF document to a brand new PDF document that meets the PDF/A conformance level according to what you have specified.
Please refer to this example for more details about our native PDF to PDF/A converter.
Be aware that both Vectorization and Rasterization approaches, when used, result in loss of fonts and text information because the text converts into shapes and raster images.
Text information can be later recovered using OCR features.
The file path where the converted PDF document will be saved. If the specified file already exists, it will be overwritten.
You are allowed to overwrite the currently opened PDF document only if the document has been loaded into memory setting the LoadInMemory parameter
to true in the previously called method.
A member of the PdfConversionConformance enumeration. Specifies the required conformance level of the converted PDF document.
Set this parameter to true, if you want to let the conversion engine use the page vectorization when the direct conversion is not possible.
Otherwise set it to false. Vectorization produces vector based graphic elements where applicable, for example, fonts and paths, and combines them with image resources.
The recommended value is true.
Set this parameter to true, if you want to let the conversion engine use the page rasterization when the direct conversion
and vectorization are not possible or allowed. Otherwise set it to false. Rasterization renders the document content using the raster (pixel-based) approach.
The recommended value is true.
This method is only allowed for use with non-encrypted documents.
Be aware that you have to specify a full file path with the correct file extension, which is "pdf".
This method requires the PDF/A Conversion & Validation component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert the loaded PDF document to the PDF/A-1b compliant document.
Dim caption As String = "Example: ConvertToPDFA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.ConvertToPDFA("converted.pdf", PdfConversionConformance.PDF_A_1b, True, True)
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been converted successfully.", caption)
Else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: ConvertToPDFA";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.ConvertToPDFA("converted.pdf", PdfConversionConformance.PDF_A_1b, true, true);
if (status == GdPictureStatus.OK)
MessageBox.Show("The PDF file has been converted successfully.", caption);
else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
Converts the currently loaded PDF document to a brand new PDF document that meets the PDF/A conformance level according to what you have specified.
Please refer to this example for more details about our native PDF to PDF/A converter.
Be aware that both Vectorization and Rasterization approaches, when used, result in loss of fonts and text information because the text converts into shapes and raster images.
Text information can be later recovered using OCR features.
The file path where the converted PDF document will be saved. If the specified file already exists, it will be overwritten.
You are allowed to overwrite the currently opened PDF document only if the document has been loaded into memory setting the LoadInMemory parameter
to true in the previously called method.
A member of the PdfConversionConformance enumeration. Specifies the required conformance level of the converted PDF document.
Set this parameter to true, if you want to let the conversion engine use the page vectorization when the direct conversion is not possible.
Otherwise set it to false. Vectorization produces vector based graphic elements where applicable, for example, fonts and paths, and combines them with image resources.
The recommended value is true.
Set this parameter to true, if you want to let the conversion engine use the page rasterization when the direct conversion
and vectorization are not possible or allowed. Otherwise set it to false. Rasterization renders the document content using the raster (pixel-based) approach.
The recommended value is true.
This method is only allowed for use with non-encrypted documents.
Be aware that you have to specify a full file path with the correct file extension, which is "pdf".
This method requires the PDF/A Conversion & Validation component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert the loaded PDF document to the PDF/A-1b compliant document.
Dim caption As String = "Example: ConvertToPDFA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.ConvertToPDFA("converted.pdf", PdfConversionConformance.PDF_A_1b, True, True)
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been converted successfully.", caption)
Else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: ConvertToPDFA";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.ConvertToPDFA("converted.pdf", PdfConversionConformance.PDF_A_1b, true, true);
if (status == GdPictureStatus.OK)
MessageBox.Show("The PDF file has been converted successfully.", caption);
else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
Converts the currently loaded PDF document to a brand new PDF document that meets the PDF/A conformance level according to what you have specified.
Please refer to this example for more details about our native PDF to PDF/A converter.
Be aware that both Vectorization and Rasterization approaches, when used, result in loss of fonts and text information because the text converts into shapes and raster images.
Text information can be later recovered using OCR features.
Converts the currently loaded PDF document to a brand new PDF document that meets the required PDF/A conformance level.
A Stream object where the converted PDF document will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
A member of the PdfConversionConformance enumeration. Specifies the required conformance level of the converted PDF document.
Set this parameter to true, if you want to let the conversion engine use the page vectorization when the direct conversion is not possible.
Otherwise set it to false. Vectorization produces vector based graphic elements where applicable, for example, fonts and paths, and combines them with image resources.
The recommended value is true.
Set this parameter to true, if you want to let the conversion engine use the page rasterization when the direct conversion
and vectorization are not possible or allowed. Otherwise set it to false. Rasterization renders the document content using the raster (pixel-based) approach.
The recommended value is true.
This method is only allowed for use with non-encrypted documents.
Be aware that the output stream should be open for writing and should be closed/disposed of by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert the loaded PDF document to the PDF/A-1b compliant document using streams.
Dim caption As String = "Example: ConvertToPDFA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim sourceDoc As System.IO.Stream = New System.IO.FileStream("test.pdf", System.IO.FileMode.Open)
Dim status As GdPictureStatus = gdpicturePDF.LoadFromStream(sourceDoc)
If status = GdPictureStatus.OK Then
Dim destDoc As System.IO.FileStream = New System.IO.FileStream("converted.pdf", System.IO.FileMode.Create)
status = gdpicturePDF.ConvertToPDFA(destDoc, PdfConversionConformance.PDF_A_1b, True, True)
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been converted successfully.", caption)
Else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption)
End If
gdpicturePDF.CloseDocument()
destDoc.Dispose()
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
sourceDoc.Dispose()
End Using
string caption = "Example: ConvertToPDFA";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
System.IO.Stream sourceDoc = new System.IO.FileStream("test.pdf", System.IO.FileMode.Open);
GdPictureStatus status = gdpicturePDF.LoadFromStream(sourceDoc);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream destDoc = new System.IO.FileStream("converted.pdf", System.IO.FileMode.Create);
status = gdpicturePDF.ConvertToPDFA(destDoc, PdfConversionConformance.PDF_A_1b, true, true);
if (status == GdPictureStatus.OK)
MessageBox.Show("The PDF file has been converted successfully.", caption);
else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption);
gdpicturePDF.CloseDocument();
destDoc.Dispose();
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
sourceDoc.Dispose();
}
Validates if the currently loaded PDF document conforms to PDF/A standard it claims.
true if currently loaded document is Valid PDF/A document, otherwise returns false.
The method can be subsequently used to determine if this method has been successful.
How to check if document is valid PDF/A document.
Dim caption As String = "Example: IsValidPDFA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim IsValid As Boolean = gdpicturePDF.IsValidPDFA()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If IsValid Then
MessageBox.Show("The PDF document is a Valid PDF/A Document.", caption)
Else
MessageBox.Show("The PDF document is not a Valid PDF/A Document.", caption)
End If
Else
MessageBox.Show("Error occurred durring the document validation process. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
string caption = "Example: IsValidPDFA";
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
bool isValid = gdpicturePDF.IsValidPDFA();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if(isValid)
{
MessageBox.Show("The PDF document is a Valid PDF/A Document.", caption);
}
else
{
MessageBox.Show("The PDF document is not a Valid PDF/A Document.", caption);
}
}
else
{
MessageBox.Show("Error occurred durring the document validation process. Status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
}
Validates if the currently loaded PDF document conforms to PDF/A standard it claims.
Output parameter. Provides detailed validation result in machine readable XML report. If the file does not conform to the requested standard the XML report will summarize all problems that have been found durring the validation process.
true if currently loaded document is Valid PDF/A document, otherwise returns false.
The method can be subsequently used to determine if this method has been successful.
How to check if document is valid PDF/A document.
Dim caption As String = "Example: IsValidPDFA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim XMLReport As String = String.Empty
Dim IsValid As Boolean = gdpicturePDF.IsValidPDFA(XMLReport)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If IsValid Then
MessageBox.Show("The PDF document is a Valid PDF/A Document.", caption)
Else
MessageBox.Show("The PDF document is not a Valid PDF/A Document. Refer to the XML Report for further details.", caption)
End If
Else
MessageBox.Show("Error occurred durring the document validation process. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
string caption = "Example: IsValidPDFA";
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string XMLReport = string.Empty;
bool isValid = gdpicturePDF.IsValidPDFA(ref XMLReport);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if(isValid)
{
MessageBox.Show("The PDF document is a Valid PDF/A Document.", caption);
}
else
{
MessageBox.Show("The PDF document is not a Valid PDF/A Document. Refer to the XML Report for further details.", caption);
}
}
else
{
MessageBox.Show("Error occurred durring the document validation process. Status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
}
Validates if the currently loaded PDF document conforms to PDF/A standard it claims.
true if currently loaded document is Valid PDF/A document, otherwise returns false.
The method can be subsequently used to determine if this method has been successful.
Output parameter. Provides detailed validation result in machine readable XML report. If the file does not conform to the requested standard the XML report will summarize all problems that have been found durring the validation process.
Output parameter. A member of the PdfValidationConformance enumeration. Provides information about the claimed conformance that the document was validated against.
How to check if document is valid PDF/A document.
Dim caption As String = "Example: IsValidPDFA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim XMLReport As String = String.Empty
Dim VerifiedConformance As PdfValidationConformance
Dim IsValid As Boolean = gdpicturePDF.IsValidPDFA(XMLReport, VerifiedConformance)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If IsValid Then
MessageBox.Show("The PDF document is a Valid PDF/A Document.", caption)
Else
MessageBox.Show("The PDF document is not a Valid PDF/A Document. Refer to the XML Report for further details.", caption)
End If
Else
MessageBox.Show("Error occurred durring the document validation process. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
string caption = "Example: IsValidPDFA";
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string XMLReport = string.Empty;
bool verifiedConformance;
bool isValid = gdpicturePDF.IsValidPDFA(ref XMLReport, ref verifiedConformance);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if(isValid)
{
MessageBox.Show("The PDF document is a Valid PDF/A Document.", caption);
}
else
{
MessageBox.Show("The PDF document is not a Valid PDF/A Document. Refer to the XML Report for further details.", caption);
}
}
else
{
MessageBox.Show("Error occurred durring the document validation process. Status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
}
Validates the currently loaded PDF document against specified PDF/A standard and provides validation report.
This method requires the PDF/A Conversion & Validation component to run.
A member of the PdfValidationConformance enumeration. Specifies the conformance level that the document shall be validated against.
Output parameter. Provides detailed validation result in machine readable XML report. If the file does not conform to the requested standard the XML report will summarize all problems that have been found durring the validation process.
true if currently loaded document is Valid PDF/A document, otherwise returns false.
The method can be subsequently used to determine if this method has been successful.
How to check if document conforms to specified PDF/A standard.
Dim caption As String = "Example: CheckPDFAConformance"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
Dim XMLReport As String = String.Empty
Dim IsValid As Boolean = gdpicturePDF.CheckPDFAConformance(PdfValidationConformance.PDF_A_2b, XMLReport)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If IsValid Then
MessageBox.Show("The PDF document conforms to specified PDF/A standard.", caption)
Else
MessageBox.Show("The PDF document does not conform to specified PDF/A standard. Refer to the XML Report for further details.", caption)
End If
Else
MessageBox.Show("Error occurred durring the document validation process. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
string caption = "Example: CheckPDFAConformance";
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
string XMLReport = string.Empty;
bool isValid = gdpicturePDF.CheckPDFAConformance(PdfValidationConformance.PDF_A_2b, ref XMLReport);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if(isValid)
{
MessageBox.Show("The PDF document conforms to specified PDF/A standard.", caption);
}
else
{
MessageBox.Show("The PDF document does not conform to specified PDF/A standard. Refer to the XML Report for further details.", caption);
}
}
else
{
MessageBox.Show("Error occurred durring the document validation process. Status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
}
Converts the currently loaded PDF document to a brand new PDF document that meets the PDF/UA conformance.
The file path where the converted PDF document will be saved. If the specified file already exists, it will be overwritten.
You are allowed to overwrite the currently opened PDF document only if the document has been loaded into memory setting the LoadInMemory parameter
to true in the previously called method.
A member of the PdfConversionConformance enumeration. Specifies the required conformance level of the converted PDF document. Currently, PDF_UA_1 is the only valid option.
This method is only allowed for use with non-encrypted documents.
Be aware that you have to specify a full file path with the correct file extension, which is "pdf".
This method requires the PDF/UA Conversion component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert the loaded PDF document to the PDF/UA-1 compliant document.
Dim caption As String = "Example: ConvertToPDFUA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.ConvertToPDFUA("converted.pdf", PdfConversionConformance.PDF_UA_1)
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been converted successfully.", caption)
Else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: ConvertToPDFUA";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.ConvertToPDFUA("converted.pdf", PdfConversionConformance.PDF_UA_1);
if (status == GdPictureStatus.OK)
MessageBox.Show("The PDF file has been converted successfully.", caption);
else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
Converts the currently loaded PDF document to a brand new PDF document that meets the PDF/UA conformance.
The file path where the converted PDF document will be saved. If the specified file already exists, it will be overwritten.
You are allowed to overwrite the currently opened PDF document only if the document has been loaded into memory setting the LoadInMemory parameter
to true in the previously called method.
A member of the PdfConversionConformance enumeration. Specifies the required conformance level of the converted PDF document. Currently, PDF_UA_1 is the only valid option.
The time interval, in other words timeout, in milliseconds, that specifies the maximum time allowed for the whole conversion process before it is automatically interrupted. Use 0 to specify no timeout.
This method is only allowed for use with non-encrypted documents.
Be aware that you have to specify a full file path with the correct file extension, which is "pdf".
This method requires the PDF/UA Conversion component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert the loaded PDF document to the PDF/UA-1 compliant document.
Dim caption As String = "Example: ConvertToPDFUA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.ConvertToPDFUA("converted.pdf", PdfConversionConformance.PDF_UA_1, 20000)
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been converted successfully.", caption)
Else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: ConvertToPDFUA";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.ConvertToPDFUA("converted.pdf", PdfConversionConformance.PDF_UA_1, 20000);
if (status == GdPictureStatus.OK)
MessageBox.Show("The PDF file has been converted successfully.", caption);
else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
Converts the currently loaded PDF document to a brand new PDF document that meets the PDF/UA conformance.
A Stream object where the converted PDF document will be saved to. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
A member of the PdfConversionConformance enumeration. Specifies the required conformance level of the converted PDF document. Currently, PDF_UA_1 is the only valid option.
This method is only allowed for use with non-encrypted documents.
Be aware that the output stream should be open for writing and should be closed/disposed of by the user as well.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert the loaded PDF document to the PDF/UA-1 compliant document using streams.
Dim caption As String = "Example: ConvertToPDFUA"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim sourceDoc As System.IO.Stream = New System.IO.FileStream("test.pdf", System.IO.FileMode.Open)
Dim status As GdPictureStatus = gdpicturePDF.LoadFromStream(sourceDoc)
If status = GdPictureStatus.OK Then
Dim destDoc As System.IO.FileStream = New System.IO.FileStream("converted.pdf", System.IO.FileMode.Create)
status = gdpicturePDF.ConvertToPDFUA(destDoc, PdfConversionConformance.PDF_UA_1)
If status = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been converted successfully.", caption)
Else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption)
End If
gdpicturePDF.CloseDocument()
destDoc.Dispose()
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
sourceDoc.Dispose()
End Using
string caption = "Example: ConvertToPDFUA";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
System.IO.Stream sourceDoc = new System.IO.FileStream("test.pdf", System.IO.FileMode.Open);
GdPictureStatus status = gdpicturePDF.LoadFromStream(sourceDoc);
if (status == GdPictureStatus.OK)
{
System.IO.FileStream destDoc = new System.IO.FileStream("converted.pdf", System.IO.FileMode.Create);
status = gdpicturePDF.ConvertToPDFUA(destDoc, PdfConversionConformance.PDF_UA_1);
if (status == GdPictureStatus.OK)
MessageBox.Show("The PDF file has been converted successfully.", caption);
else
MessageBox.Show("The file can't be converted. Status: " + status.ToString(), caption);
gdpicturePDF.CloseDocument();
destDoc.Dispose();
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
sourceDoc.Dispose();
}
Starts a smart redaction operation on the currently loaded PDF document.
This method requires the Annotations and KVP and Table Processing - Intelligent Redaction component to run.
This method requires the OCR component to run.
A SmartRedactionOptions object specifying the options.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("d:\\combined.pdf");
GdPicturePDF.SmartRedactionOptions redactOptions = new GdPicturePDF.SmartRedactionOptions()
{
ResourcePath = @"D:\resources",
RedactCreditCardNumbers = true,
RedactVehicleIdentificationNumbers = true,
RedactEmailAddresses = true,
RedactPhoneNumbers = true,
RedactVatIDs = true,
RedactURIs = true,
RedactIBANs = true,
MarkColor = GdPictureColor.Blue
};
gdpicturePDF.SmartRedaction(redactOptions);
gdpicturePDF.SaveToFile("d:\\redacted.pdf");
}
Adds redaction region on the selected page of the loaded PDF document.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the redaction bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method .
The vertical (Y) coordinate of the closest point to the currently defined origin, where the redaction bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page.
The width of the redaction bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the redaction bounding box, expressed in the current units specified by the SetMeasurementUnit method.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to redact regions on pages in PDF document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SelectPage(1)
gdpicturePDF.AddRedactionRegion(120, 300, 140, 20)
gdpicturePDF.SelectPage(2)
gdpicturePDF.AddRedactionRegion(100, 280, 70, 15)
gdpicturePDF.AddRedactionRegion(100, 310, 70, 15)
gdpicturePDF.ApplyRedaction()
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SelectPage(1);
gdpicturePDF.AddRedactionRegion(120, 300, 140, 20);
gdpicturePDF.SelectPage(2);
gdpicturePDF.AddRedactionRegion(100, 280, 70, 15);
gdpicturePDF.AddRedactionRegion(100, 310, 70, 15);
gdpicturePDF.ApplyRedaction();
gdpicturePDF.SaveToFile("output.pdf");
}
Adds redaction region on the selected page of the loaded PDF document.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the redaction bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method .
The vertical (Y) coordinate of the closest point to the currently defined origin, where the redaction bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page.
The width of the redaction bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the redaction bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The amount of red color to be used for the resulting region color. Use the value between 0 and 255.
The amount of green color to be used for the resulting region color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting region color. Use the value between 0 and 255.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to redact regions on pages in PDF document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SelectPage(1)
gdpicturePDF.AddRedactionRegion(120, 300, 140, 20, 255, 0, 0)
gdpicturePDF.SelectPage(2)
gdpicturePDF.AddRedactionRegion(100, 280, 70, 15, 0, 255, 0)
gdpicturePDF.AddRedactionRegion(100, 310, 70, 15, 0, 0, 255)
gdpicturePDF.ApplyRedaction()
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SelectPage(1);
gdpicturePDF.AddRedactionRegion(120, 300, 140, 20, 255, 0, 0);
gdpicturePDF.SelectPage(2);
gdpicturePDF.AddRedactionRegion(100, 280, 70, 15, 0, 255, 0);
gdpicturePDF.AddRedactionRegion(100, 310, 70, 15, 0, 0, 255);
gdpicturePDF.ApplyRedaction();
gdpicturePDF.SaveToFile("output.pdf");
}
Adds redaction region on the selected page of the loaded PDF document.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the redaction bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method .
The vertical (Y) coordinate of the closest point to the currently defined origin, where the redaction bounding box is to be located.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page.
The width of the redaction bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the redaction bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The amount of red color to be used for the resulting region color. Use the value between 0 and 255.
The amount of green color to be used for the resulting region color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting region color. Use the value between 0 and 255.
The transparency value of the resulting region color. Use the value between 0 (full transparency) and 255 (full opacity).
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to redact regions on pages in PDF document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SelectPage(1)
gdpicturePDF.AddRedactionRegion(120, 300, 140, 20, 255, 0, 0, 255)
gdpicturePDF.SelectPage(2)
gdpicturePDF.AddRedactionRegion(100, 280, 70, 15, 0, 255, 0, 10)
gdpicturePDF.AddRedactionRegion(100, 310, 70, 15, 0, 0, 255, 150)
gdpicturePDF.ApplyRedaction()
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SelectPage(1);
gdpicturePDF.AddRedactionRegion(120, 300, 140, 20, 255, 0, 0, 255);
gdpicturePDF.SelectPage(2);
gdpicturePDF.AddRedactionRegion(100, 280, 70, 15, 0, 255, 0, 10);
gdpicturePDF.AddRedactionRegion(100, 310, 70, 15, 0, 0, 255, 150);
gdpicturePDF.ApplyRedaction();
gdpicturePDF.SaveToFile("output.pdf");
}
Searches for all occurrences of a given regular expression pattern within the currently loaded PDF document and adds redaction region for every occurrence found.
The regular expression pattern to search for.
Set this parameter to true if you want to apply case-sensitive search, otherwise set it to false.
The amount of red color to be used for the resulting region color. Use the value between 0 and 255.
The amount of green color to be used for the resulting region color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting region color. Use the value between 0 and 255.
The transparency value of the resulting region color. Use the value between 0 (full transparency) and 255 (full opacity).
Output parameter. If the method has been successfully followed, then the parameter will return number of occurrences found.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to redact all occurrences of text string in PDF document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
Dim occurrences As Integer = 0
gdpicturePDF.SearchAndAddRedactionRegions("Sensitive text string", True, 0, 0, 0, 255, occurrences)
If occurrences > 0 Then
gdpicturePDF.ApplyRedaction()
End If
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
int occurrences = 0;
gdpicturePDF.SearchAndAddRedactionRegions("Sensitive text string", true, 0, 0, 0, 255, ref occurrences);
if (occurrences > 0)
{
gdpicturePDF.ApplyRedaction();
}
gdpicturePDF.SaveToFile("output.pdf");
}
Applies redactions based on regions added using the AddRedactionRegion method.
This method requires the Redaction component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to redact regions on pages in PDF document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SelectPage(1)
gdpicturePDF.AddRedactionRegion(120, 300, 140, 20)
gdpicturePDF.SelectPage(2)
gdpicturePDF.AddRedactionRegion(100, 280, 70, 15)
gdpicturePDF.AddRedactionRegion(100, 310, 70, 15)
gdpicturePDF.ApplyRedaction()
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SelectPage(1);
gdpicturePDF.AddRedactionRegion(120, 300, 140, 20);
gdpicturePDF.SelectPage(2);
gdpicturePDF.AddRedactionRegion(100, 280, 70, 15);
gdpicturePDF.AddRedactionRegion(100, 310, 70, 15);
gdpicturePDF.ApplyRedaction();
gdpicturePDF.SaveToFile("output.pdf");
}
Clears the list off redaction regions previously added using AddRedactionRegion method.
Removes all hidden text on currently selected page of the loaded PDF document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove hidden text from the document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For i As Integer = 1 To pageCount
gdpicturePDF.RemoveHiddenText()
Next
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
int pageCount = gdpicturePDF.GetPageCount();
for(int page = 1; page <= pageCount; i++)
{
gdpicturePDF.RemoveHiddenText();
}
gdpicturePDF.SaveToFile("output.pdf");
}
Removes all text on currently selected page of the loaded PDF document.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove all text from the document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
For page As Integer = 1 To pageCount
gdpicturePDF.SelectPage(page)
gdpicturePDF.RemoveAllText()
Next
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
int pageCount = gdpicturePDF.GetPageCount();
for(int page = 1; page <= pageCount; i++)
{
gdpicturePDF.SelectPage(page);
gdpicturePDF.RemoveAllText();
}
gdpicturePDF.SaveToFile("output.pdf");
}
Removes all text contained in specified area on currently selected page of the loaded PDF document.
The horizontal (X) coordinate of the closest point to the currently defined origin, of the area where text shall be removed.
The value is expressed in the current units specified by the SetMeasurementUnit method .
The vertical (Y) coordinate of the closest point to the currently defined origin, of the area where text shall be removed.
The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page.
The width of the area where text shall be removed, expressed in the current units specified by the SetMeasurementUnit method.
The height of the area where text shall be removed, expressed in the current units specified by the SetMeasurementUnit method.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to remove text from area on page in the PDF document.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SelectPage(2)
gdpicturePDF.RemoveTextArea(100, 120, 30, 70)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SelectPage(2);
gdpicturePDF.RemoveTextArea(100, 120, 30, 70);
gdpicturePDF.SaveToFile("output.pdf");
}
Converts specified content of currently selected page of the loaded PDF document to grayscale.
Set this parameter to true if you want to convert all text on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all path - based graphic objects on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all images on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all annotations on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all form fields on page to grayscale, otherwise set it to false.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert images on the selected page to grayscale.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
gdpicturePDF.SelectPage(2)
gdpicturePDF.ConvertToGrayscale(False, False, True, False, False)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
gdpicturePDF.SelectPage(2);
gdpicturePDF.ConvertToGrayscale(false, false, true, false, false);
gdpicturePDF.SaveToFile("output.pdf");
}
Converts specified content of currently selected page of the loaded PDF document to grayscale.
Set this parameter to true if you want to convert all text on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all path - based graphic objects on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all images on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all annotations on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all form fields on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to execute removal of unused resources of the end of the process.
We recommend to use this overload when multiple pages of the document need to be converted or if the document will be processed in any other way before saving.
This is because removal of unused resources, which is a document wide process, can be executed after last page was processed and not after every page which improves the overall performance.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to convert images on the selected pages to grayscale and remove unused resources after last page is processed.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
gdpicturePDF.SelectPage(1)
gdpicturePDF.ConvertToGrayscale(False, False, True, False, False, False)
gdpicturePDF.SelectPage(2)
gdpicturePDF.ConvertToGrayscale(False, False, True, False, False, True)
gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
gdpicturePDF.SelectPage('1);
gdpicturePDF.ConvertToGrayscale(false, false, true, false, false, false);
gdpicturePDF.SelectPage(2);
gdpicturePDF.ConvertToGrayscale(false, false, true, false, false, true);
gdpicturePDF.SaveToFile("output.pdf");
}
Checks if the currently selected page of the loaded PDF document contains any invisible text.
true if the selected page of the loaded PDF document contains any invisible text, otherwise returns false.
The method can be subsequently used to determine if this method has been successful.
How to check of the document contains any invisible text.
Using gdpicturePDF As New GdPicturePDF
gdpicturePDF.LoadFromFile("input.pdf")
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
Dim hasInvisibleText as Bool = False
For i As Integer = 1 To pageCount
hasInvisibleText = hasInvisibleText Or gdpicturePDF.HasInvisibleText()
Next
If hasInvisibleText Then
MessageBox.Show("The document contains invisible text.", "GdPicturePDF")
End If
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
gdpicturePDF.LoadFromFile("input.pdf");
int pageCount = gdpicturePDF.GetPageCount();
bool hasInvisibleText = false;
for(int page = 1; page <= pageCount; i++)
{
hasInvisibleText = hasInvisibleText || gdpicturePDF.HasInvisibleText();
}
if(hasInvisibleText)
{
MessageBox.Show("The document contains invisible text.", "GdPicturePDF");
}
}
Imports XFDF form fields and annotation data from file specified by the provided file path.
The file path of the data source document. Supports only well formed XFDF files.
Set this parameter to true if you want to import form fields data, otherwise set it to false.
Set this parameter to true if you want to import annotations data, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to import XFDF data from file.
Using pdf = New GdPicturePDF
pdf.LoadFromFile("input.pdf")
pdf.ImportXFDFDataFromFile("annotations.xfdf", False, True)
pdf.SaveToFile("output.pdf")
End Using
using (GdPicturePDF pdf = new GdPicturePDF)
{
pdf.LoadFromFile("input.pdf");
pdf.ImportXFDFDataFromFile("annotations.xfdf", false, true);
pdf.SaveToFile("output.pdf");
}
Exports XFDF form fields and annotation data to a previously instantiated Stream.
A Stream object. This stream object must be initialized before it can be sent into this method.
Set this parameter to true if you want to export form fields data, otherwise set it to false.
Set this parameter to true if you want to export annotations data, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
It is recommended to use the method to identify the specific reason for the method's failure, if any.
Also be aware that the output stream should be closed/disposed of by the user.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Exports XFDF form fields and annotation data to a file specified by the provided file path.
The file path of the output XFDF document. If the specified file already exists, it will be overwritten.
Set this parameter to true if you want to export form fields data, otherwise set it to false.
Set this parameter to true if you want to export annotations data, otherwise set it to false.
This method is only allowed for use with non-encrypted documents.
It is recommended to use the method to identify the specific reason for the method's failure, if any.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Imports PSPDFKit InstantJSON form fields and annotation data from file specified by the provided file path.
The file path of the data source document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to import InstantJSON data from file.
Using pdf = New GdPicturePDF
pdf.LoadFromFile("input.pdf")
pdf.ImportInstantJSONDataFromFile("annotations.json")
pdf.SaveToFile("output.pdf")
End Using
using (GdPicturePDF pdf = new GdPicturePDF)
{
pdf.LoadFromFile("input.pdf");
pdf.ImportInstantJSONDataFromFile("annotations.json");
pdf.SaveToFile("output.pdf");
}
Exports PSPDFKit Instant JSON form fields, annotation and bookmark data to a previously instantiated Stream.
A Stream object. This stream object must be initialized before it can be sent into this method.
This method is only allowed for use with non-encrypted documents.
It is recommended to use the method to identify the specific reason for the method's failure, if any.
Also be aware that the output stream should be closed/disposed of by the user.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Exports PSPDFKit Instant JSON form fields, annotation and bookmark data to a file specified by the provided file path.
The file path of the output Instant JSON document. If the specified file already exists, it will be overwritten.
This method is only allowed for use with non-encrypted documents.
It is recommended to use the method to identify the specific reason for the method's failure, if any.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Imports GdPicture/XMP annotation data from a previously instantiated Stream.
XMP is GdPicture's own XML-based annotation format and is otherwise produced by
and
.
A Stream object. This stream object must be initialized before it can be sent into this method.
This method is only allowed for use with non-encrypted documents.
It is recommended to use the method to identify the specific reason for the method's failure, if any.
Also be aware that the input stream should be closed/disposed of by the user.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Imports GdPicture/XMP annotation data from a file specified by the provided file path.
The file path of the XMP source document.
This method is only allowed for use with non-encrypted documents.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Exports GdPicture/XMP annotation data for the currently selected page to
a previously instantiated Stream. The exported document uses the flat single-page XMP
layout produced by — the
same shape the toolkit writes into the PDF's per-page XMP metadata stream.
For multi-page documents where every page's annotations should be bundled into a
single artifact, use instead.
A Stream object. This stream object must be initialized before it can be sent into this method.
This method is only allowed for use with non-encrypted documents.
It is recommended to use the method to identify the specific reason for the method's failure, if any.
Also be aware that the output stream should be closed/disposed of by the user.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Exports GdPicture/XMP annotation data for the currently selected page to
a file specified by the provided file path.
The file path of the output XMP document. If the specified file already exists, it will be overwritten.
This method is only allowed for use with non-encrypted documents.
It is recommended to use the method to identify the specific reason for the method's failure, if any.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Exports GdPicture/XMP annotation data for all pages of the document to a
previously instantiated Stream. The exported document uses the multi-page XMP layout
produced by — an
<AnnotationPageArray> with one <PageAnnots> entry per page,
each carrying a base64-encoded flat XMP payload.
For exporting annotations on a single page only, use
instead.
The companion auto-detects both the
flat single-page and wrapped multi-page shapes, so no Ex import variant is
required.
A Stream object. This stream object must be initialized before it can be sent into this method.
This method is only allowed for use with non-encrypted documents.
It is recommended to use the method to identify the specific reason for the method's failure, if any.
Also be aware that the output stream should be closed/disposed of by the user.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Exports GdPicture/XMP annotation data for all pages of the document to a
file specified by the provided file path. See
for the layout used.
The file path of the output XMP document. If the specified file already exists, it will be overwritten.
This method is only allowed for use with non-encrypted documents.
It is recommended to use the method to identify the specific reason for the method's failure, if any.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Disposes already used GdPicturePDF object completely. All related resources used by this object are released.
This method implicitly calls the method.
GdPicturePDF Constructor
How to create and dispose of a GdPicturePDF object.
'The elementary use of the Dispose() method.
Dim gdpicturePDF As New GdPicturePDF()
'You can do your stuff with gdpicturePDF here.
gdpicturePDF.Dispose()
'The very good practice is to use the keyword "using".
Using gdpicturePDF As New GdPicturePDF()
'You can do your stuff with gdpicturePDF here.
'You do not need to call the Dispose() method, it is called automatically inside the "using" statement.
End Using
//The elementary use of the Dispose() method.
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//You can do your stuff with gdpicturePDF here.
gdpicturePDF.Dispose();
//The very good practice is to use the keyword "using".
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
//You can do your stuff with gdpicturePDF here.
//You do not need to call the Dispose() method, it is called automatically inside the "using" statement.
}
A standard constructor for the GdPicturePDF class. It initializes an instance of the GdPicturePDF class,
which subsequently represents a wrapper for any PDF file. You will need this object to perform all available operations with the current PDF document.
Please note that a newly created GdPicturePDF object does not automatically create a new empty PDF document.
How to create a GdPicturePDF object.
'The first option
Dim gdpicturePDF As New GdPicturePDF()
'You can do your stuff with gdpicturePDF here.
gdpicturePDF.Dispose()
'The second option
'The very good practice is to use the keyword "using".
Using gdpicturePDF As New GdPicturePDF()
'You can do your stuff with gdpicturePDF here.
End Using
//The first option
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//You can do your stuff with gdpicturePDF here.
gdpicturePDF.Dispose();
//The second option
//The very good practice is to use the keyword "using".
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
//You can do your stuff with gdpicturePDF here.
}
This class handles different options requested by a GdPicturePDF instance to perform OCR.
Specifies the number of the page of the input document to be processed.
Specifies whether the OCR engine shall detect image rotation before running OCR.
The default value is true.
Specifies whether the OCR engine shall detect image skew before running OCR.
The default value is true.
Specifies the ocr mode requested.
The default value is OCRMode.FavorAccuracy.
Specifies the resources path of the OCR engine, if any.
The default value is "".
Specifies the dictionary requested to the OCR engine, if any.
The default value is "eng".
Specifies the so called white list of characters, in other words the restricted recognition characters.
It means that the engine shall only returns the specified characters when processing.
For example, if you want to only recognize numeric characters, set this parameter to "0123456789". If you want to only recognize uppercase letters,
set it to "ABCDEFGHIJKLMNOPQRSTUVWXYZ". Set this parameter to the empty string to recognize all characters.
The default value is "".
The time interval, in other words timeout, in milliseconds, that specifies the maximum time allowed for the whole OCR process.
Use 0 to specify no timeout.
The default value is 0.
Specifies if image preprocessing is activated.
The default value is true.
Specifies of the engine must remove existing OCR text layer, if any.
This class handles different options requested by a GdPicturePDF instance to perform smart redaction.
Specifies page range of the input document to be processed.
The default value is "*", meaning all pages.
Specifies whether redaction is immediately applied.
Set to false to only add redaction marks to be subsequently managed by other controls of the toolkit.
The default value is true.
Specifies the number of threads to use.
Set this parameter to 0 to let the engine to automatically maximize the performance.
Default value is 0.
Specifies whether the engine must redact email addresses.
The default value is false.
Specifies whether the engine must redact postal addresses.
The default value is false.
Specifies whether the engine must redact IP addresses.
The default value is false.
Specifies whether the engine must redact URIs.
The default value is false.
Specifies whether the engine must redact IBANs.
The default value is false.
Specifies whether the engine must redact phone numbers.
The default value is false.
Specifies whether the engine must redact VAT identifiers.
The default value is false.
Specifies whether the engine must redact credit card numbers.
The default value is false.
Specifies whether the engine must redact vehicle identification numbers.
The default value is false.
Specifies whether the engine must redact social security numbers.
The default value is false.
Specifies whether the engine shall detect image rotation before running the process.
The default value is true.
Specifies the OCR strategy applied during the redaction process.
The default value is OCRStrategy.Automatic.
Specifies the resources path of the OCR engine.
The default value is "".
Specifies the dictionary to be used by the engine.
The default value is "eng".
The time interval, in other words timeout, in milliseconds, that specifies the maximum time allowed for the whole process.
Use 0 to specify no timeout.
The default value is 0.
Specifies the redaction mark color.
The default value is GdPictureColor.Black.
Specifies if image preprocessing is activated.
The default value is true.
Specifies whether the engine shall detect image skew before running the process.
The default value is true.
Gets or sets the configuration of the reduction process.
Runs a reduction process on the document provided as parameter.
This method requires the PDF Processing component to run.
The stream of the document to be processed, which can be of any document type that is supported by the toolkit.
The stream for saving the PDF produced by the reduction process.
A member of the GdPictureStatus enumeration.
Runs a reduction process on the document provided as parameter.
The path to the file to be processed, which can be of any document type that is supported by the toolkit.
The path to the file where the result will be saved. If the specified file already exists, it will be overwritten.
A member of the GdPictureStatus enumeration.
Returns the status of the last executed operation by the current GdPicturePDFReducer instance.
Returns the reduction error status of the last reduction process operated by the current GdPicturePDFReducer instance.
A member of the PDFReducerErrorStatus enumeration.
Returns the number of the page that caused an error during the reduction process.
Returns the number of warnings raised during the last reduction process operated by the current GdPicturePDFReducer instance.
Returns the warning status corresponding to the index provided as parameter.
The 0-based index of the warning status. It must be a value between 0 and
A member of the PDFReducerWarningStatus enumeration.
Returns the number of the page that caused the warning specified by the provided index to be raised.
The 0-based index of the warning status. It must be a value between 0 and
Returns the number of the image (relatively to the page) that caused the warning specified by the provided index to be raised.
The 0-based index of the warning status. It must be a value between 0 and
The GdPictureSegmenter class offers the comprehensive image segmentation support. It is used as a wrapper class to allow you easily segment your image-based
documents into regions and to find out required results in one place.
In general, the image segmentation simply means a thresholding of your image into various areas, like blocks of text, graphics or images.
You need to create an object of this class to fully perform the image segmentation on your files. This object allows you to set the required image for the
segmentation and subsequently it enables you to very easily find out the segmentation results.
GdPictureSegmenter Constructor
How to use the instance of the GdPictureSegmenter class to process the image segmentation on your image-based file.
Dim caption As String = "Example: GdPictureSegmenter class"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
'Check the status ...
Dim status As GdPictureStatus = gdpictureSegmenter.SetImage(image)
If status = GdPictureStatus.OK Then
'Run the segmentation process.
Dim resID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resID)
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " & gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Continue ...
End If
'Release image resources.
gdpictureImaging.ReleaseGdPictureImage(image)
End Using
'Release segmentation resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GdPictureSegmenter class";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
//Check the status ...
GdPictureStatus status = gdpictureSegmenter.SetImage(image);
if (status == GdPictureStatus.OK)
{
//Run the segmentation process.
string resID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int blockCount = gdpictureSegmenter.GetBlockCount(resID);
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Continue ...
}
//Release image resources.
gdpictureImaging.ReleaseGdPictureImage(image);
}
//Release segmentation resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Creates a new instance of the GdPictureSegmenter class. This instance represents a wrapper, that you will need to perform the image segmentation process.
At the same it enables you to find out all required results in one place.
Using only this object you are able to set available parameters required for the segmentation process,
run the process itself and also to check results in one place.
A new instance of the GdPictureSegmenter class.
How to create and initialize a GdPictureSegmenter object.
'The first option
Dim gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'... setting parameters ...
Dim resId As String = gdpictureSegmenter.RunSegmentation()
'... checking results ...
gdpictureSegmenter.Dispose()
'The second option
'The very good practice Is to use the keyword "using".
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'... setting parameters ...
Dim resId As String = gdpictureSegmenter.RunSegmentation()
'... checking results ...
End Using
//The first option:
GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter();
//... setting parameters ...
string resID = gdpictureSegmenter.RunSegmentation();
//... checking results ...
gdpictureSegmenter.Dispose();
//The second option:
//The very good practice is to use the keyword "using".
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//... setting parameters ...
string resID = gdpictureSegmenter.RunSegmentation();
//... checking results ...
}
Defines the segmentation mode to be used during subsequent segmentation processes.
Just to inform you, that the toolkit uses the Paul Heckbert's stack-based seed fill algorithm for the image segmentation.
The default value is SegmentationMode.PageLayout.
How to set the required segmentation mode.
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'You can do your another stuff with gdpictureSegmenter here.
End Using
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//You can do your another stuff with gdpictureSegmenter here.
}
Specifies the input value that is required to segment a word.
Expected value is a string containing the text/word/character you wish to segment.
Segmenting a word given its value.
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
gdpictureSegmenter.SegmentationMode= SegmentationMode.WordLayout;
gdpictureSegmenter.InputValue = "words";
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("d:\\wordimage.png");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetROI(10,10,55,55)== GdPictureStatus.OK))
{
//Run the segmentation process.
string result = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//You can do your another stuff with gdpictureSegmenter here.
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
{
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
}
}
Sets up the specified image object, so that it is subsequently used when you start the next segmentation process.
This step is mandatory before running any segmentation.
This aproach permits you to highly improve performance when running multiple subsequent segmentation processes on the same image.
A unique image identifier of the created image object. You can take advantages
of the GdPictureImaging class
and its methods to obtain this identifier.
Please note that setting up an image is a mandatory step before running any segmentation process. This approach allows you to take all benefits of the speed
optimization when running the required image segmentation.
This method requires the OCR component to run.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK
We strongly recommend always checking this status first.
How to set the image you want to process and how to subsequently run the segmentation process on this image.
Dim caption As String = "Example: SetImage"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Run the segmentation process.
Dim result As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: SetImage";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Run the segmentation process.
string result = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Sets up the new region of interest (ROI) of an image, that is subsequently processed using the segmenter.
Only the specified region is included into the next segmentation process.
The x-coordinate of the upper-left point of the region of interest, in pixels, measured from the upper-left corner of the image.
The y-coordinate of the upper-left point of the region of interest, in pixels, measured from the upper-left corner of the image.
The width of the region of interest, in pixels.
The height of the region of interest, in pixels.
The point, that represents the upper-left corner of the image, has the coordinates (0,0).
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Resets the previously specified region of interest to default (whole image area).
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Runs the segmentation process on the image previously set by the method within the current GdPictureSegmenter object. The result of this
process, identifiable by its unique ID, is internally attached to the current GdPictureSegmenter object as well.
Executes the image segmentation using the available parameters you have specified within the current GdPictureSegmenter object.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have set the required image before you start the new segmentation process. This method uses the image object previously
set by method. Setting up an image is a mandatory step before running any segmentation process.
Just to inform you, that releasing already used segmentation results by the method can improve the memory management
if you run more segmentation processes in a row.
A unique result identifier of the executed segmentation process. The method can be subsequently used to determine if this method has been successful.
How to run the segmentation processon your image for the basic page layout segmentation.
Dim caption As String = "Example: RunSegmentation"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set your preferred segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.PageLayout
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results ...
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: RunSegmentation";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set your preferred segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.PageLayout;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results ...
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Runs the segmentation process on the image previously set by the method within the current GdPictureSegmenter object. You are allowed to
set the custom result identifier you prefer using this method. The result of this process, identifiable by this custom ID, is internally attached to the
current GdPictureSegmenter object as well.
Executes the image segmentation using the available parameters you have specified within the current GdPictureSegmenter object.
A unique result identifier of the executed segmentation process, that is used to identify the segmentation result.
You can define your preferable value. If you leave this parameter null or empty, a new identifier is automatically generated.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please ensure that you have set the required image before you start the new segmentation process. This method uses the image object previously
set by method. Setting up an image is a mandatory step before running any segmentation process.
Also be aware, that you can only reuse the result ID if you first release it using the method before the next use.
Releasing already used segmentation results can improve the memory management if you run more segmentation processes in a row.
A unique result identifier of the executed segmentation process. If the method has been successfully followed, then the custom identifier passed as a parameter is
returned, if it is properly defined.
The method can be subsequently used to determine if this method has been successful.
How to use the custom result identifier when running more segmentation processes.
Dim caption As String = "Example: RunSegmentation"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultIDComp4 As String = "ConnectedComponents4"
gdpictureSegmenter.RunSegmentation(resultIDComp4)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results ...
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultIDComp4)
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents8
'Run the segmentation process.
Dim resultIDComp8 As String = "ConnectedComponents8"
gdpictureSegmenter.RunSegmentation(resultIDComp8)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results ...
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultIDComp8)
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResult(resultIDComp4)
gdpictureSegmenter.ReleaseSegmentationResult(resultIDComp8)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
End Using
string caption = "Example: RunSegmentation";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultIDComp4 = "ConnectedComponents4";
gdpictureSegmenter.RunSegmentation(resultIDComp4);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results ...
int blockCount = gdpictureSegmenter.GetBlockCount(resultIDComp4);
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents8;
//Run the segmentation process.
string resultIDComp8 = "ConnectedComponents8";
gdpictureSegmenter.RunSegmentation(resultIDComp8);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results ...
int blockCount = gdpictureSegmenter.GetBlockCount(resultIDComp8);
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResult(resultIDComp4);
gdpictureSegmenter.ReleaseSegmentationResult(resultIDComp8);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
}
Releases a segmentation result specified by its unique identifier. Each segmentation result, identifiable by its unique ID, is internally attached to that
GdPictureSegmenter object, which has executed the segmentation process. By disposing of the current GdPictureSegmenter object you also release all attached segmentation results.
A unique result identifier of the executed segmentation process obtained by the method.
Please be aware, that each segmentation result is internally linked to the GdPictureSegmenter object, that has executed the segmentation process.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to release particular segmentation results.
Dim caption As String = "Example: ReleaseSegmentationResult"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = "ConnectedComponents"
gdpictureSegmenter.RunSegmentation(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results ...
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release previous resources.
gdpictureSegmenter.ReleaseSegmentationResult(resultID)
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents8
'Run the segmentation process.
gdpictureSegmenter.RunSegmentation(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results ...
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResult(resultID)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
End Using
string caption = "Example: ReleaseSegmentationResult";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = "ConnectedComponents";
gdpictureSegmenter.RunSegmentation(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results ...
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release previous resources.
gdpictureSegmenter.ReleaseSegmentationResult(resultID);
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents8;
//Run the segmentation process.
gdpictureSegmenter.RunSegmentation(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results ...
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResult(resultID);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
}
Releases all results of all previously executed segmentation processes within the current GdPictureSegmenter object. Each segmentation result is internally attached to that
GdPictureSegmenter object, which has executed the segmentation process. By disposing of the current GdPictureSegmenter object you also release all attached segmentation results.
Please be aware, that each segmentation result is internally linked to the GdPictureSegmenter object, that has executed the segmentation process.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to release resources after the processed image segmentation.
Dim caption As String = "Example: ReleaseSegmentationResults"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results ...
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
'Continue ...
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: ReleaseSegmentationResults";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results ...
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
//Continue ...
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the number of blocks within the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of detected blocks. The method can be subsequently used to determine if this method has been successful.
How to find out the number of detected blocks within the segmentation result.
Dim caption As String = "Example: GetBlockCount"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The number of detected blocks: " + blockCount.ToString(), caption)
'Continue ...
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetBlockCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The number of detected blocks: " + blockCount.ToString(), caption);
//Continue ...
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the type of the specified block, that is a part of the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the block within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The type of the specified block. A member of the OCRBlockType enumeration.
Please always use the method to determine if this method has been successful.
How to find out the number of detected blocks within the segmentation result and types of those blocks.
Dim caption As String = "Example: GetBlockType"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.PageLayout
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = ""
'Check the results.
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
message = message + "The number of detected blocks: " + blockCount.ToString()
For i As Integer = 0 To blockCount - 1
message = message + vbCrLf + "The block nr." + i.ToString() + " is of the type " + gdpictureSegmenter.GetBlockType(resultID, i).ToString() +
" and includes " + gdpictureSegmenter.GetBlockParagraphCount(resultID, i).ToString() + " paragraphs."
Next
MessageBox.Show(message, caption)
'Continue ...
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetBlockType";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.PageLayout;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "";
//Check the results.
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
message = message + "The number of detected blocks: " + blockCount.ToString();
for (int i = 0; i < blockCount; i++)
{
message = message + "\nThe block nr." + i.ToString() + " is of the type " + gdpictureSegmenter.GetBlockType(resultID, i).ToString() +
" and includes " + gdpictureSegmenter.GetBlockParagraphCount(resultID, i).ToString() + " paragraphs.";
}
MessageBox.Show(message, caption);
//Continue ...
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the left x-coordinate of the bounding box of the specified block, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the R method.
The 0-based index of the block within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the block's bounding box, in pixels.
The method can be subsequently used to determine if this method has been successful.
How to find out detected blocks within the segmentation result. All blocks are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetBlockLeft"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected blocks: "
message = message + blockCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To blockCount - 1
top = gdpictureSegmenter.GetBlockTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetBlockLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetBlockBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetBlockRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".block has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If blockCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = blockCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetBlockLeft";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//Set up the image you want to process.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected blocks: ";
message = message + blockCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < blockCount; i++)
{
top = gdpictureSegmenter.GetBlockTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetBlockLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetBlockBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetBlockRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".block has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (blockCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == blockCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the right x-coordinate of the bounding box of the specified block, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the block within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the block's bounding box, in pixels.
The method can be subsequently used to determine if this method has been successful.
How to find out detected blocks within the segmentation result. All blocks are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetBlockRight"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected blocks: "
message = message + blockCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To blockCount - 1
top = gdpictureSegmenter.GetBlockTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetBlockLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetBlockBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetBlockRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".block has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If blockCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = blockCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetBlockRight";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//Set up the image you want to process.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected blocks: ";
message = message + blockCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < blockCount; i++)
{
top = gdpictureSegmenter.GetBlockTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetBlockLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetBlockBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetBlockRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".block has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (blockCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == blockCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the top y-coordinate of the bounding box of the specified block, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the block within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the block's bounding box, in pixels.
The method can be subsequently used to determine if this method has been successful.
How to find out detected blocks within the segmentation result. All blocks are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetBlockTop"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected blocks: "
message = message + blockCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To blockCount - 1
top = gdpictureSegmenter.GetBlockTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetBlockLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetBlockBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetBlockRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".block has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If blockCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = blockCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetBlockTop";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//Set up the image you want to process.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected blocks: ";
message = message + blockCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < blockCount; i++)
{
top = gdpictureSegmenter.GetBlockTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetBlockLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetBlockBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetBlockRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".block has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (blockCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == blockCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the bottom y-coordinate of the bounding box of the specified block, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the block within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the block's bounding box, in pixels.
The method can be subsequently used to determine if this method has been successful.
How to find out detected blocks within the segmentation result. All blocks are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetBlockBottom"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected blocks: "
message = message + blockCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To blockCount - 1
top = gdpictureSegmenter.GetBlockTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetBlockLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetBlockBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetBlockRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".block has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If blockCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = blockCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetBlockBottom";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//Set up the image you want to process.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected blocks: ";
message = message + blockCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < blockCount; i++)
{
top = gdpictureSegmenter.GetBlockTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetBlockLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetBlockBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetBlockRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".block has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (blockCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == blockCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
{
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
}
else
{
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the number of paragraphs within the specified block, that is a part of the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the block within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of detected paragraphs within the specified block. Please always use the method to determine if this method has been successful.
How to find out the number of detected paragrahs within the block.
Dim caption As String = "Example: GetBlockParagraphCount"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim paragraphCount As Integer = 0
Dim index As Integer = 0
For i As Integer = 0 To blockCount - 1
paragraphCount = gdpictureSegmenter.GetBlockParagraphCount(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
index = gdpictureSegmenter.GetBlockFirstParagraphIndex(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Continue ...
Else
'handle the error
End If
Else
'handle the error
End If
Next
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetBlockParagraphCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = 0;
int index = 0;
for (int i = 0; i < blockCount; i++)
{
paragraphCount = gdpictureSegmenter.GetBlockParagraphCount(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
index = gdpictureSegmenter.GetBlockFirstParagraphIndex(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Continue ...
}
//else handle the error
}
//else handle the error
}
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the index of the first paragraph in the specified block, that is a part of the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the block within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the first paragraph in the specified block. Please always use the method to determine if this method has been successful.
How to find out the number of detected paragrahs within the block and the index of the first paragraph.
Dim caption As String = "Example: GetBlockFirstParagraphIndex"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim blockCount As Integer = gdpictureSegmenter.GetBlockCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim paragraphCount As Integer = 0
Dim index As Integer = 0
For i As Integer = 0 To blockCount - 1
paragraphCount = gdpictureSegmenter.GetBlockParagraphCount(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
index = gdpictureSegmenter.GetBlockFirstParagraphIndex(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Continue ...
Else
'handle the error
End If
Else
'handle the error
End If
Next
Else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetBlockFirstParagraphIndex";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int blockCount = gdpictureSegmenter.GetBlockCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
int paragraphCount = 0;
int index = 0;
for (int i = 0; i < blockCount; i++)
{
paragraphCount = gdpictureSegmenter.GetBlockParagraphCount(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
index = gdpictureSegmenter.GetBlockFirstParagraphIndex(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Continue ...
}
//else handle the error
}
//else handle the error
}
}
else
MessageBox.Show("The GetBlockCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the number of paragraphs within the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of detected paragraphs. Please always use the method to determine if this method has been successful.
How to find out the number of detected paragraphs within the segmentation result.
Dim caption As String = "Example: GetParagraphCount"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The number of detected paragraphs: " + paragraphCount.ToString(), caption)
'Continue ...
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetParagraphCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int paragraphCount = gdpictureSegmenter.GetParagraphCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The number of detected paragraphs: " + paragraphCount.ToString(), caption);
//Continue ...
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the index of the first text line in the specified paragraph, that is a part of the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the paragraph within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the first text line in the specified paragraph. Please always use the method to determine if this method has beensuccessful.
How to find out the number of detected text lines within the paragraph and the index of the first text line.
Dim caption As String = "Example: GetParagraphFirstTextLineIndex"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim textlineCount As Integer = 0, index As Integer = 0
For i As Integer = 0 To paragraphCount - 1
textlineCount = gdpictureSegmenter.GetParagraphTextLineCount(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
index = gdpictureSegmenter.GetParagraphFirstTextLineIndex(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Continue ...
Else
'handle the error
End If
Else
'handle the error
End If
Next
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetParagraphFirstTextLineIndex";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int paragraphCount = gdpictureSegmenter.GetParagraphCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
int textlineCount = 0, index = 0;
for (int i = 0; i < paragraphCount; i++)
{
textlineCount = gdpictureSegmenter.GetParagraphTextLineCount(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
index = gdpictureSegmenter.GetParagraphFirstTextLineIndex(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Continue ...
}
//else handle the error
}
//else handle the error
}
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the left x-coordinate of the bounding box of the specified paragraph, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the paragraph within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the paragraph's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected paragraphs within the segmentation result. All paragraphs are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetParagraphLeft"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected paragraphs: "
message = message + paragraphCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To paragraphCount - 1
top = gdpictureSegmenter.GetParagraphTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetParagraphLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetParagraphRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If paragraphCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = paragraphCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetParagraphLeft";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int paragraphCount = gdpictureSegmenter.GetParagraphCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected paragraphs: ";
message = message + paragraphCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < paragraphCount; i++)
{
top = gdpictureSegmenter.GetParagraphTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetParagraphLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetParagraphRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (paragraphCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == paragraphCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the right x-coordinate of the bounding box of the specified paragraph, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the paragraph within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the paragraph's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected paragraphs within the segmentation result. All paragraphs are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetParagraphRight"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected paragraphs: "
message = message + paragraphCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To paragraphCount - 1
top = gdpictureSegmenter.GetParagraphTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetParagraphLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetParagraphRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If paragraphCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = paragraphCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetParagraphRight";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int paragraphCount = gdpictureSegmenter.GetParagraphCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected paragraphs: ";
message = message + paragraphCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < paragraphCount; i++)
{
top = gdpictureSegmenter.GetParagraphTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetParagraphLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetParagraphRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (paragraphCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == paragraphCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the bottom y-coordinate of the bounding box of the specified paragraph, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the paragraph within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the paragraph's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected paragraphs within the segmentation result. All paragraphs are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetParagraphBottom"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected paragraphs: "
message = message + paragraphCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To paragraphCount - 1
top = gdpictureSegmenter.GetParagraphTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetParagraphLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetParagraphRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If paragraphCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = paragraphCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetParagraphBottom";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int paragraphCount = gdpictureSegmenter.GetParagraphCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected paragraphs: ";
message = message + paragraphCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < paragraphCount; i++)
{
top = gdpictureSegmenter.GetParagraphTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetParagraphLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetParagraphRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (paragraphCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == paragraphCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the top y-coordinate of the bounding box of the specified paragraph, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the paragraph within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the paragraph's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected paragraphs within the segmentation result. All paragraphs are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetParagraphTop"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected paragraphs: "
message = message + paragraphCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To paragraphCount - 1
top = gdpictureSegmenter.GetParagraphTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetParagraphLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetParagraphRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If paragraphCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = paragraphCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetParagraphTop";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int paragraphCount = gdpictureSegmenter.GetParagraphCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected paragraphs: ";
message = message + paragraphCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < paragraphCount; i++)
{
top = gdpictureSegmenter.GetParagraphTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetParagraphLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetParagraphBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetParagraphRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (paragraphCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == paragraphCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the number of text lines within the specified paragraph, that is a part of the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the paragraph within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of text lines within a paragraph. Please always use the method to determine if this method has been successful.
How to find out the number of detected text lines within the paragraph.
Dim caption As String = "Example: GetParagraphTextLineCount"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim paragraphCount As Integer = gdpictureSegmenter.GetParagraphCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim textlineCount As Integer = 0, index As Integer = 0
For i As Integer = 0 To paragraphCount - 1
textlineCount = gdpictureSegmenter.GetParagraphTextLineCount(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
index = gdpictureSegmenter.GetParagraphFirstTextLineIndex(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Continue ...
Else
'handle the error
End If
Else
'handle the error
End If
Next
Else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetParagraphTextLineCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int paragraphCount = gdpictureSegmenter.GetParagraphCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
int textlineCount = 0, index = 0;
for (int i = 0; i < paragraphCount; i++)
{
textlineCount = gdpictureSegmenter.GetParagraphTextLineCount(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
index = gdpictureSegmenter.GetParagraphFirstTextLineIndex(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Continue ...
}
//else handle the error
}
//else handle the error
}
}
else
MessageBox.Show("The GetParagraphCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the number of text lines within the segmentation result specified by its index.
The resulting value doesn't contain any empty lines, as they are not provided in the segmentation result.
The unique result identifier of the executed segmentation process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note that the resulting value doesn't contain any empty lines, if they have been recognized.
The number of detected lines in text. Please always use the method to determine if this method has been successful.
How to find out the number of detected text lines within the segmentation result.
Dim caption As String = "Example: GetTextLineCount"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim textlineCount As Integer = gdpictureSegmenter.GetTextLineCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The number of detected text lines: " + textlineCount.ToString(), caption)
'Continue ...
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetTextLineCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int textlineCount = gdpictureSegmenter.GetTextLineCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The number of detected text lines: " + textlineCount.ToString(), caption);
//Continue ...
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the top y-coordinate of the bounding box of the specified line, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the text line within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the text line's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected text lines within the segmentation result. All text lines are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetTextLineTop"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim textlineCount As Integer = gdpictureSegmenter.GetTextLineCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected text lines: "
message = message + textlineCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To textlineCount - 1
top = gdpictureSegmenter.GetTextLineTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetTextLineLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetTextLineBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetTextLineRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".text line has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If textlineCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = textlineCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetTextLineTop";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int textlineCount = gdpictureSegmenter.GetTextLineCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected text lines: ";
message = message + textlineCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < textlineCount; i++)
{
top = gdpictureSegmenter.GetTextLineTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetTextLineLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetTextLineBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetTextLineRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (textlineCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == textlineCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the left x-coordinate of the bounding box of the specified text line, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the text line within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the text line's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected text lines within the segmentation result. All text lines are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetTextLineLeft"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim textlineCount As Integer = gdpictureSegmenter.GetTextLineCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected text lines: "
message = message + textlineCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To textlineCount - 1
top = gdpictureSegmenter.GetTextLineTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetTextLineLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetTextLineBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetTextLineRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".text line has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If textlineCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = textlineCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetTextLineLeft";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int textlineCount = gdpictureSegmenter.GetTextLineCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected text lines: ";
message = message + textlineCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < textlineCount; i++)
{
top = gdpictureSegmenter.GetTextLineTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetTextLineLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetTextLineBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetTextLineRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (textlineCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == textlineCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the bottom y-coordinate of the bounding box of the specified text line, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the text line within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the text line's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected text lines within the segmentation result. All text lines are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetTextLineBottom"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim textlineCount As Integer = gdpictureSegmenter.GetTextLineCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected text lines: "
message = message + textlineCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To textlineCount - 1
top = gdpictureSegmenter.GetTextLineTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetTextLineLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetTextLineBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetTextLineRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".text line has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If textlineCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = textlineCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetTextLineBottom";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int textlineCount = gdpictureSegmenter.GetTextLineCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected text lines: ";
message = message + textlineCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < textlineCount; i++)
{
top = gdpictureSegmenter.GetTextLineTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetTextLineLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetTextLineBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetTextLineRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (textlineCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == textlineCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the right x-coordinate of the bounding box of the specified text line, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the text line within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the text line's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected text lines within the segmentation result. All text lines are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetTextLineRight"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim textlineCount As Integer = gdpictureSegmenter.GetTextLineCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected text lines: "
message = message + textlineCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To textlineCount - 1
top = gdpictureSegmenter.GetTextLineTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetTextLineLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetTextLineBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetTextLineRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".text line has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If textlineCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = textlineCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetTextLineRight";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int textlineCount = gdpictureSegmenter.GetTextLineCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected text lines: ";
message = message + textlineCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < textlineCount; i++)
{
top = gdpictureSegmenter.GetTextLineTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetTextLineLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetTextLineBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetTextLineRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".paragraph has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (textlineCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == textlineCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the number of words within the specified text line, that is a part of the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the text line within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of words within a text line. Please always use the method to determine if this method has been successful.
How to find out the number of detected words within the text line.
Dim caption As String = "Example: GetTextLineWordCount"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim textlineCount As Integer = gdpictureSegmenter.GetTextLineCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim wordCount As Integer = 0, index As Integer = 0
For i As Integer = 0 To textlineCount - 1
wordCount = gdpictureSegmenter.GetTextLineWordCount(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
index = gdpictureSegmenter.GetTextLineFirstWordIndex(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Continue ...
Else
'handle the error
End If
Else
'handle the error
End If
Next
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetTextLineWordCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int textlineCount = gdpictureSegmenter.GetTextLineCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
int wordCount = 0, index = 0;
for (int i = 0; i < textlineCount; i++)
{
wordCount = gdpictureSegmenter.GetTextLineWordCount(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
index = gdpictureSegmenter.GetTextLineFirstWordIndex(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Continue ...
}
//else handle the error
}
//else handle the error
}
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the index of the first word in the specified text line, that is a part of the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the text line within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the first word in the specified text line. Please always use the method to determine if this method has been successful.
How to find out the number of detected words within the text line and the index of the first word.
Dim caption As String = "Example: GetTextLineFirstWordIndex"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim textlineCount As Integer = gdpictureSegmenter.GetTextLineCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim wordCount As Integer = 0, index As Integer = 0
For i As Integer = 0 To textlineCount - 1
wordCount = gdpictureSegmenter.GetTextLineWordCount(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
index = gdpictureSegmenter.GetTextLineFirstWordIndex(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Continue ...
Else
'handle the error
End If
Else
'handle the error
End If
Next
Else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetTextLineFirstWordIndex";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int textlineCount = gdpictureSegmenter.GetTextLineCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
int wordCount = 0, index = 0;
for (int i = 0; i < textlineCount; i++)
{
wordCount = gdpictureSegmenter.GetTextLineWordCount(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
index = gdpictureSegmenter.GetTextLineFirstWordIndex(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Continue ...
}
//else handle the error
}
//else handle the error
}
}
else
MessageBox.Show("The GetTextLineCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the number of words within the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of detected words. Please always use the method to determine if this method has been successful.
How to find out the number of detected words within the segmentation result.
Dim caption As String = "Example: GetWordCount"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim wordCount As Integer = gdpictureSegmenter.GetWordCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The number of detected words: " + wordCount.ToString(), caption)
'Continue ...
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetWordCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int wordCount = gdpictureSegmenter.GetWordCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The number of detected words: " + wordCount.ToString(), caption);
//Continue ...
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the top y-coordinate of the bounding box of the specified word, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the word within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the word's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected words within the segmentation result. All words are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetWordTop"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim wordCount As Integer = gdpictureSegmenter.GetWordCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected words: "
message = message + wordCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To wordCount - 1
top = gdpictureSegmenter.GetWordTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetWordLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetWordBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetWordRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If wordCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = wordCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetWordTop";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int wordCount = gdpictureSegmenter.GetWordCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected words: ";
message = message + wordCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < wordCount; i++)
{
top = gdpictureSegmenter.GetWordTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetWordLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetWordBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetWordRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (wordCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == wordCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the left x-coordinate of the bounding box of the specified word, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the word within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the word's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected words within the segmentation result. All words are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetWordLeft"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim wordCount As Integer = gdpictureSegmenter.GetWordCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected words: "
message = message + wordCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To wordCount - 1
top = gdpictureSegmenter.GetWordTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetWordLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetWordBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetWordRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If wordCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = wordCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetWordLeft";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int wordCount = gdpictureSegmenter.GetWordCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected words: ";
message = message + wordCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < wordCount; i++)
{
top = gdpictureSegmenter.GetWordTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetWordLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetWordBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetWordRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (wordCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == wordCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the bottom y-coordinate of the bounding box of the specified word, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the word within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the word's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected words within the segmentation result. All words are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetWordBottom"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim wordCount As Integer = gdpictureSegmenter.GetWordCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected words: "
message = message + wordCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To wordCount - 1
top = gdpictureSegmenter.GetWordTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetWordLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetWordBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetWordRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If wordCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = wordCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetWordBottom";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int wordCount = gdpictureSegmenter.GetWordCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected words: ";
message = message + wordCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < wordCount; i++)
{
top = gdpictureSegmenter.GetWordTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetWordLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetWordBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetWordRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (wordCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == wordCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the right x-coordinate of the bounding box of the specified word, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the word within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the word's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected words within the segmentation result. All words are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetWordRight"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim wordCount As Integer = gdpictureSegmenter.GetWordCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected words: "
message = message + wordCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To wordCount - 1
top = gdpictureSegmenter.GetWordTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetWordLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetWordBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetWordRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If wordCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = wordCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetWordRight";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int wordCount = gdpictureSegmenter.GetWordCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected words: ";
message = message + wordCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < wordCount; i++)
{
top = gdpictureSegmenter.GetWordTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetWordLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetWordBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetWordRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (wordCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == wordCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the number of characters within the specified word, that is a part of the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the word within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of characters. Please always use the method to determine if this method has been successful.
How to find out the number of detected characters within the word.
Dim caption As String = "Example: GetWordCharacterCount"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim wordCount As Integer = gdpictureSegmenter.GetWordCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim characterCount As Integer = 0, index As Integer = 0
For i As Integer = 0 To wordCount - 1
characterCount = gdpictureSegmenter.GetWordCharacterCount(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
index = gdpictureSegmenter.GetWordFirstCharacterIndex(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Continue ...
Else
'handle the error
End If
Else
'handle the error
End If
Next
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetWordCharacterCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int wordCount = gdpictureSegmenter.GetWordCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
int characterCount = 0, index = 0;
for (int i = 0; i < wordCount; i++)
{
characterCount = gdpictureSegmenter.GetWordCharacterCount(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
index = gdpictureSegmenter.GetWordFirstCharacterIndex(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Continue ...
}
//else handle the error
}
//else handle the error
}
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the index of the first character in the specified word, that is a part of the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the word within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The index of the first character of the specified word. Please always use the method to determine if this method has been successful.
How to find out the number of detected characters within the word and the index of the first character.
Dim caption As String = "Example: GetWordFirstCharacterIndex"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim wordCount As Integer = gdpictureSegmenter.GetWordCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim characterCount As Integer = 0, index As Integer = 0
For i As Integer = 0 To wordCount - 1
characterCount = gdpictureSegmenter.GetWordCharacterCount(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
index = gdpictureSegmenter.GetWordFirstCharacterIndex(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Continue ...
Else
'handle the error
End If
Else
'handle the error
End If
Next
Else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetWordFirstCharacterIndex";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int wordCount = gdpictureSegmenter.GetWordCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
int characterCount = 0, index = 0;
for (int i = 0; i < wordCount; i++)
{
characterCount = gdpictureSegmenter.GetWordCharacterCount(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
index = gdpictureSegmenter.GetWordFirstCharacterIndex(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Continue ...
}
//else handle the error
}
//else handle the error
}
}
else
MessageBox.Show("The GetWordCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the number of characters within the segmentation result specified by its index.
The unique result identifier of the executed segmentation process obtained by the method.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
The number of detected characters. Please always use the method to determine if this method has been successful.
How to find out the number of detected characters within the segmentation result.
Dim caption As String = "Example: GetCharacterCount"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up the image you want to process.
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'The standard open file dialog displays to allow you to select the file.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim characterCount As Integer = gdpictureSegmenter.GetCharacterCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The number of detected characters: " + characterCount.ToString(), caption)
'Continue ...
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetCharacterCount";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int characterCount = gdpictureSegmenter.GetCharacterCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
MessageBox.Show("The number of detected characters: " + characterCount.ToString(), caption);
//Continue ...
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the top y-coordinate of the bounding box of the specified character, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the character within the specified segmentation result. It must be a value between 0 and (SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The top y-coordinate of the character's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected characters within the segmentation result. All characters are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetCharacterTop"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim characterCount As Integer = gdpictureSegmenter.GetCharacterCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected characters: "
message = message + characterCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To characterCount - 1
top = gdpictureSegmenter.GetCharacterTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetCharacterLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetCharacterBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetCharacterRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If characterCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = characterCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetCharacterTop";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int characterCount = gdpictureSegmenter.GetCharacterCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected characters: ";
message = message + characterCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < characterCount; i++)
{
top = gdpictureSegmenter.GetCharacterTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetCharacterLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetCharacterBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetCharacterRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (characterCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == characterCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the left x-coordinate of the bounding box of the specified character, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the character within the specified segmentation result. It must be a value between 0 and GetCharacterCount(SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The left x-coordinate of the character's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected characters within the segmentation result. All characters are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetCharacterLeft"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim characterCount As Integer = gdpictureSegmenter.GetCharacterCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected characters: "
message = message + characterCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To characterCount - 1
top = gdpictureSegmenter.GetCharacterTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetCharacterLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetCharacterBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetCharacterRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If characterCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = characterCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetCharacterLeft";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int characterCount = gdpictureSegmenter.GetCharacterCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected characters: ";
message = message + characterCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < characterCount; i++)
{
top = gdpictureSegmenter.GetCharacterTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetCharacterLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetCharacterBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetCharacterRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (characterCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == characterCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the bottom y-coordinate of the bounding box of the specified character, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the character within the specified segmentation result. It must be a value between 0 and GetCharacterCount(SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The bottom y-coordinate of the character's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected characters within the segmentation result. All characters are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetCharacterBottom"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim characterCount As Integer = gdpictureSegmenter.GetCharacterCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected characters: "
message = message + characterCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To characterCount - 1
top = gdpictureSegmenter.GetCharacterTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetCharacterLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetCharacterBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetCharacterRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If characterCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = characterCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetCharacterBottom";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int characterCount = gdpictureSegmenter.GetCharacterCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected characters: ";
message = message + characterCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < characterCount; i++)
{
top = gdpictureSegmenter.GetCharacterTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetCharacterLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetCharacterBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetCharacterRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (characterCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == characterCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the right x-coordinate of the bounding box of the specified character, that is a part of the segmentation result specified by its index.
This method uses a coordinate system, where the origin is in the top-left corner of the processed image and the units are pixels.
The unique result identifier of the executed segmentation process obtained by the method.
The 0-based index of the character within the specified segmentation result. It must be a value between 0 and GetCharacterCount(SegmentationResultID)-1.
It is recommend to use the method to identify the specific reason for the method's failure, if any.
Please note, that the origin of the used coordinate system is in the top-left corner of the processed image and the used units are pixels.
The right x-coordinate of the character's bounding box, in pixels.
Please always use the method to determine if this method has been successful.
How to find out detected characters within the segmentation result. All characters are subsequently color-coded and saved into the output file.
Dim caption As String = "Example: GetCharacterRight"
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
'Set up the image you want to process.
Dim image As Integer = gdpictureImaging.CreateGdPictureImageFromFile("input.tif")
If (gdpictureImaging.GetStat() = GdPictureStatus.OK) AndAlso
(gdpictureSegmenter.SetImage(image) = GdPictureStatus.OK) Then
'Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4
'Run the segmentation process.
Dim resultID As String = gdpictureSegmenter.RunSegmentation()
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
'Check the results.
Dim characterCount As Integer = gdpictureSegmenter.GetCharacterCount(resultID)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
Dim message As String = "The number of detected characters: "
message = message + characterCount.ToString() + vbCrLf
Dim top As Integer = 0, left As Integer = 0, bottom As Integer = 0, right As Integer = 0, save As Integer = 0
For i As Integer = 0 To characterCount - 1
top = gdpictureSegmenter.GetCharacterTop(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then left = gdpictureSegmenter.GetCharacterLeft(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then bottom = gdpictureSegmenter.GetCharacterBottom(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then right = gdpictureSegmenter.GetCharacterRight(resultID, i)
If gdpictureSegmenter.GetStat() = GdPictureStatus.OK Then
If gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, True) = GdPictureStatus.OK Then
message = message + (i + 1).ToString() + ".rectangle has been drawn." + vbCrLf
save += 1
Else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + vbCrLf
End If
Next
If characterCount = 0 Then
message = message + "The resulting image HAS NOT been created."
Else
If save = characterCount Then
If gdpictureImaging.SaveAsTIFF(image, "output.tif", TiffCompression.TiffCompressionAUTO) = GdPictureStatus.OK Then
message = message + "The resulting image HAS been saved successfully."
Else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString()
End If
End If
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
'Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image)
Else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption)
End If
End Using
'Release resources.
gdpictureSegmenter.ReleaseSegmentationResults()
End Using
string caption = "Example: GetCharacterRight";
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up the image you want to process.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
//The standard open file dialog displays to allow you to select the file.
int image = gdpictureImaging.CreateGdPictureImageFromFile("input.tif");
if ((gdpictureImaging.GetStat() == GdPictureStatus.OK) &&
(gdpictureSegmenter.SetImage(image) == GdPictureStatus.OK))
{
//Set the segmentation mode.
gdpictureSegmenter.SegmentationMode = SegmentationMode.ConnectedComponents4;
//Run the segmentation process.
string resultID = gdpictureSegmenter.RunSegmentation();
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
//Check the results.
int characterCount = gdpictureSegmenter.GetCharacterCount(resultID);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
string message = "The number of detected characters: ";
message = message + characterCount.ToString() + "\n";
int top = 0, left = 0, bottom = 0, right = 0, save = 0;
for (int i = 0; i < characterCount; i++)
{
top = gdpictureSegmenter.GetCharacterTop(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
left = gdpictureSegmenter.GetCharacterLeft(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
bottom = gdpictureSegmenter.GetCharacterBottom(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
right = gdpictureSegmenter.GetCharacterRight(resultID, i);
if (gdpictureSegmenter.GetStat() == GdPictureStatus.OK)
{
if (gdpictureImaging.DrawRectangle(image, left, top, right - left, bottom - top, 5, Color.Brown, true) == GdPictureStatus.OK)
{
message = message + (i + 1).ToString() + ".rectangle has been drawn.\n";
save++;
}
else
message = message + (i + 1).ToString() + ".rectangle HAS NOT been drawn. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
else
message = message + i.ToString() + ".word has failed to get its position. Status: " + gdpictureSegmenter.GetStat().ToString() + "\n";
}
if (characterCount == 0)
{
message = message + "The resulting image HAS NOT been created.";
}
else
{
if (save == characterCount)
{
if (gdpictureImaging.SaveAsTIFF(image, "output.tiff", TiffCompression.TiffCompressionAUTO) == GdPictureStatus.OK)
message = message + "The resulting image HAS been saved successfully.";
else
message = message + "The resulting image HAS NOT been saved. Status: " + gdpictureImaging.GetStat().ToString();
}
}
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetCharacterCount() method has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
}
else
MessageBox.Show("The segmentation process has failed with the status: " + gdpictureSegmenter.GetStat().ToString(), caption);
//Release the used image.
gdpictureImaging.ReleaseGdPictureImage(image);
}
else
MessageBox.Show("The error occurred when setting up the image: " + gdpictureImaging.GetStat().ToString() + " or " + gdpictureSegmenter.GetStat().ToString(), caption);
}
//Release resources.
gdpictureSegmenter.ReleaseSegmentationResults();
}
Returns the status of the last executed operation with the current GdPictureSegmenter object.
Use this method in the combination with all those, which return a value instead of a status.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
How to check the if the called method has been followed without errors.
Using gdpictureSegmenter As GdPictureSegmenter = New GdPictureSegmenter()
'Set up your prefered parameters for the segmentation.
'Run the segmentation process.
Dim result As String = gdpictureSegmenter.RunSegmentation()
'Check the status.
Dim status As GdPictureStatus = gdpictureSegmenter.GetStat()
If status = GdPictureStatus.OK Then
'The method has been followed without errors.
'Continue ...
Else
'Some error occurred.
MessageBox.Show("The segmentation process has failed with the status: " + status.ToString(), "Example: GetStat")
End If
End Using
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//Set up your prefered parameters for the segmentation.
//Run the segmentation process.
string result = gdpictureSegmenter.RunSegmentation();
//Check the status.
GdPictureStatus status = gdpictureSegmenter.GetStat();
if (status == GdPictureStatus.OK)
{
//The method has been followed without errors.
//Continue ...
}
else
{
//Some error occurred.
MessageBox.Show("The segmentation process has failed with the status: " + status.ToString(), "Example: GetStat");
}
}
Disposes of the GdPictureSegmenter object completely. All related resources used by this object are released.
All used segmentation results within the current GdPictureSegmenter object are released too.
Please note, that by disposing of the current GdPictureSegmenter object you also release all linked segmentation results.
GdPictureSegmenter Constructor
How to create and dispose of a GdPictureSegmenter object.
'The elementary use of the Dispose() method.
Dim gdpictureSegmenter As New GdPictureSegmenter()
'You can do your stuff with gdpictureSegmenter here.
gdpictureSegmenter.Dispose()
'The very good practice is to use the keyword "using".
Using gdpictureSegmenter As New GdPictureSegmenter()
'You can do your stuff with gdpictureSegmenter here.
'You do not need to call the Dispose() method, it is called automatically inside the "using" statement.
End Using
//The elementary use of the Dispose() method.
GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter();
//You can do your stuff with gdpictureSegmenter here.
gdpictureSegmenter.Dispose();
//The very good practice is to use the keyword "using".
using (GdPictureSegmenter gdpictureSegmenter = new GdPictureSegmenter())
{
//You can do your stuff with gdpictureSegmenter here.
//You do not need to call the Dispose() method, it is called automatically inside the "using" statement.
}
Implementation of the IDispose interface specific code.
Implementation of the IDispose interface specific code.
Accessor to the segmentation engine.
The engine is initialized if necessary.
The last error.
The flag indicating whether the object is disposed or not.
The segmentation engine.
The storage for the segmentation result.
Reset the last error.
Setup the segmentation session.
GdPictureTextExtraction is a streamlined class designed to effortlessly convert any GdPicture technology-supported document into plain text.
It provides a range of capabilities that allow for addressing various scenarios, including indexing and enhancing the performance of LLM inferences.
It employs internal logic to optimize extraction accuracy and minimize processing time through the dynamic utilization of page layout analysis, encoding detection, and OCR components.
The identical API serves for processing raster images, PDFs, CAD files, Email files, and office formats alike.
Documents can be loaded from file paths, Stream objects, or distant URIs.
Specifies the timeout for any subsequent process, in milliseconds.
The default value is -1, which means there is no timeout.
Use this property before the loading step to specify a range of pages that will be subsequently processed.
This allows for speeding up the loading process.
Default value is '*', which means all pages.
Specifies whether OCR is enabled.
Default value is true.
Specifies whether document orientation detection is activated.
Default value is true.
Specifies whether key value pairs extraction is enabled.
Default value is false.
Specifies whether tables extraction is enabled.
Default value is false.
Specifies the path to the directory containing the engine resources (mostly dictionaries).
The proper path is usually within your standard installation and it looks like @\GdPicture.Net 14\redist\OCR.
Of course you can specify your own path as well.
The default value is an empty string.
Specifies the dictionary to be used during the optional OCR process.
The default value is 'latin'.
Specifies that the text extraction engine must preserve text paragraphs.
This functionality is particularly useful to improve the accuracy of NLP engines.
The default value is false.
This property specifies the separator to be utilized for splitting paragraphs.
It takes effect solely when the PreserveParagraphs property is set to true.
The default value is "\r\n".
Loads a document from a file path.
The file path.
An optional parameter specifying the format of the document to be loaded. DocumentFormat.DocumentFormatUNKNOWN.
Specifies the document password, if any.
A member of the GdPictureStatus enumeration.
Loads a document from a stream object.
An optional parameter specifying the format of the document to be loaded. Default value is DocumentFormat.DocumentFormatUNKNOWN.
An optional boolean specifying if the stream object is owned by the GdPictureTextExtraction class. Default value is false.
Specifies the document password, if any.
A member of the GdPictureStatus enumeration.
Loads a document from a distant URI.
An optional parameter specifying the format of the document to be loaded. DocumentFormat.DocumentFormatUNKNOWN.
Specifies the document password, if any.
A member of the GdPictureStatus enumeration.
This method returns the number of pages in the currently loaded document.
If there is no currently loaded document it returns 0.
The number of pages in the currently loaded document.
Returns the format the currently loaded document.
A member of the DocumentFormat enumeration.
Returns the number of extracted key-value pairs within the extraction process.
Key-value pairs extraction is automatically performed during each extraction process.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The number of detected key-value pairs.
Returns the string representation of the key part of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the key-value pair.
It must be a value between 0 and ().
The string representation of the key.
Returns the string representation of the value part of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the key-value pair.
It must be a value between 0 and ().
The string representation of the value.
Returns the location of the key part of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the key-value pair.
It must be a value between 0 and ().
Returns the left x-coordinate of the key's bounding box, in pixels.
Returns the top y-coordinate of the key's bounding box, in pixels.
Returns the width of the key's bounding box, in pixels.
Returns the width of the key's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the location of the value part of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the key-value pair.
It must be a value between 0 and ().
Returns the left x-coordinate of the value's bounding box, in pixels.
Returns the top y-coordinate of the value's bounding box, in pixels.
Returns the width of the value's bounding box, in pixels.
Returns the width of the value's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the data type of a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the key-value pair.
It must be a value between 0 and ().
A member of the DataType enumeration specifying the identified data type of the pair.
Returns the detection confidence a specified key-value pair.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the key-value pair.
It must be a value between 0 and ().
The detection confidence, in the range [0 - 100].
Returns whether a specific key-value pair is strong.
A pair is marked as strong when a semantic relationship have been established during the detection process.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the key-value pair.
It must be a value between 0 and ().
Returns the number of extracted form fields within the extraction process.
Form fields extraction is automatically performed during each extraction process.
The number of extracted form fields
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the location of the key part of a specified form field.
The 0-based index of the form field pair within the last extraction process.
It must be a value between 0 and () - 1.
Returns the left x-coordinate of the field key's bounding box, in pixels.
Returns the top y-coordinate of the field key's bounding box, in pixels.
Returns the width of the field key's bounding box, in pixels.
Returns the width of the field key's bounding box, in pixels.
A member of the GdPictureStatus enumeration.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the text of a specified form field.
The 0-based index of the form field pair within the last extraction process.
It must be a value between 0 and () - 1.
The key text.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the location of the value part of a specified form field.
The 0-based index of the form field pair within the last extraction process.
It must be a value between 0 and () - 1.
Returns the left x-coordinate of the field value's bounding box, in pixels.
Returns the top y-coordinate of the field value's bounding box, in pixels.
Returns the width of the field value's bounding box, in pixels.
Returns the width of the field value's bounding box, in pixels.
A member of the GdPictureStatus enumeration.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the text of the key of a specified form field.
The 0-based index of the form field pair within the last extraction process.
It must be a value between 0 and () - 1.
The field text.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the type of a specified form field.
The 0-based index of the form field pair within the last extraction process.
It must be a value between 0 and () - 1.
A member of the FormFieldType enumeration.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
Returns the number of detected tables within the extraction process.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The number of detected tables.
Returns the location of a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the detected table within the last extraction process.
It must be a value between 0 and () - 1.
Returns the left x-coordinate of the table's bounding box, in pixels.
Returns the top y-coordinate of the table's bounding box, in pixels.
Returns the width of the table's bounding box, in pixels.
Returns the width of the table's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the location of a cell in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the detected table within the last extraction process.
It must be a value between 0 and () - 1.
The 0-based index of the cell's column in a detected table within the last extraction process.
It must be a value between 0 and () - 1.
The 0-based index of the cell's row in a detected table within the last extraction process.
It must be a value between 0 and () - 1.
Returns the left x-coordinate of the cell's bounding box, in pixels.
Returns the top y-coordinate of the cell's bounding box, in pixels.
Returns the width of the cell's bounding box, in pixels.
Returns the width of the cell's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the text content of a cell in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the detected table within the last extraction process.
It must be a value between 0 and () - 1.
The 0-based index of the cell's column in a detected table within the last extraction process.
It must be a value between 0 and () - 1.
The 0-based index of the cell's row in a detected table within the last extraction process.
It must be a value between 0 and () - 1.
The text content of the cell.
Returns the number of columns in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the detected table within the last extraction process.
It must be a value between 0 and () - 1.
The number of columns.
Returns the location of a column in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the detected table within the last extraction process.
It must be a value between 0 and () - 1.
The 0-based index of the cell's column in a detected table within the last extraction process.
It must be a value between 0 and () - 1.
Returns the left x-coordinate of the column's bounding box, in pixels.
Returns the top y-coordinate of the column's bounding box, in pixels.
Returns the width of the column's bounding box, in pixels.
Returns the width of the column's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Returns the number of rows in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the detected table within the last extraction process.
It must be a value between 0 and () - 1.
The number of rows.
Returns the location of a row in a specified table.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the detected table within the last extraction process.
It must be a value between 0 and () - 1.
The 0-based index of the row's column in a detected table within the last extraction process.
It must be a value between 0 and () - 1.
Returns the left x-coordinate of the row's bounding box, in pixels.
Returns the top y-coordinate of the row's bounding box, in pixels.
Returns the width of the row's bounding box, in pixels.
Returns the width of the row's bounding box, in pixels.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Specify whether if the cell's coordinate is located in the table's header.
This method requires the KVP and Table Processing - Intelligent Redaction component to run.
The 0-based index of the detected table within the last extraction process.
It must be a value between 0 and () - 1.
The 0-based index of the cell's column in a detected table within the last extraction process.
It must be a value between 0 and () - 1.
The 0-based index of the cell's row in a detected table within the last extraction process.
It must be a value between 0 and () - 1.
True if the specified cell is part of the header, false otherwise.
Please always use the method to determine if this method has been successful.
Retrieves the text from a particular page of the currently loaded document.
The page number, in the range [1 - GetPageCount()].
The page text.
Closes the currently loaded.
A member of the GdPictureStatus enumeration.
Returns the status of the last executed operation with the current GdPictureTextExtraction object.
Use this method in the combination with all those, which return a value instead of a status.
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
The LicenseManager class unlocks the GdPicture.NET toolkit with a purchased commercial key or a provided demo key to allow you to develop your application.
You can also determine the currently used version of the toolkit using this class.
Please follow the detailed instructions on the activation process here.
How to unlock your GdPicture.NET toolkit.
Dim oLicenseManager As New GdPicture14.LicenseManager()
'Unlocking the core license.
Dim registration As Boolean = oLicenseManager.RegisterKEY("LICENSE_KEY")
If (registration) Then
MessageBox.Show("The toolkit has been successfully unlocked.", "LicenseManager")
Else
MessageBox.Show("The toolkit has NOT been unlocked.", "LicenseManager")
End If
GdPicture14.LicenseManager oLicenseManager = new GdPicture14.LicenseManager();
//Unlocking the core license.
bool registration = oLicenseManager.RegisterKEY("LICENSE_KEY");
if (registration)
MessageBox.Show("The toolkit has been successfully unlocked.", "LicenseManager");
else
MessageBox.Show("The toolkit has NOT been unlocked.", "LicenseManager");
Unlocks the toolkit with a commercial or a demo license key. You can subsequently use this method to unlock GdPicture.NET.
Please follow the detailed instructions on the activation process here.
The license key or a demo key.
true if the toolkit has been unlocked successfully with the specified key, otherwise false (invalid license key).
How to unlock GdPicture.NET.
Dim oLicenseManager As New GdPicture14.LicenseManager()
'Unlocking the core license.
Dim registration As Boolean = oLicenseManager.RegisterKEY("MY_GDPICTURENET_KEY")
If (registration) Then
MessageBox.Show("The toolkit has been successfully unlocked.", "LicenseManager.RegisterKEY")
Else
MessageBox.Show("The toolkit has NOT been unlocked.", "LicenseManager.RegisterKEY")
End If
GdPicture14.LicenseManager oLicenseManager = new GdPicture14.LicenseManager();
//Unlocking the core license.
bool registration = oLicenseManager.RegisterKEY("MY_GDPICTURENET_KEY");
if (registration)
MessageBox.Show("The toolkit has been successfully unlocked.", "LicenseManager.RegisterKEY");
else
MessageBox.Show("The toolkit has NOT been unlocked.");
Tracks and records the usage of GdPicture features by a demo application during evaluation of GdPicture (using DEMO_PSPDFKIT_WEB license key), storing this data into a log file.
This can assist users in determining the necessary license features for purchase, tailored to their specific development needs.
The path of the file where all features used within the demo application will be logged to.
var key = "DEMO_PSPDFKIT_WEB";
var lic = new LicenseManager();
lic.RegisterKEY(key);
string assembliesRootFolder = Path.GetDirectoryName(Environment.ProcessPath);
// Handling Visual studio vsdbg adapter
if (Environment.ProcessPath.EndsWith("dotnet") && Environment.GetCommandLineArgs().Length > 0)
{
assembliesRootFolder = Path.GetDirectoryName(Environment.GetCommandLineArgs().First());
}
lic.TraceFeatures(Path.Combine(assembliesRootFolder, "license.log"));
A utility class for creating default instances of .
Creates a new instance of the .
A default instance.
A base class for building templates for GdPicture Office Templating.
The type of the derived builder class.
Adds a placeholder and its replacement value to the template.
The placeholder in the template.
The value to replace the placeholder with.
The template builder instance.
Adds an array of integers to the template.
The name of the section containing the array.
The array of integer values to add.
The template builder instance.
Adds an array of strings to the template.
The name of the section containing the array.
The array of string values to add.
The template builder instance.
Adds a section containing objects to the template.
The type of the object builder for the section.
The name of the section.
An array of actions to build objects within the section.
The template builder instance.
Adds objects to an existing section in the template.
The type of the object builder for the section.
The name of the section to add objects to.
An array of actions to build objects within the section.
The template builder instance.
Adds an image placeholder replacement using a file path.
The image tag in the template should use the format {%placeholder}.
The placeholder name (without the % prefix).
The path to the image file.
The template builder instance.
// Template contains: {%logo}
template.AddImageFromFile("logo", "C:\\images\\logo.png");
Adds an image placeholder replacement using a file path with specific dimensions.
The image tag in the template should use the format {%placeholder}.
The placeholder name (without the % prefix).
The path to the image file.
The desired width in pixels.
The desired height in pixels.
The template builder instance.
// Template contains: {%photo}
template.AddImageFromFile("photo", "C:\\images\\photo.jpg", 200, 150);
Adds an image placeholder replacement using Base64 encoded data.
The image tag in the template should use the format {%placeholder}.
The placeholder name (without the % prefix).
The Base64 encoded image data.
The image format (e.g., "png", "jpeg", "gif").
The template builder instance.
// Template contains: {%signature}
string base64 = Convert.ToBase64String(File.ReadAllBytes("signature.png"));
template.AddImageFromBase64("signature", base64, "png");
Adds an image placeholder replacement using a byte array.
The image tag in the template should use the format {%placeholder}.
The placeholder name (without the % prefix).
The image data as a byte array.
The image format (e.g., "png", "jpeg", "gif").
The template builder instance.
// Template contains: {%barcode}
byte[] barcodeData = GenerateBarcode("12345");
template.AddImageFromBytes("barcode", barcodeData, "png");
Adds an image placeholder replacement with full configuration options.
The image tag in the template should use the format {%placeholder}.
The placeholder name (without the % prefix).
The image configuration including source, sizing, and metadata.
The template builder instance.
// Template contains: {%product_image}
var imageConfig = new GdPictureOfficeTemplateImage
{
FilePath = "C:\\images\\product.jpg",
Sizing = GdPictureOfficeTemplateImageSizing.FitMax,
WidthInPixels = 400,
HeightInPixels = 300,
AltText = "Product Image"
};
template.AddImage("product_image", imageConfig);
Returns the JSON representation of the template.
A JSON string representing the template.
Represents the configuration settings for a template.
Gets or sets the delimiter settings used for template replacement.
Represents the start and end delimiters used for template replacement in a .
Gets or sets the start delimiter used to mark the beginning of a template placeholder.
Gets or sets the end delimiter used to mark the end of a template placeholder.
Gets or sets the object delimiter used to separate nested object properties (e.g., "." in "myObject.property").
Defaults to "." if not specified.
Represents the configuration for an image to be inserted into a template.
Use this class with for full control over image properties.
Gets or sets the file path to the image.
Used when the image source is a file on disk.
Gets or sets the Base64 encoded image data.
Used when the image source is Base64 encoded data.
Gets or sets the image data as a byte array.
Used when the image source is raw binary data.
Gets or sets the image format (e.g., "png", "jpeg", "gif", "bmp", "tiff").
Required when using or .
Auto-detected when using .
Gets or sets the sizing mode for the image.
Defaults to .
Gets or sets the width in pixels.
Used with ,
, or
sizing modes.
Gets or sets the height in pixels.
Used with ,
, or
sizing modes.
Gets or sets the alternative text for the image.
This text is used for accessibility purposes.
Gets or sets the title/description for the image.
Gets or sets the page number for multipage images (e.g., TIFF, GIF).
This is a 1-based index. If not specified or null, the first page is used.
Gets or sets the border color as a 6-character RGB hex string (e.g., "FF0000" for red).
If not specified, no border is drawn.
Gets or sets the border width in pixels.
If not specified or null, no border is drawn.
Gets or sets the border style.
Defaults to when a border is drawn.
Gets or sets the hyperlink URL for the image.
When specified, clicking the image will open this URL.
Must be an absolute URL (e.g., "https://example.com").
Gets or sets the caption text to display below the image.
The caption can contain template placeholders (e.g., "{{company_name}} Logo").
Gets or sets the caption label for auto-numbering (e.g., "Figure", "Table", "Chart").
When specified, generates a Word SEQ field for automatic numbering (e.g., "Figure 1: Caption text").
Gets or sets the caption position relative to the image.
Defaults to .
Gets or sets the rotation angle in degrees (0-360).
Positive values rotate clockwise.
Creates an image configuration from a file path.
The path to the image file.
A new instance.
Creates an image configuration from a file path with specific dimensions.
The path to the image file.
The desired width in pixels.
The desired height in pixels.
A new instance.
Creates an image configuration from Base64 encoded data.
The Base64 encoded image data.
The image format (e.g., "png", "jpeg").
A new instance.
Creates an image configuration from a byte array.
The image data as a byte array.
The image format (e.g., "png", "jpeg").
A new instance.
Converts this image configuration to a JSON object for serialization.
A representing this image configuration.
Specifies the style of an image border when inserted into a template.
A continuous solid line.
A dashed line.
A dotted line.
An alternating dash-dot pattern.
A line with long dashes.
A system-defined dash pattern.
Specifies where the caption should be positioned relative to the image.
Caption is placed below the image (default).
Caption is placed above the image.
Specifies how an image should be sized when inserted into a template.
Use the image's original dimensions.
Use explicitly specified width and height dimensions.
Scale to fit the specified width while preserving the aspect ratio.
Height is calculated automatically.
Scale to fit the specified height while preserving the aspect ratio.
Width is calculated automatically.
Scale to fit within the specified maximum dimensions while preserving the aspect ratio.
The image will not exceed either the specified width or height.
Specifies the quality to be used for the compression of the images from the PDF.
Default value is PDFReducerImageQuality.ImageQualityMedium.
Specifies whether the images from the PDF shall be recompressed.
Default value is true.
Specifies whether color detection must be performed on the images from the PDF.
Default value is true.
Specifies whether the PDF shall be packed when saved in order to reduce its size.
Default value is true.
Specifies whether the images from the PDF shall be downscaled.
Default value is true.
Specifies the resolution to be used to downscale images.
Default value is 150.
Specifies the resolution for downscaling the background layer by the MRC engine, if any.
Default value is 100.
Specifies whether the PDF shall be optimized for online distribution.
Default value is false.
Specifies whether the PDF fonts must be packed in order to reduce their size.
Default value is true.
Sets the version of the PDF to which the resulting PDF document will conform.
Default value is PDFReducerPDFVersion.PdfVersion15.
Specifies whether the JPEG2000 compression scheme shall be used to compress the images of the PDF.
Default value is true.
Specifies whether the JBIG2 compression scheme shall be used to compress the bitonal images of the PDF.
Default value is true.
Specifies the threshold value for the JBIG2 encoder pattern matching and substitution between 0 and 1. Any number lower than 1 may lead to lossy compression.
Default value is 0.75.
Specifies whether characters repairing shall be performed during bitonal conversion.
Default value is false.
Specifies whether MRC shall be used for compressing the PDF contents.
Default value is false.
Sets the producer name of the resulting PDF document.
Sets the title of the resulting PDF document.
Sets the producer of the resulting PDF document.
Sets the author of the resulting PDF document.
Specifies whether the blank pages shall be removed.
Default value is false.
Specifies whether the JavaScript shall be removed.
Default value is false.
Specifies if the MRC engine shall try to preserve smoothing between different layers.
Default value is true.
Specifies whether the metadata shall be removed.
Default value is false.
Specifies whether the page thumbnails shall be removed.
Default value is false.
Specifies whether the page PieceInfo dictionary used to hold private application data shall be removed.
Default value is true.
Specifies whether the form fields shall be removed from the PDF.
Default value is false.
Specifies whether the annotations shall be removed from the PDF.
Default value is false.
Specifies whether the bookmarks shall be removed from the PDF.
Default value is false.
Specifies whether the embedded files shall be removed from the PDF.
Default value is false.
Specifies whether the hyperlinks shall be removed from the PDF.
Default value is false.
Specifies whether the logical structure shall be removed from the PDF.
Default value is false.
Specifies whether the embedded font data shall be removed from the PDF.
Default value is false.
Specifies if multiple cores can be used to speed-up the process.
Threads are dynamically allocated based on the real-time available CPU resources.
Default value is true.
Multiple cores usage requires 64-bit running process.
Configuration settings for multi-zone OCR (Optical Character Recognition) processing.
These settings control the default behavior for the GdPictureMultizoneOCR engine,
including speed/accuracy tradeoffs, orientation detection, preprocessing options,
and resource management.
The OCR processing mode that balances speed and accuracy.
An value. The default is .
provides faster processing with fewer refinement passes,
while applies additional refinement algorithms for
higher recognition quality at the cost of processing time.
The maximum number of threads that can be used for OCR processing tasks.
The maximum thread count. The default is the number of logical processor cores.
The value will be constrained to be at least 1 and no greater than the number of logical
processors available on the system when applied to the OCR engine.
The accuracy level used for orientation detection.
A value between 1 and 10. The default is 10 (maximum accuracy).
Higher values increase accuracy but also increase processing time. Values outside
the range of 1 to 10 will be automatically constrained when applied to the OCR engine.
The timeout value in milliseconds for OCR operations.
The timeout in milliseconds, or 0 to disable timeout. The default is 0 (no timeout).
When set to a value greater than 0, the OCR process will be aborted if it exceeds
the specified time limit. This is useful for preventing long-running operations on
complex or problematic images.
The path to the folder containing Tesseract OCR dictionary files (.traineddata).
The full path to the resources folder. The default is an empty string, which will be
auto-detected from the system's Tesseract installation.
This folder should contain the Tesseract language data files (*.traineddata) required for
OCR processing.
Common locations for Tesseract data files:
- Windows: C:\Program Files\GdPicture.NET 14\Redist\Tesseract
- Linux: /usr/share/tesseract-ocr/tessdata/
A value indicating whether image preprocessing is enabled before performing OCR.
true to enable preprocessing; otherwise, false. The default is true.
When enabled, preprocessing steps such as noise reduction and contrast adjustment are
applied to input images to improve recognition accuracy. Disabling preprocessing may
increase performance but can reduce OCR quality, especially for low-quality images.
A value indicating whether automatic skew detection is enabled during OCR processing.
true to enable skew detection; otherwise, false. The default is false.
When enabled, the OCR engine attempts to detect and correct the skew of scanned or
photographed documents that are not perfectly aligned. This can improve recognition
accuracy for images with tilted text.
A value indicating whether automatic orientation detection is enabled during OCR processing.
true to enable orientation detection; otherwise, false. The default is false.
When enabled, the OCR engine attempts to detect and correct the orientation of pages
that have been scanned or photographed in non-standard orientations (rotated 90°, 180°, or 270°).
The accuracy of orientation detection is controlled by the
property. Enabling orientation detection increases processing time but improves results for documents
with unknown or variable orientations.
The OCR context mode that determines page segmentation behavior.
An value specifying the page segmentation mode. The default is
.
The context mode controls how the OCR engine analyzes and segments the page structure.
Common context modes:
- - Automatic page segmentation with orientation and script detection
- - Uniform text block segmentation
- - Single line of text
- - Single word recognition
- - Sparse text such as forms or tables
A value indicating whether vigorous despeckling is enabled during image preprocessing.
true to enable vigorous despeckling; otherwise, false. The default is false.
When enabled, the despeckling process applies more aggressive filtering to remove noise
and small artifacts from input images, which may improve OCR accuracy on heavily speckled
documents. This may increase processing time.
A value indicating whether GdPicture functionality is disabled.