从richtextbox生成pdf [英] generate pdf from richtextbox

查看:81
本文介绍了从richtextbox生成pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



如何生成我的文档的pdf版本,即RichTextBox。

帮我解决问题。 。



谢谢。

hello all,

How can i generate pdf version of my document, which is RichTextBox.
Help me with proper solution..

Thanks.

推荐答案

下载我之前用过的itextsharp.dll 5.1.2.0版本。然后试试这个..

download itextsharp.dll 5.1.2.0 version i have used before.Then try with this..
// step 1: creation of a document-object
iTextSharp.text.Document myDocument = new iTextSharp.text.Document(PageSize.A4.Rotate());
try
{
    // step 2:
    // Now create a writer that listens to this doucment and writes the document to desired Stream.

    PdfWriter.GetInstance(myDocument, new FileStream(sfd.FileName, FileMode.Create));

    // step 3:  Open the document now using
    myDocument.Open();

    // step 4: Now add some contents to the document
    myDocument.Add(new iTextSharp.text.Paragraph(richTextBox1.Text));
}
catch (DocumentException de)
{
    Console.Error.WriteLine(de.Message);
}
catch (IOException ioe)
{
    Console.Error.WriteLine(ioe.Message);
}
// step 5: Remember to close the documnet
myDocument.Close();



它会成功创建你写作的pdf文件。如果这些文件可以帮助你,请告诉我..


It will successfully create pdf files of your writing.Know me if these helps you..


这篇关于从richtextbox生成pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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