IOS Uiprintinteractioncontroller Printing

Source: Internet
Author: User

-(void) Printdata

{

Prepare for printing, create a reference to Sharedprintcontroller

Uiprintinteractioncontroller *printer = [Uiprintinteractioncontroller Sharedprintcontroller];

Printer.delegate = self;

Configure printing information

Uiprintinfo *pinfo = [Uiprintinfo printinfo];

Pinfo.outputtype = uiprintinfooutputgeneral;//printable text, graphics, images

Pinfo.jobname = @ "Print for Xiaodui";//optional attribute for identifying print jobs in the print center

Pinfo.duplex = uiprintinfoduplexlongedge;//Double-sided printing around the long side of the page, none to prohibit double-sided

Pinfo.orientation = uiprintinfoorientationportrait;//Print portrait or landscape

Pinfo.printerid = @ "";//Specify the default printer, or you can use Uiprintinteractioncontrollerdelegate to know

Printer.printinfo = Pinfo;

Set Page Range

Uisimpletextprintformatter *textformatter = [[Uisimpletextprintformatter alloc] initwithtext:@ "aha hand cream on time haha"];

Textformatter.startpage = 0;//Specifies from which one to start printing 0 for the first one

Textformatter.contentinsets = Uiedgeinsetsmake (36, 36, 36, 36),//72 equals 1 inches, so the margin between the upper and lower left is 0.5 inches

Textformatter.maximumcontentwidth = 504;//(72x7.5) is equivalent to a print width of 7 inches

Printer.printformatter = TextFormatter;

Printer.printingitem = [UIImage imagenamed:@ "Launchimage"];

Printer.printingitems = @[[uiimage imagenamed:@ "Welcome_page2"], [UIImage imagenamed:@ "Launchimage"], [UIImage imagenamed:@ "Welcome_page1"];

Printer.showspagerange = NO;

[Printer Presentanimated:yes completionhandler:^ (Uiprintinteractioncontroller * _nonnull Printinteractioncontroller , BOOL completed, Nserror * _nullable error) {

if (!completed && error) {

NSLog (@ "Error");

}

}];

}

IOS Uiprintinteractioncontroller Printing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.