2012-11-09 21 views

回答

2

@NisithSeth:

我建議base64編碼你的字節,幷包括編碼的b ase64字符串在你的xml中。然後,當你解析xml時,你可以base64解碼字符串來獲得一個你可以用來創建PDF的NSData。您可以使用Google找到多個代碼片段,介紹如何在obj-c中進行base64編碼/解碼。

0

您好我想你可以像波紋管PDF轉換成數據,然後嘗試打開它..

NSData *data    = yourData //some NSData 
CFDataRef myPDFData  = (CFDataRef)data; 
CGDataProviderRef provider = CGDataProviderCreateWithCFData(myPDFData); 
CGPDFDocumentRef pdf  = CGPDFDocumentCreateWithProvider(provider); 

更新

爲CGPDFDocument信息,請參閱this link

+0

我必須同時將該PDF存儲到文檔目錄中。從Documents Directory中打開時,我正面臨着此問題。 –

+0

@NishithSheth,隊友看到這個鏈接,用於存儲webview數據爲PDF格式,我認爲這裏在PDF中保存數據有問題,所以這裏pdf不能打開bcoz數據格式無效..我只是假設親愛的..看到這個鏈接它將webview存儲爲PDF http://coderchrismills.wordpress.com/2011/06/25/making-a-pdf-from-a-uiwebview/ –

+0

@NishithSheth wirte pdf像這樣.. NSData * pdfData = [NSData dataWithBytes :[responseData bytes] length:[responseData length]]; [pdfData writeToFile:filePath atomically:YES]; –

相關問題