Hi Support,
We are licensed users of Aspose.Total. We are facing formatting issues while converting document from Word to PDF.
We are trying to render the PDF with Bookmarks retained and below is how we have implemented the conversion
private static void ConvertUsingAspose(Stream docStream, string SaveLocation)
{
string _currentPath = AppDomain.CurrentDomain.BaseDirectory;
string _licenseFilePath = _currentPath + Config.AsposeLocation;
if (File.Exists(_licenseFilePath))
{
License license = new License();
license.SetLicense(_licenseFilePath);
}
var wordDocument = new Document(docStream);
var saveOptions = new Aspose.Words.Saving.PdfSaveOptions
{
SaveFormat = SaveFormat.Pdf
};
saveOptions.OutlineOptions.DefaultBookmarksOutlineLevel = 1;
foreach (var bookmark in wordDocument.Range.Bookmarks)
{
saveOptions.OutlineOptions.BookmarksOutlineLevels.Add(bookmark.Name, 1);
}
wordDocument.Save(SaveLocation, saveOptions);
}
I have attached the screenshot of both docx and pdf to highlight the differences. Please let me know for more information.
@Raghunandan_R
It seems you are experiencing formatting issues when converting a Word document to PDF using Aspose.Words. This can sometimes occur due to the complexity of the PDF format and how it handles layout and rendering compared to Microsoft Word.
To address alignment issues during the conversion, you can try the following suggestions:
-
Check Font Embedding: Ensure that the fonts used in your Word document are properly embedded in the PDF. You can control font embedding using the EmbedFullFonts
property in the PdfSaveOptions
. Setting this to true
will embed all fonts, which can help maintain the document’s appearance.
var saveOptions = new PdfSaveOptions
{
EmbedFullFonts = true
};
-
Use Core Fonts: If your document uses standard fonts like Arial or Times New Roman, consider using the UseCoreFonts
property to avoid embedding these fonts, which can sometimes lead to discrepancies in rendering.
var saveOptions = new PdfSaveOptions
{
UseCoreFonts = true
};
-
Adjust Layout Options: You can specify additional layout options in the PdfSaveOptions
to better control how the document is rendered. For example, you can set the ExportDocumentStructure
property to true
to preserve the document’s structure.
var saveOptions = new PdfSaveOptions
{
ExportDocumentStructure = true
};
-
Review Document Structure: If your document contains complex elements like tables or images, ensure that they are properly formatted in Word. Sometimes, issues in the original document can lead to unexpected results in the PDF.
-
Test with Different PDF Compliance Levels: You can experiment with different PDF compliance levels (e.g., PDF/A) to see if that resolves the formatting issues. This can be set using the Compliance
property in PdfSaveOptions
.
var saveOptions = new PdfSaveOptions
{
Compliance = PdfCompliance.PdfA2u
};
-
Check for Updates: Ensure that you are using the latest version of Aspose.Words, as updates often include bug fixes and improvements related to document conversion.
If you continue to face issues, consider sharing specific details about the formatting discrepancies you are observing, as well as any relevant code snippets or settings you are using. This will help in diagnosing the problem more effectively.
For more detailed information on rendering options and how to control the conversion process, you can refer to the Aspose documentation on specifying rendering options when converting to PDF.
If you have any further questions or need additional assistance, feel free to ask!
@Raghunandan_R Could you please attach your problematic input and output documents here for testing? We will check the issue and provide you more information. Unfortunately, screenshots does not give enough information for analysis.
@Raghunandan_R
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-28159
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.
1 Like