Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C# code: How to convert.docs files to PDF programmatically in asp.net web application?
Posted

Use iTextSharp[^].
 
Share this answer
 
C# or .Net for that matter does not support any PDF conversion. You need to use third party components.

iTextSharp[^] is a free library which does it for you.

You can also use Aspose[^]. It's paid though.
 
Share this answer
 
If you have a MS 2007(with XPS and PDF addon) or MS2010, you can directly save the doc/docx files to pdf using the "SaveAs" method.

C#
object filename = Path.GetTempPath() + @"\test.pdf";
                object fileFormat = WdSaveFormat.wdFormatPDF;

                oDoc.SaveAs(ref filename, ref fileFormat, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                             ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                             ref oMissing, ref oMissing, ref oMissing);

                object save = false;
                oDoc.Close(ref save, oMissing, oMissing);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900