SVG to PDF conversion using TCPDF in PHP
You don't really need to replace text or render, Once you have created your svg file. All you just need to include tcpdf in your script and create its object like e.g.
require_once(DOCUMENT_ROOT . '/library/Lib/tcpdf/mypdf.php');
$this->pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$this->pdf->AddPage(); // Add page to pdf before addding content
//There are several other property need to be set on basis of your need
$this->pdf->ImageSVG('file/mySVGFile.svg', 15, 20, '', '', '',
'', '', 1, false); // 15,20 are co-ordinate to position graph in pdf
Once you added your content to your pdf, Last step comes is to download the pdf using .
$this->pdf->Output('my.pdf', 'FD');
Feel free to ask for anything you have any query in this code.
Kiran
Hello, I am a full-time freelancer based in India. I am a self-taught software developer working on a number of technologies. Most of the time, I will be working in Python, Matlab, PHP/MySQL, C#, bash scripting. If you looking at my profile after seeing some of the questions/answers I have posted in this forum, I probably have the solution. Contact me at [email protected], I would be happy to help you. My interests include : Data Analysis, Data Science Data Mining, Web scraping (Have worked extensively with www.mca.gov.in, CIBIL, Bloomberg.com) API Development/Integration Blockchain I work here & here and can be reachable on Telegram here
Updated on June 14, 2022Comments
-
Kiran almost 2 years
I am trying to convert a SVG file to PDF file using TCPDF library in PHP. I have created a SVG file and use PHP to replace text and plan to render the resultant SVG file to PDF file.
Any idea, if TCPDF library supports SVG to PDF conversion. Any pointers in this direction would really help me.
-
Admin over 9 yearsneed more explanations