Gofpdi with gofpdf import multi orientation page #317
Comments
Any remarks, @phpdave11? |
@ariefdfaltah within the PDF specification, there is no concept of "portrait" or "landscape". Instead, you define one or more page boxes (MediaBox, TrimBox, etc.) with your desired page size. If you want to embed multiple pages of a PDF that have different sizes, then you should call the GetPageSizes() function to determine the width and height of each page in the PDF document. You can use the returned values to scale each page while preserving the aspect ratio. Example: package main
import (
"github.com/davecgh/go-spew/spew"
fpdi "github.com/phpdave11/gofpdi"
)
func main() {
importer := fpdi.NewImporter()
importer.SetSourceFile("example.pdf")
pageSizes := importer.GetPageSizes()
spew.Dump(pageSizes)
} Output:
|
@phpdave11 the following document I use in my case example. In the OUTPUT.pdf document of each landscape page, the template is dragged and the position does not match the SOURCE.pdf document. I attach the code that I used
|
I have the problem. My source PDF has portrait and landscape pages, when i import the source in my new pdf, the landscape pages get croped in width and get an added whitespace. It looks like the source-page get "screenshot" with a portrait mask
|
Based on this page https://github.com/jung-kurt/gofpdf/blob/master/contrib/gofpdi/gofpdi_test.go currently I have document with multiple orientation page. Legal page with portrait orientation and legal page with landscape orientation. After run code, unfortunately all of pages become legal portrait orientation. Some of content inside pages become stretch too.
Thanks!
The text was updated successfully, but these errors were encountered: