tiff

package
v1.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tiff allows standard (LZW-compressed) TIFF images to be used in documents generated with gofpdf.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFile

func RegisterFile(fpdf *gofpdf.Fpdf, imgName string, options gofpdf.ImageOptions, tiffFileStr string) (info *gofpdf.ImageInfoType)

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.

Example

ExampleRegisterFile demonstrates the loading and display of a TIFF image.

package main

import (
	"github.com/jacobfederer/gofpdf"
	"github.com/jacobfederer/gofpdf/contrib/tiff"
	"github.com/jacobfederer/gofpdf/internal/example"
)

func main() {
	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

func RegisterReader

func RegisterReader(fpdf *gofpdf.Fpdf, imgName string, options gofpdf.ImageOptions, r io.Reader) (info *gofpdf.ImageInfoType)

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL