0

I want to create an invoice print, but on the invoice there is a logo, so how can I write the logo to a Tmp File and also set the paper Size/Margin/Position on the Tmp File?

I got this code from an article and it's working for print, but I don't understand how write is working?

$tmpdir = sys_get_temp_dir();
$file = tempnam($tmpdir, 'ctk');
$handle = fopen($file, 'w');

$condensed = Chr(27) . Chr(33) . Chr(4);
$bold1 = Chr(27) . Chr(69);
$bold0 = Chr(27) . Chr(70);
$initialized = chr(27).chr(64);
$condensed1 = chr(15);
$condensed0 = chr(18);
$Data = $initialized;
$Data .= $condensed1;
$Data .= "----------------------------\n";
$Data .= "         FAKTUR/KWITANSI         \n";
$Data .= "         CV. SINTESIS INDO PRATAMA         \n";
$Data .= "----------------------------\n";
$Data .= "Selamat datang,\n";
$Data .= "--------------------------\n";
fwrite($handle, $Data);
fclose($handle);
copy($file, "//localhost/Canon iR5570iR6570 PCL6"); # Lakukan cetak
unlink($file);
Vickel
  • 7,879
  • 6
  • 35
  • 56
  • I'm still trying to understand this. You want to know more how fwrite($handle, $Data); works? – Lucas Meine Oct 30 '19 at 08:04
  • 1
    a plain text file can only have plain, unformatted text, there is no possibility to embed an image into it. You need to convert this into another format (e.g. pdf, doc,xls ..) – Atural Oct 30 '19 at 11:48
  • oh okay i understand, so how do i make a temporary pdf file and print it directly? can you explain which part of my code defines making plain text? because I don't understand the code – Welldy Rosman Oct 31 '19 at 04:08

1 Answers1

0

Finnaly I use PDF and print it with priview first