i have tried with different .net packages.my code is like this
using System;
using EO.Pdf;
using System.Drawing;
using System.Web;
namespace HTMLtoPDF5
{
class Program
{
static void Main(string[] args)
{
try
{
string Url = "https://v16smoke.smartappbeta.com/enterprisedesktop/DocumentItemDetails.aspx?smartItemId=1610934&sessionid=c4c515ca90724e0e964aae9256b146b0&pageMode=view";
HtmlToPdfOptions opts = new HtmlToPdfOptions();
opts.AutoFitX = HtmlToPdfAutoFitMode.ScaleToFit;
opts.AutoFitY = HtmlToPdfAutoFitMode.None;
opts.ZoomLevel = 1;
// opts.NoScript = true;
// opts.PageSize = PdfPageSizes.A4;
opts.OutputArea = new System.Drawing.RectangleF(0.5f, 0.5f, 8.267f, 11.692f);
HtmlToPdf.ConvertUrl(Url, @"C:\Pictures\Testing2.pdf", opts);
}
catch (Exception ex)
{
Console.WriteLine("Error");
}
}
}
}
but contents in the html are not getting in pdf only few are getting remaining contents are not visible nut two pages are getting in pdf,one is empty
Amit MohantyPosted Jun 14, 2022, 6:48 AM
Usage
- Download HtmlRenderer.PdfSharp nuget package.
- public static Byte[] PdfSharpConvert(String html)
- {
- Byte[] res = null;
- using (MemoryStream ms = new MemoryStream())
- {
- var pdf = TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4);
- pdf.Save(ms);
- res = ms.ToArray();
- }
- return res;
- }
ref link: https://stackoverflow.com/questions/564650/convert-html-to-pdf-in-netUse Example Method.
Jignesh KumarPosted Jun 14, 2022, 3:28 AM
Marvin ReidPosted Jun 13, 2022, 5:13 PM
Rahul PrasadPosted Sep 8, 2016, 9:30 PM
Nilesh JadavPosted Sep 7, 2016, 9:32 PM
Try with this tool - wkhtmtopdf it will give you optimal result in viewing.