Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法打开由Puppeter创建的pdf_Pdf_Puppeteer_Nestjs - Fatal编程技术网

无法打开由Puppeter创建的pdf

无法打开由Puppeter创建的pdf,pdf,puppeteer,nestjs,Pdf,Puppeteer,Nestjs,我正在尝试使用nestjs服务器上的Puppeter从html内容(包括希伯来文字符)生成pdf。我正在使用xhr通过浏览器将输出下载到文件中,但pdf阅读器(如chrome和Adobe Acrobat Reader)无法打开该文件。联机pdf验证工具表明该文件不是pdf/不是有效的pdf 我不是pdf专家,但从pdf结构的快速查看来看,我觉得它很好。有趣的是,我尝试传递不同的htmls,大小差别很大,我看到page.pdf()中出现了相同的缓冲区大小。我的猜测是,它指示了一些异常,但我的代码没

我正在尝试使用nestjs服务器上的Puppeter从html内容(包括希伯来文字符)生成pdf。我正在使用xhr通过浏览器将输出下载到文件中,但pdf阅读器(如chrome和Adobe Acrobat Reader)无法打开该文件。联机pdf验证工具表明该文件不是pdf/不是有效的pdf

我不是pdf专家,但从pdf结构的快速查看来看,我觉得它很好。有趣的是,我尝试传递不同的htmls,大小差别很大,我看到page.pdf()中出现了相同的缓冲区大小。我的猜测是,它指示了一些异常,但我的代码没有捕获任何内容。我怀疑这是一个大小限制,因为我的html非常小。另一件奇怪的事情是,我在容器上记录的缓冲区大小与pdf本身上与主流对象相关的第一个长度值之间存在明显的差异

怎么了

控制器:

@Post('/html-to-pdf')
异步htmlToPdf(@Res()响应:ServerResponse,@Body()体:HtmlToPdfRequestDto):承诺
测试商户
12345678
:ח.פ / ע.מ
0666111
:מספר מסוף

פרטי העסקה אשראי :אמצעי תשלום 12/05/2021, 08:48 :תאריך ושעה 5.00₪ :סכום

示例运行-服务上的标准输出:

[0520/114227.248497:ERROR:bus.cc(393)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
DevTools listening on ws://127.0.0.1:41193/devtools/browser/2350c17e-1df8-4400-a7c9-ccbe93daa3c4
Browser opened
[0520/114227.280590:WARNING:gpu_process_host.cc(1296)] The GPU process has crashed 1 time(s)
[0520/114227.308320:WARNING:gpu_process_host.cc(1296)] The GPU process has crashed 2 time(s)
[0520/114227.324496:WARNING:gpu_process_host.cc(1296)] The GPU process has crashed 3 time(s)
[0520/114227.333756:ERROR:gpu_init.cc(426)] Passthrough is not supported, GL is disabled
[0520/114227.344721:WARNING:gpu_process_host.cc(1016)] Reinitialized the GPU process after a crash. The reported initialization time was 0 ms
Page opened
Created pdf | Length: 6188
Closing browser
示例运行-将xhr.response记录到控制台:

%PDF-1.4
%����
1 0 obj
<</Creator (Chromium)
/Producer (Skia/PDF m90)
/CreationDate (D:20210520114320+00'00')
/ModDate (D:20210520114320+00'00')>>
endobj
3 0 obj
<</ca 1
/BM /Normal>>
endobj
5 0 obj
<</Filter /FlateDecode
/Length 149>> stream
-----   unprintable binary stream characters   -----
endstream
endobj
2 0 obj
<</Type /Page
/Resources <</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/ExtGState <</G3 3 0 R>>
/Font <</F4 4 0 R>>>>
/MediaBox [0 0 612 792]
/Contents 5 0 R
/StructParents 0
/Parent 6 0 R>>
endobj
6 0 obj
<</Type /Pages
/Count 1
/Kids [2 0 R]>>
endobj
7 0 obj
<</Type /Catalog
/Pages 6 0 R>>
endobj
8 0 obj
<</Length1 6464
/Filter /FlateDecode
/Length 4084>> stream
-----   unprintable binary stream characters   -----
endstream
endobj
9 0 obj
<</Type /FontDescriptor
/FontName /LiberationSerif
/Flags 4
/Ascent 891.11328
/Descent -216.30859
/StemV 68.847656
/CapHeight 654.78516
/ItalicAngle 0
/FontBBox [-176.75781 -303.22266 1006.83594 981.44531]
/FontFile2 8 0 R>>
endobj
10 0 obj
<</Type /Font
/FontDescriptor 9 0 R
/BaseFont /LiberationSerif
/Subtype /CIDFontType2
/CIDToGIDMap /Identity
/CIDSystemInfo <</Registry (Adobe)
/Ordering (Identity)
/Supplement 0>>
/W [0 [365.23438] 71 [500 443.84766 333.00781 0 0 277.83203] 81 88 500]
/DW 0>>
endobj
11 0 obj
<</Filter /FlateDecode
/Length 256>> stream
-----   unprintable binary stream characters   -----
endstream
endobj
4 0 obj
<</Type /Font
/Subtype /Type0
/BaseFont /LiberationSerif
/Encoding /Identity-H
/DescendantFonts [10 0 R]
/ToUnicode 11 0 R>>
endobj
xref
0 12
0000000000 65535 f 
0000000015 00000 n 
0000000410 00000 n 
0000000154 00000 n 
0000005733 00000 n 
0000000191 00000 n 
0000000618 00000 n 
0000000673 00000 n 
0000000720 00000 n 
0000004889 00000 n 
0000005129 00000 n 
0000005406 00000 n 
trailer
<</Size 12
/Root 7 0 R
/Info 1 0 R>>
startxref
5873
%%EOF
%PDF-1.4
%����
10 obj
endobj
30 obj
endobj
50 obj
流动
-----不可打印的二进制流字符-----
尾流
endobj
20 obj
endobj
60 obj
endobj
70 obj
endobj
80 obj
流动
-----不可打印的二进制流字符-----
尾流
endobj
9.0 obj
endobj
10 0 obj
endobj
110 obj
流动
-----不可打印的二进制流字符-----
尾流
endobj
40 obj
endobj
外部参照
0 12
0000000000 65535 f
00000000150万元
0000000 41000000N
0000000 154 00000 n
0000005733000000N
0000000191000000N
0000000 618 00000n
0000000 673 00000N
0000000 720 00000 n
000000488900000N
0000005129000000N
000000 5406 00000 n
拖车
起始外部参照
5873
%%EOF
%PDF-1.4
%����
1 0 obj
<</Creator (Chromium)
/Producer (Skia/PDF m90)
/CreationDate (D:20210520114320+00'00')
/ModDate (D:20210520114320+00'00')>>
endobj
3 0 obj
<</ca 1
/BM /Normal>>
endobj
5 0 obj
<</Filter /FlateDecode
/Length 149>> stream
-----   unprintable binary stream characters   -----
endstream
endobj
2 0 obj
<</Type /Page
/Resources <</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
/ExtGState <</G3 3 0 R>>
/Font <</F4 4 0 R>>>>
/MediaBox [0 0 612 792]
/Contents 5 0 R
/StructParents 0
/Parent 6 0 R>>
endobj
6 0 obj
<</Type /Pages
/Count 1
/Kids [2 0 R]>>
endobj
7 0 obj
<</Type /Catalog
/Pages 6 0 R>>
endobj
8 0 obj
<</Length1 6464
/Filter /FlateDecode
/Length 4084>> stream
-----   unprintable binary stream characters   -----
endstream
endobj
9 0 obj
<</Type /FontDescriptor
/FontName /LiberationSerif
/Flags 4
/Ascent 891.11328
/Descent -216.30859
/StemV 68.847656
/CapHeight 654.78516
/ItalicAngle 0
/FontBBox [-176.75781 -303.22266 1006.83594 981.44531]
/FontFile2 8 0 R>>
endobj
10 0 obj
<</Type /Font
/FontDescriptor 9 0 R
/BaseFont /LiberationSerif
/Subtype /CIDFontType2
/CIDToGIDMap /Identity
/CIDSystemInfo <</Registry (Adobe)
/Ordering (Identity)
/Supplement 0>>
/W [0 [365.23438] 71 [500 443.84766 333.00781 0 0 277.83203] 81 88 500]
/DW 0>>
endobj
11 0 obj
<</Filter /FlateDecode
/Length 256>> stream
-----   unprintable binary stream characters   -----
endstream
endobj
4 0 obj
<</Type /Font
/Subtype /Type0
/BaseFont /LiberationSerif
/Encoding /Identity-H
/DescendantFonts [10 0 R]
/ToUnicode 11 0 R>>
endobj
xref
0 12
0000000000 65535 f 
0000000015 00000 n 
0000000410 00000 n 
0000000154 00000 n 
0000005733 00000 n 
0000000191 00000 n 
0000000618 00000 n 
0000000673 00000 n 
0000000720 00000 n 
0000004889 00000 n 
0000005129 00000 n 
0000005406 00000 n 
trailer
<</Size 12
/Root 7 0 R
/Info 1 0 R>>
startxref
5873
%%EOF