Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have code bellow:
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System.Net;
using iTextSharp.text.html;
using System.Text;


public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
   protected void Button1_Click(object sender, System.EventArgs e)
    {
<code>
        String htmlText = ReadHTMLCode(("http://wms02.webmediasoft.com/wms/wms02/default.aspx")).Replace("\"", "'");</code>
        HTMLToPdf(htmlText, "PDFfile.pdf");
    }


    public void HTMLToPdf(string HTML, string FilePath)
    {
        Document document = new Document();

        PdfWriter.GetInstance(document, new FileStream(Request.PhysicalApplicationPath + "\\PDFfile.pdf", FileMode.Create));
        document.Open();
        Image pdfImage = Image.GetInstance(Server.MapPath("logo.png"));

        pdfImage.ScaleToFit(100, 50);

        pdfImage.Alignment = iTextSharp.text.Image.UNDERLYING; pdfImage.SetAbsolutePosition(180, 760);

        document.Add(pdfImage);

        iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker(document);
        hw.Parse(new StringReader(HTML));
        document.Close();
        ShowPdf("PDFfile.pdf");
    }
    private void ShowPdf(string s)
    {
        Response.ClearContent();
        Response.ClearHeaders();
        Response.AddHeader("Content-Disposition", "inline;filename=" + s);
        Response.ContentType = "application/pdf";
        Response.WriteFile(s);
        Response.Flush();
        Response.Clear();

    }
}

help me i have underline a code.please help me.
Posted

1 solution

ReadHTMLCode appears to be a method in your code.
A URL is being passed to this method.
htmlText is assigned a string return value from this method.
Before assigning however, \ is replaced with ' for some reason.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900