|
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
modified 30-May-14 4:55am.
|
|
|
|
|
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.
|
|
|
|
|
yeah, my mistake, I have already posted to .net framework
|
|
|
|
|
Which is not VB.NET, please delete it from there and try the Visual Basic forum.
|
|
|
|
|
Appology for the mistake, code is now converted to C#
|
|
|
|
|
|
Don't crosspost.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
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
|
|
|
|
|
When a file is sent to print in printer++ (a open source virtual printer, developed in c#.net), I want to get the full file name with its full physical path of that file in my c# winform app. Means I want to create a copy of these file(s) that are printed by printer++.
Actually I don't need print, i need copy that image to another location using my winform app. The scenario is when a user print any image with printer++ then my app (it will be installed with printer++ on users pc) automatically get that image and keep a copy in a folder.
These Files should be images like *.png, *.gif, *.jpg etc.
how I do this. Any suggestions for doing this in C#.Net.
|
|
|
|
|
Look at the source code for printer++, and see how it saves and manages the path as it is printing.
|
|
|
|
|
Can you help me to find solution from printer++ source? I searched but not any luck
modified 29-May-14 6:59am.
|
|
|
|
|
It doesn't quite work like that.
We do not do your work for you.
If you want someone to write your code, you have to pay - I suggest you go to VWorker.com and ask there.
But be aware: you get what you pay for. Pay peanuts, get monkeys.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Sorry, but I have no knowledge of this product. If it is open source then it's up to you to figure out how it works and modify it as required.
|
|
|
|
|
Thank you Richard MacCutchan for your kind reply.
|
|
|
|
|
Hi, I have a project that required me to integrate VLC video player into my c# program.
I managed to have the following functions play, pause, stop, load, fast forward in the program. But one function that I have no idea on how to implement is the 'Bookmark' function which means when the video is play at some point of time when I add a bookmark on the specified time, it will automatically save into a box and when I press the bookmark it will bring me back to the time where I have bookmark on it.
Please advise if someone has done this before. Thanks in advance.
|
|
|
|
|
I try to create a form with 2 constructors.
The first constructor takes no parameters. User will give their input manually.
The second constructor has parameters. Some ui-controls are filled with data from a database.
I want the second constructor to call the first (or default) constructor for initialisation purposes. How can I do that ?
Public class something
{
Public Something()
{
Backcolor = clgreen;
}
Public Something(string name)
{
Label.text = name
}
}
I used to write code in Delphi, which uses the keyword "inherited" to do this.
I found this article on code project, that is doing the opposite. I have no clue why a default constructor would call the more complex constructor.
How to call an overloaded constructors in C#[^]
|
|
|
|
|
public class Something
{
public Something()
{
Backcolor = clgreen;
}
public Something(string name)
: this()
{
Label.text = name
}
}
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
modified 28-May-14 17:14pm.
|
|
|
|
|
wow, I didn't expect it to be that simple.
In the article the first constructor is calling the second constructor and the second constructor is calling the third constructor.
namespace Dummy
{
public class Something
{
private string myName;
private int myIndex;
public Something()
{
myName = "default";
myIndex = -1;
DoStuff();
}
public Something(string name)
{
myName = name;
myIndex= -1;
DoStuff();
}
public Something(string name, index)
{
myName = name;
myIndex= index;
DoStuff();
}
private void DoStuff()
{
}
}
This is the other way around.
Instead of doing most of the initializing in the first constructor. In the article all initialisation is done in the third (last) constructor.
Which one is the better way to develop.
|
|
|
|
|
Well, you can seriously simplify your logic here:
namespace Dummy
{
public class Something
{
private string myName;
private int myIndex;
public Something() : this("default", -1)
{
}
public Something(string name): this(name, -1)
{
}
public Something(string name, index)
{
myName = name;
myIndex= index;
DoStuff();
}
private void DoStuff()
{
}
} As the three constructors are doing the same thing, with the first two providing default values, simply adding the logic into the final constructor makes things simpler. This example is no longer violating the DRY principle (Don't Repeat Yourself).
|
|
|
|
|
sneezesnoeze wrote: I have no clue why a default constructor would call the more complex constructor. Because someone created a named Something, or because another constructor points to it.
using System;
using System.Windows.Forms;
using System.Drawing;
namespace ConsoleApplication1084
{
class Program
{
public class something
{
Color _backColor;
public something()
{
Console.WriteLine("Fiiiiiiiiiiiiirst!");
}
public something(string name): this (name, Color.Green)
{
Console.WriteLine(string.Format("Name = {0}", name));
}
public something(string name, Color backColor): this()
{
_backColor = Color.Green;
Console.WriteLine(string.Format("Name = {0}", name));
Console.WriteLine(string.Format("Color = {0}", _backColor));
}
}
static void Main()
{
new something("Hello world");
Console.ReadLine();
}
}
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
sneezesnoeze wrote: I have no clue why a default constructor would call the more complex constructor.
Surprisingly, this is common and reasonable.
This is to accomplish providing default values for the various parameters of the complex constructor.
See section "10.11.6 Optional instance constructor parameters" of the : C# Language Specification[^]
Starting with C# 4.0 optional arguments (see C# Language Features, From C# 2.0 to 4.0[^]) provides this capability if the default values are constant value expressions (or new S() or default(S) where S is a value type):
See section "10.6.1 Method parameters" of the C# Language Specification (linked above).
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
There's two ways to write this:
public class Option1 {
public Option1() : this(name) {}
public Option1(string name) {
Label.Text = name;
BackColor = Color.Green;
}
}
or
public class Option2 {
public Option2() : this(name) {
BackColor = Color.Green;
}
public Option2(string name) : this() {
Label.Text = name;
}
}
There is no functional difference between these two, it's a matter of style. I normally prefer the first option (calling the more complex constructor with default arguments) because that way all the initialisation is in one place and it's easy to confirm that you have set everything you meant to.
|
|
|
|
|
|
Hi every1. This is my first post so be gentle
I want to make ,a song organizer connected with database(sql).
So basicaly windows app with option for just inserting my favorite song names with artist/genre selection thats it..
Any similar tutorial step by step or so? Im new into c# but don't know how to start.. Help plz
|
|
|
|
|
Search around for tutorials, pick the one that uses books as a subject (assuming there is not one based on songs).
Never underestimate the power of human stupidity
RAH
|
|
|
|