0

i have follow situation. I'm using fabric.js for my canvas. My target is to convert the canvas to a PDF with a transparent background and the vector informations. The vector informations are important for the printing process.

I've tried to generate a jpg/jpeg picture of the canvas and convert it than to a pdf with pdf.js library but the thing is, that jpg/jpeg can't display transparent background. If I convert the canvas to a PNG-File, the vector informations get deleted.

I have no idea how i can reach my target. Have anyone else an idea how i can reach my target? Is there a possibility to convert the fabric.js canvas directly to a pdf ?

Stefan
  • 61
  • 6
  • 1
    https://github.com/fabricjs/fabric.js/issues/5906 – melchiar May 06 '22 at 16:48
  • Thanks for your answers. I've tried now to create the pdf file with a php pdf library. I've converted the canvas to a svg and sendit to the server. There i load it into the library. The thing is now that it doesn't work with all php pdf libraries which i've found. I've tried it with tcpdf and dompdf. On Both it doesn't work. TCPDF generaters me a blank pdf file. Dompdf a pdf file with a box and the information, that the image can't be found or the type of it is unknown. – Stefan May 09 '22 at 08:58
  • I've found some posts. One of them was https://stackoverflow.com/questions/60494783/problems-using-php-and-dompdf-to-output-svg. I did all things which he recommend to fix this issue. But it doesn't work for me... Here is an image of the actual pdf file: https://ibb.co/DKLhhKC – Stefan May 09 '22 at 08:59
  • I've done it with TCPDF now. My mistake was to execute the function setAlpha. I thought that this function makes the background transparent. Now i've seen that this function set the Alpha of the imported Picture. – Stefan May 09 '22 at 11:58

0 Answers0