0

I need to write vb.net code in my asp.net website to fill in forms using data from a sql server db. The form can be a pre-existing Word document or a PDF. After the merge then the user can adjust the inputs as needed, etc…

Any suggestions on how I should go about this? Someone mentioned something about utilizing Open XML but I have no clue if:

  1. It's the best suggestion
  2. Where to start/how to go about it.
crthompson
  • 15,653
  • 6
  • 58
  • 80
WebDevGuy
  • 173
  • 4
  • 18
  • Can you clarify a bit "After the merge then the user can adjust the inputs as needed" if that must be done before the user downloads the form that is a major criteria. Also are you willing to spend money? PDF soulutions especially generally cost money. There a few free ones but they are usually not as robust. – KHeaney Sep 18 '14 at 17:36
  • @KHeaney Thanks for your reply. When the user clicks the "merge" button it will basically open the Word or PDF document with the fields filled in from the database. – WebDevGuy Sep 18 '14 at 18:39
  • on the server or download it to their machine? – KHeaney Sep 18 '14 at 18:43
  • It would download to their machine and open in their local copy of Word or PDF application. @KHeaney – WebDevGuy Sep 18 '14 at 18:53

1 Answers1

1

To make this clear this is a large topic, and something I am still working on fully implementing myself as well. I will start with your own idea of using "Open XML".

For Word this is not a bad idea although you will not be using open xml but rather an xml document in Microsoft's format. I specifically use this in conjunction with the Response.ContentType command to create dynamic multi-page excel sheets. I have not tried it in word but how you would do this is create a document similar to what you want in word and save it as an XML document instead of a doc or docx. You then open that document and use it to reverse engineer it creating a page in that format.

Understand though that this is only realistic on an intranet type setting as Response.ContentType behaves best only in IE and the xml files will not open as word documents by default. it is possible but not recommended.

You can also use XML in combination with VBA scripts in order to create the word document although this is not really a common or recommended way either.

The most common way is to generate the word document using .net's library for Office. You will have to google yourself how to use it as that is an extensive topic.

On the PDF end the options are a little more sparse. Your requirement for editing limits you to a few tools.

Creating the document and saving it on the server means you can essentially do the same procedure as described with the word document. The problem here is you require Adobe Acrobat Pro or a similar product to generate the document and a Pro licence is usually not cheap.

More people usually just use either PDFSharp or ITextSharp for this purpose though. ITextSharp is the much more robust program that allows for digital signatures and all that fun stuff. ITextSharp requires a licence for all projects where the code is not open source though. PDFSharp on the other hand is free but does not have as much features. If you wanted to do digital signatures with it you would need to do something like described here Adding a digital signature to a pdf file.

Community
  • 1
  • 1
KHeaney
  • 785
  • 8
  • 18