diff options
| author | Kurt <kurt.w.jung@gmail.com> | 2019-08-12 10:52:36 -0400 | 
|---|---|---|
| committer | Kurt <kurt.w.jung@gmail.com> | 2019-08-12 10:52:36 -0400 | 
| commit | befc80ff5b4799b1212f5db486aecd695d57e769 (patch) | |
| tree | e841d2187b63a8179cebe91ffd8f09d72f9e70f8 /contrib | |
| parent | a9a0e5d100759b0563d809ea80eae2c33cc4599a (diff) | |
| parent | fdac35522f22a910970fc07bd6922f4f53ba6642 (diff) | |
Merge branch 'mrtsbt-update-contrib-gofpdi'
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/gofpdi/gofpdi.go | 25 | 
1 files changed, 25 insertions, 0 deletions
| diff --git a/contrib/gofpdi/gofpdi.go b/contrib/gofpdi/gofpdi.go index b951ea3..e600fb1 100644 --- a/contrib/gofpdi/gofpdi.go +++ b/contrib/gofpdi/gofpdi.go @@ -2,6 +2,7 @@ package gofpdi  import (  	realgofpdi "github.com/phpdave11/gofpdi" +	"io"  )  // Create new gofpdi instance @@ -23,7 +24,22 @@ type gofpdiPdf interface {  func ImportPage(f gofpdiPdf, sourceFile string, pageno int, box string) int {  	// Set source file for fpdi  	fpdi.SetSourceFile(sourceFile) +	// return template id +	return getTemplateID(f, pageno, box) +} + +// ImportPageFromStream imports a page of a PDF with the specified box +// (/MediaBox, TrimBox, /ArtBox, /CropBox, or /BleedBox). Returns a template id +// that can be used with UseImportedTemplate to draw the template onto the +// page. +func ImportPageFromStream(f gofpdiPdf, rs *io.ReadSeeker, pageno int, box string) int { +	// Set source stream for fpdi +	fpdi.SetSourceStream(rs) +	// return template id +	return getTemplateID(f, pageno, box) +} +func getTemplateID(f gofpdiPdf, pageno int, box string) int {  	// Import page  	tpl := fpdi.ImportPage(pageno, box) @@ -61,3 +77,12 @@ func UseImportedTemplate(f gofpdiPdf, tplid int, x float64, y float64, w float64  	f.UseImportedTemplate(tplName, scaleX, scaleY, tX, tY)  } + +// GetPageSizes returns page dimensions for all pages of the imported pdf. +// Result consists of map[<page number>]map[<box>]map[<dimension>]<value>. +// <page number>: page number, note that page numbers start at 1 +// <box>: box identifier, e.g. "/MediaBox" +// <dimension>: dimension string, either "w" or "h" +func GetPageSizes() map[int]map[string]map[string]float64 { +	return fpdi.GetPageSizes() +} | 
