1

我有一个从网络服务获取的 pdf 格式的字节数组。现在我想查看 PDF 文件,但没有运气。

样本字节[]:

JVBERi0xLjQKJeLjz9MKMSAwIG9iaiAKPDwKL01hdHJpeCBbMSAwIDAgMSAwIDBdCi9TdWJ0eXBlIC9Gb3JtCi9GaWx0ZXIgL0ZsYXRlRGVjb2RlCi9MZW5ndGggMTUwMzc3Ci9SZXNvdXJjZXMgCjw8Ci9FeHRHU3RhdGUgCjw8Ci9HUzAgMiAwIFIKL0dTMSAzIDAgUgo+PgovQ29sb3JTcGFjZSAKPDwKL0NTMCA0IDAgUgo+PgovUHJvcGVydGllcyAKPDwKL01DMyAKPDwKL01ldGFkYXRhIDUgMCBSCj4+Ci9NQzIgCjw8Ci9NZXRhZGF0YSA2IDAgUgo+PgovTUMxIAo8PAovTWV0YWRhdGEgNyAwIFIKPj4KL01DMCAKPDwKL01ldGFkYXRhIDggMCBSCj4+Cj4+Ci9YT2JqZWN0IAo8PAovRm0xIDkgMCBSCi9GbTAgMTAgMCBSCi9GbTIgMTEgMCBSCj4+Ci9Gb250IAo8PAovVDFfMyAxMiAwIFIKL1QxXzIgMTMgMCBSCi9UMV8xIDE0IDAgUgovVDFfMCAxNSAwIFIKPj4KL1Byb2NTZXQgWy9QREYgL1RleHRdCj4+Ci9Gb3JtVHlwZSAxCi9UeXBlIC9YT2JqZWN0Ci9CQm94IFswIDAgNjEyIDc5Ml0KPj4Kc3RyZWFtCnic3L1bjy09ciX2/v2K/WgZ2KXknQQEAR5JbdiGgBmogXkYG4askWZst2TrMrDf5q+bwSCZychgXqoqso6MBvo7depUcW/uJNeK21r/+Nsf//d/tbz+0z//9se/+/vl9ef/12//7rc//qv/+6//4fUnf/LHf/ln/8Ofv5bXn/7pv/nzP3v99m9+/9vygv+p1/8JP6XKT/1e/a/wN7//u99S+WZ6Was+lA2vYPTHovMffv/3v/2H/+Z/Xkz4o7eO8Aff/gB/o9sf4L8u/9fBH2z+g4E/mPYH/Udv5eEPKv8hwB+W/AdT/2b4aZ1/nVq2P63zkirBH1z9aW3pDxn6F7q9TFV==

4

3 回答 3

1

我已经解决了这个问题。实际上它是base64编码。在使用 base64_decode 解码后,我能够生成 pdf。

于 2014-06-06T17:23:48.953 回答
1
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="service.pdf"');
echo base64_decode($byte_string);

刚为我工作。

于 2015-11-15T16:35:20.510 回答
0

You could just echo it with headers.

header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="service.pdf"');
echo $byte_string;

header

But I cannot read provided string as PDF.

于 2013-11-15T07:41:56.853 回答