我使用 docX 库创建了一个 docX,并在标题中添加了一个图像。但是,当我使用 Spire.doc 库将 docX 转换为 PDF 时,图像会丢失。知道为什么吗?下面是我的代码:
var doc = DocX.Create(fileName);
string url = @"C:\Users\Desktop\Capture.JPG";
Novacode.Image img = doc.AddImage(url);
Picture pic = img.CreatePicture();
doc.AddHeaders();
Header header_default = doc.Headers.odd;
Paragraph p1 = header_default.InsertParagraph();
p1.Append(headerText).Bold().Color(System.Drawing.Color.LightGray).FontSize(20);
p1.AppendPicture(pic);
doc.Save();
Document docS = new Document();
docS.LoadFromFile(fileName);
string pdfPath = @"C:\Users\Documents\toPDF.PDF";
docS.SaveToFile(pdfPath, FileFormat.PDF);