Welcome Guest Search | Active Topics | Sign In | Register

Adding an SVG to a PDF document? Options
Guest
Posted: Tuesday, June 24, 2014 12:27:30 PM
Rank: Guest
Groups: Guest

Joined: 5/27/2007
Posts: -34
I searched through the support forum, but I still can't find the answer to my problem. I'm new to EO.Pdf. I generate the PDf document from HTML, no problem. All I want to do is add onto the PDF document, the contents of my signature.svg file. I can't use the PdfImage object, because it uses System.Drawing.Image. The System.Drawing.Image doesn't support .svg as a file type.

Can you please tell me what I'm doing wrong? Here is my code:
Code: Visual Basic.NET
Dim htmlOutput As String = Server.HtmlDecode(sw.ToString)

                        HtmlToPdf.ConvertHtml(htmlOutput, doc)

                        HtmlToPdf.ConvertHtml(htmlOutput, doc)

                        ''''*****  THIS IS WHERE I WANT TO ADD THE SVG to the doc   ***********'

                        fileName = "Patient Form Response.pdf"

                        Response.Buffer = True
                        Response.Clear()
                        Response.ContentType = Utility.ReturnFiletype(ext)
                        Response.AddHeader("content-disposition", ("attachment; filename=" + fileName))
                        doc.Save(Response.OutputStream)
                        Response.End()
eo_support
Posted: Tuesday, June 24, 2014 3:01:24 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

The easiest way is to render an SVG image is to wrap them with an img element. For example:

Code: C#
//You must set AllowLocalAccess to true so that the HTML engine
//is allowed to access your local files 
HtmlToPdf.Options.AllowLocalAccess = true;

//Wrap the SVG in an img element and render it on the first page
HtmlToPdf.ConvertHtml("<img src='file:///c:/1.svg' />", doc.Pages[0]);


Note the second argument for the ConvertHtml call here is the PdfPage object on which you want your SVG image to be placed. To precisely control where you want to put it, you can either add CSS positioning attribute to your HTML, or set HtmlToPdf.Options.OutputArea before calling ConvertHtml. You can also modify your original HTML to embed the SVG into the original HTML and render them all together at once.

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.