PDFGenerator icon indicating copy to clipboard operation
PDFGenerator copied to clipboard

UIView moves after rendering pdf

Open Oscar053 opened this issue 7 years ago • 6 comments

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

Oscar053 avatar Nov 15 '17 22:11 Oscar053

Found any solution for this ? @Oscar053

n1tesh avatar May 03 '18 06:05 n1tesh

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

Oscar053 avatar May 03 '18 06:05 Oscar053

how to share pdf file from UIwebview?

FarisAlbalawi avatar May 14 '18 00:05 FarisAlbalawi

i have this issue too

rursache avatar Aug 16 '18 11:08 rursache

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.

timgerdes93 avatar Jan 17 '20 10:01 timgerdes93

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

Saurabh-vegans avatar Jun 03 '21 04:06 Saurabh-vegans