How to add barcode to PDF file in C#, VB.NET and VBScript with BarCode SDK - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

How to add barcode to PDF file in C#, VB.NET and VBScript with BarCode SDK

  • Home
  • /
  • Articles
  • /
  • How to add barcode to PDF file in C#, VB.NET and VBScript with BarCode SDK

The following samples demonstrate how to add barcode to existing PDF document with Bytescout BarCode Generator SDK.

Add barcode to PDF file in C#, VB.NET, VBScript - BarCode Generator SDK

C#

using Bytescout.BarCode;

namespace AddBarcodeToPdfDocument
{
	class Program
	{
		static void Main()
		{
            // Create new barcode and register it.
            Barcode barcode = new Barcode();
			barcode.RegistrationName = "demo";
			barcode.RegistrationKey = "demo";

            // Set symbology
            barcode.Symbology = SymbologyType.DataMatrix;
            // Set value
            barcode.Value = "Sample barcode";

			// Place barcode at bottom-right corner of every document page
			barcode.DrawToPDF("wikipedia.pdf", -1, 500, 50, "result.pdf");

            // Open output file in default PDF viewer
            System.Diagnostics.Process.Start("result.pdf");
		}
	}
}

Visual Basic .NET

Imports Bytescout.BarCode

Class Program
	Friend Shared Sub Main()
		' Create new barcode and register it.
		Dim barcode As New Barcode()
		barcode.RegistrationName = "demo"
		barcode.RegistrationKey = "demo"

		' Set symbology
		barcode.Symbology = SymbologyType.DataMatrix
		' Set value
		barcode.Value = "Sample barcode"

		' Place barcode at bottom-right corner of every document page
		barcode.DrawToPDF("wikipedia.pdf", -1, 500, 50, "result.pdf")

		' Open output file in default PDF viewer
		System.Diagnostics.Process.Start("result.pdf")
	End Sub
End Class

VBScript

' Create barcode object and register it
Set barcode = CreateObject("Bytescout.BarCode.Barcode")
barcode.RegistrationName = "demo"
barcode.RegistrationKey = "demo"

' set symbology to DataMatrix
barcode.Symbology = 15 ' 15 = DataMatrix symbology type

' set barcode value to encode
barcode.Value = "Sample barcode" 

' Place barcode at bottom-right corner of every document page
barcode.DrawToPDF "..wikipedia.pdf", -1, 500, 50, "result.pdf"

' Open the output file in default PDF viewer.
Set shell = CreateObject("WScript.Shell")
shell.Run "result.pdf", 1, false
Set shell = Nothing

Set barcode = Nothing

Tutorials:

prev
next