需要以编程方式将 Web 文件转换为 PDF?使用Aspose.Words for Node.js via .NET JavaScript 代码即可将 MD 转换为 PDF 格式。
我们的 JavaScript API 从 MD 以专业品质创建 PDF。直接在您的浏览器中测试最高质量的 MD 到 PDF 转换。强大的 Node.js via .NET 转换 API 允许将 MD 文件转换为多种流行格式。
以下示例演示了如何在 JavaScript MD 转换为 PDF。
按照简单的步骤将 MD 文件转换为 PDF 格式。从本地驱动器读取您的 MD 文件,然后只需将其保存为便携式文档格式,并通过 PDF 扩展名指定所需的文件格式。对于 MD 阅读和 PDF 写作,您可以使用完全限定的文件名。输出的 PDF 内容和格式将与原始 MD 文档相同。
npm install @aspose/words
复制
const aw = require('@aspose/words');
var doc = new aw.Document("Input.md")
doc.save("Output.pdf")
const aw = require('@aspose/words');
var doc = new aw.Document("Input.md")
doc.save("Output.pdf")
const aw = require('@aspose/words');
var doc = new aw.Document("Input.md")
for (var page = 0; page < doc.pageCount; page++) {
var extractedPage = doc.extractPages(page, 1);
extractedPage.save(`Output_${page + 1}.pdf`);
}
const aw = require('@aspose/words');
var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)
builder.insertImage("Input.md")
doc.save("Output.pdf")
const aw = require('@aspose/words');
var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)
shape = builder.insertImage("Input.md")
shape.getShapeRenderer().save("Output.pdf", new aw.Saving.ImageSaveOptions(aw.SaveFormat.pdf))
We host our Node.js via .Net packages in NPM repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Node.js via .NET" to your developer environment.
This package is compatible with Node.js 14.17.0 or higher.