PDFGenerator icon indicating copy to clipboard operation
PDFGenerator copied to clipboard

ScrollView Content Disappears

Open NolanRegier opened this issue 9 years ago • 9 comments

Hello there, I have an issue that after I render a scrollView to PDF the buttons on my tool bar are not usable and if the device is rotated then the scrollview content disappears off screen. I have tried many methods to stop this and no luck so far. Please advise how I can resume the view to the original state after PDF generation? Thank you for your help.

NolanRegier avatar Oct 10 '16 17:10 NolanRegier

Any Help? I'm getting the same issue.

jeremiasdsa avatar Apr 03 '17 17:04 jeremiasdsa

Any update on this?

chriswill0w avatar Apr 24 '17 20:04 chriswill0w

Hi @ltblueberry0 , I got a work around.

1-Create a xib looking like your scrollview. But without scrollview :) 2-genereate a pdf using your xib.

jeremiasdsa avatar Apr 24 '17 21:04 jeremiasdsa

@jeremiasdsa Thank you for the quick reply! Did you also figure out how to create a multi-page PDF from a UIScrollView?

chriswill0w avatar Apr 24 '17 21:04 chriswill0w

@ltblueberry0 I did something like that:

on my xib file I got 2 views. Now you can use let page1 = PDFPage.View(view1) let page2 = PDFPage.View(view2) let pages = [page1, page2, ... ] and use pages to generate your PDF multi-page

pdf2

So, now you are using a View( xib [view1,view2] ) that is not showing on your screen, and it wont messing you scrollview. hope you can get the idea :)

jeremiasdsa avatar Apr 24 '17 21:04 jeremiasdsa

@jeremiasdsa what do u mean by creating a new xib looking like your scrollview, I am new to iOS can you please elaborate, I mean I have my scrollview present and there are some components in that, you mean to say we have to copy that content to new xib file, how to do that?

kikukiran avatar Apr 24 '18 11:04 kikukiran

@kikukiran I just had to create Xib file with my views, without scroll. Also I didn't display this xib, I just use it fo fill up with some labels/images... (same info I've got on my scroll). So, I just generated a pdf from my xib that represents a copy of my view, but as I mentioned without scroll.

jeremiasdsa avatar Apr 28 '18 00:04 jeremiasdsa

a simple solution is to add:

override func viewDidAppear(_ animated: Bool) {
       super.viewDidAppear(animated)
       scrollView.translatesAutoresizingMaskIntoConstraints = true
    
}

to your view controller after taking layout from your scrollView

MohamedElsayedTryvin avatar May 17 '20 13:05 MohamedElsayedTryvin

Before generating the PDF file, we need to set the ScrollView's frame. That's the problem, you just need to set the ScrollView's frame equal to its own frame, and you can solve the problem. If you have other questions, you can add my wechat account: coobjc

ZYiDa avatar Dec 08 '20 07:12 ZYiDa