从7.3.3版本开始,spire.doc支持转换word文档到pdf时,保留word文档的标题作为pdf书签。本文将介绍如何使用spire.doc来实现这一功能。
原word文档:
c#
using spire.doc;
namespace keep_word_headings_as_pdf_bookmarks {
class program {
private static void main(string[] args) {
document doc = new document(false);
doc.loadfromfile("input.docx");
topdfparameterlist topdf = new topdfparameterlist();
topdf.createwordbookmarks = true;
topdf.createwordbookmarksusingheadings = true;
doc.savetofile("output.pdf", topdf);
}
}
}
vb.net
imports spire.doc
namespace keep_word_headings_as_pdf_bookmarks
class program
private shared sub main(byval args() as string)
dim doc as document = new document(false)
doc.loadfromfile("input.docx")
dim topdf as topdfparameterlist = new topdfparameterlist
topdf.createwordbookmarks = true
topdf.createwordbookmarksusingheadings = true
doc.savetofile("output.pdf", topdf)
end sub
end class
end namespace
生成pdf文档: