summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorKurt <kurt.w.jung@gmail.com>2016-05-16 15:09:28 -0400
committerKurt <kurt.w.jung@gmail.com>2016-05-16 15:09:28 -0400
commitfca2246f52dda72fcac9d7261cf2bb5faeddd28f (patch)
tree83330bcd05345bd87d0be38121f26175fcd04fec /contrib
parentbcfb7a87cbd135e18715e0b68ac4a31de4b04d5f (diff)
parentff13dc5b70f7db15ecfba5d9108b3324f5f41cd0 (diff)
Merge branch 'ruudk-pdf417'. This provides support for PDF417 barcodes.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/barcode/barcode.go13
-rw-r--r--contrib/barcode/barcode_test.go13
2 files changed, 26 insertions, 0 deletions
diff --git a/contrib/barcode/barcode.go b/contrib/barcode/barcode.go
index 4a143da..b2ba2c2 100644
--- a/contrib/barcode/barcode.go
+++ b/contrib/barcode/barcode.go
@@ -33,6 +33,7 @@ import (
"github.com/boombuler/barcode/qr"
"github.com/boombuler/barcode/twooffive"
"github.com/jung-kurt/gofpdf"
+ "github.com/ruudk/golang-pdf417"
)
// barcodes represents the barcodes that have been registered through this
@@ -131,6 +132,18 @@ func RegisterDataMatrix(pdf barcodePdf, code string) string {
return registerBarcode(pdf, bcode, err)
}
+// RegisterPdf417 registers a barcode of type Pdf417 to the PDF, but not to the
+// page. code is the string to be encoded. columns specifies the number of
+// barcode columns; this should be a value between 1 and 30 inclusive.
+// securityLevel specifies an error correction level between zero and 8
+// inclusive. Barcodes for use with FedEx must set columns to 10 and
+// securityLevel to 5. Use Barcode() with the return value to put the barcode
+// on the page.
+func RegisterPdf417(pdf barcodePdf, code string, columns int, securityLevel int) string {
+ bcode := pdf417.Encode(code, columns, securityLevel)
+ return registerBarcode(pdf, bcode, nil)
+}
+
// RegisterEAN registers a barcode of type EAN to the PDF, but not to the page.
// It will automatically detect if the barcode is EAN8 or EAN13. Use Barcode()
// with the return value to put the barcode on the page.
diff --git a/contrib/barcode/barcode_test.go b/contrib/barcode/barcode_test.go
index c12ff12..f2c57f1 100644
--- a/contrib/barcode/barcode_test.go
+++ b/contrib/barcode/barcode_test.go
@@ -124,3 +124,16 @@ func ExampleRegisterTwoOfFive() {
// Output:
// Successfully generated ../../pdf/contrib_barcode_RegisterTwoOfFive.pdf
}
+
+func ExampleRegisterPdf417() {
+ pdf := createPdf()
+
+ key := barcode.RegisterPdf417(pdf, "1234567895", 10, 5)
+ barcode.Barcode(pdf, key, 15, 15, 100, 20, false)
+
+ fileStr := example.Filename("contrib_barcode_RegisterPdf417")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_barcode_RegisterPdf417.pdf
+}