473,738 Members | 3,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hide Save File as dialog when printing

58 New Member
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
Feb 24 '10 #1
8 6131
Bassem
344 Contributor
Hi,

How do you print your document?
Please, post your code for this part.

Thanks,
Bassem
Feb 24 '10 #2
deegeorge
58 New Member
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
Feb 24 '10 #3
MrMancunian
569 Recognized Expert Contributor
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
Feb 24 '10 #4
deegeorge
58 New Member
Sorry I didnt get your explanation about that.
And sorry that i was not aware of using tags.
I didnt boss u.....

Ok.....


Deeps
Feb 24 '10 #5
MrMancunian
569 Recognized Expert Contributor
What's your default printer? Is it an actual printer of is it an Image Writer...You should check this in Windows.

Steven
Feb 24 '10 #6
Bassem
344 Contributor
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
Feb 24 '10 #7
deegeorge
58 New Member
Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3. string fpath="some filepath";
  4. FileStream f = new FileStream(fpath,FileMode.Open);
  5. streamtoPrint = new StreamReader(f);
  6. try
  7. {
  8. printfont=new Font("Arial",10);
  9. PrintDocument pd = new PrintDocument();
  10. pd.PrintPage+=new PrintPageEventHandler(this.pd_PrintPage);
  11. pd.PrintController = new StandardPrintController();
  12.  
  13. pd.Print();
  14. finally 
  15. {
  16. streamtoPrint.Close();
  17. }
  18. }
  19. catch(Exception ex)
  20. {
  21. }
  22.  
  23.  
  24.  
  25.  
  26.  

This is my code when coming to pd.Print() showing the dialogbox Save File As


Regards,
Deeps
Feb 24 '10 #8
Bassem
344 Contributor
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.
Expand|Select|Wrap|Line Numbers
  1.                 Process printJob = new Process();
  2.                 printJob.StartInfo.FileName = "filePath";
  3.                 printJob.StartInfo.UseShellExecute = true;
  4.                 printJob.StartInfo.Verb = "print";
  5.                 printJob.Start();
  6.  
Now if the same dialog box appear then simply as MrMancunian told us change your default print to an actual printer.

Thanks,
Bassem
Feb 25 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9351
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...
4
5106
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
4
5558
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...
0
2978
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. ...
1
5714
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...
1
5565
by: Fox | last post by:
How to hide the printing dialog box during printdoucment.print() called?
2
1876
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?
3
3319
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...
3
6437
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...
3
8846
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...
0
8787
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,...
0
9473
Oralloy
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...
1
9259
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,...
0
8208
agi2029
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...
1
6750
isladogs
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...
0
6053
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();...
0
4569
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...
1
3279
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
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.