Using base64 images in pdfsharp html to pdf conversion - c#

I am trying to embed base64 images in HTML which will then be converted to PNG, normal images work fine but if I set the src to a base64 string is shows the broken image in my pdf:
https://gyazo.com/7c86e05373b165840225e931cf5975c9
Here is an example of an image string I would send, works fine in the html, broken after converting to pdf.
<img id="fmacttcChartPNG-PullUps" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAJAgMAAACd/+6DAAAAAXNSR0IArs4c6QAAAAlQTFRF7QA07QA0////wRtPhQAAAAF0Uk5TAEDm2GYAAAABYktHRAJmC3xkAAAACW9GRnMAAAORAAAJpwDTb3gUAAAACXBIWXMAAAsSAAALEgHS3X78AAAAB3RJTUUH4AoEBBQC2OsgcQAAABBJREFUCNdjYIAC1lDsGAgAIgICHfAWayEAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTYtMTAtMDRUMDQ6MjA6MDIrMDI6MDAcnXh7AAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE2LTEwLTA0VDA0OjIwOjAyKzAyOjAwbcDAxwAAACl0RVh0ZGM6Zm9ybWF0AGFwcGxpY2F0aW9uL3ZuZC5hZG9iZS5waG90b3Nob3DkrZ9UAAAAOHRFWHRpY2M6Y29weXJpZ2h0AENvcHlyaWdodCAoYykgMTk5OCBIZXdsZXR0LVBhY2thcmQgQ29tcGFueflXeTcAAAAhdEVYdGljYzpkZXNjcmlwdGlvbgBzUkdCIElFQzYxOTY2LTIuMVet2kcAAAAmdEVYdGljYzptYW51ZmFjdHVyZXIASUVDIGh0dHA6Ly93d3cuaWVjLmNoHH8ATAAAADd0RVh0aWNjOm1vZGVsAElFQyA2MTk2Ni0yLjEgRGVmYXVsdCBSR0IgY29sb3VyIHNwYWNlIC0gc1JHQkRTSKkAAAAYdEVYdGxhYmVsAFJlY3RhbmdsZSA4IGNvcHkgMsSFowcAAAAVdEVYdHBob3Rvc2hvcDpDb2xvck1vZGUAM1YCs0AAAAAmdEVYdHBob3Rvc2hvcDpJQ0NQcm9maWxlAHNSR0IgSUVDNjE5NjYtMi4xHC9sCwAAABN0RVh0dGlmZjpYUmVzb2x1dGlvbgA3Mg5QcYUAAAATdEVYdHRpZmY6WVJlc29sdXRpb24ANzKTX5DzAAAAKHRFWHR4bXA6Q3JlYXRlRGF0ZQAyMDE2LTA5LTIwVDIyOjEyOjEwKzA1OjAwdPNMtwAAADF0RVh0eG1wOkNyZWF0b3JUb29sAEFkb2JlIFBob3Rvc2hvcCBDQyAyMDE0IChXaW5kb3dzKTJLJSkAAAAqdEVYdHhtcDpNZXRhZGF0YURhdGUAMjAxNi0wOS0yOFQyMzo0OTo0OSswNTowMAbjefgAAAAodEVYdHhtcDpNb2RpZnlEYXRlADIwMTYtMDktMjhUMjM6NDk6NDkrMDU6MDA6RypGAAAAS3RFWHR4bXBNTTpEb2N1bWVudElEAGFkb2JlOmRvY2lkOnBob3Rvc2hvcDozNjQ2ZDY3ZC03ZjVkLTExZTYtYmMwYS1jMjA1ZmMxYjZiNmKXgewtAAAAPXRFWHR4bXBNTTpJbnN0YW5jZUlEAHhtcC5paWQ6ZWI5ZTBjYzQtOTVlMy05NjQ3LWI5Y2QtNDcyOGVjMzBhNTc0GfVhRwAAAEV0RVh0eG1wTU06T3JpZ2luYWxEb2N1bWVudElEAHhtcC5kaWQ6OGM1NTVkNDMtNDM2MC1hZTQ5LWJkMGMtZjkyY2E0MWY5MzUxLlI9uAAAAABJRU5ErkJggg==">
Does anyone know if this is supported or have any ideas on the correct direction to proceed on this?
Thanks,
Sam

Related

how to convert html file containing SVG (Scalable Vector Graphics) images to pdf file using ironPdf in C#?

I am trying to convert HTML page to pdf. Html page contains css, js code with svg images. I used wkhtmltopdf, iTextSharp and IronPdf dlls to get the exact html page into pdf. Functionality present in each of the above dll gives me pdf file containing content of html,css and js but excludes svg images.
Is there any way to render the svg images into pdf.
I am pasting code snippet here:
HtmlToPdf HtmlToPdf = new HtmlToPdf();
HtmlToPdf.PrintOptions.EnableJavaScript = true;
HtmlToPdf.PrintOptions.CssMediaType =PdfPrintOptions.PdfCssMediaType.Screen;
PdfResource PDF = HtmlToPdf.RenderUrlAsPdf(new Uri(htmlFilePath));
PDF.SaveAs(pdfFilePath);
IronPDF extract SVG images, To convert html page containing SVG images we need to set height with some values on SVG tag. If we did not mention height in SVG tag it will be considered as default i.e. to 0px.
This can be achieved using style= height:400px in SVG tag.

Convert BitMap Image to string or jpeg

I am trying to convert a Bit map image in my windows 8 app (C#), to a string or a regular jpeg.
I am doing thins because I am trying to print the image in some html.
The image is stored in variable itemImage.
When I try to print in in the HTML using the image tag it doesn't show up.
"<img src=" +itemImage + "/>"
When I print in in the html in shows up as Windows.UI.Xaml.Media.Imaging.BitmapImage
How do I show the Image in the html?
You need to write the image out as a separate file, and then point the <img href=""> tag at that file. Alternatively, set the href to a callback line which calls your program with arguments that cause the program to emit the image data.
OR, you can embed the image data directly in the HTML, but that is a very EVIL hack and you absolutely should not under any circumstances do this. I did not mention this option. :)

How to convert Text containing Images into pdf using iText#

I have a richtextbox and by far, i have been successful in converting plain text into pdf using iTextsharp. Now, the situation is, when i copy some text from any source let's say a website and along text, it contains images. Now when i try to convert the content (text + images) into pdf, resulting pdf doesn't show images. I know that there would be some property to be set for the richtextbox or using itextsharp so to have images as well. I also know that we can insert images by giving path to that image but this is not what i want. I want to have plain text along with images while direct conversion from richtextbox to pdf. Forexample i have,![Im resulting pdf i want the same as in richtextbox][1]: http://i.stack.imgur.com/ts0ec.jpg
How can i have the same as in richtextbox? How can i specify orientation for text and image to be justified?

Convert Image to SVG using C#

I want convert Image file (PNG,JPG) to SVG using C#. But I don't want to have image/base64 string in my svg tag.
SVG means Scalable Vector Graphics, which is not an image in the way a .PNG or .JPG is. Rather than storing an array of pixels, it stores a list of mathematical shapes and designs. The intent of an SVG is to create an 'image' that retains quality regardless of how far you zoom in or out.
There is no benefit to converting .PNG to .SVG - in fact, it loses quite a bit of quality because you can't literally "convert" it, you can only trace it (IE, draw a new SVG that looks like the PNG.)
In summary: I think you're asking the wrong thing here, or you simply don't understand what you're asking. Please clarify if you can.
I've used the website below and got great results converting logos and what-have-you to vector formats. I have no connection to them:
http://vectormagic.com/home

How can I save an HTML string to a Bitmap \ Image?

I made a program that converts an image to ASCII based webpage.
http://postimage.org/image/2pi49sa4k/
That image was rendered using Chrome, on 50% size (miminal).
Obviously, I can make it myself because the code is only based on the FONT tag,
but I believe that it'll make things more complicated, as I'm not too good with graphics etc.
I would like to know how I can convert that string to a Bitmap or Image, with some parameters.(like size etc)
Thank you !

Categories