Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can we convert word document into pdf by asp.net. I browse a ms-word file by FileUpload & when i click on OK, it automatically convert that file into PDF. Can anybody guide me how can be it possible. I got some code by google but thats are incomplete. If Anybody know the solution kindly share with me.
Posted
Updated 5-Jun-12 21:17pm
v2
Comments
Pandvi 6-Jun-12 3:47am    
You'd better put the code you find here, then we can direct you where to modify.

Try some codes:

C#
// Open document.
Document doc = new Document("resume.doc");
 
// Save all pages of the docuemnt as separete PDFs.
for (int pageIndex = 0; pageIndex < doc.PageCount; pageIndex++)
{
    PdfSaveOptions options = new PdfSaveOptions();
    options.PageIndex = pageIndex;
    options.PageCount = 1;
    doc.Save(string.Format("out_{0}.pdf", pageIndex), options);
}


Or

C#
Document doc = new Document("C:\\Temp\\Kane_International_Tax_Spring_2011.docx");
 
doc.Save("C:\\Temp\\out.pdf");


or the following code:

C#
Document doc = new Document("C:\\Temp\\Kane_International_Tax_Spring_2011.docx");
 
PdfSaveOptions options = new PdfSaveOptions();
options.PageCount = 1;
for (int pageIndex = 0; pageIndex < doc.PageCount; pageIndex++)
{
    string outputFileName = string.Format("{0}\\{1}_{2}.pdf", "C:\\Temp", "Test", pageIndex + 1);
    options.PageIndex = pageIndex;
    doc.Save(outputFileName, options);
}


Convert a Word Document to PDF[^]
Creating PDF Documents in ASP.NET[^]
Convert Word-Documents to PDF on an ASP.NET Server[^]

Detailed discussion with code[^]
 
Share this answer
 
Comments
Mas11 6-Jun-12 2:44am    
But PdfSaveOptions is not exist in my code for this i have to add new namespace. Can you tell me which namespace.
Ohhhhh.. you just go through this link dude..


Convert Word-Documents to PDF on an ASP.NET Server
 
Share this answer
 
Hi,

Do a simple Google/CP search before posting a question. here is the Google[^] link for you.
Thanks
--RA
 
Share this answer
 
Comments
[no name] 12-Jul-12 22:14pm    
I can search many solutions in google but the time is also wasted in such a huge search.

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