using System;
using System.IO;
using TallComponents.PDF.Layout;
using TallComponents.PDF.Layout.Paragraphs;
using TallComponents.PDF.Layout.Fonts;
namespace txt2pdf
{
class Program
{
static void Main(string[] args)
{
Document document = new Document();
Section section = new Section();
section.PageSize = PageSize.Letter;
document.Sections.Add(section);
string[] lines = File.ReadAllLines("test.txt");
foreach (string line in lines)
{
TextParagraph text = new TextParagraph();
text.SpacingAfter = 12;
section.Paragraphs.Add(text);
Fragment fragment = new Fragment();
fragment.FontSize = 12;
fragment.Font = Font.Courier;
fragment.Text = line;
text.Fragments.Add(fragment);
}
using (FileStream file = new FileStream(
"test.pdf", FileMode.Create, FileAccess.Write))
{
document.Write(file);
}
}
}
}
We have sent an email with a download link. Alternatively, you may want to use the NuGet package manager to install our library.
Use the NugetID and start right away, or download the package and install it handmatically