Questions tagged [uiprintformatter]

UIPrintFormatter is an abstract base class for print formatters: objects that lay out custom printable content that can cross page boundaries. Given a print formatter, the printing system can automate the printing of the type of content associated with the print formatter.

Examples of such content could be a web view, a mix of images and text, or a long text document. The UIKit framework provides several concrete subclasses of UIPrintFormatter: UISimpleTextPrintFormatter, UIMarkupTextPrintFormatter, and UIViewPrintFormatter.

You can assign a single print formatter for a print job via the printFormatter property of the UIPrintInteractionController shared instance; or you can specify one or more print formatters that are associated with specific pages of a page renderer through the addPrintFormatter:startingAtPageAtIndex:method of UIPrintPageRenderer. A page renderer is an instance of a custom subclass of UIPrintPageRenderer that draws content for printing.

UIPrintFormatter publishes an interface that allows you to specify the starting page for a print job and the margins around the printed content; given that information plus the content, a print formatter computes the number of pages for the print job.

Source

21 questions
14
votes
3 answers

Unexpected page breaks when printing UIWebView

TLDR: If you print UIWebView which contains HTML content consisting of elements with text aligned right / center, resulting document will have pages with unexpectedly large bottom margins. I came across this issue, and was quite surprised when I…
Jakub Vano
  • 3,833
  • 15
  • 29
7
votes
2 answers

UIMarkupTextPrintFormatter never renders base64 images

Im creating a pdf file out of html content in swift 3.0: /** * */ func exportHtmlContentToPDF(HTMLContent: String, filePath: String) { // let webView = UIWebView(frame: CGRect(x: 0, y: 0, width: 694, height: 603)); //…
Mulgard
  • 9,877
  • 34
  • 129
  • 232
6
votes
1 answer

Printing PDF file that's displayed in a WKWebView

I’m trying to print from a WKWebView. Webpages and images are working fine. Only when I print a PDF file the pages are all blank. This is the code I've used to create a printController: let printController =…
user5087998
5
votes
2 answers

UIPrintInteractionController borderless printing

I am working on the iPhone app using print image concept using UIPrintInteractionController. I have stuck at one point i.e. border, whenever I tried to print any image using printer it always show border on all sides which is not required. Image…
5
votes
2 answers

AirPrint contents of a UIView

I'm trying to set up printing through an iPad app, where clicking Print will print a view with all of its contents. Here's what I've tried (pulled together from a few examples online): // This is the View I want to print // Just a 200x200 blue…
Jody Heavener
  • 2,704
  • 5
  • 41
  • 70
3
votes
1 answer

UIPrintPageRenderer how to switch between US-Letter and DIN-A4 format

I tried to implement a custom PDF-Renderer, inherited from UIPrintPageRenderer. My problem ist that the output-size of the PDF is 215,9 x 279,4 mm. But the correct DIN A4 dimensions i need are 210 x 297 mm. Obviously im getting the size of a…
Joel
  • 396
  • 1
  • 15
2
votes
0 answers

How can I get rid of page margins using UIPrintInteractionController for Airprint

I am trying to AirPrint a UIImage using UIPrintInteractionController this code works successfully except a margin is added to the print preview which is not desirable for me. how can I customize the left, right , top & bottom margins to zero or…
EhsanR
  • 467
  • 7
  • 17
2
votes
0 answers

AirPrint UIWebView content in iOS8

I am trying to AirPrint the contents of my UIWebView (iOS8.1) and am getting an exception with no detail as to what the problem is. If I toggle "Global Breakpoint State" to OFF in Xcode 6.1 then it occasionally prints, although sometimes the page is…
2
votes
3 answers

UIPrintInteractionController not printing to full page in iPhone

I am printing a pdf from iPhone to Airprint compatible printer using Apple print document example. But I am not getting full page print from iPhone, please see the picture of what I am getting, I need the pdf to be printed on full paper…
2
votes
2 answers

Offscreen iOS 6 MKMapViews and UIViewPrintFormatter — getting them to render in time?

I'm interested in printing some MKMapViews that are not part of the view hierarchy, and are created only when the user hits Print. It seems that the following things are true: Offscreen MKMapViews do not render at all. Printing a MKMapView prints…
Amy Worrall
  • 16,250
  • 3
  • 42
  • 65
1
vote
0 answers

Remaining page rect after UIViewPrintFormatter added to UIPrintPageRenderer

I'm using an instance of a UIPrintPageRenderer subclass to print many records, each of which is included by adding a UIViewPrintFormatter generated by a myTextView.viewPrintFormatter(). Some of the records occupy much less than a page, so I'd like…
Son of a Beach
  • 1,733
  • 1
  • 11
  • 29
1
vote
0 answers

iOS print NSAttributedString with images as NSTextAttachement to PDF

I'm trying to convert the content of an UITextView to PDF. The UITextView uses an NSAttributedString that contains text and images. The images are instances of NSTextAttachment. I went through the UIPrintPageRenderer way passing the UIPrintFormatter…
1
vote
5 answers

Why are printf not working properly in Java? JAVA

I am getting this type of error in my eclipse software : Question Why do I get an error? code : package loops; public class Escapey { public static void main(String[] args) { String name ="micheal"; …
Micheal
  • 11
  • 4
1
vote
2 answers

Printing Contents of Multiple UIWebViews in one go

I have an iPad application that uses WebViews to display a list of URL's. I would like to be able to print all of the WebViews in one go, without prompting the user multiple times with the PrintInteractionController. The problem is that the…
1
vote
1 answer

How to print an UIImage with scale to page for UIPrintInfo in Swift 3?

I have an UIView with subviews like below mentioned image. Here I have to print or share marked - view. For Sharing, I convert the marked UIView to PDF and share it in Email. It is working Perfectly what my client expected. For Printing, I convert…
1
2