Class PdfBarcodeException
Inheritance
System.Object
System.Exception
System.ApplicationException
PdfBarcodeException
Implements
System.Runtime.Serialization.ISerializable
System.Runtime.InteropServices._Exception
Inherited Members
System.Exception.GetBaseException()
System.Exception.ToString()
System.Exception.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)
System.Exception.GetType()
System.Exception.Message
System.Exception.Data
System.Exception.InnerException
System.Exception.TargetSite
System.Exception.StackTrace
System.Exception.HelpLink
System.Exception.Source
System.Exception.HResult
System.Exception.SerializeObjectState
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.MemberwiseClone()
Namespace: Syncfusion.Pdf.Barcode
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfBarcodeException : ApplicationException, ISerializable, _Exception
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add(); ///
/Creates a new PdfCodabarBarcode.
PdfCodabarBarcode codaBarcode = new PdfCodabarBarcode();
//barcode text.
string barcodeText = "0123x";
string validExpression = @"^[\d\-\$\:\/\.\+]+$";
Regex regex = new Regex(validExpression, RegexOptions.Compiled);
if (!regex.IsMatch(barcodeText))
{
//Create new barcode exception instance.
PdfBarcodeException barcodeException = new PdfBarcodeException("Barcode Text contains characters that are not accepted by this barcode specification.");
throw barcodeException;
}
else
{
//Sets the barcode text.
codaBarcode.Text = "0123x";
//Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("output.pdf");
}
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
'Creates a new PdfCodabarBarcode.
Dim codaBarcode As New PdfCodabarBarcode()
'barcode text.
Dim barcodeText As String = "0123x"
Dim validExpression As String = "^[\d\-\$\:\/\.\+]+$"
Dim regex As New Regex(validExpression, RegexOptions.Compiled)
If Not regex.IsMatch(barcodeText) Then
'Create new barcode exception instance.
Dim barcodeException As New PdfBarcodeException("Barcode Text contains characters that are not accepted by this barcode specification.")
Throw barcodeException
Else
'Sets the barcode text.
codaBarcode.Text = "0123x"
'Draws a barcode on the new Page.
codaBarcode.Draw(page, New PointF(25, 500))
'Save document to disk.
document.Save("output.pdf")
End If
'Close the document.
document.Close(True)
Constructors
PdfBarcodeException()
Initializes a new instance of the PdfBarcodeException class.
Declaration
public PdfBarcodeException()
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add(); ///
/Creates a new PdfCodabarBarcode.
PdfCodabarBarcode codaBarcode = new PdfCodabarBarcode();
//barcode text.
string barcodeText = "0123x";
string validExpression = @"^[\d\-\$\:\/\.\+]+$";
Regex regex = new Regex(validExpression, RegexOptions.Compiled);
if (!regex.IsMatch(barcodeText))
{
//Create new barcode exception instance.
PdfBarcodeException barcodeException = new PdfBarcodeException();
throw barcodeException;
}
else
{
//Sets the barcode text.
codaBarcode.Text = "0123x";
//Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("output.pdf");
}
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
'Creates a new PdfCodabarBarcode.
Dim codaBarcode As New PdfCodabarBarcode()
'barcode text.
Dim barcodeText As String = "0123x"
Dim validExpression As String = "^[\d\-\$\:\/\.\+]+$"
Dim regex As New Regex(validExpression, RegexOptions.Compiled)
If Not regex.IsMatch(barcodeText) Then
'Create new barcode exception instance.
Dim barcodeException As New PdfBarcodeException()
Throw barcodeException
Else
'Sets the barcode text.
codaBarcode.Text = "0123x"
'Draws a barcode on the new Page.
codaBarcode.Draw(page, New PointF(25, 500))
'Save document to disk.
document.Save("output.pdf")
End If
'Close the document.
document.Close(True)
PdfBarcodeException(SerializationInfo, StreamingContext)
Initializes a new instance of the PdfBarcodeException class.
Declaration
protected PdfBarcodeException(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | The object that holds the serialized object data. |
System.Runtime.Serialization.StreamingContext | context | The contextual information about the source or destination. |
PdfBarcodeException(String)
Initializes a new instance of the PdfBarcodeException class.
Declaration
public PdfBarcodeException(string message)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | User defined error message. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add(); ///
/Creates a new PdfCodabarBarcode.
PdfCodabarBarcode codaBarcode = new PdfCodabarBarcode();
//barcode text.
string barcodeText = "0123x";
string validExpression = @"^[\d\-\$\:\/\.\+]+$";
Regex regex = new Regex(validExpression, RegexOptions.Compiled);
if (!regex.IsMatch(barcodeText))
{
//Create new barcode exception instance.
PdfBarcodeException barcodeException = new PdfBarcodeException("Barcode Text contains characters that are not accepted by this barcode specification.");
throw barcodeException;
}
else
{
//Sets the barcode text.
codaBarcode.Text = "0123x";
//Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("output.pdf");
}
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
'Creates a new PdfCodabarBarcode.
Dim codaBarcode As New PdfCodabarBarcode()
'barcode text.
Dim barcodeText As String = "0123x"
Dim validExpression As String = "^[\d\-\$\:\/\.\+]+$"
Dim regex As New Regex(validExpression, RegexOptions.Compiled)
If Not regex.IsMatch(barcodeText) Then
'Create new barcode exception instance.
Dim barcodeException As New PdfBarcodeException("Barcode Text contains characters that are not accepted by this barcode specification.")
Throw barcodeException
Else
'Sets the barcode text.
codaBarcode.Text = "0123x"
'Draws a barcode on the new Page.
codaBarcode.Draw(page, New PointF(25, 500))
'Save document to disk.
document.Save("output.pdf")
End If
'Close the document.
document.Close(True)
PdfBarcodeException(String, Exception)
Initializes a new instance of the PdfBarcodeException class.
Declaration
public PdfBarcodeException(string message, Exception innerException)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | User defined error message. |
System.Exception | innerException | The inner exception. |
Examples
//Create a new PDF document.
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add(); ///
/Creates a new PdfCodabarBarcode.
PdfCodabarBarcode codaBarcode = new PdfCodabarBarcode();
//barcode text.
string barcodeText = "0123x";
string validExpression = @"^[\d\-\$\:\/\.\+]+$";
Regex regex = new Regex(validExpression, RegexOptions.Compiled);
if (!regex.IsMatch(barcodeText))
{
//Create new barcode exception instance.
PdfBarcodeException barcodeException = new PdfBarcodeException("Barcode Text contains characters that are not accepted by this barcode specification.", new InvalidDataException("Invalid input text"));
throw barcodeException;
}
else
{
//Sets the barcode text.
codaBarcode.Text = "0123x";
//Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("output.pdf");
}
//Close the document.
document.Close(true);
'Create a new PDF document.
Dim document As New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
'Creates a new PdfCodabarBarcode.
Dim codaBarcode As New PdfCodabarBarcode()
'barcode text.
Dim barcodeText As String = "0123x"
Dim validExpression As String = "^[\d\-\$\:\/\.\+]+$"
Dim regex As New Regex(validExpression, RegexOptions.Compiled)
If Not regex.IsMatch(barcodeText) Then
'Create new barcode exception instance.
Dim barcodeException As New PdfBarcodeException("Barcode Text contains characters that are not accepted by this barcode specification.", New InvalidDataException("Invalid input text"))
Throw barcodeException
Else
'Sets the barcode text.
codaBarcode.Text = "0123x"
'Draws a barcode on the new Page.
codaBarcode.Draw(page, New PointF(25, 500))
'Save document to disk.
document.Save("output.pdf")
End If
'Close the document.
document.Close(True)
Implements
System.Runtime.Serialization.ISerializable
System.Runtime.InteropServices._Exception