I need to create a PDF File with c#. It have to be that I need a template (eg. Editable PDF or HTML Template). In this template I have to insert text and Picutures.
I have no ideas how to do this. Could someone say me a technique I could use do this?
You can use PdfSharp plugin via NuGet. Just create html template file, read it as string, replace what you need, and pass full html to function bellow.
using TheArtOfDev.HtmlRenderer.PdfSharp;
public static bool PdfSharpConvert(String html, string SaveTo)
{
try
{
using (var pdf = PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4))
{
pdf.Save(SaveTo);
}
return true;
}
catch (Exception er)
{
return false;
}
finally
{
GC.Collect();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With