複数の単一のpdfページを1つのpdfに結合し、同時に最初のページの上部に番号を付けたいです。透かしのようなものですが、左上に配置されています。
これを解決する方法を知っている人はいますか?
今、ファイルをマージする次のコードを取得しました。
        Console.WriteLine("Merging started.....");
    PdfDocument outputPDFDocument = new PdfDocument();
    foreach (string pdfFile in pdfFiles)
    {
        PdfDocument inputPDFDocument = PdfReader.Open(pdfFile, PdfDocumentOpenMode.Import);
        outputPDFDocument.Version = inputPDFDocument.Version;
        foreach (PdfPage page in inputPDFDocument.Pages)
        {
            outputPDFDocument.AddPage(page);
        }
    }
    outputPDFDocument.Save(outputFilePath);
    Console.WriteLine("Merging Completed");
            addOverlay(outputPDFDocument);
編集:保存後に結合されたドキュメントを開き、テキストを追加することで機能させました。
    public static void addOverlay(PdfDocument combined_pdf)
{
    PdfDocument document = combined_pdf;
    // Select the first page
    PdfPage page = document.Pages[0];
    page.Orientation = PageOrientation.Portrait;
    XGraphics gfx = XGraphics.FromPdfPage(page, XPageDirection.Downwards);
    // Write on top of background with known colors
    gfx.DrawString("TEXT ON PDF PAGE", new XFont("Helvetica", 12, XFontStyle.Regular), XBrushes.White, 10, 0, XStringFormats.TopLeft);
    // Save the new modified document...
    document.Save("final_path");
}