objective c - How to I parse pdf from url to text in ObjectiveC? -


i trying fetch pdf-data url , parse nsstring in ios-app.

libraries fastpdfkit fetches information , displays in new modal viewcontroller not want. should rather loaded , parsed in same viewcontroller.

when trying parse quartz shown here:

https://developer.apple.com/library/mac/documentation/graphicsimaging/conceptual/drawingwithquartz2d/dq_pdf_scan/dq_pdf_scan.html

i don't callback ever though page count 1 should be.

so how can in single viewcontroller? :d

code tried:

static void op_mp (cgpdfscannerref s, void *info) {     const char *name;      if (!cgpdfscannerpopname(s, &name))         return;      printf("mp /%s\n", name); }  static void op_dp (cgpdfscannerref s, void *info) {     const char *name;      if (!cgpdfscannerpopname(s, &name))         return;      printf("mp /%s\n", name); }  static void op_bmc (cgpdfscannerref s, void *info) {     const char *name;      if (!cgpdfscannerpopname(s, &name))         return;      printf("mp /%s\n", name); } static void op_bdc (cgpdfscannerref s, void *info) {     const char *name;      if (!cgpdfscannerpopname(s, &name))         return;      printf("mp /%s\n", name); } static void op_emc (cgpdfscannerref s, void *info) {     const char *name;      if (!cgpdfscannerpopname(s, &name))         return;      printf("mp /%s\n", name); }   - (void)viewdidload {     [super viewdidload];      cgpdfoperatortableref mytable;      mytable = cgpdfoperatortablecreate();      cgpdfoperatortablesetcallback (mytable, "mp", &op_mp);     cgpdfoperatortablesetcallback (mytable, "dp", &op_dp);     cgpdfoperatortablesetcallback (mytable, "bmc", &op_bmc);     cgpdfoperatortablesetcallback (mytable, "bdc", &op_bdc);     cgpdfoperatortablesetcallback (mytable, "emc", &op_emc);      cgpdfdocumentref mydocument;     cfurlref url = cfbundlecopyresourceurl(cfbundlegetmainbundle(), cfstr("lel.pdf"), null, null);      mydocument = cgpdfdocumentcreatewithurl(url);      int k;     cgpdfpageref mypage;     cgpdfscannerref myscanner;     cgpdfcontentstreamref mycontentstream;      int numofpages = cgpdfdocumentgetnumberofpages (mydocument);// 1     nslog(@"%i", numofpages);     (k = 0; k < numofpages; k++) {         mypage = cgpdfdocumentgetpage (mydocument, k + 1 );// 2         mycontentstream = cgpdfcontentstreamcreatewithpage (mypage);// 3         myscanner = cgpdfscannercreate (mycontentstream, mytable, null);// 4         cgpdfscannerscan (myscanner);// 5         cgpdfpagerelease (mypage);// 6         cgpdfscannerrelease (myscanner);// 7         cgpdfcontentstreamrelease (mycontentstream);// 8     }     cgpdfoperatortablerelease(mytable);  } 

when trying use pdf2iphone zachron error:

http://gyazo.com/52c87cc88a397a64cdbb015113c201c6

viewcontroller.m:

#import "jonviewcontroller.h" #import "pdf.h"  @interface jonviewcontroller ()  @end  @implementation jonviewcontroller  - (void)viewdidload {     [super viewdidload];     // additional setup after loading view, typically nib.     nsurl *path = [[nsbundle mainbundle] urlforresource:@"lel" withextension:@"pdf"];     nsstring *string = [[nsstring alloc] initwithcontentsofurl:path encoding:nsutf8stringencoding error:nil];     nsstring *pdfstring = convertpdf(string);     nslog(@"%@", pdfstring); } 

the pdfiphone code worked me: https://github.com/zachron/pdfiphone

it parse pdf , return nsstring converpdf method.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -