Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8871991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:07:00+00:00 2026-06-14T18:07:00+00:00

In my Asp.net web application, i have to convert one docx file into pdf

  • 0

In my Asp.net web application, i have to convert one docx file into pdf file programatically.I have used microsoft interoperability word package and using the method saveAs() method.

This is my C# code…

var TheDocument = wdApp.Documents.Open("sample.docx"); //control stopped here...

TheDocument.ExportAsFixedFormat("sample.pdf", Microsoft.Office.Interop.Word.WdExportFormat.wdExportFormatPDF,
               OptimizeFor: Microsoft.Office.Interop.Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen,
               BitmapMissingFonts: true, DocStructureTags: false);

((Microsoft.Office.Interop.Word._Document)TheDocument).Close();

But when executing this line, var TheDocument = wdApp.Documents.Open("sample.docx"); the control stopped on this line and there is no further response.Browser symbol seems like loading, loading…

I dont know what is the issue here…

Please guide me to get out of this issue…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:07:01+00:00Added an answer on June 14, 2026 at 6:07 pm

    Check this link -> convert doc to pdf in c#

    It uses the Microsoft.Office.Interop.

    private Microsoft.Office.Interop.Word.ApplicationClass MSdoc;       
    
            //Use for the parameter whose type are not known or say Missing
            object Unknown = Type.Missing;
    
      private void word2PDF(object Source, object Target)
            {   //Creating the instance of Word Application          
           if (MSdoc == null)MSdoc = new Microsoft.Office.Interop.Word.ApplicationClass();
    
                try
                {  
                    MSdoc.Visible = false;               
                    MSdoc.Documents.Open(ref Source, ref Unknown,
                         ref Unknown, ref Unknown, ref Unknown,
                         ref Unknown, ref Unknown, ref Unknown,
                         ref Unknown, ref Unknown, ref Unknown,
                         ref Unknown, ref Unknown, ref Unknown, ref Unknown, ref Unknown);
                    MSdoc.Application.Visible = false;
                    MSdoc.WindowState = Microsoft.Office.Interop.Word.WdWindowState.wdWindowStateMinimize;               
    
                    object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF;
    
                    MSdoc.ActiveDocument.SaveAs(ref Target, ref format,
                            ref Unknown, ref Unknown, ref Unknown,
                            ref Unknown, ref Unknown, ref Unknown,
                            ref Unknown, ref Unknown, ref Unknown,
                            ref Unknown, ref Unknown, ref Unknown,
                           ref Unknown, ref Unknown);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
                finally
                {
                    if (MSdoc != null)
                    {
                        MSdoc.Documents.Close(ref Unknown, ref Unknown, ref Unknown);
                        //WordDoc.Application.Quit(ref Unknown, ref Unknown, ref Unknown);
                    }               
                    // for closing the application
                    WordDoc.Quit(ref Unknown, ref Unknown, ref Unknown);
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one question; In my ASP.NET MVC web application have to do certain
I have a web application developed in asp.net 3.5. The application is used in
I have an MVC web application in asp.net 3.5 How can I convert that
Ive been trying to convert my asp.net website into a web application following the
I have a confusing question. I have to convert an ASP.NET Web application in
I have a asp.net web application that uses C#. It logs in on a
So I have this asp.net web application that I renamed. I changed the assembly
I have an ASP.NET web application the entire site is browsed over HTTPS using
I have an asp.net web application written in C# using a SQL Server 2008
We have an ASP.NET web application hosted by a web farm of many instances

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.