Could not find pdf header: '% pdf' not found

I am trying to download pdf content from a webservice endpoint that comes in binary. After decoding in base64, I attach the decoded file to the webview, which could not find the pdf header error.

Does anyone know how I can fix this error? Did I miss any step here?

Thanks.

+8
ios objective-c iphone cocoa ipad
source share
3 answers

Try adding something like

NSData *dataContent; // response data. CFDataRef myPDFData; myPDFData = (CFDataRef)dataContent; CGDataProviderRef provider = CGDataProviderCreateWithCFData(myPDFData); pdfDocument = CGPDFDocumentCreateWithProvider(provider); CGDataProviderRelease(provider); 

Then load pdfDocument into your webview.

or look at creating a custom zoomPDFViewer. Apple has a good example at http://developer.apple.com/library/ios/#samplecode/ZoomingPDFViewer/Introduction/Intro.html , which I did since I could not load the pdfdocument to load correctly in the webview.

+3
source share

I had this error while developing my application that read pdf, the problem is that PDF does not exist where you call it. The returned binary data is a response to an error caused by the web service. For example, if I request a pdf document at:

http: // localhost: 8080 / template / DocumentServlet? documentId = 923447 & JSSESIONID = 77EFJD3IJD8I3MMWW2435353J

if this document does not exist at this address, then I will get an error response, and this is what returns binary data.

+2
source share

here is the solution if you use the SAP web service: in the SAP system there is a way to convert binary data (XSTRING) to Base64: cl_http_utility => encode_x_base64 Using http, you can transmit Base64 data. In xcode, I used this library: link

 // 3) Decode Base 64 // Then you can put that back like this NSData *b64DecData = [Base64 decode:b64EncStr]; 

then [webDisplay loadData:b64DecData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];

0
source share

All Articles