Hi,
we got a document which resuits in a broken layout after converting to PDF and also the logo colour in the header does not match.
using Aspose.Words;
var lic = new License();
lic.SetLicense(@"D:\Aspose.Total.NET.lic");
var doc = new Document(@"D:\tmp\in.docx");
doc.Save(@"D:\tmp\out.pdf");
example.zip (410.9 KB)
Zip contains Aspose output and a PDF generated by Word.
Tested with net 8.0 on Win 11.
@Serraniel
To address the issue of layout changes and color discrepancies when converting a Word document to PDF using Aspose.Words, you can utilize the PdfSaveOptions
class to customize the PDF output settings. Here are some steps and options you can consider to improve the layout and ensure the logo color matches:
-
Embed Fonts: Ensure that all fonts used in the document are embedded in the PDF. This can help maintain the original appearance of the document. You can do this by setting the EmbedFullFonts
property to true
in the PdfSaveOptions
.
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.EmbedFullFonts = true;
-
Image Compression: If the logo color is not rendering correctly, check the image compression settings. You can set the ImageCompression
property to control how images are handled in the PDF. For example, you can use JPEG compression for better quality.
saveOptions.ImageCompression = PdfImageCompression.Jpeg;
-
DML Effects Rendering: If your document contains DrawingML (DML) shapes, you can adjust the rendering mode to ensure better fidelity. Set the DmlEffectsRenderingMode
to DmlEffectsRenderingMode.Fine
for higher quality rendering.
saveOptions.DmlEffectsRenderingMode = DmlEffectsRenderingMode.Fine;
-
Export Document Structure: If you want to maintain the document’s structure, you can enable the ExportDocumentStructure
option. This can help with accessibility and navigation in the PDF.
saveOptions.ExportDocumentStructure = true;
-
Save the Document: Finally, save the document with the specified options.
var doc = new Document(@"D:\tmp\in.docx");
doc.Save(@"D:\tmp\out.pdf", saveOptions);
By applying these settings, you should be able to achieve a more accurate representation of your Word document in the PDF format, including the correct layout and logo colors.
If you continue to experience issues, consider checking the original document for any specific formatting or color settings that may not translate well during the conversion process.
For more detailed information on the PdfSaveOptions
and its properties, you can refer to the Aspose documentation on saving documents as PDF.
Sources:
[1]: Saving Documents as PDF in Aspose.Words for Java
Issues still exist after applying the bots suggestions.
@Serraniel
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-27713
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.