Hello Aspose Support Team,
I’m generating documents using Aspose.Words from a template (.docx
) and dynamic JSON data. The output is generated in both DOCX and PDF formats, but I’m observing a noticeable alignment difference between the two outputs — for example, table or text alignment shifts when comparing the DOCX and the converted PDF.
Here’s the relevant part of my code:
// Save the result
using (MemoryStream outputStream = new MemoryStream())
{
if (outputFormate == ".pdf")
{
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.OutlineOptions.DefaultBookmarksOutlineLevel = 1;
docContent.Save(outputStream, pdfSaveOptions);
}
else if (outputFormate == ".docx")
{
docContent.Save(outputStream, SaveFormat.Docx);
}
modifiedByte = outputStream.ToArray();
}
I’m using the same input JSON and Word template for both outputs.
However, when I open the generated files, the alignment and layout differ (especially in tables and text blocks).
Could you please help me understand:
- What rendering or layout algorithm Aspose.Words uses internally for DOCX vs. PDF output?
- Why might alignment differ between the two formats?
- Are there any recommended settings or compatibility options to ensure layout consistency between DOCX and PDF outputs?
I can share the template, input JSON, and both generated outputs (DOCX & PDF) if needed for investigation.
Mortgage - Non MERS Barcode.docx (34.4 KB)
OutputTestAssemble.docx (26.3 KB)
test1.pdf (85.8 KB)
output json is like below
{
"LenderNameOverride": "First Horizon Bank",
"LoanNumber": "2395678910",
"PreparedByIndividualName": "BRIAN T. MORGAN",
"PreparedByCompanyName": "Horizon Mortgage Services",
"PreparedByAddress": "1825 Magnolia Avenue",
"PreparedByCity": "Birmingham",
"PreparedByState": "AL",
"PreparedByZip": "35205",
"PreparedByPhone": "205-555-7821",
"RecordReturnToCompanyName": "Outamation, Inc.",
"RecordReturnToAddress": "1371 SAWGRASS CORPORATE PARKWAY",
"RecordReturnToCity": "SUNRISE",
"RecordReturnToState": "FL",
"RecordReturnToZip": "33323",
"casenumber": "AL99887766",
"PropertyAddress": "3187 Oak Meadow Drive"
}
Thank you,
Vaibhavi