iPhone 本地制作的 AirPrint HTML 文件
我目前正在创建一个 html 文件并将其存储在本地,我让用户选择通过 HTML 发送 html 或打印。
由于某种原因,它无法打印。如果我测试 -
if([UIPrintInteractionController canPrintData:myData]){
它不会超过这一点。
是否可以打印本地 HTML 文件,如果可以的话,该怎么做。
Dan
编辑代码来创建 html -
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *Daily = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.html",self.title]];
[urlToLoad writeToFile:Daily atomically:YES encoding:NSUTF8StringEncoding error:NULL];
NSString *fileName = [NSString stringWithFormat:@"%@/%@.html", documentsDirectory,self.title];
NSData *myData = [NSData dataWithContentsOfFile:fileName];
I am currently creating a html file and storing it locally, i give the user the choice of sending the html by HTML or print.
For some reason it is failing to print. if i test -
if([UIPrintInteractionController canPrintData:myData]){
it doesn't get past this point.
Is it possible to print local HTML files if so how to go about it.
Dan
edit code to create html -
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *Daily = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.html",self.title]];
[urlToLoad writeToFile:Daily atomically:YES encoding:NSUTF8StringEncoding error:NULL];
NSString *fileName = [NSString stringWithFormat:@"%@/%@.html", documentsDirectory,self.title];
NSData *myData = [NSData dataWithContentsOfFile:fileName];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[UIPrintInteractionController canPrintData:]
期望数据包含格式正确的 PDF 数据,而不是 HTML。尝试这样做:
[UIPrintInteractionController canPrintData:]
is expecting the data to contain properly formatted PDF data, not HTML.Try doing this instead: