mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-09 19:29:34 +08:00
Set context when adding a page directly in creator
This commit is contained in:
parent
914a10a49b
commit
9e755691ff
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user