-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPDFGenerator.cs
More file actions
41 lines (32 loc) · 1.1 KB
/
PDFGenerator.cs
File metadata and controls
41 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;
using System.Text;
namespace GenerateEmployeeScheduleReport
{
public class PDFGenerator
{
public void GeneratePDF(string FileName, StringBuilder stBuilder)
{
using (var document = new Document())
{
MemoryStream memoryStream = new MemoryStream();
using (var writer = PdfWriter.GetInstance(document, memoryStream))
{
document.Open();
Paragraph paragraph = new Paragraph();
foreach (var item in stBuilder.ToString().Split("\t"))
{
paragraph.Add(item);
paragraph.TabSettings = new TabSettings(56f);
paragraph.Add(Chunk.TABBING);
}
document.Add(paragraph);
document.Close();
byte[] bytes = memoryStream.ToArray();
File.WriteAllBytes(FileName, bytes);
}
}
}
}
}