[ # ] How to Convert Txt Docs to PDF in Aspose c#

/* Posted March 18th, 2008 at 8:43am */
/* Filed under C#, PDF */

We are using the Aspose product for pdf to convert word docs to pdf.  We also wanted to use that same product to convert txt docs into pdf.  Unlike most other pdf convertor tools, aspose dosn’t have a auto convert to pdf for txt docs.  The solution to this problem is to stream in the txt doc and create a new pdf from it.

Code Below: 

System.IO.TextReader tr = new StreamReader(“C:/Test.txt”);//Instantiate Pdf pbject by calling its empty constructorPdf pdf1 = new Pdf();//Create a new section in the Pdf objectAspose.Pdf.Section sec1 = pdf1.Sections.Add();//Set the left margin of the sectionsec1.PageInfo.Margin.Left = 110;//Set the right margin of the section

sec1.PageInfo.Margin.Right = 120;//Create a new text paragraph and pass the text to its constructor as argumentText t2 = new Text(tr.ReadToEnd());sec1.Paragraphs.Add(t2);pdf1.Save(“C:/testText.Pdf”);

  • Digg
  • del.icio.us
  • Propeller
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Mixx
  • NewsVine
  • Blogsvine
  • Facebook
  • Google
  • TwitThis


Random Posts

Leave a Reply


*


* (not published, used to display your gravatar)



(* required)

Anything Geeky Goes!

Highlights

Featured Wii

Featured iPhone

Featured PSP/PS3

Featured A/V

Related Links

Archives

Products Highlight


Featured Sites

Categories

Subscribe

Recent Posts

Commentors

Other Links