I´m trying to put in my HTML a SVG vector graphic.
This SVG: http://webkunst.comeze.com/graphic.svg
I managed to load it thru like this:
<embed src="images/grafica-2.svg" type="image/svg+xml"/>
the problem is that it just loads the file, but I need that I can modify the percentages of each color. I mean, that I can control thru the html the data of the svg, not just importing the svg "closed".
Is there anyway to do that?
Frameworks like d3.js and Raphaël allow you to create and modify SVGs. There are plenty of examples for each of them.
Related
I'm trying to use html2pdf to automatically create brochures that may need to go to print so need certain elements to be vector based. The class is hopelessly documented and I've got stuck trying to embed SVGs.
If I just try to embed the SVGs in the HTML to output like <embed src="img/test.svg" type="image/svg+xml" /> then I get an error saying the necessary methods to use this tag don't yet exist, likewise for <object> tags.
Digging further and the examples seem to show some sort of, I assume, proprietary <draw> tags that consist of all the required co-ords to draw the SVG. However I can't find any documentation anywhere to explain how to generate these?
Has anyone ever successfully embedded a SVG into a PDF using html2pdf?
Well I've partly figured this out, it seems the <draw> tag just contains the contents of an SVG file ("show SVG code" when saving as SVG from Illustrator) but it turns out html2pdf doesn't support bezier curves, which makes it pretty much useless for most things.
I want to dynamically create a visual flow chart using php on web.
I tried to use iMagick extension to draw rectangles, lines, and etc.
However, I ran into a problem that all the drawings have to be on an image and that makes my html code not appear on screen.
So I searched if there is a flow chart extension or functions I can use which I failed.
Is there any flow chart making library/application that I can use with php to dynamically draw flow chart on web?
If not, is there a way to have plain html texts above the image I created with iMagick extension so I can see my html texts positioned at the same spot as the rectangles I made using iMagick?
What is generally done is you have two files, one with the page contents, and the other that is the image, then you embed the image like you would a regular image (<img> tags).
Say you have index.php which is your main page, and you have image.php that has your flowchart code. On index.php you embed the image like this:
<img src="image.php" alt="flowchart" />
I'm developing an app where the user adds items to a list. That list is stored in an array and passed to PHP with JSON.
The objective is to then create a PDF with all the values extracted from the user. The PDF is quite complicated. It includes images depending on what the user selects and the text varies depending on the images and the input data.
The first idea was to generate the pdf in php with one of those pdf libraries, but that's going to be a real hassle.
Then I thought of creating an html & css (much easier) and the convert it to PDF. But since the html & css are quite complex I don't think those pdf converters will work with this.
Then I thought I could convert the html to jpg and then to pdf.
It'll be much simpler if I could just use html but the output needs to be pdf.
What do you suggest?
Here's a post that discusses creating PDF files with PHP and the PDFLib extension.
Generate PDFs with PHP it's on sitepoint.
Or if you want to go from HTML to the PDF it looks like TCPDF might work.
You can try using FPDF
Then I thought of creating an html & css (much easier) and the convert it to PDF. But since the html & css are quite complex I don't think those pdf converters will work with this.
wkhtmltopdf to the rescue! If you are on a VPS or dedicated machine, it's probably the best (open source) HTML-to-PDF engine out there. It leverages Webkit, the rendering engine used by Google Chrome and Apple Safari, amongst others.
Otherwise, your only other options are going to involve drawing every aspect of the PDF or image yourself, "by hand" in your code.
I have been reading about this but I have to do some thing. I have a table with diagonal text in the heading columns and horizontal text in the rows. I was able to make text diagonal using CSS rotation thing, table data is coming from db and I want to generate the same html into the pdf. I don't know who to write diagonal text in the pdf. The solution is to create an image of the visible html table with data and then store it and then make pdf and embed that image there. I have been reading the GD library but how can I make table in GD library I am stuck , Stack Overflow is the last resort. Please help.
try this ezpdf class http://www.ros.co.nz/pdf/readme.pdf. they got some sample code to rotate text and how to embed image into pdf.
example
for ($angle=0;$angle<360;$angle=$angle+20){
$r=rand(0,100)/100;
$g=rand(0,100)/100;
$b=rand(0,100)/100;
$pdf->setColor($r,$g,$b);
$pdf->addText(300+cos(deg2rad($angle))*40,300-
sin(deg2rad($angle))*40,20,$demotext,$angle);
{
$pdf->stream();
If you want to go directly from your HTML code to PDF, and if you need something entirely in PHP you can try dompdf. The 0.6.0 release will include CSS transform support.
For image generation in PHP you can use GD functions (fast) or iMagick (not so wide spread, docs are WorkInProgress, but you could do almost anything you can imagine with it).
GD should be enough.
A simple idea about making text diagonal would be to just rotate the image, once you output text from the db onto it.
Use wkhtmltoimage or wkhtmltopdf.
Do you need to do this only once or does this need to be an ondemand service? If not why not just load the html page take a screenshot and crop it down to the table?
Instead of trying to convert HTML directly to a PDF document, you might want to try a PDF library for creating the document directly in PHP. This way you will get more control over what the PDF looks like, and it may be a better solution that trying to convert your HTML output.
https://stackoverflow.com/questions/560583/which-is-the-best-pdf-library-for-php
Is there a way to generate an HTML file using a PHP script which has an SVG embedded where the SVG itself is dynamically generated by the PHP script?
Basically, I want to display a dynamically generated SVG image to a client but <embed>, <object> as well as <iframe> only refer to external sources while PHP generates the current HTML page only (and not the external sources)
Further, is there a Javascript solution possible where I add SVG elements in the current DOM one by one?
Try linking to your php file like this: <object href=svg_generator.php> <!-- other attributes necessary for embedding svg not listed here -->
You can have a look at raphael http://raphaeljs.com/ a wonderful javascript library which make easy to manipulate svg objects in a cross-browser way.
I am sure that it will help you a lot