如何将Windows窗体的输出转换为Pdf,Txt, [英] How Can I Convert Output Of Windows Forms Into Pdf, Txt,
问题描述
有人可以帮助我在这方面如何将我的Windows窗体结果转换为word,text或pdf文件格式。
我必须使用哪个库?
以及我必须使用哪种方法?
任何人都可以为此设置示例方法吗?
如果结果只是文本,你可以将它导出到一个简单的使用System.IO.StreamWriter
类或使用System.IO.File.WriteAllText
方法的文本文件。
将单行文本框结果导出到文本文件中:
使用( var writer = new System.IO.StreamWriter( output.txt))
{
writer.WriteLine(textbox1.Text);
}
要将多行文本框或RichTextbox结果导出到文本文件中:
< pre lang =c#> System.IO.File.WriteAllText( output.txt,textbox2 。文本);
System.IO.File.WriteAllText( output2.rtf,richTextbox1.Text) ;
要导出为PDF格式,您可以使用一些免费的开源库:
1)iTextSharp (推荐): http://sourceforge.net/projects/itextsharp/ [ ^ ]
2)Spire.PDF : https://visualstudiogallery.msdn.microsoft。 com / b590710c-efe6-4667-842e-2a592ce000cc [ ^ ]
3)PDF小丑: http://pdfclown.org/ [ ^ ]
希望这个答案有所帮助! - CCB
你的结果类型是什么?
如果是文本,只需将其写入文本文件。
尝试 https://social.msdn.microsoft.com/论坛/ vstudio / EN-US / b41e6115-f19e-4be2-be7e-f2fcd80dc64d /怎么办,我保存最文本中,文本到文本文件和当时读它,背并在文本框中添加文本 [ ^ ]。
can someone help me in this regard how can i convert my windows forms result into word, text, or pdf file format.
what library i have to use for this?
and what methods i have to call for this?
can anyone have sample method for this??
If the result is just text, you can "export" it to a simple text file with theSystem.IO.StreamWriter
class or withSystem.IO.File.WriteAllText
method.
To export a single-line Textbox result into a text file:
using(var writer = new System.IO.StreamWriter("output.txt")) { writer.WriteLine(textbox1.Text); }
To export a multiline Textbox or RichTextbox result into a text file:
System.IO.File.WriteAllText("output.txt", textbox2.Text); System.IO.File.WriteAllText("output2.rtf", richTextbox1.Text);
To export to PDF format you can use some free open-source libraries:
1) iTextSharp (recommended) : http://sourceforge.net/projects/itextsharp/[^]
2)Spire.PDF : https://visualstudiogallery.msdn.microsoft.com/b590710c-efe6-4667-842e-2a592ce000cc[^]
3)PDF Clown : http://pdfclown.org/[^]
Hope this answer helps! - CCB
What is your result type?
If its text, just write it to a text file.
Try https://social.msdn.microsoft.com/Forums/vstudio/en-US/b41e6115-f19e-4be2-be7e-f2fcd80dc64d/how-do-i-save-the-text-in-textbox-to-text-file-and-then-read-it-back-and-add-the-text-in-the-textbox[^].
这篇关于如何将Windows窗体的输出转换为Pdf,Txt,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!