C# PDFSharp在更多页面上写入

C# PDFSharp在更多页面上写入,c#,C#,我想在多个页面上编写PDF。 我已经创建了4个页面,但是程序进行了剪切 在第一页。所以第2、3、4页是空的 如何解决这个问题 代码: 我必须在这里写更多的细节:p 看起来是这样的: 第1页: 你好,我的名字是 第2页: 第3页: 第4页:似乎每页都有一个图表。您是否尝试过使用graph2.DrawString(…)?似乎每个页面都有一个图形。您是否尝试过使用graph2.DrawString(…)? string outFileName = "Vertrag/vertrag.txt"; usin

我想在多个页面上编写PDF。 我已经创建了4个页面,但是程序进行了剪切 在第一页。所以第2、3、4页是空的

如何解决这个问题

代码:

我必须在这里写更多的细节:p

看起来是这样的:

第1页: 你好,我的名字是 第2页: 第3页:
第4页:

似乎每页都有一个图表。您是否尝试过使用
graph2.DrawString(…)
?似乎每个页面都有一个图形。您是否尝试过使用
graph2.DrawString(…)
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;