Can a PrintDialog be modified? - c#

I am working at a print module and I use a PrintDialog to set the printer settings and then to print. The problem is that I have to do that before each print operation.
I want to select the printer settings (all the options provided by PrintDialog) and then to store them somewhere (not to print the document directly from the PrintDialog). Then, when I want to print something, it should print using the stored options.
So my question is the following: can I modify the PrintDialog by changing the name of the "Print" button into "Store Settings"? Or should I rewrite completely the functionality of that Dialog? (I hope not).
I want to change that button name in order to transform it from a print window into a print settings window.
Also, is there an existing implementation of a similar PrintDialog, other than the default one?
Thank you!

#CosminIoniță
If I were you I would do this.
Save all the options of the printdialog in a serialized bin file. Read the file the next time and populate all options of the printdialog from there the next time onward.
Hope it helps

Related

print a form with texts in c# that looks like a word document

i am trying to create a contract (document) that I can print like a normal word document.
I have a form which is my 'entry form') where i can type in details such as customer name, amount,date of contract etc. these information is then saved in ms access.
i have another form (which i call 'contract doc'). it has labels in it and the label holds the information i typed in my 'entry form'. I assigned one label to get the values that i entered in the textbox in the entry form.
contractdoc.contract_date_label.Text = contract_date_tb.Text;
contractdoc.deposit_label.Text = deposit_tb.Text;
contractdoc.customer_name_label.Text = customer_name_tb.Text;
i also added labels and typed the rest of the documents body and position them in the 'contract doc form ' to look like an actual contract.
but i dont know how to print it like a document. i iused :
printForm1.Print();
but what happens is, it asks me to save in xls format and only a messege box that says:"printing page 1 of document" with a cancel button.
I hope you can help. thank you in advance
I presume from the name printForm1, that you're using the PrintForm class provided as part of the Visual Basic PowerPack.
In that case, you need to make sure that the PrintAction property is set appropriately. To print to a physical printer, you need to set it to PrintAction.PrintToPrinter. Depending on what printer is configured as the system default, you might also need to set the PrinterSettings property. Then when you call the Print method, it will print to the correct printer.
It's probably prompting you to save the file in XLS format because your system default printer is a virtual one that generates XLS files.

c#/WPF print formatting

I am very new to c#/WPF and I need help with what should be a very simple app. In the app I am designing a user simply browses for a .txt or .jpg file which is then loaded. I would like the user to then be able to print what's displayed. The code I have found to work appears to only print part of the contents on one page. In addition, when the .txt files are printed there are no margins and the text seems to go right off the page. Here is the code I am using as it seems to be very basic.
System.Windows.Controls.PrintDialog pd = new System.Windows.Controls.PrintDialog();
if (pd.ShowDialog() != true) return;
pd.PrintVisual(textbox2, "textbox2.");
I guess my question would be, how do I set margin spacing and allow for multiple page document printing? Any help would be greatly appreciated. Thank you.
To print text files you will probably want to use a FlowDocument, this allows you to set margins, pagination etc, e.g.
Printing a WPF FlowDocument
To print a JPEG, you can use PrintVisual, e.g.
Load image from file and print it using WPF... how?

IHTMLDocument2 Printing without Dialog Box

I've been working on a project that automatically prints HTML invoices. It's been particularly challenging as I've needed to keep the CSS formatting.
Following advice, I've found myself using IHTMLDocument2 to carry out my printing. I'm supposed to be able to:
mshtml.IHTMLDocument2 doc = new mshtml.HTMLDocument() as mshtml.IHTMLDocument2;
doc.write(htmlContent); //htmlContent is a string of HTML
doc.execCommand("PRINT", false, null);
The second argument specifies whether to produce the Printer Options box, but it doesn't help. I've read that using PRINT will always result in a dialog box - however I haven't been able to find an alternative.
Any ideas?
According MSDN:
Print
Opens the print dialog box so the user can print the current page.
So I think there is no way to workaround this behaviour. Try to use other classes for your application or open the print dialog box during printing.
You should note that you must provide true as secord parameter (showUI [in, optional]) in execCommand method.

Print multiple documents continuously

I want to implement a continious printing of document.Please see image belowalt text http://www.freeimagehosting.net/uploads/c87bde9396.png
When I choose the checkboxes then click the print button, all the information of a particular applicant will be printed.Take note that each document was printed on a new page. I found a soluton from this forum http://bytes.com/topic/asp-net/answers/861073-print-multiple-files-continuously
But I need an additional resources about this to implement the best solution for this functionality.Any ideas?
I believe that the best approach for this problem is to open a popup window with the contents using page break when necessary. This way you have better control over what is printed and you can give user a chance to review what is going to be printed if you like or call window.print on ready.

asp.net Fontdialog problem in web application

I want to display font dialog box in my web application(asp.net). Im using the following code. Its working fine.
Problem:
Dialogbox is getting open but it is behind the page. Even though i closed the application it is still open. It is not binded to the application.
Code:
FontDialog fontDialog = new FontDialog();
fontDialog.ShowColor = true;
DialogResult dR = fontDialog.ShowDialog();
if (dR == DialogResult.OK)
{
txtChange.Font = fntDialog.Font;
}
Edit:
I want to create an application for Entry pages to fill the database.
In this i want to store text and its font size, name and color.
Im my mind there are two options:
Displaying the fonts from the system.(Dropped bcz these entry page application is in the one system and the report page application going to run kiosk). It will create problem if the fonts are not available in the kiosk.
Font dialogbox.(Also creating problem)
Please is there any other good option for this.
Er.... this is NOT a good idea. This dialog will launch on the server, which means if you are accessing this from a remote computer (which is more than likely), you'll never see the dialog, but the server could end up with countless dialog instances popping up.
What use is the fonts dialog in a web application anyway??
EDIT: To be safe, I'd produce a list of known fonts on the system and then simply list them in a drop down box. You've already discovered the problem with enumerating the fonts and attempting to use a dialog.
There are lots of Html font coloring panel free over web , written in javascript. For setting values of Font Sizes you can use a dropdown for the same with your predefined values. While saving , save the value of font size and its concerned data as plain text in db and while fetching apply it.

Categories

Resources