The width of the table does not fit the content. The drilling tool combination column in the table is too wide. What is the reason for this

Hello, the width of the table in the HTML to PDF file has been compressed. The code is as follows

Document doc = new Document("E:\\测试文档\\正式文档.html");
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2019);
// 保存为 Word 文件
doc.save("E:\\测试文档\\1.pdf", SaveFormat.PDF);

problem.zip (208.2 KB)

@Mikeykiss The attached input HTML does not correspond the attached PDF and screenshots.

Please also note, Aspose.Words is designed to work with MS Word documents. HTML documents and MS Word documents object models are quite different and it is not always possible to provide 100% fidelity after conversion one format to another. In most cases Aspose.Words mimics MS Word behavior when import HTML documents. Here is a PDF document produced by MS Word 2019 from your original HTML document:
ms.pdf (149.5 KB)

And here is output produced by Aspose.Words:
out.pdf (62.8 KB)

Sorry, the input file is not the source file. Could you please download it again and take a look at the issue? Thank you

Could you please download the issue again and take a look? Thank you

problem.zip (208.2 KB)

@Mikeykiss The table in the source HTML is simply too wide. You can increase page size to improve output. For example see the following code:

Document doc = new Document("C:\\Temp\\in.html");
doc.getFirstSection().getPageSetup().setPaperSize(PaperSize.A3);
doc.getFirstSection().getPageSetup().setOrientation(Orientation.LANDSCAPE);
doc.save("C:\\Temp\\out.pdf");

What method is there to make the table automatically adapt to the window size without setting the page size

@Mikeykiss Unfortunately, there is no way to automatically adjust page width to content. HTML documents and MS Word documents are quite different. In HTML there is no page concept and content is adjusted to the window. In MS Word documents each section has page setup and content is adjusted to page by the consumer application. If you open HTML using MS Word you will see the similar behavior.
You can consider using Aspose.HTML if it is required to render HTML like browser does.

Hello, may I ask why the exported Wrod table and PDF table are different? Please check the Wrod.png and PDF files

output file.zip (874.6 KB)

@Mikeykiss On my side table in MS Word loos similar to the produced PDF:

Document layout depends on the preferred language specified in MS Word. If change preferred language to Chinese in MS Word, table looks like on your screenshot.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26100

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.