chikos
chikos

Reputation: 9

parse pdf file and conversion

i try to edit pdf file and generate other pdf file. the problem that this conversion not work. it mean i can save pdf file in the document but it is empty file

aData = [str dataUsingEncoding:NSUTF8StringEncoding];

NSArray *documentPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

// This should be our documents directory
NSString *saveDirectory = [documentPath objectAtIndex:0];

NSString *str=[self convertNsdataToString:nsdata];


//str = [str stringByReplacingOccurrencesOfString:@"<<" withString:@"chikos"];
NSData* aData;
aData = [str dataUsingEncoding:NSUTF8StringEncoding];

//writing the pdf converted in the memory at path

NSString *saveDirectory2 = [saveDirectory stringByAppendingPathComponent:@"Test.pdf"] ;
[aData writeToFile:saveDirectory2 atomically:YES];

Upvotes: 0

Views: 248

Answers (1)

mark stephens
mark stephens

Reputation: 3184

You can't just do a search and replace on text data in a PDF file. It is not structured like that. You need to parse the content streams (which can be compressed/encrypted) to see what s going on.

Upvotes: 2

Related Questions