この簡単な記事では、Python で Word を PCL に変換する方法について説明します。これには、環境を確立するために必要な情報がすべて含まれており、Python を使用して DOCX を PCL に変換するための実用的なコード例が提供されています。開発されたアプリケーションは、macOS、Linux、または MS Windows の Python および .NET で構成された環境内で使用できます。
Python で DOCX を PCL にエクスポートする手順
- .NET 経由の Python 用 Aspose.Words を使用して Python で DOCX ファイルを PCL に変換する環境を確立します
- Document クラスのインスタンスを作成して、それを PCL ファイルに変換します
- PclSaveOptions クラス オブジェクトのインスタンスを作成して、必要な出力 PCL ファイル設定を設定します
- ロードした DOCX ドキュメントを PCL ファイルとしてディスクに保存します
上記の手順は、単純な API インターフェイスを使用して Word ドキュメントを Python の PCL に変換するプロセスを説明しています。このプロセスは、ディスクまたはメモリ ストリームを使用してソース DOCX ファイルをロードすることによって開始され、その後、PclSaveOptions クラス オブジェクトを作成して、目的の出力 PCL ファイル プロパティを設定します。最後に、アクセスした Word 文書は、save メソッドを使用してディスク上の PCL ファイルにエクスポートされます。
Python で Word を PCL に変換するコード
import aspose.words as aw | |
import io | |
# Path to the source files | |
filePath = "Y://Documents//KnowledgeBase//TestData//" | |
# Load the Aspose.Words license in your application to convert DOCX to PCL | |
wordLicense = aw.License() | |
wordLicense.set_license(filePath + "Conholdate.Total.Product.Family.lic") | |
# Instantiate the Document class object to load the source word | |
srDocument = aw.Document(filePath + "Test1.docx") | |
# Set the PCL save options | |
options = aw.saving.PclSaveOptions() | |
options.allow_embedding_post_script_fonts = True | |
options.color_mode = aw.saving.ColorMode.GRAYSCALE | |
options.jpeg_quality = 100 | |
# Save the PCL file | |
srDocument.save(filePath + "DocumentAppendDocument.pcl", options) | |
print ("Documents converted to PCL successfully") |
前述のコードは、いくつかの API 呼び出しを使用して Python で DOCX を PCL にエクスポートするプロセスを実行します。 PclSaveOptions クラスを使用すると、いくつかを認識するように color_mode、allow_embedding_post_script_fonts、dml_3d_Effects_rendering_mode、export_generator_name、fallback_font_name、jpeg_quality を設定するなど、さまざまなプロパティを設定して、出力 PCL ファイルをさらにカスタマイズできます。
この記事では、Python を使用して Word ドキュメントを PCL に変換する方法について説明します。 Word 文書を結合するプロセスについて詳しく知りたい場合は、Python を使用して Word ドキュメントを結合する方法 の記事を参照してください。