Здравствуйте. Мне в ajax приходит содержимое pdf файла. В строковую переменную, как правильно его можно отобразить в iframe. А то, что-то никак не могу осилить эту задачу.
const blob = new Blob( [ data ], { type: 'application/pdf' } );
iframe.src = `data:application/pdf;charset=utf-8;base64,${ btoa(unescape(encodeURIComponent(data))) }`;
%PDF-1.3
3 0 obj
<</Type /Page
/Parent 1 0 R
/Resources 2 0 R
/MediaBox [0 0 595.28 841.89]
/Contents 4 0 R
>>
endobj
4 0 obj
<</Length 72>>
stream
0.57 w
0 G
BT
/F1 16 Tf
18.4 TL
0 g
28.35 813.54 Td
(Hello world!) Tj
ET
endstream
endobj
1 0 obj
<</Type /Pages
/Kids [3 0 R ]
/Count 1
>>
endobj
5 0 obj
<</BaseFont/Helvetica/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
6 0 obj
<</BaseFont/Helvetica-Bold/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
7 0 obj
<</BaseFont/Helvetica-Oblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
8 0 obj
<</BaseFont/Helvetica-BoldOblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
9 0 obj
<</BaseFont/Courier/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
10 0 obj
<</BaseFont/Courier-Bold/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
11 0 obj
<</BaseFont/Courier-Oblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
12 0 obj
<</BaseFont/Courier-BoldOblique/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
13 0 obj
<</BaseFont/Times-Roman/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
14 0 obj
<</BaseFont/Times-Bold/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
15 0 obj
<</BaseFont/Times-Italic/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
16 0 obj
<</BaseFont/Times-BoldItalic/Type/Font
/Encoding/WinAnsiEncoding
/Subtype/Type1>>
endobj
17 0 obj
<</BaseFont/ZapfDingbats/Type/Font
/Encoding/StandardEncoding
/Subtype/Type1>>
endobj
2 0 obj
<<
/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/Font <<
/F1 5 0 R
/F2 6 0 R
/F3 7 0 R
/F4 8 0 R
/F5 9 0 R
/F6 10 0 R
/F7 11 0 R
/F8 12 0 R
/F9 13 0 R
/F10 14 0 R
/F11 15 0 R
/F12 16 0 R
/F13 17 0 R
>>
/XObject <<
>>
>>
endobj
18 0 obj
<<
/Producer (jsPDF 1.x-master)
/CreationDate (D:20170806115131+03'00')
>>
endobj
19 0 obj
<<
/Type /Catalog
/Pages 1 0 R
/OpenAction [3 0 R /FitH null]
/PageLayout /OneColumn
>>
endobj
xref
0 20
0000000000 65535 f
0000000238 00000 n
0000001532 00000 n
0000000009 00000 n
0000000118 00000 n
0000000295 00000 n
0000000385 00000 n
0000000480 00000 n
0000000578 00000 n
0000000680 00000 n
0000000768 00000 n
0000000862 00000 n
0000000959 00000 n
0000001060 00000 n
0000001153 00000 n
0000001245 00000 n
0000001339 00000 n
0000001437 00000 n
0000001768 00000 n
0000001859 00000 n
trailer
<<
/Size 20
/Root 19 0 R
/Info 18 0 R
>>
startxref
1963
%%EOF