0

Html を PDF に変換できるコンポーネントを使用して、aspx ページを PDF に変換したいと考えています。ポストバック中に aspx ページからの出力をリダイレクトし、ストリームまたは文字列として HtmlToPdf メソッドに送信することは可能ですか?

4

4 に答える 4

2
protected override void Render(HtmlTextWriter writer)
{
    // setup a TextWriter to capture the page markup
    TextWriter tw = new StringWriter();
    HtmlTextWriter htw = new HtmlTextWriter(tw);

    // render the page into our surrogate TextWriter
    base.Render(htw);

    // convert the TextWriter markup to a string
    string pageSource = tw.ToString();

    if (convertToPDF)
    {
        // convert the page markup to a pdf
        // eg, byte[] pdfBytes = HtmlToPdf(pageSource);
    }

    // write the page markup into the output stream
    writer.Write(pageSource);
}
于 2009-02-11T14:19:59.140 に答える