I am facing an issue when converting DOCX files to PDF using Aspose.Words for .NET and later filling custom tags in the PDF using Aspose.PDF.Drawing.
We use a custom tagging format in the DOCX files:
#REG_DATUMS#
#REG_NUMURS#
(i.e. strings in the format #([^#]*)#).
Problem:
When the DOCX is converted with Aspose.Words, the table cell text containing these tags (e.g. #REG_DATUMS#) becomes shifted to the left and partially hidden/overflowing inside the PDF.
When the same DOCX is converted to PDF directly in Microsoft Word and then processed with Aspose.PDF.Drawing, the issue does not occur — everything fills correctly.
Text placeholders inside table cells should remain properly positioned (as in the MS Word PDF conversion).
Actual Result:
Placeholders in PDFs generated with Aspose.Words are shifted left inside the table cells, partially hidden, and do not correctly display filled values.
Attachments:
aspose_words_converted.pdf – converted with Aspose.Words (problematic).
ms_office_converted.pdf – converted with Microsoft Word (works correctly).
aspose_words_converted_aspose_pdf_filled.pdf – filled with Aspose.PDF after Aspose.Words conversion (shows the overflow/hidden issue).
ms_office_converted_aspose_pdf_filled.pdf – filled with Aspose.PDF after Word conversion (works correctly).
It seems you’re experiencing issues with text placeholders in table cells when converting DOCX files to PDF using Aspose.Words. The placeholders are shifting and becoming partially hidden in the resulting PDF, which does not occur when converting the same DOCX file directly in Microsoft Word.
To address this issue, you can try the following steps:
Check Table Cell Properties: Ensure that the table cell properties in your DOCX file are set correctly. Sometimes, padding or margins can cause text to overflow or shift.
Use Layout Options: When converting the DOCX to PDF, you can specify layout options to better handle the content. For example, you can set the PdfSaveOptions to control how the document is rendered. Here’s a sample code snippet:
Document doc = new Document("template.docx");
PdfSaveOptions options = new PdfSaveOptions();
options.LayoutOptions = PdfLayoutOptions.KeepTogether; // Adjust as needed
doc.Save("output.pdf", options);
Adjust Placeholder Formatting: If the placeholders are formatted differently in the DOCX, consider standardizing their formatting to ensure consistent rendering.
Post-Processing in Aspose.PDF: After converting to PDF, you might need to adjust the positioning of the placeholders programmatically using Aspose.PDF. This can help align them correctly.
If these suggestions do not resolve the issue, consider sharing a minimal reproducible example with the Aspose support team for further assistance.
Feel free to reach out if you have any further questions!
@janimos I think your workflow must be changed to get the desired output. You should fill the document with data before converting it to PDF. As I can see the value that must be replaced is represented with DOCPROPERTY field. So you can use the following code:
Document doc = new Document(@"C:\Temp\in.docx");
if (doc.CustomDocumentProperties["REG_NUMURS"] == null)
doc.CustomDocumentProperties.Add("REG_NUMURS", "");
doc.CustomDocumentProperties["REG_NUMURS"].Value = "IKSD-25-3-LI";
if (doc.CustomDocumentProperties["REG_DATUMS"] == null)
doc.CustomDocumentProperties.Add("REG_DATUMS", "");
doc.CustomDocumentProperties["REG_DATUMS"].Value = "25.09.2025";
doc.UpdateFields();
doc.Save(@"C:\Temp\out.pdf");
@alexey.noskov Yes, we have this as a default workflow, but mentioned workflow in issue is an optional and before we haven’t encountered the problem because we weren’t using Aspose to convert file as option previously, but now with client specific templates we encountered this problem when users convert files to PDF before these custom tags and fields are filled.
Some fields have display value with mentioned custom tag and some are the plain text in format of #([^#]*)#. System allows to fill these custom tags even in PDF.
@janimos Since you are replacing placeholders in PDF using Aspose.PDF. I will move your topic to Aspose.PDF support forum. My colleagues will help you shortly.
If possible, can you please provide the sample JSON in text or .zip format for our reference? We will test the scenario in our environment and address it accordingly.
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): PDFNET-60819
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.