如何使用itextstarp在pdf中添加HTML复选框,单选按钮,文本框? [英] How to add HTML checkbox, radiobutton, textbox in pdf using itextstarp?

查看:636
本文介绍了如何使用itextstarp在pdf中添加HTML复选框,单选按钮,文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用此代码使用itextstarp.Am以pdf格式添加html复选框,radiobutton,textbox。



How to add html checkbox,radiobutton,textbox in pdf using itextstarp.Am using this code.

StringWriter stringWriter = new StringWriter(); MemoryStream stream = new 
      System.IO.MemoryStream();

        var viewData = ViewData;

        ViewEngineResult viewEngineResult = 
       ViewEngines.Engines.FindView(ControllerContext, "ABCDFORM", null);
        ViewContext viewContext = new ViewContext(ControllerContext, 
       viewEngineResult.View, viewData, new TempDataDictionary(), stringWriter);
        viewEngineResult.View.Render(viewContext, stringWriter);

        // Get the view HTML string
        string htmlToConvert = stringWriter.ToString();
        StringReader sr = new StringReader(htmlToConvert);

        Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 0f, 0f);
        PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream);
        pdfDoc.Open();

        XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);
        pdfDoc.Close();

        string fileName = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");

        return File(stream.ToArray(), "application/pdf", string.Format("{0}.pdf", 
       fileName));





在ABCDFORM是我的观点,我正在研究MVC。我创建ABCDFORM为html

文件。



我需要添加html复选框,pdf的radiobutton。



我尝试了什么:



我尝试使用itextsharp在pdf中添加checkbox,radiobutton。



In ABCDFORM is a my view,I am working on MVC.and am create ABCDFORM as html
file.

I need add html checkbox,radiobutton in pdf.

What I have tried:

I tried to add checkbox,radiobutton in pdf using itextsharp.

推荐答案

请按照: iTextSharp - 创建表单字段。 |简单的.Net解决方案 [ ^ ]



详情请见:

书页:iText 7:使用pdfHTML将HTML转换为PDF [ ^ ]



XML Worker | iText开发人员 [ ^ ]
Please, follow this: iTextSharp – Creating Form fields. | Simple .Net Solutions[^]

For further details, please see:
Book page : iText 7: Converting HTML to PDF with pdfHTML[^]
and
XML Worker | iText Developers[^]


这篇关于如何使用itextstarp在pdf中添加HTML复选框,单选按钮,文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆