sgr-ksmt / PDFGenerator

A simple generator of PDF written in Swift.
MIT License
755 stars 110 forks source link

UIView moves after rendering pdf #88

Open Oscar053 opened 6 years ago

Oscar053 commented 6 years ago

After I execute rendering code on my UIView, this view itself moves to (0,0) from (centerX,centerY). Code is executed on an IBAction, button pressed.

pdf = renderFPL()

func renderFPL() -> Data?{
        let v1 = self.fplContainer!   
        let dst = URL(fileURLWithPath: NSTemporaryDirectory().appending("sample1.pdf"))
        do {
            let data = try PDFGenerator.generated(by: [v1])
            try data.write(to: dst, options: .atomic)       
            return data
        } catch (let error) {
            print(error)
        }
        return nil
 }

before after

n1tesh commented 6 years ago

Found any solution for this ? @Oscar053

Oscar053 commented 6 years ago

The solution was to set constraints by code after the rendering. It's a workaround but it works.

FarisAlbalawi commented 6 years ago

how to share pdf file from UIwebview?

rursache commented 6 years ago

i have this issue too

timgerdes93 commented 4 years ago

Hey, in case it's still needed I was able to solve that problem. I put in '.translatesAutoresizingMaskIntoConstraints = true' and that fixed it for me. Everything stays in its position.

Saurabh-vegans commented 3 years ago

Hey, in case it's still needed I was able to solve that problem. I put in '.translatesAutoresizingMaskIntoConstraints = true' and that fixed it for me. Everything stays in its position.

It helped somewhat but not 100%. thanks