Hello, how can I transfer a word document to pdf?

Hello, how can I transfer a word document to pdf? The format of pdf is the same as that of word document. The page numbers of pdf and word are the same, and the format is always the same. Please use java code to give an example. Thank you

@Mikeykiss Please see our documentation to learn how to convert document to PDF:
https://docs.aspose.com/words/java/convert-a-document-to-pdf/

Generally code is pretty simple:

Document doc = new Document("C:\\Temp\\in.docx");
doc.save("C:\\Temp\\out.pdf");

but please note, the fonts used in the original document must be available to build an accurate document layout. If Aspose.Words cannot find the fonts used in the document the fonts are substituted. This might lead into the layout differences due to differences in fonts metrics. You can implement IWarningCallback to get a notification when font substitution is performed.
The following articles can be useful for you:
https://docs.aspose.com/words/java/specify-truetype-fonts-location/
https://docs.aspose.com/words/java/install-truetype-fonts-on-linux/

@alexey.noskov May I ask which version of the method this code doc.getLayoutOptions().setKeepOriginalFontMetrics(true); is for

@Mikeykiss This option has been introduced in 23.6 version of Aspose.Words:
https://releases.aspose.com/words/java/release-notes/2023/aspose-words-for-java-23-6-release-notes/