通过Nuget添加iTextSharp引用,具体代码如下
/// <summary>
/// 添加页码
/// </summary>
/// <param name="pdfPath">pdf文件</param>
/// <param name="outPath">输出文件位置</param>
public static void PdfAddPageNumber(string pdfPath, string outPath)
{
//读取pdf
iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(pdfPath);
//创建新pdf
System.IO.Stream outStream = new System.IO.FileStream(outPath, System.IO.FileMode

该代码示例展示了如何通过iTextSharp库在PDF文件中添加页码。首先,通过Nuget引入iTextSharp,然后读取PDF,创建一个新的PDFStamper,在每一页上添加页码并设置字体、颜色和位置。最后,关闭流并启动输出文件。
最低0.47元/天 解锁文章
266

被折叠的 条评论
为什么被折叠?



