What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 27084 |  Welcome, Guest!   Register  Login
 Home > Coding Horrors > C# > Not converting word doc to pdf using c# code? ...
Srilu.Nayini577

Not converting word doc to pdf using c# code?

 Coding Horror posted by: Srilu.Nayini577 | Posted on: 8/22/2012 | Category: C# | Views: 2030 | Level: Starter | Status: [Member] | Points: 75 | Alert Moderator   






SRILATHA
.Net Developer
Found interesting? Add this to:


Experience:0 year(s)
Home page:http://www.dotnetfunda.com
Member since:Thursday, August 02, 2012
Level:Starter
Status: [Member]
Biography:Iam currently working as a .Net developer with experience of 0.6years.
 Responses
Srilu.Nayini577
Posted by: Srilu.Nayini577 | Posted on: 8/23/2012 | Level: Starter | Status: [Member] | Points: 15 | Alert Moderator 

Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();


object oMissing = System.Reflection.Missing.Value;


FileInfo[] wordFiles = info.GetFiles("*.doc");

word.Visible = false;
word.ScreenUpdating = false;

foreach (FileInfo wordFile in wordFiles)
{


Object filename = (Object)wordFile.FullName;

Document doc = word.Documents.Open(ref filename, 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, ref oMissing, ref oMissing);
doc.Activate();

object outputFileName = wordFile.FullName.Replace(".docx", ".pdf");
object fileFormat = WdSaveFormat.wdFormatPDF;


doc.SaveAs(ref outputFileName,
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, ref oMissing);


object saveChanges = WdSaveOptions.wdDoNotSaveChanges;
((_Document)doc).Close(ref saveChanges, ref oMissing, ref oMissing);
doc = null;


}




((Microsoft.Office.Interop.Word.Application)word).Quit(ref oMissing, ref oMissing, ref oMissing);
word = null;



By using this i solved my problem guys.


Thank you,


SRILATHA
.Net Developer

>> Write Response - Respond to this post and get points

More Coding Horrors

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/22/2013 4:28:07 PM