Aspose.Wordsで変換したHTMLの文字の開始位置が違います

お世話になっております、ホープランの秦です。

掲題の件、
「Aspose.Words for Java Developer Small Business」(バージョン18.1+JDK8)でワードをHTMLに変換する場合、ワード中に文字の位置がずれませんが、変換後のHTMLは文字の位置がずれました。お客様から指摘されましたので、解決策をご提示ください。
詳細は文字開始位置ずれ問題.zip (634.6 KB)資料中の 表の枠線問題.xlsx ファイルをご参照ください。

以上、よろしくお願い致します。

@bluezealot

ご質問ありがとうございます。 Aspose.WordsはMS Wordの動作を模倣しています。 あなたの場合、リストラベルはインラインテキストとして出力されます。 Aspose.Words 'の出力はMS Wordより優れています。 Aspose.Words for Java 18.10の最新バージョンにアップグレードすることをお勧めします。

あなたの場合、リストラベルはインラインテキストとして出力されます。

ご回答いただき、有難うございました。
此方は色々調査しましたが、仰っている内容は理解できておりません。
ワードファイルのどこの設定なのかを少し詳細に説明していただけますか?

English translation:
Thanks for reply, we have investigated for two days but still can’t find out what’s wrong with the word file.Can you please explain this more specifically?(We have to find out how to make the lines start at the same place either by modify the word file or by upgrade aspose.)

@bluezealot

ご質問ありがとうございます。 あなたの文書では、1つのリスト項目がフォント "Webdings"と他の画像を持つlableを持っています。 添付イメージ を確認してください。 同じタイプのリストを使用してください。

ExportListLabels は、リストラベルをHTMLにエクスポートする方法を指定する定数を含むユーティリティクラスです。 定数はAS_INLINE_TEXT、BY_HTML_TAGS、AUTOです。 リストラベルとして画像を使用する場合は、以下のようにExportListLabels.BY_HTML_TAGSを使用してください。 これがあなたを助けることを願っています

Document doc = new Document(MyDir + "input.docx");
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportListLabels(ExportListLabels.BY_HTML_TAGS);
doc.save(MyDir + "18.10.html", options);

ご回答いただき、有難うございました。

教えていただいた方法で試しました、 文字開始位置ずれ問題.zip中のワードファイルを変更してみました。
変更後のHTMLは画像イメージConvertResult.zip (38.7 KB)になります、リストのアイコンが変になりました。
此方の使い方は間違っていますか?正しい変更する方法を教えていただけますか?
(Wordファイルのフォントは確認中です。)

English translation:
Thanks for your information, we added the ExportListLabels.BY_HTML_TAGS option to our source code,but the result became to ConvertResult.zip (38.7 KB).As we mentioned in the attachment(ConvertResult.zip (38.7 KB)) that we got a new problem which is the icon of list had been changed to the ones that different from the word file.
Could you tell how to correct this please?

以上、よろしくお願い致します。

@bluezealot

ご質問ありがとうございます。 私たちはあなたの質問を処理しており、すぐにあなたに連絡します。

@bluezealot

お待ち頂きまして、ありがとうございます。 以下のコード例を使用して、Windows 10およびUbuntuオペレーティングシステムでAspose.Words for Java 18.10の最新バージョンを使用してシナリオをテストしました。 我々は共通の問題を発見していない。 Aspose.Words for Java 18.10を使用してください。 私たちはあなたの親切な参照のためにこの投稿と出力文書を添付しました。
Docs.zip (20.0 KB)

Document doc = new Document(MyDir + "input.docx");
doc.save(MyDir + "18.10.html");

お待ち頂きまして、ありがとうございます。 以下のコード例を使用して、Windows 10およびUbuntuオペレーティングシステムでAspose.Words for Java 18.10の最新バージョンを使用してシナリオをテストしました。 我々は共通の問題を発見していない。 Aspose.Words for Java 18.10を使用してください。 私たちはあなたの親切な参照のためにこの投稿と出力文書を添付しました。
Docs.zip (20.0 KB)

ご回答いただき、ありがとうございました。
此方は以下の環境で試しました、ご提示いただいたHTML(Docs.zip (20.0 KB))を変換できません。
OS情報
windows:Windows7(6.1.7601)
Linux :Red Hat Enterprise Linux Server release 6.4(Santiago)
ASPOSEのバージョン情報
Aspose.Words for Java 18.10
変更対象ワードファイル
word.zip (289.0 KB)
質問:

ソース

Document doc = new Document(MyDir + "input.docx"); 
doc.save(MyDir + "18.10.html”);

変換結果result1.zip (23.7 KB)
問題点
trouble1.png (62.3 KB)


ソース

Document doc = new Document(MyDir + "input.docx”);
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportListLabels(ExportListLabels.BY_HTML_TAGS);
doc.save(MyDir + "18.10.html", options);

変換結果result2.zip (45.3 KB)
問題点
trouble2.png (54.2 KB)
長くなり、申し訳ございませんが、問題点を再度ご確認いただければと思います。

English version:
Thanks for your answer.But we can’t get the same result(Docs.zip (20.0 KB)).We have tried in the environment below.

OS :
windows:Windows7(6.1.7601)
Linux :Red Hat Enterprise Linux Server release 6.4(Santiago)
ASPOSE:
Aspose.Words for Java 18.10
Word file:
word.zip (289.0 KB)
Here is the source code and the troubles we got:
1.
Source:

Document doc = new Document(MyDir + "input.docx"); 
doc.save(MyDir + "18.10.html”);

Convert result:result1.zip (23.7 KB)
Trouble:
trouble1.png (62.3 KB)
2.
Source:

Document doc = new Document(MyDir + "input.docx”);
HtmlSaveOptions options = new HtmlSaveOptions();
options.setExportListLabels(ExportListLabels.BY_HTML_TAGS); 
doc.save(MyDir + "18.10.html", options);

Convert result:result2.zip (45.3 KB)
Trouble:
trouble2.png (54.2 KB)

Thanks for your patience to read this long article. Can you check this issue agin please?

以上、よろしくお願い致します。

@bluezealot

詳細を共有していただきありがとうございます。 ExportListLabels.BY_HTML_TAGSを使用して、期待される出力に直面しています。 しかし、このオプションはあなたのケースでは役に立ちません。 ですので、使用しないでください。

Linuxオペレーティングシステムで次のコード例を使用して、リストラベルの後にスペーシングの問題が発生しています。 出力HTMLは、Aspose.Words for Java 18.1によって生成されます。 Aspose.Words for Java 18.11の最新バージョンを使用することをお勧めします。

Aspose.WordsのDOMに文書をインポートする前に一時ライセンスを取得して適用してください。
一時ライセンスを取得する
ライセンスを適用する

教えていただき、ありがとうございました。
こちらは原因を究明するために、調査用のソースを作成しました。
添付ファイル「TestListConvert.zip (92.3 KB)
」をご参照ください。

調査用ソースの構成:
該当ファイルを解凍し、srcフォルダ配下はソース、testFileフォルダ配下はテスト用ワードファイル、
WithoutParameterフォルダはExportListLabels.BY_HTML_TAGSを使っていない変換結果、
WithParameterフォルダはExportListLabels.BY_HTML_TAGSを使った変換結果です。

こちらのソースと変換結果をご確認ください、こちらの実装は正しくないのであれば御指摘ください。こちらの実装は正しければ、下記質問をご確認ください。

  1. リストのラベルは画像の場合(list1.docx)、下記のように対応していただければどうでしょうか?
    HTMLは画像の横幅によってliタグのスタイルmargin-leftを設定して、
    余計な設定text-indentとlist-style-position:inside;を削除すれば、文字ずれが修正できます。 この方法によって作ったHTMLはmodify.zip (2.0 KB)です。
    2.リストのラベルは画像ではない場合(list2.docx)、なぜExportListLabels.BY_HTML_TAGSパラメータを指定しないと、ワード中のリストをHTMLに変換した結果はリストではなくなりますか?(WithoutParameter/list2.htmlをご確認ください。)

English:
Thanks for reply.
We created a test project(TestListConvert.zip (92.3 KB)) to research this issue.
Please unzip the file and you’ll find the following contents:
src folder: The source files.
testFile folder:Word files that used as test input.
WithouParameter folder:Convert result that without using ExportListLabels.BY_HTML_TAGS option.
WithParameter folder:Convert result that using ExportListLabels.BY_HTML_TAGS option.

If we are correctly using aspose in this small project,please kindly answer the following questions.
1.When the list lable is image(list1.docx situation),how about change html as the following?
Set the “li”'s margin-left style as the width of list lable image(in this example it is 60px).
Then delete text-indent and list-style-position options.
We’ve made a example html modify.zip (2.0 KB).
2.When the list lable is not image(list2.docx situation),
Why does aspose lost list style when without using ExportListLabels.BY_HTML_TAGS option? (The converted html sample: WithoutParameter/list2.html)

@bluezealot

ご質問ありがとうございます。

ListLevel.ImageDataプロパティを使用して、リストラベルに画像の箇条書きの形状があるかどうかを確認できます。 ParagraphFormat.FirstLineIndentプロパティを使用して、最初の行またはぶら下げインデントを設定できます。 最初の行インデントを設定するには正の値を使用し、負のインデントを設定するには負の値を使用します。 次のコードスニペットを確認してください。

Document document = new Document(MyDir + "list1.docx");

if(document.getFirstSection().getBody().getFirstParagraph().getListFormat().getList().getListLevels().get(0).getImageData() != null)
{
    document.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().setFirstLineIndent(-60);
}

HtmlSaveOptions.ExportListLabelsプロパティのデフォルト値はAutoです。 出力リストのラベルは自動モードです。 可能であれば、HTMLネイティブ要素を使用します。 このプロパティにはBY_HTML_TAGS値またはAS_INLINE_TEXT値を使用することをおすすめします。