Click here to Skip to main content
15,906,624 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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??
Posted

If the result is just text, you can "export" it to a simple text file with the System.IO.StreamWriter class or with System.IO.File.WriteAllText method.

To export a single-line Textbox result into a text file:
C#
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:
C#
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
 
Share this answer
 
 
Share this answer
 
Comments
dastgeer 28-Dec-15 4:27am    
my data type is in another language then how i can do this i'm exporting "URDU Language" words like "ہیلوˆ" etc.
kendokumar 28-Dec-15 6:51am    
Then you can use the language simulator like the things which has been mentioned in the below link :
http://www.hanselman.com/blog/SimulatingAnIPhoneOrIPadBrowserForASPNETMobileWebDevelopmentWithWebMatrix2OrVisualStudio2012.aspx
kendokumar 28-Dec-15 6:53am    
and also you can use this link:
http://forums.asp.net/t/1490233.aspx?simulator+for+asp+net

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900