如何在HTML / Blade中显示PDF代码(不是文件)
我正在使用 SendCloud 的 API 进行客户运输,该过程的一部分是标签生成。但是,当我尝试生成标签时,它会输出如下所示的 pdf 代码:
%PDF-1.3 1 0 obj << /Type /Pages /Count 1 /Kids [ 3 0 R ] >> endobj 2 0 obj << /Producer (PyPDF2) >> endobj 3 0 obj << /Type /Page /Parent 1 0 R /Resources 5 0 R /Contents 8 0 R /MediaBox [ 0 0 419.53 297.64 ] /Rotate 90 >> endobj 4 0 obj << /Type /Catalog /Pages 1 0 R >> endobj 5 0 obj << /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] /Font << /F1 6 0 R /F2 7 0 R >> /XObject << >> >> endobj 6 0 obj << /Type /Font /BaseFont /Helvetica /Subtype /Type1 /Encoding /WinAnsiEncoding >> endobj 7 0 obj << /Type /Font /BaseFont /Helvetica-Bold /Subtype /Type1 /Encoding /WinAnsiEncoding >> endobj 8 0 obj << /Length 332 >> stream 2 J 0.57 w BT /F1 8.00 Tf ET BT 12.76 274.83 Td (Customer, 20 Address, 3500 Hasselt) Tj ET BT /F1 10.00 Tf ET BT 175.75 175.58 Td (BE Customer Test) Tj ET BT 175.75 162.83 Td (Gaarveldstraat 106) Tj ET BT /F2 10.00 Tf ET BT 175.75 150.07 Td (3500 HASSELT) Tj ET BT /F1 10.00 Tf ET BT 175.75 137.31 Td (Belgium / Belgique) Tj ET endstream endobj xref 0 9 0000000000 65535 f 0000000009 00000 n 0000000068 00000 n 0000000108 00000 n 0000000231 00000 n 0000000280 00000 n 0000000396 00000 n 0000000493 00000 n 0000000595 00000 n trailer << /Size 9 /Root 4 0 R /Info 2 0 R >> startxref 978 %%EOF
有人知道如何使用 html/blade 将其作为可打印图像在网页上显示吗?
I'm using SendCloud's API for my customer's shipping, and part of the process is label generation. However, when I try to generate a label, it spits out pdf code that looks like this:
%PDF-1.3 1 0 obj << /Type /Pages /Count 1 /Kids [ 3 0 R ] >> endobj 2 0 obj << /Producer (PyPDF2) >> endobj 3 0 obj << /Type /Page /Parent 1 0 R /Resources 5 0 R /Contents 8 0 R /MediaBox [ 0 0 419.53 297.64 ] /Rotate 90 >> endobj 4 0 obj << /Type /Catalog /Pages 1 0 R >> endobj 5 0 obj << /ProcSet [ /PDF /Text /ImageB /ImageC /ImageI ] /Font << /F1 6 0 R /F2 7 0 R >> /XObject << >> >> endobj 6 0 obj << /Type /Font /BaseFont /Helvetica /Subtype /Type1 /Encoding /WinAnsiEncoding >> endobj 7 0 obj << /Type /Font /BaseFont /Helvetica-Bold /Subtype /Type1 /Encoding /WinAnsiEncoding >> endobj 8 0 obj << /Length 332 >> stream 2 J 0.57 w BT /F1 8.00 Tf ET BT 12.76 274.83 Td (Customer, 20 Address, 3500 Hasselt) Tj ET BT /F1 10.00 Tf ET BT 175.75 175.58 Td (BE Customer Test) Tj ET BT 175.75 162.83 Td (Gaarveldstraat 106) Tj ET BT /F2 10.00 Tf ET BT 175.75 150.07 Td (3500 HASSELT) Tj ET BT /F1 10.00 Tf ET BT 175.75 137.31 Td (Belgium / Belgique) Tj ET endstream endobj xref 0 9 0000000000 65535 f 0000000009 00000 n 0000000068 00000 n 0000000108 00000 n 0000000231 00000 n 0000000280 00000 n 0000000396 00000 n 0000000493 00000 n 0000000595 00000 n trailer << /Size 9 /Root 4 0 R /Info 2 0 R >> startxref 978 %%EOF
Does anybody know how to display this on a webpage as a printable image with html/ blade?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
传入是带有旋转的PDF,因此不会像标签打印那样显示其正确的显示方式。
因此,您的第一步是使用
pdftopng -Rot 270 shipplesh.pdf Label
,您可以从XPDF或Poppler(其他库),ON上使用pdftopng -Rot 270 shigper.pdf标签
,图像更简单,图像更简单。 Windows要么只是一个EXE文件,但是在其他平台上,您可能需要使用支持文件来酿造。如果将传入的pdf
/旋转90
row to/rotate 00
可以使用命令pdftotext -layout运输提取文本。 pdf label-001.txt
从上面的库中插入&lt; pre&gt;
代码部分&lt;/pre&gt;
。库还具有可执行选项的
pdftohtml
这是PDF上方的原始默认值而且,如果将传入的PDF转换为Base64,则可以使用可能不会在此处显示的iframe。
The incoming is a PDF with rotation so will not be the correct way up for display as its intended for label printing.
Thus your first step is to convert into a rotated image or text, image is simpler by using
pdftopng -rot 270 shipping.pdf label
which you can use from xpdf or poppler (other libraries are available), on windows either can be just a single exe file, but on other platforms you may need to brew with supporting files.If you change incoming pdf
/rotate 90
to/Rotate 00
you can extract the text using the commandpdftotext -layout shipping.pdf label-001.txt
from the above libraries and insert that into a<pre>
code section</pre>
.and the libraries also have
pdftohtml
with executable options this is raw default from above pdfand if you convert the incoming pdf to base64 you could use an iFrame which probably wont show here.