将文本转换为pdf c#win。形成 [英] converting text to pdf c# win. form

查看:114
本文介绍了将文本转换为pdf c#win。形成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PdfWriter.GetInstance(document, new FileStream(Server.MapPath("~/") + "pdf/" + "print.pdf", FileMode.Create));
   // document.NewPage();
    document.Open();

    List<IElement> htmlarraylist = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(
                      new StringReader(lblArticle.Text), null);

    for (int k = 0; k < htmlarraylist.Count; k++)
    {
        document.Add((IElement)htmlarraylist[k]);

    }

    Paragraph mypara = new Paragraph();
    document.Add(mypara);







这里,lblArticle是一个Lablel控件,但我想 .txt页面转换pdf页面,我可以试试这个?请帮帮我吗?




here,lblArticle is a "Lablel" control,but i want to ".txt" page to converting the pdf page,what can i try this? please help me any one?

推荐答案

你有.txt文件,你想把它转换成pdf文件。



在这种情况下,您只需逐字节读取文件,然后再逐字节地写入文档对象。它将解决您的问题。
Ok you have .txt file and you want to convert it to pdf file.

In that case you just read the file byte by byte and again write byte by byte to document object. It will solve your problem.


这篇关于将文本转换为pdf c#win。形成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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