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. .NET (Core and Framework)
  4. Activex code to print pdf files on client machine

Activex code to print pdf files on client machine

Scheduled Pinned Locked Moved .NET (Core and Framework)
comjavascriptgraphicssysadmintesting
3 Posts 2 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

    Imports System.Drawing
    Imports System.Drawing.Printing
    Imports System.Runtime.InteropServices

    Namespace ActiveX
    Public Interface IActiveXPrintLib
    Sub PrintFile(filePath As String)
    End Interface

    <ProgId("ActiveX.PrintFile")>
    

    <ClassInterface(ClassInterfaceType.AutoDual)>
    <ComVisible(True)>
    Public Class ActiveXPrintLib
    Implements IActiveXPrintLib

        <ComVisible(True)>
        Public Sub PrintFile(filePath As String) Implements IActiveXPrintLib.PrintFile
    
            Dim AcroPdf As New AcroPDFLib.AcroPDF()
            AcroPdf.LoadFile(filePath)
            AcroPdf.printAll()
           
        End Sub
    
    End Class
    

    End Namespace

    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 {
    yourAxComponent.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

    A 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

      Imports System.Drawing
      Imports System.Drawing.Printing
      Imports System.Runtime.InteropServices

      Namespace ActiveX
      Public Interface IActiveXPrintLib
      Sub PrintFile(filePath As String)
      End Interface

      <ProgId("ActiveX.PrintFile")>
      

      <ClassInterface(ClassInterfaceType.AutoDual)>
      <ComVisible(True)>
      Public Class ActiveXPrintLib
      Implements IActiveXPrintLib

          <ComVisible(True)>
          Public Sub PrintFile(filePath As String) Implements IActiveXPrintLib.PrintFile
      
              Dim AcroPdf As New AcroPDFLib.AcroPDF()
              AcroPdf.LoadFile(filePath)
              AcroPdf.printAll()
             
          End Sub
      
      End Class
      

      End Namespace

      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 {
      yourAxComponent.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

      A Offline
      A Offline
      AmitGajjar
      wrote on last edited by
      #2

      Hi, I google for your issue and found one discussion, http://forums.asp.net/t/1482178.aspx?ActiveX+Select+printer+and+print+custom+page+[^] you will get your answer from this discussion. read it through.

      Thanks Amit

      S 1 Reply Last reply
      0
      • A AmitGajjar

        Hi, I google for your issue and found one discussion, http://forums.asp.net/t/1482178.aspx?ActiveX+Select+printer+and+print+custom+page+[^] you will get your answer from this discussion. read it through.

        Thanks Amit

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

        Hi, Thanks for sharing the link, but information shared on this link is not complete and still I am facing same issue. Thanks,

        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