I am working on an application that has a requirement for me to create a document, populated with data captured in my WPF application, for attaching to an email and sending to insurance company.
My client has been performing this by sending an editable PDF document to clients then proof reading upon receipt of completed form and manually attaching to email.
I initially thought of creating a word document laid out same format as existing and automating word using find/replace on placeholders such as etc...
However it would be great if I could populate the existing PDF docs wouldn't it.... Anyone know if possible?
Thanks.
You can use PDFsharp/MigraDoc to edit pdf-files. Parsing the existing document and inserting text/images is simple enough, but I don't know if there is any support for actual placeholders.
EDIT: Found this approach, using iTextSharp and form fields: Using itextsharp (or any c# pdf library), how to open a PDF, replace some text, and save it again?
Related
I use ITextSharp to create a PDF with form data based on another PDF.
The problem is the file generated is not editable (the form on it).
If I use ITextSharp in append mode, I get the form editable but most of the form data is not preserved. I want the user to see the resulted PDF with the PDF Form data preserved.
I understand there is NOTHING I can do. The only way for the user to edit the resulted PDF is to use a paid Acrobat version on it. This is because I CHANGE the PDF file by entering form data and setting fonts on it.
Is there something I can do?
Paul
Your question isn't very clear, but here are some answers to similar questions that have been asked before:
End users can't edit a form locally unless the form is "reader-enabled". Making a form reader-enabled is only possible when you use Adobe software: "Adding Enable for commenting Adobe Reader" using Acrobat
You need to fill out reader-enabled forms in append mode if you don't want to break the reader-enabling: Pdf with Acroform editing using iText
This doesn't mean you can't ask people to fill out a PDF form to gather data. See
Edit pdf embedded in the browser and save the pdf directly to server
You can capture that data, and fill out the form without flattening if you want to serve this form (including the data) to the end user: How to fill out a pdf file programmatically?
I'm pretty sure one of these question is a duplicate of what you're asking, but since your question isn't clear, it's hard to mark your question as an exact duplicate of one of them.
Short answer: No
Pdf file are likely to be secure (read only) and this is why everyone is using it. Most of the time, we convert a file into a pdf so maybe if you can get the 'file' and not the pdf will be a good move there.
From my experience in the past, I can confirm with you that iTextSharp may not convert all your data properly and this can make your generated file unusable. If not, you might have some weird line or some changes in the document behavior (ex. fields are not editable anymore).
If you really want to work with pdf file as input and do your stuff with it, you will need to understand the inner structure of it:
[PDF file format]
http://resources.infosecinstitute.com/pdf-file-format-basic-structure/
This can be a hell of a ride. You might need to re-consider the use of a pdf as input. If you can't change that, you might need to use some sort of adobe pluging to do so. Alot of third party pdf library is doing that.
Good luck
Its a general scenario when we provide an option of attaching a file (MS .doc) to end user. This file is stored in DB as binary. When user try to access this attachment next time, we allow them to download it. Now, here I want to give a feature to user where he should be able to open this doc file on click, edit it and save it without downloading.
.doc is a binary format and not easy to work with - a library such as Aspose, as mentioned by Christian, is definitely the way to go.
However, if .DOCX is acceptable (and that's Office 2007 and higher), then you can achieve what you want in three steps:
Convert .docx to HTML
Convert Word to HTML then render HTML on webpage
Display the HTML using any rich text control of your choice
What is the best rich textarea editor for jQuery?
Finally, convert HTML back to .docx:
Convert Html to Docx in c#
You would have to "reinvent" Microsoft Office Online (look into your skydrive account). I am unsure if there are any "out of the box" libraries for that, but you could build a simple editing app by leveraging Aspose word (or some other library). But that would be far from simple.
Link to aspose: http://www.aspose.com/.net/word-component.aspx
Word will only open files that are locally stored. What you are looking for is something similar to editing items that SharePoint provides using the WebDAV interface.
You may be able to use this approach to support your requirement. You should be cautious about the security aspects of the solution unless you have fully authenticated access to the shared folder on the server.
I am not sure if a standalone MS Word Document editor exists. However, this can be done with using a combination of rich text formatting / converting tool (for example, the DevExpress ASPxHtmlEditor + Document Server):
Load binary data from a DB;
Import loaded data (MS Word content) as HTML content into the ASPxHtmlEditor;
Edit imported data via the WYSIWYG ASPxHtmlEditor;
Convert the edited HTML back to MS Word content;
Save the converted / edited MS Word content back to the DB.
I believe, it is possible to do something like this if you have such products (free or commercial analogs) in your project.
I've created an xml template for a report. A user is supposed to be able to add information to personalise this report to their own needs by a program im creating in C#
How can I edit the contents of an entity then from what a user puts into a textbox and then display this on word?
There's a ton of information on the net about creating Word documents using XML and C#. There are lots of possibilities.
Microsoft publishes something they call the "Open XML Format SDK" that helps with this.
Try this search.
This page provides a bunch of "how to" articles summarizing how to fiddle with Word documents using XML and C#.
I’d like in an ASP.NET MVC application generate document (invoice for example) based on a word document than I use as template. I create a word document with :
Some fix data :
Company info
Logo
general layout
Some data to add in a specific place :
Invoice number
A section with a table, with some column (price, quantity, description, vat, …)
In the bottom the total with and without VAT
A date
In this document, I can create a kind of tag, example <PDF:InvoiceNumber> and replace it by the value by code, same for all the other "TAG"
Do you have an idea how I can do this? Did you experiment another way (suggestions are welcome)? I accept to use 3rd control free or commercial. The only restriction is … I don’t want install Microsoft Word on the server.
Thanks,
Use the OSS .net port of iText, iTextSharp (google or bing for it).
General process:
1) Create a PDF file of your existing Word Doc
2) Using Acrobat (or similar tool) add PDF form fields to the file as placeholders for the data you will insert into the form at run-time
3) Using iTextSharp 's PDF form-filling API, insert the data into the form-fields in the PDF
4) Save, print, return-as-stream-to-client's-browser-with-PDF-mime-type, etc. the resulting PDF
I realise you don't want to install MS-Word on the server, but you could consider installing it on a separate machine and then consider the approach in this article. It uses Web Services and is clean and efficient.
I wrote this article so the usual disclaimers apply.
Okay, here is what i want to do..
A user will run a query and return 3 pieces of data (really more but for this example lets say 3.. such as name, city, state).
The user will then be prompted with a list of 1 or more documents that are basically word merge documents. Does not have to be word but needs to be something standard.
Once they pic the document, we need to merge the data with the document and would then like to have a PDF displayed back to the user so they can print or save.
So, looking for ideas on what would be a suggested format to store the merge documents in as well as how to do the merge and create the PDF via ASP C#.
Thanks!
firstly ... stop thinking "doc" as standard cause .. it is not.
PDF is much more standard than doc and using any online viewer it is easy to provide access to it's content
now...
for manipulating PDF files fore free u have a very nice C# Library called iTextSharp