Gunakake API konversi dokumen kanggo ngembangake piranti lunak independen platform tingkat dhuwur ing Python. Iki minangka solusi piranti lunak profesional lengkap kanggo ngimpor lan ngekspor MHTML, PDF, lan akeh format dokumen liyane nggunakake Python.
Kanggo pangembang Python sing nggoleki solusi sing lancar kanggo ngowahi MHTML dadi PDF, Aspose.Words for Python via .NET nyedhiyakake API konversi file sing intuisi lan langsung. Solusi kita ngidini pangembang Python gampang ngowahi file saka format siji menyang format liyane, dadi alat sing penting kanggo ngotomatisasi tugas konversi file.
Apa sampeyan nggarap MHTML, PDF utawa format file liyane, Aspose.Words for Python via .NET nyakup kabeh lan njamin asil sing paling dhuwur. Tes carane kode Python bisa digunakake karo file MHTML sampeyan saiki.
Conto ing ngisor iki nduduhake carane ngowahi MHTML dadi PDF kanthi mung sawetara baris kode Python. Mulai kanthi nyakup spasi jeneng Aspose.Words ing proyek Python. Sabanjure, nemtokake path menyang file input lan nggawe obyek Document kanggo mbukak isi MHTML. Sampeyan banjur kudu nemtokake path menyang file output PDF lan nggunakake metode save() kanggo nyimpen asil minangka PDF. API konversi bakal nemtokake format file output adhedhasar ekstensi file sing ditemtokake.
pip install aspose-words
Nyalin
import aspose.words as aw
doc = aw.Document("Input.mhtml")
doc.save("Output.pdf")
import aspose.words as aw
doc = aw.Document("Input.mhtml")
doc.save("Output.pdf")
import aspose.words as aw
doc = aw.Document("Input.mhtml")
save_options = aw.saving.ImageSaveOptions(aw.SaveFormat.pdf)
for page in range(doc.page_count):
save_options.page_set = aw.saving.PageSet(page)
doc.save(f"Output_{page + 1}.pdf", save_options)
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
builder.insert_image("Input.mhtml")
doc.save("Output.pdf")
import aspose.words as aw
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
shape = builder.insert_image("Input.mhtml")
shape.get_shape_renderer().save("Output.pdf", aw.saving.ImageSaveOptions(aw.SaveFormat.pdf))
Kita dadi tuan rumah paket Python ing repositori PyPi. Mangga tindakake langkah-langkah dening-instruksi carane nginstal "Aspose.Words for Python via .NET" kanggo lingkungan pangembang.
Paket iki kompatibel karo Python ≥3.5 lan <3.12. Yen sampeyan ngembangake piranti lunak kanggo Linux, deleng syarat tambahan kanggo gcc lan libpython ing Dokumentasi Produk.
Sampeyan bisa ngowahi MHTML menyang akeh format file liyane: