Frequently Asked Question
What is the difference between PDFHttpStream and OpenMem on iOS?
Last Updated 14 days ago 51 views
Applies to: RadaeePDF Classic and Master SDK for iOS
PDFHttpStream opens a remote PDF directly from a network URL with a local disk cache, whereas PDFopenMem: opens a PDF from raw document bytes loaded in a memory buffer.
Assume pdfFullPath is the path to your file and m_pdf is your document instance. Use PDFHttpStream to stream from a URL. Use PDFopenMem: on a document object when you read the file data into a memory buffer.
// For URL streaming
NSString *cachefile = [[NSTemporaryDirectory() stringByAppendingString:@""] stringByAppendingString:@"cache.pdf"];
PDFHttpStream *stream = [[PDFHttpStream alloc] init];
[stream open:@"http://pdf_url" :cachefile];
// For memory buffer
const char *path1 = [pdfFullPath UTF8String];
FILE *file1 = fopen(path1, "rb");
fseek(file1, 0, SEEK_END);
long filesize1 = ftell(file1);
fseek(file1, 0, SEEK_SET);
void *buffer = malloc((filesize1) * sizeof(char));
fread(buffer, filesize1, 1, file1);
fclose(file1);
int result = [m_pdf PDFopenMem:buffer :(int)filesize1 :nil]; Caveat: Documents opened with PDFopenMem: are read-only.