相关疑难解决方法(0)

使用asp.net中的itextsharp将HTML文本转换为pdf文件时出错

我使用以下代码将Editor(Ajax控件)中的内容转换为pdf,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using System.IO;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
/// <summary>
/// Summary description for pdfgeneration
/// </summary>
public class pdfgeneration
{
    public pdfgeneration()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public void pdfgenerator(String name1, AjaxControlToolkit.HTMLEditor.Editor Editor1)
    {

        HttpContext.Current.Response.Clear();
        HttpContext.Current.Response.ContentType = "application/pdf";
        // Create PDF document
        Document pdfDocument = new Document(PageSize.A4, 70, 55, 40, 25);

        PdfWriter wri = PdfWriter.GetInstance(pdfDocument, new FileStream("e://" +name1 + ".pdf", FileMode.Create));

        PdfWriter.GetInstance(pdfDocument, HttpContext.Current.Response.OutputStream); …
Run Code Online (Sandbox Code Playgroud)

asp.net pdf-generation itext html-to-pdf

2
推荐指数
1
解决办法
3681
查看次数

标签 统计

asp.net ×1

html-to-pdf ×1

itext ×1

pdf-generation ×1