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
  1. Home
  2. General Programming
  3. C#
  4. Activex code to print pdf files on client machine

Activex code to print pdf files on client machine

Scheduled Pinned Locked Moved C#
comjavascriptgraphicssysadmintesting
8 Posts 4 Posters 0 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.
  • S Offline
    S Offline
    Sachin Mehndiratta
    wrote on last edited by
    #1

    Hi All, I am looking for expert advice on printing the pdf files at client machine. I have created a sample project named ClientPrint as

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Printing;
    using System.Runtime.InteropServices;

    namespace ActiveX
    {
    public interface IActiveXPrintLib
    {
    void PrintFile(string filePath);
    }

    \[ProgId("ActiveX.PrintFile")\]
    \[ClassInterface(ClassInterfaceType.AutoDual)\]
    \[ComVisible(true)\]
    public class ActiveXPrintLib : IActiveXPrintLib
    {
    
    	\[ComVisible(true)\]
    	public void PrintFile(string filePath)
    	{
    		AcroPDFLib.AcroPDF AcroPdf = new AcroPDFLib.AcroPDF();
    		AcroPdf.LoadFile(filePath);
    		AcroPdf.printAll();
    
    	}
    
    }
    

    }

    I have created the dll and register the dll using regasm command on client machine. Now at time of consuming the print method at client side using javascript as <object id="myControl1" name="myControl1" classid="clsid:ActiveX.ActiveXPrintLib"> </object>

    var axComponent = new ActiveXObject("ActiveX.ActiveXPrintLib");
    alert(axComponent);
    if (axComponent == null) {
    alert('Probably not installed');
    }
    else {
    axComponent.PrintFile('<%= Page.ResolveUrl("~/PdfTemp/0d818b57-9384-4f52-ae89-8ef5868064b7.pdf") %>');
    alert('yes');
    }

    I am getting the error that automation server can't create object, using IE I have enabled the active x and permisssions to download the activex. but it still gives me same error. I am not sure whether my code is correct or not. Any advice is really helpful. Thanks in advance.

    Sachin Mehndiratta mehndi.sachin@gmail.com

    P L 2 Replies Last reply
    0
    • S Sachin Mehndiratta

      Hi All, I am looking for expert advice on printing the pdf files at client machine. I have created a sample project named ClientPrint as

      using System;
      using System.Collections;
      using System.Collections.Generic;
      using System.Data;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Printing;
      using System.Runtime.InteropServices;

      namespace ActiveX
      {
      public interface IActiveXPrintLib
      {
      void PrintFile(string filePath);
      }

      \[ProgId("ActiveX.PrintFile")\]
      \[ClassInterface(ClassInterfaceType.AutoDual)\]
      \[ComVisible(true)\]
      public class ActiveXPrintLib : IActiveXPrintLib
      {
      
      	\[ComVisible(true)\]
      	public void PrintFile(string filePath)
      	{
      		AcroPDFLib.AcroPDF AcroPdf = new AcroPDFLib.AcroPDF();
      		AcroPdf.LoadFile(filePath);
      		AcroPdf.printAll();
      
      	}
      
      }
      

      }

      I have created the dll and register the dll using regasm command on client machine. Now at time of consuming the print method at client side using javascript as <object id="myControl1" name="myControl1" classid="clsid:ActiveX.ActiveXPrintLib"> </object>

      var axComponent = new ActiveXObject("ActiveX.ActiveXPrintLib");
      alert(axComponent);
      if (axComponent == null) {
      alert('Probably not installed');
      }
      else {
      axComponent.PrintFile('<%= Page.ResolveUrl("~/PdfTemp/0d818b57-9384-4f52-ae89-8ef5868064b7.pdf") %>');
      alert('yes');
      }

      I am getting the error that automation server can't create object, using IE I have enabled the active x and permisssions to download the activex. but it still gives me same error. I am not sure whether my code is correct or not. Any advice is really helpful. Thanks in advance.

      Sachin Mehndiratta mehndi.sachin@gmail.com

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      I've looked and I can't see the C# in there. You might want to try the VB.NET forum, where the VB.NET experts hang out.

      S 2 Replies Last reply
      0
      • P Pete OHanlon

        I've looked and I can't see the C# in there. You might want to try the VB.NET forum, where the VB.NET experts hang out.

        S Offline
        S Offline
        Sachin Mehndiratta
        wrote on last edited by
        #3

        yeah, my mistake, I have already posted to .net framework

        L 1 Reply Last reply
        0
        • S Sachin Mehndiratta

          yeah, my mistake, I have already posted to .net framework

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Which is not VB.NET, please delete it from there and try the Visual Basic forum.

          S 1 Reply Last reply
          0
          • S Sachin Mehndiratta

            Hi All, I am looking for expert advice on printing the pdf files at client machine. I have created a sample project named ClientPrint as

            using System;
            using System.Collections;
            using System.Collections.Generic;
            using System.Data;
            using System.Diagnostics;
            using System.Drawing;
            using System.Drawing.Printing;
            using System.Runtime.InteropServices;

            namespace ActiveX
            {
            public interface IActiveXPrintLib
            {
            void PrintFile(string filePath);
            }

            \[ProgId("ActiveX.PrintFile")\]
            \[ClassInterface(ClassInterfaceType.AutoDual)\]
            \[ComVisible(true)\]
            public class ActiveXPrintLib : IActiveXPrintLib
            {
            
            	\[ComVisible(true)\]
            	public void PrintFile(string filePath)
            	{
            		AcroPDFLib.AcroPDF AcroPdf = new AcroPDFLib.AcroPDF();
            		AcroPdf.LoadFile(filePath);
            		AcroPdf.printAll();
            
            	}
            
            }
            

            }

            I have created the dll and register the dll using regasm command on client machine. Now at time of consuming the print method at client side using javascript as <object id="myControl1" name="myControl1" classid="clsid:ActiveX.ActiveXPrintLib"> </object>

            var axComponent = new ActiveXObject("ActiveX.ActiveXPrintLib");
            alert(axComponent);
            if (axComponent == null) {
            alert('Probably not installed');
            }
            else {
            axComponent.PrintFile('<%= Page.ResolveUrl("~/PdfTemp/0d818b57-9384-4f52-ae89-8ef5868064b7.pdf") %>');
            alert('yes');
            }

            I am getting the error that automation server can't create object, using IE I have enabled the active x and permisssions to download the activex. but it still gives me same error. I am not sure whether my code is correct or not. Any advice is really helpful. Thanks in advance.

            Sachin Mehndiratta mehndi.sachin@gmail.com

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Don't crosspost.

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

            Richard DeemingR 1 Reply Last reply
            0
            • L Lost User

              Don't crosspost.

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              Normally, I'd agree with you. But in this case, both Pete and RMC told the user to post the question to a different forum, and they obviously didn't notice the "delete" button on the old messages. :)


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              1 Reply Last reply
              0
              • L Lost User

                Which is not VB.NET, please delete it from there and try the Visual Basic forum.

                S Offline
                S Offline
                Sachin Mehndiratta
                wrote on last edited by
                #7

                Appology for the mistake, code is now converted to C#

                1 Reply Last reply
                0
                • P Pete OHanlon

                  I've looked and I can't see the C# in there. You might want to try the VB.NET forum, where the VB.NET experts hang out.

                  S Offline
                  S Offline
                  Sachin Mehndiratta
                  wrote on last edited by
                  #8

                  Code is edited to C# now

                  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