Class PdfDataMatrixBarcode
Represents the PDF datamatrix barcode.
Inherited Members
Namespace: Syncfusion.Pdf.Barcode
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfDataMatrixBarcode : PdfBidimensionalBarcode
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Set the barcode location.
datamatrix.Location = new PointF(100, 100);
//Draws a barcode on the new Page.
datamatrix.Draw(page);
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Set the barcode location.
datamatrix.Location = New PointF(100, 100)
'Draws a barcode on the new Page.
datamatrix.Draw(page)
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Constructors
PdfDataMatrixBarcode()
Initialize a new instance of the PdfDataMatrixBarcode class.
Declaration
public PdfDataMatrixBarcode()
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Set the barcode location.
datamatrix.Location = new PointF(100, 100);
//Draws a barcode on the new Page.
datamatrix.Draw(page);
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Set the barcode location.
datamatrix.Location = New PointF(100, 100)
'Draws a barcode on the new Page.
datamatrix.Draw(page)
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
PdfDataMatrixBarcode(String)
Initialize a new instance of the PdfDataMatrixBarcode class.
Declaration
public PdfDataMatrixBarcode(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Data to be converted as barcode. |
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode("Test");
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Set the barcode location.
datamatrix.Location = new PointF(100, 100);
//Draws a barcode on the new Page.
datamatrix.Draw(page);
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode("Test")
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Set the barcode location.
datamatrix.Location = New PointF(100, 100)
'Draws a barcode on the new Page.
datamatrix.Draw(page)
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Properties
Encoding
Declaration
public PdfDataMatrixEncoding Encoding { get; set; }
Property Value
Type | Description |
---|---|
PdfDataMatrixEncoding |
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Set data matrix barcode encoding.
datamatrix.Encoding = PdfDataMatrixEncoding.ASCII;
//Sets the barcode text.
datamatrix.Text = "Test";
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Set the barcode location.
datamatrix.Location = new PointF(100, 100);
//Draws a barcode on the new Page.
datamatrix.Draw(page);
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Set data matrix barcode encoding.
datamatrix.Encoding = PdfDataMatrixEncoding.ASCII
'Sets the barcode text.
datamatrix.Text = "Test"
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Set the barcode location.
datamatrix.Location = New PointF(100, 100)
'Draws a barcode on the new Page.
datamatrix.Draw(page)
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Size
Declaration
public PdfDataMatrixSize Size { get; set; }
Property Value
Type | Description |
---|---|
PdfDataMatrixSize |
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Set barcode size.
datamatrix.Size = PdfDataMatrixSize.Size20x20;
//Set the barcode location.
datamatrix.Location = new PointF(100, 100);
//Draws a barcode on the new Page.
datamatrix.Draw(page);
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Set barcode size.
datamatrix.Size = PdfDataMatrixSize.Size20x20
'Set the barcode location.
datamatrix.Location = New PointF(100, 100)
'Draws a barcode on the new Page.
datamatrix.Draw(page)
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Methods
Draw(PdfGraphics)
Draws the barcode on the PdfGraphics.
Declaration
public override void Draw(PdfGraphics graphics)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphics | graphics | The PDF graphics. |
Overrides
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();
//Create Pdf graphics for the page.
PdfGraphics graphics=page.Graphics;
//Creates a new PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set back color.
datamatrix.BackColor = new PdfColor(Color.Red);
//Set the dimension of the barcode.
datamatrix.XDimension = 5;
//Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, new PointF(100,100));
//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()
'Create Pdf graphics for the page.
Dim graphics As PdfGraphics =page.Graphics
'Creates a new PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set back color.
datamatrix.BackColor = New PdfColor(Color.Red)
'Set the dimension of the barcode.
datamatrix.XDimension = 5
'Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, New PointF(100,100))
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Draw(PdfGraphics, PointF)
Draws the barcode on the PdfGraphics at the specified location.
Declaration
public override void Draw(PdfGraphics graphics, PointF location)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphics | graphics | The PDF graphics. |
System.Drawing.PointF | location | Location to draw barcode. |
Overrides
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();
//Create Pdf graphics for the page.
PdfGraphics graphics=page.Graphics;
//Creates a new PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set back color.
datamatrix.BackColor = new PdfColor(Color.Red);
//Set the dimension of the barcode.
datamatrix.XDimension = 5;
//Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, new PointF(100,100));
//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()
//Create Pdf graphics for the page.
Dim graphics As PdfGraphics =page.Graphics
'Creates a new PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set back color.
datamatrix.BackColor = New PdfColor(Color.Red)
'Set the dimension of the barcode.
datamatrix.XDimension = 5
'Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, New PointF(100,100))
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Draw(PdfGraphics, PointF, SizeF)
Draws the barcode on the PdfGraphics at the specified location and size.
Declaration
public void Draw(PdfGraphics graphics, PointF location, SizeF Size)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphics | graphics | |
System.Drawing.PointF | location | |
System.Drawing.SizeF | Size |
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();
//Create Pdf graphics for the page.
PdfGraphics graphics=page.Graphics;
//Creates a new PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set back color.
datamatrix.BackColor = new PdfColor(Color.Red);
//Set the dimension of the barcode.
datamatrix.XDimension = 5;
//Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, new PointF(100,100), new SizeF(200,200));
//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()
'Create Pdf graphics for the page.
Dim graphics As PdfGraphics graphics=page.Graphics
'Creates a new PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set back color.
datamatrix.BackColor = New PdfColor(Color.Red)
'Set the dimension of the barcode.
datamatrix.XDimension = 5
'Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, New PointF(100,100), New SizeF(200,200))
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Draw(PdfGraphics, RectangleF)
Draws the barcode on the PdfGraphics at the specified rectangle.
Declaration
public void Draw(PdfGraphics graphics, RectangleF Rectangle)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphics | graphics | The PDF page to be drawn the barcode. |
System.Drawing.RectangleF | Rectangle | The rectangle bounds of the rendering area. |
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();
//Create Pdf graphics for the page.
PdfGraphics graphics=page.Graphics;
//Creates a new PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set back color.
datamatrix.BackColor = new PdfColor(Color.Red);
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, new RectangleF(100, 100, 200, 200));
//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()
'Create Pdf graphics for the page.
Dim graphics As PdfGraphics =page.Graphics
'Creates a new PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set back color.
datamatrix.BackColor = New PdfColor(Color.Red)
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, New RectangleF(100, 100, 200, 200))
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Draw(PdfGraphics, Single, Single, Single, Single)
Draws the barcode based on the provided float values.
Declaration
public void Draw(PdfGraphics graphics, float x, float y, float Width, float Height)
Parameters
Type | Name | Description |
---|---|---|
PdfGraphics | graphics | The PDF graphics to be draw the barcode. |
System.Single | x | The x coordinate of the upper-left corner of the bounding rectangle. |
System.Single | y | The Y coordinate of the upper-top corner bounding rectangle. |
System.Single | Width | The width of the barcode bounding rectangle. |
System.Single | Height | The height of the barcode bounding rectangle. |
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();
//Create Pdf graphics for the page.
PdfGraphics graphics=page.Graphics;
//Creates a new PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set back color.
datamatrix.BackColor = new PdfColor(Color.Red);
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, 100, 100, 200, 200);
//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()
'Create Pdf graphics for the page.
Dim graphics As PdfGraphics = page.Graphics
'Creates a new PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set back color.
datamatrix.BackColor = New PdfColor(Color.Red)
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Draws a barcode on the new PdfGraphics.
datamatrix.Draw(graphics, 100, 100, 200, 200)
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Draw(PdfPageBase)
Draws datamatrix in the PdfPage.
Declaration
public override void Draw(PdfPageBase page)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | The PDF page. |
Overrides
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set back color.
datamatrix.BackColor = new PdfColor(Color.Red);
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Draws a barcode on the new Page.
datamatrix.Draw(page, new PointF(100,100));
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set back color.
datamatrix.BackColor = New PdfColor(Color.Red)
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Draws a barcode on the new Page.
datamatrix.Draw(page, New PointF(100,100))
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Draw(PdfPageBase, PointF)
Declaration
public override void Draw(PdfPageBase page, PointF location)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | |
System.Drawing.PointF | location |
Overrides
Draw(PdfPageBase, PointF, SizeF)
Draw DataMatrix barcode on Pdf Document.
Declaration
public void Draw(PdfPageBase page, PointF location, SizeF size)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | |
System.Drawing.PointF | location | |
System.Drawing.SizeF | size |
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set back color.
datamatrix.BackColor = new PdfColor(Color.Red);
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Draws a barcode on the new Page.
datamatrix.Draw(page, new PointF(100,100), new SizeF(200,200));
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set back color.
datamatrix.BackColor = New PdfColor(Color.Red)
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Draws a barcode on the new Page.
datamatrix.Draw(page, New PointF(100,100), New SizeF(200,200))
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Draw(PdfPageBase, RectangleF)
Draw DataMatrix Barcode in pdf document.
Declaration
public void Draw(PdfPageBase page, RectangleF rectangle)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | The PDF page to be drawn the barcode. |
System.Drawing.RectangleF | rectangle | The rectangle bounds of the rendering area. |
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set back color.
datamatrix.BackColor = new PdfColor(Color.Red);
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Draws a barcode on the new Page.
datamatrix.Draw(page, new RectangleF(100, 100, 200, 200));
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set back color.
datamatrix.BackColor = New PdfColor(Color.Red)
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Draws a barcode on the new Page.
datamatrix.Draw(page, New RectangleF(100, 100, 200, 200))
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
Draw(PdfPageBase, Single, Single, Single, Single)
Draw DataMatrix barcode in pdf document.
Declaration
public void Draw(PdfPageBase page, float x, float y, float width, float height)
Parameters
Type | Name | Description |
---|---|---|
PdfPageBase | page | The PDF page to be draw the barcode. |
System.Single | x | The x coordinate of the upper-left corner of the bounding rectangle. |
System.Single | y | The Y coordinate of the upper-top corner bounding rectangle. |
System.Single | width | |
System.Single | height |
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set back color.
datamatrix.BackColor = new PdfColor(Color.Red);
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Draws a barcode on the new Page.
datamatrix.Draw(page, 100, 100, 200, 200);
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set back color.
datamatrix.BackColor = New PdfColor(Color.Red)
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Draws a barcode on the new Page.
datamatrix.Draw(page, 100, 100, 200, 200)
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
ToImage()
Declaration
public override Image ToImage()
Returns
Type | Description |
---|---|
System.Drawing.Image |
Overrides
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Set the barcode location.
datamatrix.Location = new PointF(100, 100);
//Get the barcode as image.
Image img = datamatrix.ToImage();
//Draw image to PDF page.
page.Graphics.DrawImage(new PdfBitmap(img), PointF.Empty);
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Set the barcode location.
datamatrix.Location = New PointF(100, 100)
'Get the barcode as image.
Dim img As Image = datamatrix.ToImage()
'Draw image to PDF page.
page.Graphics.DrawImage(New PdfBitmap(img), PointF.Empty)
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)
ToImage(SizeF)
Declaration
public Image ToImage(SizeF size)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.SizeF | size |
Returns
Type | Description |
---|---|
System.Drawing.Image |
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 PDF datamatrix barcode.
PdfDataMatrixBarcode datamatrix = new PdfDataMatrixBarcode();
//Sets the barcode text.
datamatrix.Text = "Test";
//Set the dimention of the barcode.
datamatrix.XDimension = 5;
//Set the barcode location.
datamatrix.Location = new PointF(100, 100);
//Get the barcode as image.
Image img = datamatrix.ToImage(new SizeF(200,200));
//Draw image to PDF page.
page.Graphics.DrawImage(new PdfBitmap(img), PointF.Empty);
//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 PDF datamatrix barcode.
Dim datamatrix As New PdfDataMatrixBarcode()
'Sets the barcode text.
datamatrix.Text = "Test"
'Set the dimention of the barcode.
datamatrix.XDimension = 5
'Set the barcode location.
datamatrix.Location = New PointF(100, 100)
'Get the barcode as image.
Dim img As Image = datamatrix.ToImage(New SizeF(200,200))
'Draw image to PDF page.
page.Graphics.DrawImage(New PdfBitmap(img), PointF.Empty)
'Save document to disk.
document.Save("output.pdf")
'Close the document.
document.Close(True)