Converting a DOCX after merge to a PDF is not keeping some of the merged fields.

0 Answers 6 Views
PdfProcessing
Paul
Top achievements
Rank 1
Paul asked on 12 Nov 2025, 09:30 AM

I have a DOCX that undergoes a merge leaving me with 3 text fields after merge. All 3 fields are Times New Roman 12. I'm not using any custom font provider.

After export to PDF, 2 of the fields remain intact but one of them is always blank. 

I've attached screenshots showing the 3 fields plus the DOCX and PDF.

Can you tell me what the issue is? There are no special characters around the text and it's using the same font as the other fields? Printing it to PDF from Word locally works fine, giving me the 3 fields.

Here's the code that the export happens in -


        private async Task<Tuple<int, bool>> MakePDFFromWordDocxBytes(string pdfFilePath, byte[] bytes, string traceInfo, bool isSecondaryMergeNeeded)
        {
            int result = 0;
            byte[] pdfBytes = null;
            bool isError = false;
            try
            {
                RadFlowDocument document = ReplaceSignatureFieldsAndEmptyTables(bytes);

                // Create a new list with the data to avoid enumeration issues
                RadFlowDocument merged = PartialMailMerge(document, isSecondaryMergeNeeded); //   document.MailMerge(dataSource);

                if (isSecondaryMergeNeeded)
                {
                    DocxFormatProvider docProvider = new DocxFormatProvider();
                    string docxFileName = pdfFilePath.Replace(".pdf", ".docx");
                    using (IFileManager fileMan = FileCommon.GetFileInstance(docxFileName))
                    {
                        var docxBytes = docProvider.Export(merged, TimeSpan.FromSeconds(docLoadTimeoutSeconds));
                        fileMan.SaveFile(docxFileName, docxBytes);
                    }
                }
                TelPDFFlow.PdfFormatProvider pdfProvider = new TelPDFFlow.PdfFormatProvider();
                pdfProvider.ExportSettings = new TelPDFFlow.Export.PdfExportSettings()
                {
                    ComplianceLevel = TelPDFFixed.Export.PdfComplianceLevel.PdfA1B,
                    FontEmbeddingType = TelPDFFixed.Export.FontEmbeddingType.Full
                };
                pdfBytes = pdfProvider.Export(merged, TimeSpan.FromSeconds(docLoadTimeoutSeconds));
            }
            catch (Exception ex)
            {
                EventLogger.WriteError(traceInfo, ex);
                pdfBytes = ExceptionPDFAsBytes(ex, $"ERROR {traceInfo}");
                isError = true;
            }

            using (IFileManager fileManager = FileCommon.GetFileInstance(pdfFilePath))
            {
                fileManager.SaveFile(pdfFilePath, pdfBytes);
            }
            result = GetPDFPageCountFromPDFBytes(pdfBytes);
            return new Tuple<int, bool>(result, isError);
        }

No answers yet. Maybe you can help?

Tags
PdfProcessing
Asked by
Paul
Top achievements
Rank 1
Share this question
or