I have a line of code that I received in an xml response from a remote server and it needs to be converted to a PDF file. The string consists of 3-digit numbers from 000 to 255 and looks like this:

037 080 068 070 045 049 046 052 ... such 95,000 lines

How can I do this with PHP?

    3 answers 3

    The answer is found, If someone can help:

    $string = '037 080 068 070 045 049 046 052 ...'; $dataVals = array(); foreach(explode(PHP_EOL, $string) as $ascii) { if(is_numeric($ascii)) $dataVals []= chr($ascii); } $data = implode('', $dataVals); header("Content-type: application/octet-stream"); echo $data; 

      Look towards libraries for generating PDF files. Here is an example: https://github.com/mpdf/mpdf . This is specifically supported, there is enough information and answers to it on the same StackOverflow. In operation and configuration, it is quite simple.

        Look in the direction of fpdf it is very simple + good documentation. There is also a good post on Habré , which describes how to use fpdf in practice.