Print a PDF that is located online only


i'm trying use print pdf online, displayed in webview. here have unsuccessfully tried.

code:
  -(ibaction)print {  	nsstring *urlstring = @"http://www.lagrangecoc.com/meditation.pdf";  	  	nsurl *url = [nsurl urlwithstring:urlstring];  	  	nsdata *file = [nsdata datawithcontentsofurl:url];  	  	nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);  	  	nsstring *documentsdirectory = [paths objectatindex:0];  	  	nsstring *pdfpath = [documentsdirectory stringbyappendingpathcomponent:@"meditation.pdf"];  	  	[file writetofile:pdfpath atomically:yes];  	  	nsstring *path = [[nsbundle mainbundle] pathforresource:pdfpath oftype:@"pdf"];  	nsdata *mydata = [nsdata datawithcontentsoffile:path];  	  	  	uiprintinteractioncontroller *pic = [uiprintinteractioncontroller sharedprintcontroller];  	  	if(pic && [uiprintinteractioncontroller canprintdata: mydata] ) {  		  		pic.delegate = self;  		  		uiprintinfo *printinfo = [uiprintinfo printinfo];  		printinfo.outputtype = uiprintinfooutputgeneral;  		printinfo.jobname = [path lastpathcomponent];  		printinfo.duplex = uiprintinfoduplexlongedge;  		pic.printinfo = printinfo;  		pic.showspagerange = yes;  		pic.printingitem = mydata;  		  		void (^completionhandler)(uiprintinteractioncontroller *, bool, nserror *) = ^(uiprintinteractioncontroller *pic, bool completed, nserror *error) {  			//self.content = nil;  			if (!completed && error) {  				nslog(@"failed! due error in domain %@ error code %u", error.domain, error.code);  			}   		};  		  		[pic presentanimated:yes completionhandler:completionhandler];  		  	}	  	  }
any suggestions? pdf changes regularly, can't load app.
 

i have no specific suggestions based on code (other superficially looks on target), offer general ones based on reading documentation:
  • did implement of uiprintinteractioncontrollerdelegate methods?
    if not, please do, , drop nslog statements them see what's going on.
  • how code compare of sample projects?
 


Forums iPhone, iPad, and iPod Touch iOS Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Mac OS X Server as File Server for 50/50 Mac & PC Workgroup

Permissions Problem?

iPhone won't sync with iTunes