Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active July 18, 2021 10:01
Show Gist options
  • Save GroupDocsGists/bceca465883f710a35bf6c447f251634 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/bceca465883f710a35bf6c447f251634 to your computer and use it in GitHub Desktop.
Generate Barcode using C# - Add Barcodes to Documents and Images using Signature API for .NET
// Generate and apply barcodes to documents (DOC, DOCX, PDF, PPT, XLS, XLSX, ...)
using (Signature signature = new Signature("path/document.pdf"))
{
// Create barcode options with the barcode text
BarcodeSignOptions options = new BarcodeSignOptions("Signed by GroupDocs using GroupDocs.Signature.")
{
// Set the Barcode Encoding Ttype
EncodeType = BarcodeTypes.Code128,
// Set Signature Position
Left = 205,
Top = 170,
Width = 200,
Height = 50
};
// Apply Barcode on document to Sign.
SignResult result = signature.Sign("path/document-with-barcode.pdf", options);
}
// Generate and apply barcodes to Images (JPG, PNG, BMP, ...)
using (Signature signature = new Signature("path/image.jpg"))
{
// Create barcode options with the barcode text
BarcodeSignOptions options = new BarcodeSignOptions("Signed by GroupDocs using GroupDocs.Signature.")
{
// Set the Barcode Encoding Ttype
EncodeType = BarcodeTypes.Code128,
// Set Signature Position
Left = 20,
Top = 150,
Width = 160,
Height = 30
};
// Apply Barcode on document to Sign.
SignResult result = signature.Sign("path/document-with-barcode.jpg", options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment