How to convert doc in pdf? - c#

I have a Code where I can upload files (doc, txt) and save it sql and I want that user can click on a download button and download the file in pdf. So it should convert the doc in pdf.

You have a couple options for handling this within your application:
You can convert the DOC / TXT file before saving it to the SQL db
Or you can do this on-the-fly when the user clicks the download button.
Either way, you will need a SDK, API, or utility to do the conversion. There are quite a bit of information already on this on the web, here are some links you should take a look at to see how to do the conversion in C#:
net library to convert microsoft office docs to pdf
How do I convert Word files to PDF programmatically?

Related

OPEN XML to Export 2007/2010

In my application I already have functionality to export into 2003 format. Where I am constructing a string out of the template and write using System.IO.File.WriteAllText.
But it does not work with excel 2007/2010, that's why I wanted to convert it to Openxml in order to support 2007 and 2010.
I have string ready with creation of cells and rows from template.
I want advice on how to achieve or any body has reference link.
Please let me know.
Regards
WriteAllText class will save you a text file. You are saving an html(text) based file with xls extension. This is not a real xls file (that is actually a binary file), but MS Excel recognize and interpret the html format.
An xlsx file is a binary file. You can use OpenXML Office library ( Excel.XlFileFormat.xlOpenXMLWorkbook ) or another .NET Excel library like EasyXLS. Check this sample of code for more details.

How to convert ics file to pdf format programatically?

I have an ics file. I want to convert it to pdf format programatically using c#. Can you please tell me how can i do that programatically. Do i need to use any dll for that?
If you don't want to approach the ics file as a flat file (as flat text), you can use something like DDay.iCal to get to the data through an Object Model. From there on, you'd use e.g. iTextSharp to create your pdf.
You will need a pdf conversion library. There are several available, some paid, some free.
Here'a an example of a free one: http://www.pdfsharp.com/PDFsharp/
You can work with .ics file like with simple text file. So you can use any library which allow to create pdf.
I use itextsharp. You can download it here: http://sourceforge.net/projects/itextsharp/
You can use the NET library Aspose.iCal to parse the ICS file
http://www.aspose.com/community/blogs/salman.sarfraz/archive/2008/11/21/where-is-aspose-icalendar.aspx (used to be http://www.aspose.com/categories/file-format-components/aspose.network-for-.net/default.aspx)
And the using iTextSharp at http://sourceforge.net/projects/itextsharp/ or similar software create the PDF.

Creating print previews of documents

I need to create a software which will create print previews of the documents of following formats: the MS Office documents (.doc(x), .ppt(x), .xls(x)), images, .txt files and PDF files. I have made a working prototype using XPS files. So basically I do the following: I convert the office files to .xps using Office Automation and then I render the .xps documents to images. I simply create XPS files from images and .txt by adding text or an image to FlowDocument, then rendering it. But I have found out that there is no way to convert PDF to XPS fast (A document which has 600 pages takes more than 2 minutes to convert and this is totally not suitable). So I am stuck at this point. It seems that I should start over again, using the different file format. Should I rewrite my program using PDF, for example, or is there any other way to accomplish my task? And if I should use PDF, could you, please, suggest me a good PDF C# library to render previews of pages as fast as possible? I tried using Websupergoo's ABCPdf, but it is too slow, because it does not allow me to render the previews to System.Windows.Media.Imaging.BitmapSource, only System.Drawing.Bitmap, so I have to convert Bitmap to BitmapSource and it takes up a lot of time.
Thanks in advance.
Use Ghostscipt to convert PDF to images. Though, I don't know why you wouldn't just use the PDF. I have used GhostScript for a number of PDF/Image manipulation tasks.
http://www.wibit.net/blog/integrating_ghostscript_c
Ghostscript will output any PDF to images to the settings you specify. I think you can use it as a DLL or as a commandline process.

Access text recognized by Acrobat OCR

I have PDF files that have been "recognized" using the OCR Text Recognition -> Recognize Text Using OCR functionality in Acrobat.
I would like to take these as an upload (C# ASP.NET MVC) and be able to extract this information for indexing and search purposes.
I have tried opening the PDF files and I don't find any of the recognized text so I'm guessing it's compressed and/or encoded.
Any ideas?
There is an article on CodeProject that explains how you can extract text from PDF using C#.
xpdf and poppler have pdftotext tools.

Convert Word Document to XML and back ASP.Net

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)

Categories

Resources