Class PdfBarcodeException
Inheritance
System.Object
PdfBarcodeException
Namespace: Syncfusion.Pdf.Barcode
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfBarcodeException : ApplicationException
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)