TPPDF icon indicating copy to clipboard operation
TPPDF copied to clipboard

when export to pdf i got extra one empty page

Open muhammadahmad665 opened this issue 3 years ago • 2 comments

ℹ Please fill out this template when filing an issue. All lines beginning with an ℹ symbol instruct you with what info we expect. You can delete those lines once you've filled in the info.

I am saving images into pdf document

let suppose I have 3 images and add them to the document it should show 3 pages. but what's happing is this I am getting 4 pages with the first page empty.

TPPDF Environment

TPPDF version: 2.3.5 Xcode version: 13.0 Swift version: 4 or above

Demo Code / Project

let document = PDFDocument(format: .a4)
document.add(.footerLeft, textObject: PDFSimpleText(text: "Generated from Pdf Scanner"))
for eachImage in images{
                    let imageElement = PDFImage(image: eachImage)
                    imageElement.sizeFit = .height
                    document.add(.contentCenter ,image: imageElement)
                    // Height should fittppdf
                    
                }
                
                let generator = PDFGenerator(document: document)
                
                let pdfUrl = (try? generator.generateURL(filename: "Example.pdf"))!

muhammadahmad665 avatar Nov 15 '21 07:11 muhammadahmad665

I noticed that you also posted this on stackoverflow. Did you try the suggestions or try to narrow down which image cause the page overflow?

BMinas avatar Dec 28 '21 04:12 BMinas

Hi, thanks for opening up the issue and providing a code example.

Could you please also upload the images, or at least images with the same resolution? I believe this might be a calculation error, therefore this would help to reproduce the image.

(you can also replace the images with single-color ones, but the sizes must match)

philprime avatar Dec 29 '21 13:12 philprime

Closed due to inactivity

philprime avatar Dec 03 '22 14:12 philprime