spire.pdf导出图片,只能导出11张图片,而且带有水印

发布时间 2023-08-12 12:49:42作者: .net&new

/// <summary>
/// 有水印
/// </summary>
/// <param name="pdfUrl">pdf文件路径</param>
/// <param name="imagePath">输出图片路径</param>
public static void SpirePdfToImage(string pdfUrl,string imagePath)
{
Spire.Pdf.PdfDocument doc = new Spire.Pdf.PdfDocument();
doc.LoadFromFile(pdfUrl);

#region 注释生成所有图片
//save to image
//for (int i = 0; i < doc.Pages.Count; i++)
//{
// String fileName = String.Format("ToBmp-img-{0}.bmp", i);
// using (Image image = doc.SaveAsImage(i, 300, 300))
// {
// image.Save(fileName, System.Drawing.Imaging.ImageFormat.Bmp);
// System.Diagnostics.Process.Start(fileName);

// }
//}
#endregion


//可以生成,但是有水印
if (doc.Pages.Count>0)
{

for (int i = 0; i < doc.Pages.Count; i++)
{
String fileName = imagePath + DateTime.Now.ToString("yyyyMMddHHmmssfff")+".png";
using (Image image = doc.SaveAsImage(i, 12, 12))
{
image.Save(fileName, System.Drawing.Imaging.ImageFormat.Bmp);
//System.Diagnostics.Process.Start(fileName);

}
}

}

doc.Close();
}