Class PdfBarcode
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Syncfusion.Pdf.Barcode
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfBarcode
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();
//Sets the barcode text.
codaBarcode.Text = "0123";
//Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCodabarBarcode = New PdfCodabarBarcode()
'Sets the barcode text.
codaBarcode.Text = "0123"
'Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
Constructors
PdfBarcode()
Initializes a new instance of the PdfBarcode class.
Declaration
public PdfBarcode()
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();
//Sets the barcode text.
codaBarcode.Text = "0123";
//Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCodabarBarcode = New PdfCodabarBarcode()
'Sets the barcode text.
codaBarcode.Text = "0123"
'Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
PdfBarcode(String)
Initializes a new instance of the PdfBarcode class.
Declaration
public PdfBarcode(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Set the barcode text. |
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("0123");
//Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCodabarBarcode = New PdfCodabarBarcode("0123")
'Draws a barcode on the new Page.
codaBarcode.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
Fields
barHeight
Indicates the bar height of the barcode.
Declaration
protected float barHeight
Field Value
Type | Description |
---|---|
System.Single |
bounds
Indicates the region of the barcode.
Declaration
protected RectangleF bounds
Field Value
Type | Description |
---|---|
System.Drawing.RectangleF |
size
Indicates the size of the the barcode to draw in the PDF Document.
Declaration
protected SizeF size
Field Value
Type | Description |
---|---|
System.Drawing.SizeF |
Properties
BackColor
Declaration
public PdfColor BackColor { get; set; }
Property Value
Type | Description |
---|---|
PdfColor |
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 PdfCode93Barcode.
PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93");
//Sets the barcode back color.
code93.BackColor = new PdfColor(Color.Green);
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code39 As PdfCode93Barcode = New PdfCode93Barcode("CODE93")
'Sets the barcode back color.
code93.BackColor = new PdfColor(Color.Green)
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
BarColor
Declaration
public PdfColor BarColor { get; set; }
Property Value
Type | Description |
---|---|
PdfColor |
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 PdfCode93Barcode.
PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93");
//Sets the barcode color.
code93.BarColor = new PdfColor(Color.Green);
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code39 As PdfCode93Barcode = New PdfCode93Barcode("CODE93")
'Sets the barcode color.
code93.BarColor = new PdfColor(Color.Green)
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
BarHeight
Declaration
public float BarHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
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 PdfCode93Barcode.
PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93");
//Sets the barcode height.
code93.BarHeight = 50f;
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code39 As PdfCode93Barcode = New PdfCode93Barcode("CODE93")
'Sets the barcode height.
code93.BarHeight = 50f
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
Bounds
Declaration
public RectangleF Bounds { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.RectangleF |
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 PdfCode93Barcode.
PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93");
//Sets the barcode bounds.
RectangleF bounds=code93.Bounds;
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code39 As PdfCode93Barcode = New PdfCode93Barcode("CODE93")
'Get the barcode bounds.
RectangleF bounds=code93.Bounds
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
Location
Declaration
public PointF Location { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.PointF |
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();
PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93");
//Sets the barcode location.
code93.Location = new PointF(50, 50);
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code93 As PdfCode93Barcode = New PdfCode93Barcode("CODE93")
'Sets the barcode location.
code93.Location = new PointF(50, 50)
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
NarrowBarWidth
Declaration
public float NarrowBarWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
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 PdfCode93Barcode.
PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93");
//Sets the barcode narrow width.
code93.NarrowBarWidth =1f;
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code39 As PdfCode93Barcode = New PdfCode93Barcode("CODE93")
'Sets the barcode narrow width.
code93.NarrowBarWidth = 1f
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
QuietZone
Declaration
public PdfBarcodeQuietZones QuietZone { get; set; }
Property Value
Type | Description |
---|---|
PdfBarcodeQuietZones |
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 PdfCode93Barcode.
PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93");
//Creates a new PdfBarcodeQuietZones.
PdfBarcodeQuietZones quietZones = new PdfBarcodeQuietZones();
quietZones.All = 0f;
//Sets the barcode quiet zone.
code93QuietZone = quietZones;
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code39 As PdfCode93Barcode = New PdfCode93Barcode("CODE93")
'Creates a new PdfBarcodeQuietZones.
PdfBarcodeQuietZones quietZones = new PdfBarcodeQuietZones()
quietZones.All = 0f
'Sets the barcode quiet zone.
code93QuietZone = quietZones
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
Size
Declaration
public SizeF Size { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.SizeF |
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 PdfCode93Barcode.
PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93");
//Sets the barcode size
SizeF size=code93.Size;
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code39 As PdfCode93Barcode = New PdfCode93Barcode("CODE93")
'Get the barcode size.
SizeF size=code93.Size
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
Text
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String |
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 PdfCode93Barcode.
PdfCode93Barcode code93 = new PdfCode93Barcode();
//Sets the barcode text.
code93.Text ="CODE93";
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code39 As PdfCode93Barcode = New PdfCode93Barcode()
'Sets the barcode back color.
code93.Text ="CODE93"
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save document to disk.
document.Save("PdfBarcode.pdf")
TextColor
Declaration
public PdfColor TextColor { get; set; }
Property Value
Type | Description |
---|---|
PdfColor |
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 PdfCode93Barcode.
PdfCode93Barcode code93 = new PdfCode93Barcode("CODE93");
//Sets the barcode text color.
code93.TextColor = new PdfColor(Color.Green);
//Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500));
//Save document to disk.
document.Save("PdfBarcode.pdf");
'Create a new PDF document.
Dim document As PdfDocument = 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 PdfCode93Barcode.
Dim code39 As PdfCode93Barcode = New PdfCode93Barcode("CODE93")
'Sets the barcode text color.
code93.TextColor = new PdfColor(Color.Green)
'Draws a barcode on the new Page.
code93.Draw(page, new PointF(25, 500))
'Save the document to disk.
document.Save("PdfBarcode.pdf")
Methods
GetSizeValue()
Internal method which calculates the size of the barcode which is going to rendered.
Declaration
protected virtual SizeF GetSizeValue()
Returns
Type | Description |
---|---|
System.Drawing.SizeF |
Validate(String)
Internal method which validates whether the given text is acceptable by the current barcode specification or not.
Declaration
protected virtual bool Validate(string data)
Parameters
Type | Name | Description |
---|---|---|
System.String | data | The Text. |
Returns
Type | Description |
---|---|
System.Boolean | True if Valid, Otherwise False |