Guest User

Untitled

a guest
Oct 17th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. // create a business object that is used
  2. // as the data source
  3. Invoice invoice = new Invoice() { Name = "Report" };
  4.  
  5. using (ServerTextControl tx = new ServerTextControl())
  6. {
  7. tx.Create();
  8.  
  9. LoadSettings ls = new LoadSettings() {
  10. ApplicationFieldFormat = ApplicationFieldFormat.MSWord
  11. };
  12.  
  13. // load the created template
  14. tx.Load("template.docx", StreamType.WordprocessingML, ls);
  15.  
  16. // create a new MailMerge engine
  17. using (MailMerge mailMerge = new MailMerge())
  18. {
  19. // connect to ServerTextControl
  20. mailMerge.TextComponent = tx;
  21.  
  22. // merge the template that is loaded with
  23. // the business object
  24. mailMerge.MergeObject(invoice);
  25. }
  26.  
  27. // export the document as PDF
  28. tx.Save("test.pdf", StreamType.AdobePDF);
  29. }
Add Comment
Please, Sign In to add comment