From 8905a622336664d66de462bbbaffea5acc26026f Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 12 Nov 2016 07:14:22 -0500 Subject: Document the TIFF image functions. Correct related documentation. --- README.md | 2 +- compare.go | 11 ++++------- contrib/tiff/tiff.go | 14 ++++++++++++-- contrib/tiff/tiff_test.go | 1 + doc.go | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 96dfc33..94974ff 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ text, drawing and images. * Choice of measurement unit, page format and margins * Page header and footer management * Automatic page breaks, line breaks, and text justification -* Inclusion of JPEG, PNG, GIF and basic path-only SVG images +* Inclusion of JPEG, PNG, GIF, TIFF and basic path-only SVG images * Colors, gradients and alpha channel transparency * Outline bookmarks * Internal and external links diff --git a/compare.go b/compare.go index edc1ae4..416e545 100644 --- a/compare.go +++ b/compare.go @@ -113,9 +113,8 @@ func CompareBytes(sl1, sl2 []byte) (err error) { } // ComparePDFs reads and compares the full contents of the two specified -// readers. The comparison is done byte-for-byte with the exception of the -// CreationDate fields which are effectively ignored. Nil is returned if the -// buffers are equal, otherwise an error. +// readers byte-for-byte. Nil is returned if the buffers are equal, otherwise +// an error. func ComparePDFs(rdr1, rdr2 io.Reader) (err error) { var b1, b2 *bytes.Buffer _, err = b1.ReadFrom(rdr1) @@ -129,10 +128,8 @@ func ComparePDFs(rdr1, rdr2 io.Reader) (err error) { } // ComparePDFFiles reads and compares the full contents of the two specified -// files. The comparison is done byte-for-byte with the exception of the -// CreationDate fields which are effectively ignored. Nil is returned if the -// file contents are equal, or if the second file is missing, otherwise an -// error. +// files byte-for-byte. Nil is returned if the file contents are equal, or if +// the second file is missing, otherwise an error. func ComparePDFFiles(file1Str, file2Str string) (err error) { var sl1, sl2 []byte sl1, err = ioutil.ReadFile(file1Str) diff --git a/contrib/tiff/tiff.go b/contrib/tiff/tiff.go index 5bc34d9..3f13a38 100644 --- a/contrib/tiff/tiff.go +++ b/contrib/tiff/tiff.go @@ -30,7 +30,12 @@ import ( "golang.org/x/image/tiff" ) -// RegisterReader ... +// RegisterReader registers a TIFF image, adding it to the PDF file but not +// adding it to the page. imgName specifies the name that will be used in the +// call to Image() that actually places the image in the document. options +// specifies various image properties; in this case, the ImageType property +// should be set to "tiff". The TIFF image is a reader from the reader +// specified by r. func RegisterReader(fpdf *gofpdf.Fpdf, imgName string, options gofpdf.ImageOptions, r io.Reader) (info *gofpdf.ImageInfoType) { var err error var img image.Image @@ -55,7 +60,12 @@ func RegisterReader(fpdf *gofpdf.Fpdf, imgName string, options gofpdf.ImageOptio return } -// RegisterFile ... +// RegisterFile registers a TIFF image, adding it to the PDF file but not +// adding it to the page. imgName specifies the name that will be used in the +// call to Image() that actually places the image in the document. options +// specifies various image properties; in this case, the ImageType property +// should be set to "tiff". The TIFF image is read from the file specified by +// tiffFileStr. func RegisterFile(fpdf *gofpdf.Fpdf, imgName string, options gofpdf.ImageOptions, tiffFileStr string) (info *gofpdf.ImageInfoType) { var f *os.File var err error diff --git a/contrib/tiff/tiff_test.go b/contrib/tiff/tiff_test.go index d222375..33b294b 100644 --- a/contrib/tiff/tiff_test.go +++ b/contrib/tiff/tiff_test.go @@ -6,6 +6,7 @@ import ( "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) diff --git a/doc.go b/doc.go index d9302c3..a0af537 100644 --- a/doc.go +++ b/doc.go @@ -26,7 +26,7 @@ Features • Automatic page breaks, line breaks, and text justification -• Inclusion of JPEG, PNG, GIF and basic path-only SVG images +• Inclusion of JPEG, PNG, GIF, TIFF and basic path-only SVG images • Colors, gradients and alpha channel transparency -- cgit v1.2.1-24-ge1ad