Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. COM
  4. Convert document to PDF format

Convert document to PDF format

Scheduled Pinned Locked Moved COM
comhelpwindows-admintutorial
3 Posts 3 Posters 12 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hemananthan
    wrote on last edited by
    #1

    Can anybody help me programatically using COM components to get the solution for converting any type of document to PDF format we already tried through this coding: public static void ConverWordToPDF(string Filepath, string Targetpath) { object Unknown = Type.Missing; object Source = Filepath; object Target = Targetpath; ApplicationClass MSdoc = new 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) { log.Info("Converted Word to PDF", e); } finally { if (MSdoc != null) { MSdoc.Documents.Close(ref Unknown, ref Unknown, ref Unknown); } MSdoc.Quit(ref Unknown, ref Unknown, ref Unknown); } } Normally in while runing this application in local its working fine in XP System: while run through IIS i getting the following error: System.Runtime.InteropServices.COMException (0x800A11FD): =================== System.Runtime.InteropServices.COMException (0x800A11FD): This method or property is not available because a document window is not active. at Microsoft.Office.Interop.Word.Documents.Close(Object& SaveChanges, Object& OriginalFormat, Object& RouteDocument) Can anybody suggest me how to resolve it or any new solution for conversion process

    Thanks Regards Hemananthan>S

    M 1 Reply Last reply
    0
    • H hemananthan

      Can anybody help me programatically using COM components to get the solution for converting any type of document to PDF format we already tried through this coding: public static void ConverWordToPDF(string Filepath, string Targetpath) { object Unknown = Type.Missing; object Source = Filepath; object Target = Targetpath; ApplicationClass MSdoc = new 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) { log.Info("Converted Word to PDF", e); } finally { if (MSdoc != null) { MSdoc.Documents.Close(ref Unknown, ref Unknown, ref Unknown); } MSdoc.Quit(ref Unknown, ref Unknown, ref Unknown); } } Normally in while runing this application in local its working fine in XP System: while run through IIS i getting the following error: System.Runtime.InteropServices.COMException (0x800A11FD): =================== System.Runtime.InteropServices.COMException (0x800A11FD): This method or property is not available because a document window is not active. at Microsoft.Office.Interop.Word.Documents.Close(Object& SaveChanges, Object& OriginalFormat, Object& RouteDocument) Can anybody suggest me how to resolve it or any new solution for conversion process

      Thanks Regards Hemananthan>S

      M Offline
      M Offline
      Member 4524333
      wrote on last edited by
      #2

      Hi, I am also facing the same problem if any body knows solution please let us know. Thanks, Venu

      N 1 Reply Last reply
      0
      • M Member 4524333

        Hi, I am also facing the same problem if any body knows solution please let us know. Thanks, Venu

        N Offline
        N Offline
        Nitin K Kawale
        wrote on last edited by
        #3

        use primopdf software you can easily download from the net

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups