Open Pdf In Iframe Passing Byte Data Types
I'm trying to load document using pdfJS and passing data instead of url. The data is the response of $http.get(PATH_TO_PDF_FILE) and its look like that -
See More On Stackoverflow
I have a byte array with the contents of a PDF document open in memory. Does anyone know a way to open this document from memory without saving it to disk first? Join a community of over 2.6m developers to have your questions answered on Best way to display a PDF from base64-string of Telerik AppBuilder discussion General Discussion. Start with our free trials. Doing so opens a popup window in which the PDF should automatically open. Now the PDF itself is coming out of an SQL database and is stored in a byte array. And I'm able to get the data just fine, only problem is instead of PDF opening in the window, I get the open/save dialog and then selecting open, opens the PDF in acrobat, not the browser window.
pdfFileFromAjaxResponse =
'
%PDF-1.3 1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj 2 0 obj << /Type /Pages /Kids [3 0 R 7 0 R 11 0 R 15 0 R 19 0 R 23 0 R 27 0 R 31 0 R 35 0 R 39 0 R 43 0 R 47 0 R 51 0 R 55 0 R 59 0 R 63 0 R 67 0 R 71 0 R 75 0 R 79 0 R 83 0 R 87 0 R 91 0 R 95 0 R ] /Count 24
endobj 3 0 obj << /Type /Page /Parent 2 0 R /MediaBox [ 0 0 599 842] /Resources << /XObject << /Im1 4 0 R /ProcSet [ /PDF /ImageC ] /Contents 5 0 R endobj 4 0 obj << /Type /XObject /Subtype /Image /Filter /CCITTFaxDecode /DecodeParms << /K -1 /Columns 2080>> /Width 2080 /Height 2923 /BitsPerComponent 1 /ColorSpace /DeviceGray /Length 46622 stream ;_§; ðòß¹2'MËH�%¦¶@UË£àÐlàJÖÀÔ7ØØ-ÒHÃ_2CVF·[ÖsH:RÊEÎÕü>쩶ü?ùUîýá¡þÁøò©Ë!{¸È'¯!°·ÿX}�aKy áÂ!°±$ä4«È(+xUÜ;Õ))Ú ©ýHl[»øP°ï�å0KÔaýּáû¿
¡ä6÷_°]õX?!7Î�ÁÞAu%d�ò�]k�òÁVú¼µðC8.ÃÿyrÛZWRÛUô�Ø'#+Ù@ÂئÜB0JC
Ü°)l¥Gdò86°wD.Ó@Èñt�pUb$Ar&¤3ûgQHà^CâöÂÄ4½È5�ØuÙ�;Ì}Î9srG�FÂwnC ì6AØ1 VØÈ ÿÅ°â ÷a rC°Èg,Ûl1K»a Þpí²Ç d7UP¡¶,4F9�§ÝÃìá°H À&Û ÝÆÎ9�: áÁhDqÃD· WÁÃP' .Q¿Ëe(m±!zÁx¶,cÖ7�@É�Dw,¸� Bäq!áD3ìHÈ*d�Aq Ò9�::9TxÈj:q�lR@¹VÄ[épì B$+¤A¹°² cä�)ÃexXîä3»!¦=Úò:`ë Ó8bPáH$c9cÝSÛ ±�Ðb#³ @ÁBîÈHã�ÎÞ ªðØqÂ]8Wl6Æ$ú·Â $íé Ó á3ȸ0D
...
'
When trying to use:
var arrayBufferOfPdfData = pdfFileFromAjaxResponse;
var myData = new Uint8Array(arrayBufferOfPdfData); //put it in a Uint8Array
var docInitParams = {data: myData};
PDFJS.getDocument(docInitParams).then(function(pdf){
//render a page here
});
I get the error and warnning:
'
Error: stream must have data
Warning: Unsupported feature 'unknown'
'
anyone knows how to load it or what am i doing wrong?
Thanks!