Search code examples
c#asp.netweb-servicespdfevopdf

EVO PDF PDF contents have small font


I am trying to create a PDF file by using EVOHTMLTOPDF. But the pdf generated is wrong and the contents has a font size so small that i cant even read it.

This is the current code I use inside a webservice

        HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
        htmlToPdfConverter.LicenseKey = "4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=";

        htmlToPdfConverter.HtmlViewerWidth = int.Parse("1024");
        htmlToPdfConverter.PdfDocumentOptions.PdfPageSize = EvoPdf.PdfPageSize.Letter;
        htmlToPdfConverter.PdfDocumentOptions.PdfPageOrientation = EvoPdf.PdfPageOrientation.Portrait;
        htmlToPdfConverter.PdfDocumentOptions.TopMargin = 15f;
        htmlToPdfConverter.PdfDocumentOptions.RightMargin = 15f;
        htmlToPdfConverter.PdfDocumentOptions.BottomMargin = 15f;
        htmlToPdfConverter.PdfDocumentOptions.LeftMargin = 15f;
        byte[] outPdfBuffer = null;
        outPdfBuffer = htmlToPdfConverter.ConvertHtml(DocContent, baseUrl);
        HttpContext.Current.Response.ContentType = "application/pdf";
        HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + filename);
        HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);

        File.WriteAllBytes(sourcepath, outPdfBuffer);

I have also attached a screenshot

Some time i get this error which reads "PDF is too big"

Please anybody provide a solution as i want to create a pdf and download the pdf to the users computer.


Solution

  • Could you try to see which is the minimum width of the browser window that can display the content of the HTML page you convert?

    If the content width is very large it will be scaled down to fit the PDF page width. The solution would be to modify your HTML page to allow the content reflow at different browser window widths.

    You can find a live demo where to test various scaling options at HTML to PDF Scaling Options Demo . For example you can check on 'Clip HTML Content Width' option to truncate the HTML content if it is too wide.

    Regarding the "PDF is too big", when do you get this error? When you create the PDF, when you open the PDF in a viewer, etc. This does not seem to be an error from library.