以正确格式显示PDF

发布于 2025-01-30 08:49:56 字数 957 浏览 1 评论 0原文

我有来自第三方服务的PDF数据始于此:

%PDF-1.3 %���� 5 0 obj << /Type /Page /Parent 1 0 R /LastModified (D:20220519105837+02'00') /Resources 2 0 R /MediaBox [0.000000 0.000000 595.276000 841.890000] /CropBox [0.000000 0.000000 595.276000 841.890000] /BleedBox [0.000000 0.000000 595.276000 841.890000] /TrimBox [0.000000 0.000000 595.276000 841.890000] /ArtBox [0.000000 0.000000 595.276000 841.890000] /Contents 6 0 R /Rotate 0 /Group << /Type /Group /S /Transparency /CS /DeviceRGB >> /PZ 1 >> endobj 6 0 obj <> stream x�3�357�r/ �R��R)@���\N! �n�

我想通过网页向访问者提供此PDF数据。目前,我正在设置application/pdf; charset = utf-8content_disposition作为我对此数据的响应的内联。

但是我的网页上有一个空白的PDF布局页面。这样:

“在此处输入图像描述”

您知道如何正确显示此PDF数据吗?

I have a PDF data that coming from a 3th party service starts with this:

%PDF-1.3 %���� 5 0 obj << /Type /Page /Parent 1 0 R /LastModified (D:20220519105837+02'00') /Resources 2 0 R /MediaBox [0.000000 0.000000 595.276000 841.890000] /CropBox [0.000000 0.000000 595.276000 841.890000] /BleedBox [0.000000 0.000000 595.276000 841.890000] /TrimBox [0.000000 0.000000 595.276000 841.890000] /ArtBox [0.000000 0.000000 595.276000 841.890000] /Contents 6 0 R /Rotate 0 /Group << /Type /Group /S /Transparency /CS /DeviceRGB >> /PZ 1 >> endobj 6 0 obj <> stream x�3�357�r/ �R��R)@���\N! �n�

and I would like to provide this PDF data to my visitors via a web page. Currently, I am setting application/pdf; charset=UTF-8 and CONTENT_DISPOSITION as inline on my response with this data.

But I am getting a blank PDF layout page on my webpage. Like that:

enter image description here

Do you know how can I show this PDF data on browser correctly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隔纱相望 2025-02-06 08:49:56

特别感谢@mkl
看来我需要将第三方服务响应评估为字节。然后,我将其转换为base64,然后用Charset ISO-8859-1将其解码为字符串。

最后,我将此字符串放在HTML上,并使用application/pdf; charset = ISO-8859-1内容类型。

Special thanks to @mkl
It seems I need to evaluate 3rd party service response as byte. Then I convert it to base64 and decode it to string with charset ISO-8859-1.

Lastly, I put this string on HTML with application/pdf; charset=ISO-8859-1 content type.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文