I want to write a PDF on more than one page. I already created 4 pages, but the programm do a cut on the first page. So the page 2,3,4 are empty.
How to fix that?
Code:
string outFileName = "Vertrag/vertrag.txt";
using (StreamWriter writer = new StreamWriter(outFileName, false, Encoding.UTF8))
{
foreach (string inFileName in Directory.EnumerateFiles("schnippsel", "DE*.txt"))
{
using (StreamReader reader = new StreamReader(inFileName))
{
writer.Write(reader.ReadToEnd());
}
}
}
TextReader readFile = new StreamReader("Vertrag/vertrag.txt");
PdfDocument pdf = new PdfDocument();
PdfPage pdfPage = pdf.AddPage();
PdfPage pdfPage2 = pdf.AddPage();
PdfPage pdfPage3 = pdf.AddPage();
PdfPage pdfPage4 = pdf.AddPage();
XGraphics graph = XGraphics.FromPdfPage(pdfPage);
XGraphics graph2 = XGraphics.FromPdfPage(pdfPage2);
XGraphics graph3 = XGraphics.FromPdfPage(pdfPage3);
XGraphics graph4 = XGraphics.FromPdfPage(pdfPage4);
XFont font = new XFont("Verdana", 10, XFontStyle.Regular);
string line = null;
int yPoint = 0;
while (true)
{
line = readFile.ReadLine();
if (line == null)
{
break;
}
else
{
yPoint = yPoint + 40;
graph.DrawString(line, font, XBrushes.Black, new XRect(40, yPoint, 40, pdfPage.Height.Point), XStringFormats.TopLeft);
}
}
pdf.Save("Vertrag/vertrag.pdf");
readFile.Close();
readFile = null;
I must write more details here :P
It looks like that:
Page1: Hello, my name is Page 2: Page 3: Page 4:
