mailmerge field

Technical support for Spire.Doc

Moderator: iceblue support

mailmerge field

Postby derek » Tue Apr 23, 2013 4:30 pm

Hi, I have a mailmerge field which could soill over to more than page, but it doesn't after I convert to PDF, can you help? please see attached. I have also attached my template, the field in question is "Drugs".
You do not have the required permissions to view the files attached to this post.
derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Re: mailmerge field

Postby amy.zhao » Wed Apr 24, 2013 3:20 am

Dear Derek,

With regard to this issue, you need first to save the data to a stream after mailmerge with your template, and then reload the stream to convert it to pdf . Please refer to the code below.
Code: Select all
            Document document = new Document();
            document.LoadFromFile("repeat_request.doc");
            DataSet ds = new DataSet();
            ds.ReadXml("data.xml");

            document.MailMerge.ExecuteWidthRegion(ds.Tables[0]);

            using (MemoryStream stream = new System.IO.MemoryStream())
            {
                document.SaveToStream(stream, FileFormat.Doc);

                stream.Position = 0;
                document.LoadFromStream(stream, FileFormat.Doc);
            }

            document.SaveToFile("output.pdf", FileFormat.PDF);


If you still have this issue after try the code above, please tell us.

Best Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2256
Joined: Wed Jun 27, 2012 8:50 am

Re: mailmerge field

Postby amy.zhao » Fri Apr 26, 2013 3:21 am

Dear Derek,

Does the code above solve your issue?
Please give us a feedback at your early convenience.
If you have any issue, please feel free to contact us.

Thanks &Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2256
Joined: Wed Jun 27, 2012 8:50 am

Re: mailmerge field

Postby derek » Tue Apr 30, 2013 2:23 pm

Hi, we actually have a requirement to limit to one page, so thank you.
derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am

Re: mailmerge field

Postby amy.zhao » Wed May 01, 2013 3:28 am

Dear Derek,

Thanks for your reply.
Please try to increase PageSize of document to let all data output in one page.
Please refer to the code snippet below.

Code: Select all
  Document document = new Document();
            document.LoadFromFile("repeat_request.doc");
            foreach(Section section in document.Sections)
            {
                section.PageSetup.PageSize = PageSize.A3;
            }
       
            DataSet ds = new DataSet();
            ds.ReadXml("Dugs1.xml");

            document.MailMerge.ExecuteWidthRegion(ds.Tables[0]);
     
            using (MemoryStream ms = new System.IO.MemoryStream())
            {
                document.SaveToStream(ms, FileFormat.Doc);

                ms1.Position = 0;
                document.LoadFromStream(ms, FileFormat.Doc);

                document.SaveToFile("result.pdf", FileFormat.PDF);
            }


Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2256
Joined: Wed Jun 27, 2012 8:50 am

Re: mailmerge field

Postby amy.zhao » Fri May 03, 2013 10:07 am

Dear Derek,

Do you test the code? How does it work?
Please send us a feedback message.

Thanks &Regards,
Amy
E-iceblue support team
User avatar
amy.zhao
 
Posts: 2256
Joined: Wed Jun 27, 2012 8:50 am

Re: mailmerge field

Postby Gary.zhang » Tue May 07, 2013 8:57 am

Hello Derek,

Has the issue been resolved? Could you please update the thread if convenience.

If there are any questions, welcome to get it back to us.

Thanks,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1390
Joined: Thu Apr 04, 2013 1:30 am

Re: mailmerge field

Postby derek » Wed May 08, 2013 10:57 am

fine now thanks
derek
 
Posts: 42
Joined: Mon Nov 19, 2012 11:55 am


Return to Spire.Doc

Who is online

Users browsing this forum: No registered users and 1 guest