github.com/phpdave11/gofpdf@v1.4.2/contrib/tiff/tiff_test.go (about)

     1  package tiff_test
     2  
     3  import (
     4  	"github.com/phpdave11/gofpdf"
     5  	"github.com/phpdave11/gofpdf/contrib/tiff"
     6  	"github.com/phpdave11/gofpdf/internal/example"
     7  )
     8  
     9  // ExampleRegisterFile demonstrates the loading and display of a TIFF image.
    10  func ExampleRegisterFile() {
    11  	pdf := gofpdf.New("L", "mm", "A4", "")
    12  	pdf.SetFont("Helvetica", "", 12)
    13  	pdf.SetFillColor(200, 200, 220)
    14  	pdf.AddPageFormat("L", gofpdf.SizeType{Wd: 200, Ht: 200})
    15  	opt := gofpdf.ImageOptions{ImageType: "tiff", ReadDpi: false}
    16  	_ = tiff.RegisterFile(pdf, "sample", opt, "../../image/golang-gopher.tiff")
    17  	pdf.Image("sample", 0, 0, 200, 200, false, "", 0, "")
    18  	fileStr := example.Filename("Fpdf_Contrib_Tiff")
    19  	err := pdf.OutputFileAndClose(fileStr)
    20  	example.Summary(err, fileStr)
    21  	// Output:
    22  	// Successfully generated ../../pdf/Fpdf_Contrib_Tiff.pdf
    23  }