Word to Pdf Not Keeping Format

Creating a PDF from a Word document using Document Save method does not keep the styling of the original document. Notice the first line on the second page of the Word document CommodityReferencePrice appears as the last line of the first page of the resulting PDF
XXXXXXXX_202508080000173Z_3fe2aadc-71be-46d9-920d-ee3c447d5982.pdf (120.7 KB)
XXXXXXXX_202508080000173Z_3fe2aadc-71be-46d9-920d-ee3c447d5982.pdf (120.7 KB)

AsianSwap.docx (33.6 KB)

@IanMcInnes

It seems you’re experiencing formatting issues when converting a Word document to PDF using Aspose.Words. This can occur due to various reasons, such as complex layouts or specific styles in the Word document that may not translate perfectly to PDF.

To improve the fidelity of the conversion, you can use the PdfSaveOptions class to specify additional settings that might help maintain the original formatting. Here’s a simple example of how to implement this:

// Load the Word document
Document doc = new Document("AsianSwap.docx");

// Create PdfSaveOptions and set properties if needed
PdfSaveOptions options = new PdfSaveOptions();
// You can set options like compliance, optimization, etc.
// options.Compliance = PdfCompliance.Pdf17;
// options.OptimizeOutput = true;

// Save the document as PDF
doc.Save("Output.pdf", options);

If the issue persists, consider checking the following:

  1. Ensure that the Word document does not contain unsupported features or complex formatting.
  2. Experiment with different PdfSaveOptions settings to see if they affect the output.

If you are working with a plain text file instead of a Word document, please note that Aspose.Words is not designed for direct text file to PDF conversion without using a Word document format. In such cases, consider converting the text to a Word document first, then using the above method to convert it to PDF.

For further assistance, please consult the official Aspose.Words documentation for detailed guidance on converting documents to PDF and exploring various options and best practices.

I have tried different save options, saving the Word document as a PDF in Microsoft Word works fine

@IanMcInnes The problem is not reproducible on my side. As I can see, your document uses Aptos, which is cloud font, so it is not installed by default and is downloaded by MS Word on demand. Aspose.Words does not download cloud fonts.
The fonts are required to build document layout. If Aspose.Words cannot find the font used in the document, the font is substituted . This might lead into fonts mismatch and document layout differences due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

You can download Aptos fonts from here .