summaryrefslogtreecommitdiff
path: root/vendor/github.com/jung-kurt/gofpdf/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/jung-kurt/gofpdf/contrib')
-rw-r--r--vendor/github.com/jung-kurt/gofpdf/contrib/barcode/barcode.go10
-rw-r--r--vendor/github.com/jung-kurt/gofpdf/contrib/barcode/barcode_test.go152
-rw-r--r--vendor/github.com/jung-kurt/gofpdf/contrib/httpimg/httpimg_test.go23
-rw-r--r--vendor/github.com/jung-kurt/gofpdf/contrib/tiff/tiff_test.go23
4 files changed, 208 insertions, 0 deletions
diff --git a/vendor/github.com/jung-kurt/gofpdf/contrib/barcode/barcode.go b/vendor/github.com/jung-kurt/gofpdf/contrib/barcode/barcode.go
index 0649564..63a4908 100644
--- a/vendor/github.com/jung-kurt/gofpdf/contrib/barcode/barcode.go
+++ b/vendor/github.com/jung-kurt/gofpdf/contrib/barcode/barcode.go
@@ -21,6 +21,7 @@ import (
"bytes"
"errors"
"github.com/boombuler/barcode"
+ "github.com/boombuler/barcode/aztec"
"github.com/boombuler/barcode/codabar"
"github.com/boombuler/barcode/code128"
"github.com/boombuler/barcode/code39"
@@ -110,6 +111,15 @@ func Register(bcode barcode.Barcode) string {
return key
}
+// RegisterAztec registers a barcode of type Aztec to the PDF, but not to
+// the page. Use Barcode() with the return value to put the barcode on the page.
+// code is the string to be encoded. minECCPercent is the error correction percentage. 33 is the default.
+// userSpecifiedLayers can be a value between -4 and 32 inclusive.
+func RegisterAztec(pdf barcodePdf, code string, minECCPercent int, userSpecifiedLayers int) string {
+ bcode, err := aztec.Encode([]byte(code), minECCPercent, userSpecifiedLayers)
+ return registerBarcode(pdf, bcode, err)
+}
+
// RegisterCodabar registers a barcode of type Codabar to the PDF, but not to
// the page. Use Barcode() with the return value to put the barcode on the page.
func RegisterCodabar(pdf barcodePdf, code string) string {
diff --git a/vendor/github.com/jung-kurt/gofpdf/contrib/barcode/barcode_test.go b/vendor/github.com/jung-kurt/gofpdf/contrib/barcode/barcode_test.go
new file mode 100644
index 0000000..c3c648c
--- /dev/null
+++ b/vendor/github.com/jung-kurt/gofpdf/contrib/barcode/barcode_test.go
@@ -0,0 +1,152 @@
+package barcode_test
+
+import (
+ "github.com/boombuler/barcode/code128"
+ "github.com/boombuler/barcode/qr"
+ "github.com/jung-kurt/gofpdf"
+ "github.com/jung-kurt/gofpdf/contrib/barcode"
+ "github.com/jung-kurt/gofpdf/internal/example"
+)
+
+func createPdf() (pdf *gofpdf.Fpdf) {
+ pdf = gofpdf.New("L", "mm", "A4", "")
+ pdf.SetFont("Helvetica", "", 12)
+ pdf.SetFillColor(200, 200, 220)
+ pdf.AddPage()
+ return
+}
+
+func ExampleRegister() {
+ pdf := createPdf()
+
+ fileStr := example.Filename("contrib_barcode_Register")
+
+ bcode, err := code128.Encode("gofpdf")
+
+ if err == nil {
+ key := barcode.Register(bcode)
+ barcode.Barcode(pdf, key, 15, 15, 100, 10, false)
+ }
+
+ err = pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_barcode_Register.pdf
+}
+
+func ExampleRegisterCodabar() {
+ pdf := createPdf()
+
+ key := barcode.RegisterCode128(pdf, "codabar")
+ barcode.Barcode(pdf, key, 15, 15, 100, 10, false)
+
+ fileStr := example.Filename("contrib_barcode_RegisterCodabar")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_barcode_RegisterCodabar.pdf
+}
+
+func ExampleRegisterAztec() {
+ pdf := createPdf()
+
+ key := barcode.RegisterAztec(pdf, "aztec", 33, 0)
+ barcode.Barcode(pdf, key, 15, 15, 100, 100, false)
+
+ fileStr := example.Filename("contrib_barcode_RegisterAztec")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_barcode_RegisterAztec.pdf
+}
+
+func ExampleRegisterCode128() {
+ pdf := createPdf()
+
+ key := barcode.RegisterCode128(pdf, "code128")
+ barcode.Barcode(pdf, key, 15, 15, 100, 10, false)
+
+ fileStr := example.Filename("contrib_barcode_RegisterCode128")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_barcode_RegisterCode128.pdf
+}
+
+func ExampleRegisterCode39() {
+ pdf := createPdf()
+
+ key := barcode.RegisterCode39(pdf, "CODE39", false, true)
+ barcode.Barcode(pdf, key, 15, 15, 100, 10, false)
+
+ fileStr := example.Filename("contrib_barcode_RegisterCode39")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_barcode_RegisterCode39.pdf
+}
+
+func ExampleRegisterDataMatrix() {
+ pdf := createPdf()
+
+ key := barcode.RegisterDataMatrix(pdf, "datamatrix")
+ barcode.Barcode(pdf, key, 15, 15, 20, 20, false)
+
+ fileStr := example.Filename("contrib_barcode_RegisterDataMatrix")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_barcode_RegisterDataMatrix.pdf
+}
+
+func ExampleRegisterEAN() {
+ pdf := createPdf()
+
+ key := barcode.RegisterEAN(pdf, "96385074")
+ barcode.Barcode(pdf, key, 15, 15, 100, 10, false)
+
+ fileStr := example.Filename("contrib_barcode_RegisterEAN")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_barcode_RegisterEAN.pdf
+}
+
+func ExampleRegisterQR() {
+ pdf := createPdf()
+
+ key := barcode.RegisterQR(pdf, "qrcode", qr.H, qr.Unicode)
+ barcode.Barcode(pdf, key, 15, 15, 20, 20, false)
+
+ fileStr := example.Filename("contrib_barcode_RegisterQR")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_barcode_RegisterQR.pdf
+}
+
+func ExampleRegisterTwoOfFive() {
+ pdf := createPdf()
+
+ key := barcode.RegisterTwoOfFive(pdf, "1234567895", true)
+ barcode.Barcode(pdf, key, 15, 15, 100, 20, false)
+
+ fileStr := example.Filename("contrib_barcode_RegisterTwoOfFive")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // 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
+}
diff --git a/vendor/github.com/jung-kurt/gofpdf/contrib/httpimg/httpimg_test.go b/vendor/github.com/jung-kurt/gofpdf/contrib/httpimg/httpimg_test.go
new file mode 100644
index 0000000..bf13492
--- /dev/null
+++ b/vendor/github.com/jung-kurt/gofpdf/contrib/httpimg/httpimg_test.go
@@ -0,0 +1,23 @@
+package httpimg_test
+
+import (
+ "github.com/jung-kurt/gofpdf"
+ "github.com/jung-kurt/gofpdf/contrib/httpimg"
+ "github.com/jung-kurt/gofpdf/internal/example"
+)
+
+func ExampleRegister() {
+ pdf := gofpdf.New("L", "mm", "A4", "")
+ pdf.SetFont("Helvetica", "", 12)
+ pdf.SetFillColor(200, 200, 220)
+ pdf.AddPage()
+
+ url := "https://github.com/jung-kurt/gofpdf/raw/master/image/logo_gofpdf.jpg?raw=true"
+ httpimg.Register(pdf, url, "")
+ pdf.Image(url, 15, 15, 267, 0, false, "", 0, "")
+ fileStr := example.Filename("contrib_httpimg_Register")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/contrib_httpimg_Register.pdf
+}
diff --git a/vendor/github.com/jung-kurt/gofpdf/contrib/tiff/tiff_test.go b/vendor/github.com/jung-kurt/gofpdf/contrib/tiff/tiff_test.go
new file mode 100644
index 0000000..33b294b
--- /dev/null
+++ b/vendor/github.com/jung-kurt/gofpdf/contrib/tiff/tiff_test.go
@@ -0,0 +1,23 @@
+package tiff_test
+
+import (
+ "github.com/jung-kurt/gofpdf"
+ "github.com/jung-kurt/gofpdf/contrib/tiff"
+ "github.com/jung-kurt/gofpdf/internal/example"
+)
+
+// ExampleRegisterFile demonstrates the loading and display of a TIFF image.
+func ExampleRegisterFile() {
+ pdf := gofpdf.New("L", "mm", "A4", "")
+ pdf.SetFont("Helvetica", "", 12)
+ pdf.SetFillColor(200, 200, 220)
+ pdf.AddPageFormat("L", gofpdf.SizeType{Wd: 200, Ht: 200})
+ opt := gofpdf.ImageOptions{ImageType: "tiff", ReadDpi: false}
+ _ = tiff.RegisterFile(pdf, "sample", opt, "../../image/golang-gopher.tiff")
+ pdf.Image("sample", 0, 0, 200, 200, false, "", 0, "")
+ fileStr := example.Filename("Fpdf_Contrib_Tiff")
+ err := pdf.OutputFileAndClose(fileStr)
+ example.Summary(err, fileStr)
+ // Output:
+ // Successfully generated ../../pdf/Fpdf_Contrib_Tiff.pdf
+}