I want to NSLog the content of a PDF that has compressed stream objects which include zeros ('0') in the middle of the stream.
Unfortunately the first occurrence of '0' in the first stream object terminates the output on the console...
Couldn't find anything on SO or in the cloud at all.
Tried it in 4 different ways...
NSString *pdfFilePath = [[NSBundle mainBundle] pathForResource: @"myPDF" ofType: @"pdf"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:pdfFilePath];
NSData *myData = [NSData dataWithContentsOfURL:fileURL];
________________________________________________________________________
//1
NSString *string = [[NSString alloc] initWithData:myData
encoding:NSASCIIStringEncoding];
NSLog(@"%@", string);
________________________________________________________________________
//2
NSString *myDataAsString = [[NSString alloc] initWithData:myData
encoding:NSASCIIStringEncoding];
NSLog(@"%@", myDataAsString);
________________________________________________________________________
//3
NSString *myPDFasString = [NSString stringWithContentsOfURL:fileURL
encoding:NSASCIIStringEncoding error:NULL];
NSLog(@"%@", myPDFasString);
________________________________________________________________________
//4
NSString *stringFromFileAtURL = [[NSString alloc] initWithContentsOfURL:fileURL
encoding:NSASCIIStringEncoding error:NULL];
NSLog(@"%@", stringFromFileAtURL);
OUTPUT on the console for all 4 of them: (of course -- it is always a null-terminated string in the backing-store)
%PDF-1.1
%
1 0 obj <<
/Type /Catalog
/Count 1
/Pages 6 0 R >>
endobj
2 0 obj <<
%%/Type /Stream
/Filter /FlateDecode
/Length 12 >>
stream
x+TT
Here the stream ends because of the '0' after 'x+TT' (which is the beginning of stream object)...
Anyone?