需要以 HTML 转换为 SVG 图像吗?使用 Aspose.Words for Python via .NET 任何开发人员都可以轻松地将 HTML 转换为 SVG 图像格式,只需几行 Python 代码。
现代文档处理 Python API 从 HTML 高速 SVG 直接在浏览器中 HTML 到 SVG 转换的质量。强大的 Python 库允许将 HTML 文件转换为许多流行的图像格式。
下面的例子演示了如何转换 HTML 为 SVG 画面中 Python 。
按照简单的步骤将 HTML 文件转换为 SVG 图形格式。从本地驱动器读取 HTML ,然后将其保存为 SVG SVG 扩展名指定所需的图像格式。对于 HTML 读取和 SVG 写入,您可以使用完全限定的文件名。输出 SVG 图形内容将与原始 HTML 文件相同。
import aspose.words as aw doc = aw.Document("Input.html") doc.save("Output.svg") import aspose.words as aw doc = aw.Document(Input.html) for page in range(0, doc.page_count): extractedPage = doc.extract_pages(page, 1) extractedPage.save(f"Output_{page + 1}.svg") import aspose.words as aw doc = aw.Document() builder = aw.DocumentBuilder(doc) builder.insert_image("Input.html") doc.save("Output.svg") import aspose.words as aw doc = aw.Document() builder = aw.DocumentBuilder(doc) shape = builder.insert_image("Input.html") shape.get_shape_renderer().save("Output.svg", aw.saving.ImageSaveOptions(aw.SaveFormat.svg)) Aspose.Words for Python via .NET安装 Aspose.Words。 将库引用(导入库)添加到您的Python项目。. 在Python打开源HTML文件。. 调用save()方法,传递带有SVG扩展名的输出文件名。. HTML转换的结果SVG 。. Aspose.Total Aspose.Words Aspose.PDF Aspose.Cells Aspose.Email Aspose.Slides Aspose.Imaging Aspose.BarCode Aspose.Diagram Aspose.Tasks Aspose.OCR Aspose.Note Aspose.CAD Aspose.3D Aspose.HTML Aspose.GIS Aspose.ZIP Aspose.Page Aspose.PSD Aspose.OMR Aspose.PUB Aspose.SVG Aspose.Finance Aspose.Drawing Aspose.Font Aspose.TeX 我的订单和报价 API 参考 aspose.com aspose.cloud aspose.app groupdocs.com groupdocs.cloud groupdocs.app conholdate.com conholdate.cloud conholdate.app containerize.com codeporting.com fileformat.com
import aspose.words as aw doc = aw.Document(Input.html) for page in range(0, doc.page_count): extractedPage = doc.extract_pages(page, 1) extractedPage.save(f"Output_{page + 1}.svg") import aspose.words as aw doc = aw.Document() builder = aw.DocumentBuilder(doc) builder.insert_image("Input.html") doc.save("Output.svg") import aspose.words as aw doc = aw.Document() builder = aw.DocumentBuilder(doc) shape = builder.insert_image("Input.html") shape.get_shape_renderer().save("Output.svg", aw.saving.ImageSaveOptions(aw.SaveFormat.svg)) Aspose.Words for Python via .NET安装 Aspose.Words。 将库引用(导入库)添加到您的Python项目。. 在Python打开源HTML文件。. 调用save()方法,传递带有SVG扩展名的输出文件名。. HTML转换的结果SVG 。. Aspose.Total Aspose.Words Aspose.PDF Aspose.Cells Aspose.Email Aspose.Slides Aspose.Imaging Aspose.BarCode Aspose.Diagram Aspose.Tasks Aspose.OCR Aspose.Note Aspose.CAD Aspose.3D Aspose.HTML Aspose.GIS Aspose.ZIP Aspose.Page Aspose.PSD Aspose.OMR Aspose.PUB Aspose.SVG Aspose.Finance Aspose.Drawing Aspose.Font Aspose.TeX 我的订单和报价 API 参考 aspose.com aspose.cloud aspose.app groupdocs.com groupdocs.cloud groupdocs.app conholdate.com conholdate.cloud conholdate.app containerize.com codeporting.com fileformat.com
import aspose.words as aw doc = aw.Document() builder = aw.DocumentBuilder(doc) builder.insert_image("Input.html") doc.save("Output.svg") import aspose.words as aw doc = aw.Document() builder = aw.DocumentBuilder(doc) shape = builder.insert_image("Input.html") shape.get_shape_renderer().save("Output.svg", aw.saving.ImageSaveOptions(aw.SaveFormat.svg)) Aspose.Words for Python via .NET安装 Aspose.Words。 将库引用(导入库)添加到您的Python项目。. 在Python打开源HTML文件。. 调用save()方法,传递带有SVG扩展名的输出文件名。. HTML转换的结果SVG 。. Aspose.Total Aspose.Words Aspose.PDF Aspose.Cells Aspose.Email Aspose.Slides Aspose.Imaging Aspose.BarCode Aspose.Diagram Aspose.Tasks Aspose.OCR Aspose.Note Aspose.CAD Aspose.3D Aspose.HTML Aspose.GIS Aspose.ZIP Aspose.Page Aspose.PSD Aspose.OMR Aspose.PUB Aspose.SVG Aspose.Finance Aspose.Drawing Aspose.Font Aspose.TeX 我的订单和报价 API 参考 aspose.com aspose.cloud aspose.app groupdocs.com groupdocs.cloud groupdocs.app conholdate.com conholdate.cloud conholdate.app containerize.com codeporting.com fileformat.com
import aspose.words as aw doc = aw.Document() builder = aw.DocumentBuilder(doc) shape = builder.insert_image("Input.html") shape.get_shape_renderer().save("Output.svg", aw.saving.ImageSaveOptions(aw.SaveFormat.svg)) Aspose.Words for Python via .NET安装 Aspose.Words。 将库引用(导入库)添加到您的Python项目。. 在Python打开源HTML文件。. 调用save()方法,传递带有SVG扩展名的输出文件名。. HTML转换的结果SVG 。. Aspose.Total Aspose.Words Aspose.PDF Aspose.Cells Aspose.Email Aspose.Slides Aspose.Imaging Aspose.BarCode Aspose.Diagram Aspose.Tasks Aspose.OCR Aspose.Note Aspose.CAD Aspose.3D Aspose.HTML Aspose.GIS Aspose.ZIP Aspose.Page Aspose.PSD Aspose.OMR Aspose.PUB Aspose.SVG Aspose.Finance Aspose.Drawing Aspose.Font Aspose.TeX 我的订单和报价 API 参考 aspose.com aspose.cloud aspose.app groupdocs.com groupdocs.cloud groupdocs.app conholdate.com conholdate.cloud conholdate.app containerize.com codeporting.com fileformat.com