需要以編程方式將圖像轉換為 HTML 文件嗎?借助Aspose.Words for Node.js via .NET,任何開發人員只需幾行 JavaScript 代碼即可輕鬆將圖像轉換為 HTML 格式。
現代圖像處理 JavaScript API 從圖像中高速創建 HTML。直接在瀏覽器中測試圖像到 HTML 轉換的質量。強大的 JavaScript 庫允許將圖片轉換為許多流行的文檔格式。
以下示例演示瞭如何在 JavaScript 中將圖像轉換為 HTML。
按照簡單的步驟將圖片轉換為 HTML 格式。從本地驅動器讀取圖像,然後將其簡單地保存為 HTML 文件,並通過 HTML 擴展名指定所需的文檔格式。對於圖像讀取和 HTML 寫入,您可以使用完全限定的文件名。輸出 HTML 內容將與源圖像相同。
npm install @aspose/words
複製
const aw = require('@aspose/words');
var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)
builder.insertImage("Input.png")
doc.save("Output.html")
const aw = require('@aspose/words');
var doc = new aw.Document("Input.png")
doc.save("Output.html")
const aw = require('@aspose/words');
var doc = new aw.Document("Input.png")
for (var page = 0; page < doc.pageCount; page++) {
var extractedPage = doc.extractPages(page, 1);
extractedPage.save(`Output_${page + 1}.html`);
}
const aw = require('@aspose/words');
var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)
builder.insertImage("Input.png")
doc.save("Output.html")
const aw = require('@aspose/words');
var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)
shape = builder.insertImage("Input.png")
shape.getShapeRenderer().save("Output.html", new aw.Saving.ImageSaveOptions(aw.SaveFormat.html))
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.
您可以將圖片轉換為許多其他文件格式: