Activex code to print pdf files on client machine
-
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
-
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
-
yeah, my mistake, I have already posted to .net framework
-
yeah, my mistake, I have already posted to .net framework
-
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
-
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
-
Appology for the mistake, code is now converted to C#
-
Code is edited to C# now