Export Page to PDF Error: font size too small

Last Reply 3 months ago By dharmendr

Posted 3 months ago

i try to convert my dynamic page data into pdf but when i try to download pdf then show error

"font size too small"

please help to solve this

    protected void Download(object sender, EventArgs e)
    {
        Button1.Visible = false;
        Button2.Visible = false;
        Button3.Visible = false;
        Response.ContentType = "application/pdf";
        string qno = "ABIQuotetionNo" + ViewState["qno"].ToString() + ".pdf";
        //  Response.AddHeader("content-disposition", "attachment;filename=TestPage.pdf");
        Response.AddHeader("content-disposition", "attachment;filename=" + qno + "");
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);
        this.Page.RenderControl(hw);
        StringReader sr = new StringReader(sw.ToString());
        // html to turn into pdf
        var htmlToPdf = new HtmlToPdf();
 
        // turn html to pdf
        htmlToPdf.PrintOptions.EnableJavaScript = true;
        htmlToPdf.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print;
        htmlToPdf.PrintOptions.FirstPageNumber = 1;
 
        Document pdfDoc = new Document(PageSize.A4);
         
        HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
        PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
        pdfDoc.Open();
         
        htmlparser.Parse(sr);
        pdfDoc.Close();
        Response.Write(pdfDoc);
        Response.End();
        Response.Redirect("printQuotation.aspx");
    }

 

You are viewing reply posted by: dharmendr 3 months ago.