Hi,
I am printing a word document. When printing in the Print statement its showing a dialog box Save File as. How can i hide this dialog box....
Reply fast...
Deeps
8 6131
Hi,
How do you print your document?
Please, post your code for this part.
Thanks,
Bassem
try
{
string fpath="some filepath";
FileStream f = new FileStream(fpat h,FileMode.Open );
streamtoPrint = new StreamReader(f) ;
try
{
printfont=new Font("Arial",10 );
PrintDocument pd = new PrintDocument() ;
pd.PrintPage+=n ew PrintPageEventH andler(this.pd_ PrintPage);
pd.PrintControl ler = new StandardPrintCo ntroller();
pd.Print();
}
finally
{
streamtoPrint.C lose();
}
This is my code when coming to pd.Print() showing the dialogbox Save File As
Please help.
Thanks for ur reply
Regards,
Deeps
Reply fast...
Answer: WOOF! No seriously, there's no need to boss us around. We're volunteers remember? And please use Code Tags around your code...
/Ontopic: Could it be that StandardPrintCo ntroller(); is some sort of image writer?
Steven
Sorry I didnt get your explanation about that.
And sorry that i was not aware of using tags.
I didnt boss u.....
Ok.....
Deeps
What's your default printer? Is it an actual printer of is it an Image Writer...You should check this in Windows.
Steven
Hi,
I didn't figure that, the nested try is very odd to me or you just posted the important area of code.
Another thing is, why do you attach - every time you try to print - the print event handler?
Thanks,
Bassem
- try
-
{
-
string fpath="some filepath";
-
FileStream f = new FileStream(fpath,FileMode.Open);
-
streamtoPrint = new StreamReader(f);
-
try
-
{
-
printfont=new Font("Arial",10);
-
PrintDocument pd = new PrintDocument();
-
pd.PrintPage+=new PrintPageEventHandler(this.pd_PrintPage);
-
pd.PrintController = new StandardPrintController();
-
-
pd.Print();
-
}
-
finally
-
{
-
streamtoPrint.Close();
-
}
-
}
-
catch(Exception ex)
-
{
-
}
-
-
-
-
-
This is my code when coming to pd.Print() showing the dialogbox Save File As
Regards,
Deeps
Hi,
First, I think you should move the attach of the event handler to the Page_Load - because if it works for the first time it will not work again; the Print() method is invoked after the attach - and according to that you have to make your PrintDocument as a class field.
Now let's check MrMancunian's suggestion. Please, open a new solution (project)
and post this inside the Page_Load method. Sure you will change the filePath to an actual file path on your computer. - Process printJob = new Process();
-
printJob.StartInfo.FileName = "filePath";
-
printJob.StartInfo.UseShellExecute = true;
-
printJob.StartInfo.Verb = "print";
-
printJob.Start();
-
Now if the same dialog box appear then simply as MrMancunian told us change your default print to an actual printer.
Thanks,
Bassem
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Greg |
last post by:
looking for an easy way for users to browse for a file on their local
drive, and then have access automatically make a copy of that file
(files will most likely be images) and save it under a new name
(somehow relating it to the PK of the main table) in a directory on
the server where the DB is stored...
i realize that might not be the best wording of what im trying to do,
so ill try explaining it a lil differently. each record created...
|
by: John |
last post by:
Hi,
I generate a report in a comma delimited file and give it
a name like MyReport.csv . I then set a Hyperlink
control to point tp the file
HyperLink1.text = "Download"
Hyperlink1.NavigateUrl = "MyReport.csv"
When the user clicks the HyperLink I would always like to
|
by: Richard |
last post by:
Hi
I'm new to ASP/Web programming so any help would be appreciated...
Situation: On my web page I would like to present a link {or button} that would allow the user to download a large file. When the user clicks to start the download I would like to display the "Save As" dialog, allow the user to name a place to save the file, and then show the download progress bar while the file downloads
Question:
How do I make a windows "Save...
|
by: Dune |
last post by:
Hi there,
I have an aspx page that allows users to enter several parameters using drop downs and text boxes. The users then press a button that produces an extract based on the parameters they entered. When this button is pressed and extract is prduced and IE's standard Open/Save dialog should popup so they can navigate to the directory to save the extract in, or if they want, they can choose to open and view the extract without saving it.
...
|
by: hamil |
last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview
control, the PageSetup control, and the Print dialog control. The code
attached is a concatination of two examples taken out of a Microsoft book,
"Visual Basic,Net Step by Step" in Chapter 18.
All but the bottom two subroutines will open a text file, and then allow me
to use the above controls, example 1. The bottom two subroutines will print
a graphic file, example...
| |
by: Fox |
last post by:
How to hide the printing dialog box during printdoucment.print() called?
|
by: zhangyl |
last post by:
I use a WebBrowser control to open an office Document in my form , but every
time when I open a file, there a
dialogbox named "File download" showed asking "Whether you want open or save
this file?", how can I hide it?
Actually, when opening an office file embeded in IE, there also show this
dialog, How can I do it?
|
by: mo |
last post by:
I have an application that uses Reporting Services. When the user
chooses to print a report, they are taken to a window that allows them
to fill in parameters for the report. They then click a button to
either export to PDF or to EXCEL. Once the report is generated, the
byte array containing the data is put into session and an aspx page is
loaded into a hidded iframe that "prints" the report (using the byte
array from session) causing...
|
by: =?Utf-8?B?YXNkZg==?= |
last post by:
Hello. I am making a web application with c# and am using this code:
Response.ContentType = "application/x-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=" +
HttpUtility.UrlEncode("あいうえお") + ".csv");
Encoding encoding = Encoding.GetEncoding("Shift-JIS");
Response.BinaryWrite(encoding.GetBytes(csvStr));
Response.End();
It works fine..the data gets saved nicely to an excel file. The user pushes
the...
|
by: deciacco |
last post by:
I'm trying to write a label printing SDI app with a small preview on the main form itself. Every time I run the InvalidatePreview event on the preview
control to redraw the preview I get the "Generating Previews" dialog box while the preview is being generated. I want to suppress this. I've been able
to find this from another forum:
"The 'Generating Previews' dialog is shown while calculating the layout for pages in OnPaint(). One of our...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |