MHT Python のファイルビューア

Adobe Acrobat や Python を使ったオートメーションを使わずに MHT ドキュメントをブラウザで表示できます。

Python for .NET ライブラリを使用して MHT ファイルを表示する方法

MHT ファイルを表示するには、Aspose.PDF for .NET API を使用します。これは python-net プラットフォーム用の機能豊富でパワフルで使いやすいドキュメント操作 API です。NuGet パッケージマネージャーを開き、AsPose.pdf を検索してインストールします。パッケージマネージャーコンソールから以下のコマンドを使用することもできます。

Python Package Manager Console

pip install aspose-pdf

Python 経由で MHT ファイルを表示する


ご使用の環境でコードを試すには Aspose.PDF for .NET が必要です。

1。MHT を Document のインスタンスとともにロードします。 1。結果のファイルを表示します。

Python-MHT ファイルを表示するためのサンプルコード。

<% viewer-files.code-block.subtitle %>

    MhtLoadOptions options= new MhtLoadOptions();
    Resolution resolution = new Resolution(300);
    BmpDevice imageDevice = new BmpDevice(resolution);
    Document pdfDocument= new Document(_dataDir + "test.mhtm", options);
    for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
    {
        using (FileStream imageStream =
        new FileStream($"{_dataDir}image{pageCount}_out.{ext}", FileMode.Create))
        {
            // Convert a particular page and save the image to stream
            imageDevice.Process(pdfDocument.Pages[pageCount], imageStream);

            // Close stream
            imageStream.Close();
        }
    }