Set context when adding a page directly in creator

This commit is contained in:
Gunnsteinn Hall 2017-07-12 15:47:22 +00:00
parent 914a10a49b
commit 9e755691ff
2 changed files with 15 additions and 2 deletions

View File

@ -161,8 +161,21 @@ func (c *Creator) NewPage() {
c.pages = append(c.pages, page)
}
func (c *Creator) AddPage(page *model.PdfPage) {
func (c *Creator) AddPage(page *model.PdfPage) error {
mbox, err := page.GetMediaBox()
if err != nil {
common.Log.Debug("Failed to get page mediabox: %v", err)
return err
}
c.context.X = mbox.Llx + c.pageMargins.left
c.context.Y = c.pageMargins.top
c.context.PageHeight = mbox.Ury - mbox.Lly
c.context.PageWidth = mbox.Urx - mbox.Llx
c.pages = append(c.pages, page)
return nil
}
// Call before writing out. Takes care of adding headers and footers, as well as generating front Page and

View File

@ -931,7 +931,7 @@ func makeQrCodeImage(text string, width float64, oversampling int) (goimage.Imag
return nil, err
}
pixelWidth := 5 * int(math.Ceil(width))
pixelWidth := oversampling * int(math.Ceil(width))
qrCode, err = barcode.Scale(qrCode, pixelWidth, pixelWidth)
if err != nil {
return nil, err