PDF Barcode
With the Aloaha PDF SDK only one API is required to add a barcode to existing PDF documents.
Following Barcode Types are supported:
- Code39 (or Code 3 of 9)
- EAN-13
- Code128
- PostNet
- Interleaved 2 of 5
Please find below some self explaining sample code:
PDF Barcoding API
Dim pdf
Dim infile
Dim outfile
Dim Barcode
'PDF coordinates in points
dim d_Left
dim d_Top
dim d_Width
dim d_Height
'Barcode Type
Dim b_type
'Code39= 1
'EAN-13 = 2
'Code128 = 3
'PostNet = 4
'Interleaved 2 of 5 = 5
b_type = 1
'Barcode Options
'B_options
if b_type=1 or b_type=3 or b_type=5 then
B_options=0
else
'value betwee 0-3
B_options=0
end if
'Barcode Direction
Dim B_Direction
'possible values are 0, 1, 2, 3
B_Direction = 0
Dim P_Page 'PDF Page to be used
P_Page = 1
'Background Image
Dim B_Image
This variable holds the path to an image to be used as background. Empty value will make Bardcode transparent.
B_Image = "c:\whitepixel.bmp"
Barcode="47110815"
infile = "c:\input.pdf"
outfile = "c:\output.pdf"
Set pdf = CreateObject("aloahapdf.edit")
d_Left = 0
d_Top = 400
d_Width = 400
d_Height = 100
If pdf.load_pdf_to_mem(CStr(infile)) = true Then
If pdf.place_barcode(CDbl(d_Left), CDbl(d_Top), CDbl(d_Width), CDbl(d_Height), CStr(Barcode), CLng(b_type
), CLng(B_options), CLng(B_Direction), CLng(P_Page), CStr(B_Image)) = true Then
Call pdf.save_pdf_to_file(CStr(outfile))
End If
End If
Set pdf = nothing
Download Barcoding Sample
Barcode Code128 sample as TXT file (1,23 KB)
Barcode Code128 sample as VBS file (1,23 KB)
Aloaha Software / Knowledge Base / PDF SDK / PDF Barcoding