Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Fixes #1383 & Fixes #1417: Print & PDF option give blank preview (#1432)
Browse files Browse the repository at this point in the history
* Change buildactivity

* Working
  • Loading branch information
oliviabrown9 authored and sblatz committed Oct 18, 2018
1 parent b4dc4b3 commit 4600927
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Blockzilla/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ extension BrowserViewController: URLBarDelegate {
let utils = OpenUtils(url: url, webViewController: webViewController)
let items = PageActionSheetItems(url: url)
let sharePageItem = PhotonActionSheetItem(title: UIConstants.strings.sharePage, iconString: "icon_openwith_active") { action in
let shareVC = utils.buildShareViewController(url: url)
let shareVC = utils.buildShareViewController(url: url, printFormatter: self.webViewController.printFormatter)

// Exact frame dimensions taken from presentPhotonActionSheet
shareVC.popoverPresentationController?.sourceView = urlBar.pageActionsButton
Expand Down
21 changes: 11 additions & 10 deletions Blockzilla/OpenUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ class OpenUtils: NSObject {
self.webViewController = webViewController
}

func buildShareViewController(url: URL) -> UIActivityViewController {
func buildShareViewController(url: URL, printFormatter: UIPrintFormatter?) -> UIActivityViewController {
var activityItems: [Any] = [url]

activityItems.append(self)

let printFormatter = UIPrintFormatter()
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = url.absoluteString
printInfo.outputType = .general
activityItems.append(printInfo)

let renderer = UIPrintPageRenderer()
renderer.addPrintFormatter(printFormatter, startingAtPageAt: 0)
activityItems.append(renderer)
if let printFormatter = printFormatter {
let printInfo = UIPrintInfo(dictionary: nil)
printInfo.jobName = url.absoluteString
printInfo.outputType = .general
activityItems.append(printInfo)

let renderer = UIPrintPageRenderer()
renderer.addPrintFormatter(printFormatter, startingAtPageAt: 0)
activityItems.append(renderer)
}

let shareController = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)

Expand Down

0 comments on commit 4600927

Please sign in to comment.