按模板生成内容,转换成长图保存:
Document doc = new Document("A_BizRpt.docx");
.......
Image[] imgs = doc.SaveToImages(ImageType.Metafile);
var finalHeight = imgs.Sum(img => img.Height);
var finalWidth = imgs.Max(img => img.Width);
var finalImg = new Bitmap(finalWidth, finalHeight);
Graphics g = Graphics.FromImage(finalImg);
g.Clear(SystemColors.AppWorkspace);
var height = 0;
foreach (Image img in imgs)
{
g.DrawImage(img, new Point(0, height));
height += img.Height;
img.Dispose();
}
g.Dispose();
finalImg.Save("1.png", System.Drawing.Imaging.ImageFormat.Png);
finalImg.Dispose();