hello,
you can look at the following document when converting to PDF it behaves differently than in ms Word
input.docx (36.9 KB)
input.Save(@"...input.pdf", SaveFormat.Pdf);
hello,
you can look at the following document when converting to PDF it behaves differently than in ms Word
input.docx (36.9 KB)
input.Save(@"...input.pdf", SaveFormat.Pdf);
When converting a Word document to PDF using Aspose.Words, you may encounter differences in formatting compared to how the document appears in Microsoft Word. This can happen due to various reasons, including how certain elements are rendered or how specific formatting is interpreted during the conversion process.
To address these differences, you can utilize the PdfSaveOptions
class, which provides various settings to control the PDF output. Here are some options you might consider adjusting:
Font Embedding: Ensure that all fonts used in the document are embedded in the PDF. This can help maintain the appearance of the document. You can set this option as follows:
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.EmbedFullFonts = true; // Embed all fonts
Image Compression: If your document contains images, you can control how they are compressed in the PDF. This can affect the quality and size of the output PDF:
saveOptions.ImageCompression = PdfImageCompression.Jpeg; // Use JPEG compression
Document Structure: If you want to maintain the document’s structure in the PDF, you can enable the export of document structure:
saveOptions.ExportDocumentStructure = true; // Export document structure
Handling Warnings: If there are any rendering issues during the conversion, you can implement a warning callback to capture and handle these warnings:
doc.WarningCallback = new HandleDocumentWarnings();
Compliance Level: You can specify the PDF compliance level to ensure compatibility with different PDF standards:
saveOptions.Compliance = PdfCompliance.Pdf17; // Set compliance to PDF 1.7
Here is a sample code snippet that incorporates these options:
Document doc = new Document("input.docx");
PdfSaveOptions saveOptions = new PdfSaveOptions
{
EmbedFullFonts = true,
ImageCompression = PdfImageCompression.Jpeg,
ExportDocumentStructure = true,
Compliance = PdfCompliance.Pdf17
};
doc.Save("output.pdf", saveOptions);
By adjusting these settings, you may be able to reduce the differences you observe between the Word document and the resulting PDF. If you continue to experience issues, consider reviewing the specific elements in your document that are not rendering as expected, as some complex formatting may require additional handling.
For more detailed information on the available options and their effects, you can refer to the Aspose documentation on exporting documents to PDF.
@benestom
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-27859
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.
The issues you have found earlier (filed as WORDSNET-27859) have been fixed in this Aspose.Words for .NET 25.4 update also available on NuGet.