H
H
Hfnas2020-06-30 22:02:17
PHP
Hfnas, 2020-06-30 22:02:17

What is the pdf format please?

Contents of the pdf:

%PDF-1.4
%
5 0 obj
</DeviceRGB/Subtype/Image/Height 1/Filter/FlateDecode/Type/XObject/Width 1/Length 11/BitsPerComponent 8>>stream
x?
endstream
endobj
6 0 obj
</FlateDecode/Length 435>>stream ....


I get this pdf content on the server and I need to write it to json, then on the client side, print the pdf content, is that possible?
I can not.
On the server side I write
echo json_encode(["mm"=>"kkk","pdf"=>"содержимое pdf"],JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_QUOT | JSON_INVALID_UTF8_IGNORE | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);

client side SyntaxError: Unexpected token < in JSON at position 0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2020-06-30
@Hfnas

https://medium.com/octopus-labs-london/downloading...
PDF content is encoded in base64, the user is given a link like

<a href="data:application/pdf;base64,[base64]" download="file.pdf">
- and the browser obediently opens the contents of this file on his computer or offers to save it.
Forcing the browser to immediately print a PDF is unlikely to succeed, but users know how to do it themselves, after all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question