i have a project using asp.net mvc 3 C#. and now i want to have a view that can read word file. i want it looks like SkyDrive, just select the word file (.docx) and then it will show the file in my view. i don't have any idea how to start, can you explain me how to make it happen ?
thanks a lot.
Use Open Xml SDK. It's free, you don't need any Office libraries and there are many resources on the web. This one, for example.
If you just want to show an image of the document then you can open the .docx file as a zip and extract the docProps\thumbnail.wmf file.
Related
I'm working on a C# project and I need to open a word doc and do a search/replace on it and save the result for later editing within Word itself.
This is to be a stand alone application and not a Word plugin.
Is there any simple code to get me started?
I've searched and not found anything helpful.
EDIT:
Looks like the nuget package DocX will do what I need.
http://docx.codeplex.com/
http://nuget.org/packages/DocX
If you save the doc as a .xml initially from within word you could open it as plain markup (as opposed to a binary) and do a (very rough) search and replace of the raw doc, you'll have to make sure you didn't mangle any tags containing the target words, but it would work.
You'll preserve all formatting and will be able to open/redistribute it as normal in word, the .xml is basically just an uncompressed .docx .
Edit: Giving this is a possible easy solution, not necessarily saying it's the best idea.
with Open XML you can open and manipulate a word document.
I have a csv file and I need to make a pdf copy in the console application that creates the csv. All I have found 3rd party libraries for working with pdf but I don't want to use that. Can I just make a copy and save it as a pdf? If so, how?
Also, I'm using C#, in case you didn't read the title.
Try the below link hope it will help you.
http://sourceforge.net/project/platformdownload.php?group_id=72954
You can open the csv with excel.
than use office PIA (interop) to save as PDF.
see:
Can I use Microsoft Office 2010: Primary Interop Assemblies to convert word,excel to PDF
first read the csv files using c# code, and load that data's into DataTable,
write the datatable values into pdf file using c#
may this idea will help 4 u
Hi All,
I am creating a PDF document using ITEXTSHARP. I need to add some content to PDF toolbar while creating the PDF document. How can i achieve this using C#. Please see the attached image for reference.
Thanks in advance.
iTextSharp is used to generate PDF files, not modifying the PDF viewer. If you need to modify toolbars and stuff like this in Adobe Reader this definitely is not something that you could achieve with iTextSharp.
eh...
Ok so how to do it.
Make template in Word.
eg of Word
Name <FirstName>
Surname <LastName>
Job <JobType>
Salary <Salary>
When generating:
Open word and replace and other marks
Then makepdf (pdfcreator for example)
Edit:
Okay Ill show u schema, no ready code cuz little busy
1) Create word template and
store it in safe place. 2) Copy
template to temp folder 3) Open in
programicaly in C# and replace
"" with ur data
.Replace('', 'Voon') 4)
Programiticaly print to PDF and save
it.
Only a plugin can modify the acrobat/reader toolbar. There might be C# bindings for the acrobat API these days, but I wouldn't count on it.
PS: You can make Acrobat plugins for free. To "Reader Enable" a plugin requires Adobe's direct intervention, and $$$. They sign a version of the plugin, and only that signed version will run in Reader.
Your best bet is to go looking for some third-party PDF viewer. I still wouldn't count on this feature being available, but it's better odds than "0".
In my application I am using some templates in docx and pdf format. I am storing this docs to DB as Bytes.
Befor showing/sending this docs back to user or application I need to replace some contents inside the doc. eg:if the doc contain ##username## I need to replace this with the exact username of the customer. I am not getting a proper solution for this. Any good ideas?
For the docx file, your best bet is to use OpenXML, and instead of having special text like ##username##, replace it with a content control that you can fill in.
Since you specified docx, you can use OpenXML, which is great, it's an API. If it has to work with older doc files, then you'll have to automate Word (which should be avoided if at all possible).
For the PDF, your best bet is to create a PDF form, and fill it in a runtime (using a tool like itextsharp).
HTH,
Brian
For DOC / DOCX:
You should use the MSWord object model through MSWord assembly reference (will work only on machines which have msoffice installed.. or else you can use something like ASPOSE word libraries which wont need msoffice installation on server). You can programmatically trigger the Find-Replace context of word through the library's API.
For PDF: You will need a third party library for editing pdf files.. 3rd party libraries like ABCpdf are available.. (not sure whether Adobe itself has something for this)
The same mechanism like for word library.. but I am not sure whether you will be able to trigger the Find-replace context here or do something else... I have not used a pdf generation library.
I need to convert Word Document to XML and back once editing has been performed on it.
I don't have Microsoft Office Installed at my server, and I want my users to edit their documents via Web Browser.
I am using C# and ASP.Net
Thanks
I believe the latest version of Microsoft Word (and Excel) already save files in XML format, hence the .docx and (.xlsx) extensions. Hope that suffices your need.
Alternatively, you could see if they are tools to convert the old .doc format files to .docx which should, as a result, provide you with a XML based word file.
So you have a couple of options here:
1) Use OfficeWriter from SoftArtisans. This allows you to crack open the binary office file format(e.g. .doc and .xls) note:I am biased because my company makes this product but I think it's awesome.
2) If you can use the newest file format (.docx and .xlsx) you can use the SDK that microsoft has released that will do all of that uzipping rezipping nonsense for you. (called the opem XML SDK)