Print one scrollview without bottom view in swift

Problem:

I want to print the content of scrollview. But  end of scroll view my print button is there.I want to print without that button.How to achieve that.

 Solution:

It's possible.You first hide the button after click print then generate the pdf.After generation of pdf show the button.It will works perfectly.


    func printContent() {

        

        let printInfo = UIPrintInfo(dictionarynil)

        printInfo.jobName = scrollView.description

        printInfo.outputType = .general

        self.scrollView.subviews.last.ishidden = true

        let path = self.scrollView.exportAsPdfFromViews()

        self.scrollView.subviews.last.ishidden = false


        let printController = UIPrintInteractionController.shared

        

        printController.printInfo = printInfo

        printController.printingItem = NSURL(fileURLWithPath:path)

        printController.present(animated: true)

    }

    


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift