github.com/phpdave11/gofpdf@v1.4.2/contrib/httpimg/httpimg_test.go (about)

     1  package httpimg_test
     2  
     3  import (
     4  	"github.com/phpdave11/gofpdf"
     5  	"github.com/phpdave11/gofpdf/contrib/httpimg"
     6  	"github.com/phpdave11/gofpdf/internal/example"
     7  )
     8  
     9  func ExampleRegister() {
    10  	pdf := gofpdf.New("L", "mm", "A4", "")
    11  	pdf.SetFont("Helvetica", "", 12)
    12  	pdf.SetFillColor(200, 200, 220)
    13  	pdf.AddPage()
    14  
    15  	url := "https://github.com/phpdave11/gofpdf/raw/master/image/logo_gofpdf.jpg?raw=true"
    16  	httpimg.Register(pdf, url, "")
    17  	pdf.Image(url, 15, 15, 267, 0, false, "", 0, "")
    18  	fileStr := example.Filename("contrib_httpimg_Register")
    19  	err := pdf.OutputFileAndClose(fileStr)
    20  	example.Summary(err, fileStr)
    21  	// Output:
    22  	// Successfully generated ../../pdf/contrib_httpimg_Register.pdf
    23  }