A barcode or bar code is a way of presenting data in a visual, machine-readable form. Generally speaking, barcode is an image of a rectangular form that consists of parallel black lines and white spaces of different widths. Barcodes are used in various areas where quick identification is necessary - as part of the purchase process in retail stores, in warehouses to track inventory, and on invoices to assist in accounting, among many other uses.
Barcodes allow storing of product-related data like manufacturing and expiry dates, manufacturer name, country of origin, and product price. There are plenty of barcode types nowadays because different companies use different combinations of numbers and bars in their barcodes depending on their needs. From the document signature perspective, Barcode may contain different characters (letters, digits, or symbols) and may have various lengths and sizes depending on the type and settings to keep signature information, title, subject, or short encrypted data.
How to eSign Document with Barcode Signature
GroupDocs.Signature for Python via .NET supports a wide range of Barcode types that can be used to create electronic signatures within the documents. Please refer to the BarcodeTypes description to get the full list of supported barcodes. To specify different options for Barcode signature GroupDocs.Signature for Python via .NET provides BarcodeSignOptions class. The main fields are:
encode_type - specifies the Barcode type (AustralianPost, Codabar, EAN13, OPC, etc.);
Here are the steps to eSign a document with the Barcode signature using GroupDocs.Signature for Python via .NET API:
Create a new instance of Signature class and pass the source document path as a constructor parameter.
Instantiate the BarcodeSignOptions object according to your requirements and specify the Barcode type by setting the encode_type property with one of the predefined supported types. Set the text property value.
This example shows how to sign a PDF document with a Barcode signature using Python:
importgroupdocs.signatureassignaturefromgroupdocs.signature.optionsimportBarcodeSignOptionsfromgroupdocs.signature.domainimportBarcodeTypesimportgroupdocs.signature.domainasgsdimportsysimportosdefrun():withsignature.Signature("./sample.pdf")assign:# Create barcode signature optionsoptions=BarcodeSignOptions()# Set barcode textoptions.text="John Smith"# Set barcode typeoptions.encode_type=BarcodeTypes.QR# Set barcode positionoptions.left=100options.top=100# Set barcode sizeoptions.width=100options.height=100# Set barcode colorsoptions.fore_color=gsd.Color.BLUEoptions.back_color=gsd.Color.WHITEoptions.border_color=gsd.Color.BLACK# Set barcode borderoptions.border_visiblity=Trueoptions.border_dash_style=gsd.DashStyle.DASHoptions.border_weight=2# Sign documentsign.sign("./SampleSigned.pdf",options)
Advanced Barcode Signature Options
You can customize the barcode signature further with additional options:
importgroupdocs.signatureassignaturefromgroupdocs.signature.optionsimportBarcodeSignOptionsfromgroupdocs.signature.domainimportBarcodeTypesimportgroupdocs.signature.domainasgsdimportsysimportosdefrun():withsignature.Signature("./sample.pdf")assign:# Create barcode signature optionsoptions=BarcodeSignOptions("JohnSmith")# Setup Barcode encoding typeoptions.encode_type=BarcodeTypes.QR# Set signature position and sizeoptions.left=100options.top=100options.width=200options.height=100# Set advanced optionsoptions.fore_color=gsd.Color.BLUEoptions.back_color=gsd.Color.WHITEoptions.opacity=0.8options.rotation_angle=45# Set barcode alignmentoptions.horizontal_alignment=gsd.HorizontalAlignment.CENTERoptions.vertical_alignment=gsd.VerticalAlignment.CENTER# Add borderoptions.border_color=gsd.Color.BLACKoptions.border_dash_style=gsd.DashStyle.SOLIDoptions.border_weight=2# Sign documentsign.sign("./SampleSigned.pdf",options)
Different Barcode Types
GroupDocs.Signature supports various barcode types. Here’s an example showing how to use different barcode types:
importgroupdocs.signatureassignaturefromgroupdocs.signature.optionsimportBarcodeSignOptionsfromgroupdocs.signature.domainimportBarcodeTypes# Initialize signaturewithsignature.Signature("sample.pdf")assign:# Create barcode signature optionsoptions=BarcodeSignOptions("1234567890")# Setup different Barcode encoding types# For numeric dataoptions.encode_type=BarcodeTypes.EAN_13# For alphanumeric data# options.encode_type = BarcodeTypes.CODE_128# For QR codes# options.encode_type = BarcodeTypes.QR# For 2D barcodes# options.encode_type = BarcodeTypes.DATA_MATRIX# Set signature positionoptions.left=100options.top=100# Sign documentsign.sign("SampleSigned.pdf",options)
Summary
This guide demonstrates how to use GroupDocs.Signature for Python via .NET to add barcode-based signatures to documents. It covers creating, configuring, and applying barcode signatures with support for various barcode types and customization options. For further exploration, refer to related guides on document information and advanced signing techniques.
More Resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: