C#. Document conversion to PDF
صفحه اصلي

C#. Document conversion to PDF



I need to convert below mentioned file formats to pdf using C#/VB.Net. User will upload the file using FileUpload control and system will returns the pdf file after converting the document.

doc/docx to pdf xls/xlsx to pdf ppt/pps to pdf

Does ITextSharp provide such facility ? Please Only mentioned open source or free libraries.

Thanks


How do you update the aspnetdb membership IsApproved value?

1:

Restrict file types allowed for upload asp.net
I did the same thing only for Word format. MVC & EF - usingi use Microsoft.Office.Interop.Word. Style list of divs as 2 column layout with css below the code. MVC2 DataAnnotations on ViewModel - Don't understand using it with MVVM pattern. Creating a 'website builder' - How would I architect it?
public static void Word2PDF(string fileName) {     ApplicationClass wordApplication = new ApplicationClass();     Document wordDocument = null;     object paramSourceDocPath = fileName + @".doc";     object paramMissing = Type.Missing;     string paramExportFilePath = fileName + @".pdf";     WdExportFormat paramExportFormat = WdExportFormat.wdExportFormatPDF;     bool paramOpenAfterExport = false;      WdExportOptimizeFor paramExportOptimizeFor =WdExportOptimizeFor.wdExportOptimizeForPrint;      WdExportRange paramExportRange = WdExportRange.wdExportAllDocument;     int paramStartPage = 0;      int paramEndPage = 0;     WdExportItem paramExportItem = WdExportItem.wdExportDocumentContent;      bool paramIncludeDocProps = true;     bool paramKeepIRM = true;      WdExportCreateBookmarks paramCreateBookmarks =     WdExportCreateBookmarks.wdExportCreateWordBookmarks;      bool paramDocStructureTags = true;     bool paramBitmapMissingFonts = true;      bool paramUseISO19005_1 = false;      try     {         // Open the source document. good/simple asp.net mvc application with fluent nhibernate        wordDocument = wordApplication.Documents.Open(         ref paramSourceDocPath, ref paramMissing, ref paramMissing,         ref paramMissing, ref paramMissing, ref paramMissing,         ref paramMissing, ref paramMissing, ref paramMissing,         ref paramMissing, ref paramMissing, ref paramMissing,         ref paramMissing, ref paramMissing, ref paramMissing,         ref paramMissing);          // Export it in the specified format. Maintaining state and data context between requests        if (wordDocument != null)             wordDocument.ExportAsFixedFormat(paramExportFilePath,             paramExportFormat, paramOpenAfterExport,             paramExportOptimizeFor, paramExportRange, paramStartPage,             paramEndPage, paramExportItem, paramIncludeDocProps,             paramKeepIRM, paramCreateBookmarks, paramDocStructureTags,             paramBitmapMissingFonts, paramUseISO19005_1,             ref paramMissing);     }     catch (Exception ex)     {          // Respond to the error     }     finally     {         // Close and release the Document object.         if (wordDocument != null)         {             wordDocument.Close(ref paramMissing, ref paramMissing,             ref paramMissing);             wordDocument = null;         }         // Quit Word and release the ApplicationClass object.         if (wordApplication != null)         {             wordApplication.Quit(ref paramMissing, ref paramMissing,             ref paramMissing);             wordApplication = null;         }         GC.Collect();         GC.WaitForPendingFinalizers();         GC.Collect();         GC.WaitForPendingFinalizers();     } } 
Hope this helps. . Note: i am using version 12, means office 2007..

2:

I've never seen any free libraries to convert office docs to pdf. However, there are free PDF printer drivers, like PDFCreator http://sourceforge.net/projects/pdfcreator/files/, so possibly you could install one of those and then just have your app automate the printing of the documents to one of those pdf printers.. Might be a possible quick fix if it's just a small intranet site or similar..

3:

I am not aware of any free libraries as this is an extremely complicated field. Some commercial ones are available, although they generally lack fidelity when converting files.. I have worked on a Web Services based PDF Converter, which works well although it is not free..

4:

There are a number of open source libraries this handle PDF. However I'm not certain any will did the conversion for you between the formats.. You will probably need two libraries. One to read DOC/DOCX and one to write out to PDF. Reading DOC/DOCX might actually be the more difficult part, at least without installing Microsoft Word. If you have Word then you have access to the COM interfaces to manipulate Word documents, although obviously you have to pay for Word.. Wikipedia list a number of libraries, open source and commercial, including iTextSharp you mentioned.. http://en.wikipedia.org/wiki/List_of_PDF_software. Given OpenOffice is open source, it may be worth looking into how they did it as they must read DOC (and DOCX?) and write out to PDF.. Alternatively, you could look into PDF Printer solutions. Again, I'm not certain of open source / free solutions, although if there is one, you'd basically just print to a special PDF Printer from C# and it would convert to a PDF file. Some products will also just let you dump a file into a folder and it converts it.. I have used Adobe Distiller (part of Acrobat) and ActivePDF, although these are commercial solutions. ActivePDF did provide a library though.. There is also CutePDF which claims to be free. Have not tried it and not sure what the limitations are over their professional version..


67 out of 100 based on 42 user ratings 477 reviews

^