StrataFrame Forum

Mail merge pdf documents

http://forum.strataframe.net/Topic33251.aspx

By Larry Caylor - 1/16/2016

Ben/Trent,

I have, what initially seemed like a simple requirement, to create a mail merge using multiple pdf documents per client that are then merged into a single file for printing. However after a week and a half of reviewing various .Net pdf tools I’ve found that they are expensive, have restrictive licensing and distribution policies, and few are 100% managed code. The cost goes up when you need to merge barcodes.

Another approach I considered is to convert the pdfs to Word format and use tools that can use the Word doc as a template for a mail merge. I found a few 100% managed code tools but they either lack support for merging of barcodes or do not fully support all .docx layouts. I also considered using MS office automation but from what I’ve read there are potential issues with that and I would rather not be dependent on MS word and deal with updates to that.

The last option I can think of is to reproduce the pdfs in a .Net reporting tool which other than the tedious process of creating the report layouts would seem to be the simplest solution from a programming perspective.

I’m assuming that you guys must have to deal with multiple insurance and other forms in your medical application and I’m wondering how you’ve handled it.

-Larry
  
By Olivier - 1/16/2016

Hello Larry

For my crm i use Telerik Reporting, it read the database and it's look like report vfp in better

it's work with winform, wpf, webform, windows phone and more.

it's good investissement in time for your company and you can distribute free for all your customer

http://demos.telerik.com/reporting

So the other solution to manipulate xml to create docx document, but it's a long way to get a good and lot of document.


http://stackoverflow.com/questions/19656626/how-do-i-create-the-docx-document-with-microsoft-office-interop-word
http://praisachion.blogspot.ro/2016/01/exporttodocx-20.html

thanks
Olivier,
By Edhy Rijo - 1/16/2016

Hi Larry,

Like Olivier suggested, a reporting tool may be what you need here.  I use DevExpress and they do have a control the PDF Viewer that allows you to do some manipulation, I am not sure if it supports merging PDF files.

https://www.devexpress.com/Products/NET/Controls/WinForms/PDF-Viewer/
By Ivan George Borges - 1/17/2016

Yep, I also use the report engine way, with the Perpetuum Soft tool. It would be just a matter of generating a report with whatever information you need, use the engine to export it to PDF or any other supported format. From there, you could print it, attach it to an e-mail, upload it somewhere, as needed.

Cheers.

Ivan
By Larry Caylor - 1/28/2016

Thank you for all of the suggestions. I tried a number of products and ended up buying Aspose.Words for .Net. It's pricey, when you have multiple programmers,  but for high volume mail merges with complex form layouts and minimal programming I think its the best product out there. My requirement was to be able to create and fill in form letters merged with government forms having complex layouts without having to go through the tedious effort of having to re-create the forms in a reporting tool like Sharpshooter, Crystal, etc.. The solution also had to be 100% managed code and produce a single high quality pdf document for printing each merge batch.

I initially started with pdf tools that allowed me to work with the forms in their native format. However as I mentioned in my original post they tended to be very expensive, with convoluted licensing, and many were not managed code but com objects with a .Net wrapper.

After giving up on native pdf tools, the first thing I tried was Active Reports. Their page reports support layers which allowed me to import my forms as an image on one layer and overlay it with my data fields on another layer, no layout programming required. This worked but it doesn't scale. Anything over a couple hundred pages is slow, the output file is huge, and the quality is not that good. You also cannot create multiple page reports in a single document but have to create an individual pdf for each merge record and combine them into a single pdf (I used Essential Objects pdf tool which is reasonably priced and works well). For use cases with low volumes it is a viable solution if you don't need really high quality output. But when you get into the thousands of pages it is just too slow.

The next approach I took was to convert my government pdf forms into Word documents using Acrobat. The conversion usually results in a document that only requires minor tweaking to get it perfect. With the document in docx format I could use MS Office mail merge. But I didn't want to rely on having Office installed on the PC and from what I've read there are potential issues in programmatically managing Office. The two managed code tools I found that could do mail merges using docx files were TX Text Control and Aspose.Words. Text Control is pretty slick and offers an end user Word editor that you can embed in your application to allow users to create/edit Word documents or templates without MS Word. I liked the product, they had lots of examples on their web site and provided great support during my evaluation, but the issues I ran into is that it doesn't support all of the layout formats that Word does (like n-columns before a single column on the same page) and the editor is a little touchy to use. I had a hard time adding lines to forms without messing up the layout.

Aspose.Words is the other product I found for mail merge using Word documents. The product doesn't have an embeddable editor but relies on MS Word for creating/editing Word templates.  However is does support all of the format layouts that Word does. Word itself is stable and easy to use to create and edit documents and I don't have any requirement to provide an end user editor in my application. It is relatively simple to program. All I had to do was to implement their data source interface in the business objects I wanted to use as data sources and add a few lines of code to my merge form. It is relatively fast, especially if you merge to docx format. Converting to pdf adds processing time but its not too bad. Acrobat does a decent job in converting my original pdf forms to word so I don't have to spend a lot of time tweaking the form to get accurate results. The resulting output quality is great. One thing that is lacking are events to support progress during processing, however there is a callback used for custom merging that I might be able to use to support this.

The only other thing I needed to do was add barcodes to my documents. TX Control provides a barcode control you can add to the docx file using their editor. Aspose.Words can support merge fields that use barcode fonts. I tried IDAutomations's barcode fonts with their .Net encoding software. It was easy to implement but the barcode was lost in the conversion to pdf. I ended up going with Aspose.Barcode to create barcode images within the merge interface and then merge them into the document. The image is carried over in the conversion to pdf. It required a little more programming but was easy to do once I figured out how it worked. Aspose.Words has a lot of examples on their web site but none of them showed exactly what I wanted to do. You could probably use other .Net tools to create barcode images (IDAutomation has a few) but I decided to keep it simple and go with a single vendor.

-Larry
By Edhy Rijo - 1/29/2016

Hi Larry,
Thanks very much for such detail explanation about why you choose to use Aspose.