在iphone或ipad上打印PDF文件 [英] Print PDF file on iphone or ipad
问题描述
我将一个文件附加到我正在使用此代码的邮件中。
I attached a file to the mail I am using this code.
[mail addAttachmentData:[myView PDFData] mimeType:@"application/pdf" fileName:@"name.pdf"];
我怎样才能打印文件,我需要打印[myView PDFData] 。
How can I do the same thing for printing a file, I need to print this [myView PDFData].
我发现只有这个用于打印:
I found only this for printing:
NSString *PDFFileWithName = [[NSBundle mainBundle] pathForResource:@"name" ofType:@"pdf"];
NSData *dataFromPath = [NSData dataWithContentsOfFile:PDFFileWithName];
谢谢
推荐答案
您应该通读适用于iOS的绘图和打印指南。 printingItem 属性#// apple_ref / occ / instp / UIPrintInteractionController / printingItemrel =noreferrer> UIPrintInteractionController
可以设置为 NSData
的PDF。
You should read through the Drawing and Printing Guide for iOS. The printingItem
property of UIPrintInteractionController
can be set to the NSData
of a PDF.
添加代码的更新
dataFromPath的值应该等于[myView PDFData],虽然我建议在变量名称工作后更改变量名称。
The value of dataFromPath should be equal to [myView PDFData] although I would recommend changing the variable name once you get it working.
NSData *dataFromPath = [myView PDFData];
这篇关于在iphone或ipad上打印PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!