Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Nov 30, 2015 3:02 am

There seems to be a problem with the before/after mail merge properties when converting from DOCX to PDF, in that they are not present in the PDF.

If I save as another DOCX file, the values are there (although not formatted with respect to the formatting conditions), but not in the PDF version.

I've attached the sample input/output documents and code. I am using the 5.5.541 hotfix.

Is there something else I need to do for this to work upon export to PDF?

Sample Code (also in the attached zip):
Code: Select all
   var DocxIn = @"c:\mergetest_in.docx";

   var DocxOut = DocxIn.Replace("_in", "_out");
   var PdfOut = Path.ChangeExtension(DocxOut, "pdf");
   
   var Docx = new Document(DocxIn, FileFormat.Docx);
   Docx.MailMerge.MergeField += MailMerge_MergeField;
   Docx.MailMerge.Execute(
      new[] {"Some Field"},
      new[] {"some replacement value"}
   );
   
   // before/after fields present
   Docx.SaveToFile(DocxOut, FileFormat.Docx);
   Process.Start(DocxOut);

   // before/after fields NOT present
   Docx.SaveToFile(PdfOut, FileFormat.PDF);
   Process.Start(PdfOut);


Edit: I see hotfix 5.5.71 is listed as having fixed this. Apparently the bug is back =(
Last edited by daniel.flint on Mon Nov 30, 2015 3:23 am, edited 1 time in total.
User avatar

daniel.flint
 
Posts: 8
Joined: Tue Nov 24, 2015 4:48 am

Mon Nov 30, 2015 3:04 am

As a workaround, I am saving the merged DOCX to a stream, and then using said stream to save out to PDF which works, but isn't ideal:

Code: Select all
using (var MemStream = new MemoryStream())
{
   Docx.SaveToStream(MemStream, FileFormat.Docx);
   var Merged = new Document(MemStream, FileFormat.Docx);

   Merged.SaveToFile(DocxOut, FileFormat.Docx);
   Process.Start(DocxOut);

   Merged.SaveToFile(PdfOut, FileFormat.PDF);
   Process.Start(PdfOut);
}
User avatar

daniel.flint
 
Posts: 8
Joined: Tue Nov 24, 2015 4:48 am

Mon Nov 30, 2015 6:10 am

Hello,

Thanks for your feedback. I have noticed the issue and posted it to our Dev team, once it is resolved or we have some other update for you, we will let you know ASAP.

Regards,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Dec 02, 2015 9:14 am

Hello,

The issue has been resolved, please try to the newest version(Spire.Doc Pack(hot fix) Version:5.5.183).
 
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Dec 02, 2015 11:44 pm

Thank you Gary, the before and after fields are now present in the PDF document after applying that fix 8)

However, I have noticed the formatting rules are not applied in a consistent manner as Word.

The merge field I have is:
* Before Text: "BEFORE"
* After Text: "AFTER"
* Format: Title Case


Using a substitution value of "some replacement value", Word produces "Beforesome Replacement Valueafter", where as the document from Spire.Doc (either PDF or Docx) is "BEFORESome Replacement ValueAFTER".

Word has performed the substitution of the merge text, applies the before/after text, then applied the formatting rules.
Spire applies the formatting rules to the merge text, performs the substitution, then applies the before/after text.

While the example is indeed contrived, I'm just wondering if that difference in processing will made consistent with Word, or if it is just a difference we should be aware of an account for.
User avatar

daniel.flint
 
Posts: 8
Joined: Tue Nov 24, 2015 4:48 am

Thu Dec 03, 2015 3:37 am

Hello,

Thanks for your feedback. I have noticed the issue on the formatting you mentioned. Once it is resolved, we will let you know ASAP.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Dec 08, 2015 1:53 am

Hello,

The issue has bee resolved, please download and test the newest hotfix(Spire.Doc Pack(hot fix) Version:5.5.189).

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Dec 08, 2015 9:49 pm

Hi Gary,

That hot fix has indeed resolved the formatting problem.

Thank you very much for getting that resolved so quickly! 8)

Regards,
Daniel
User avatar

daniel.flint
 
Posts: 8
Joined: Tue Nov 24, 2015 4:48 am

Wed Dec 09, 2015 1:31 am

Hello,

Thanks for your prompt response.

Regards,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.Doc