Click here to Skip to main content
15,886,074 members
Home / Discussions / C#
   

C#

 
GeneralRe: Printing in Different paper size Pin
eggie52-Jan-04 8:26
eggie52-Jan-04 8:26 
GeneralRe: Printing in Different paper size Pin
IntegraSoft2-Jan-04 8:33
IntegraSoft2-Jan-04 8:33 
GeneralRe: Printing in Different paper size Pin
eggie52-Jan-04 8:39
eggie52-Jan-04 8:39 
GeneralRe: Printing in Different paper size Pin
Mazdak2-Jan-04 8:42
Mazdak2-Jan-04 8:42 
GeneralRe: Printing in Different paper size Pin
Heath Stewart2-Jan-04 9:18
protectorHeath Stewart2-Jan-04 9:18 
GeneralRe: Printing in Different paper size Pin
IntegraSoft2-Jan-04 9:25
IntegraSoft2-Jan-04 9:25 
GeneralRe: Printing in Different paper size Pin
Heath Stewart2-Jan-04 9:31
protectorHeath Stewart2-Jan-04 9:31 
GeneralRe: Printing in Different paper size Pin
IntegraSoft2-Jan-04 9:47
IntegraSoft2-Jan-04 9:47 
This is the example I am trying. I am using an Epson LX-300 printer. The enumeration worked, i forgot to tell you that. But my initial question was that I need to create a custom form, and print using that paper size. In this example, I created manually, in Server Properties, in the printer & faxes form, and created the "MIPAPEL" form. When selecting the papersize I use the last element in the enumeration, and it printed the size I wanted, but I created it manually. If I use the new PaperSize("CUSTOM", 8.5*100, 5.5*100) it doesnt work. It seems as it is ignoring my custom size. Also, when doing this, there are no exceptions.
Just create a C# project and copy this.

-Code Start Here-

using System;
using System.Drawing.Printing;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication1
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(112, 176);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(296, 213);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e)
{
PrintDocument pd = new PrintDocument();
string s = "";
// enumerating the valid papers
foreach( PaperSize ps in pd.PrinterSettings.PaperSizes )
{
s += ps.PaperName + "\n";
}
// show the paper sizes defined for the printer
MessageBox.Show(s);

// this is a custom paper size defined manually
// using the dialogs provided on Windows XP
pd.DefaultPageSettings.PaperSize = pd.PrinterSettings.PaperSizes[pd.PrinterSettings.PaperSizes.Count - 1];


pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.QueryPageSettings += new QueryPageSettingsEventHandler(pd_QueryPageSettings);

// printing the document
pd.Print();
}

private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
// printing code goes here.....
e.HasMorePages = false;
}
}
}


Carlos Eduardo Hernandez P.
GeneralRe: Printing in Different paper size Pin
Heath Stewart2-Jan-04 10:08
protectorHeath Stewart2-Jan-04 10:08 
GeneralRe: Printing in Different paper size Pin
IntegraSoft2-Jan-04 10:18
IntegraSoft2-Jan-04 10:18 
GeneralRe: Printing in Different paper size Pin
Heath Stewart2-Jan-04 10:31
protectorHeath Stewart2-Jan-04 10:31 
GeneralRe: Printing in Different paper size Pin
IntegraSoft2-Jan-04 10:52
IntegraSoft2-Jan-04 10:52 
GeneralRe: Printing in Different paper size Pin
Heath Stewart2-Jan-04 11:00
protectorHeath Stewart2-Jan-04 11:00 
GeneralRichTextBox Pin
Luther Baker2-Jan-04 8:07
Luther Baker2-Jan-04 8:07 
GeneralRe: RichTextBox Pin
Heath Stewart2-Jan-04 9:15
protectorHeath Stewart2-Jan-04 9:15 
GeneralRe: RichTextBox Pin
Luther Baker2-Jan-04 10:14
Luther Baker2-Jan-04 10:14 
QuestionHow to send mail using SMTP Pin
gr8tushar2-Jan-04 7:55
gr8tushar2-Jan-04 7:55 
AnswerRe: How to send mail using SMTP Pin
eggie52-Jan-04 8:20
eggie52-Jan-04 8:20 
AnswerRe: How to send mail using SMTP Pin
Mazdak2-Jan-04 8:31
Mazdak2-Jan-04 8:31 
AnswerRe: How to send mail using SMTP Pin
Heath Stewart2-Jan-04 9:14
protectorHeath Stewart2-Jan-04 9:14 
GeneralRe: How to send mail using SMTP Pin
gr8tushar2-Jan-04 19:44
gr8tushar2-Jan-04 19:44 
GeneralRe: How to send mail using SMTP Pin
Heath Stewart2-Jan-04 19:47
protectorHeath Stewart2-Jan-04 19:47 
QuestionHOW TO Create a Summary Row For a Windows Form DataGrid by Using C# ???? Pin
zfeng_my2-Jan-04 3:02
zfeng_my2-Jan-04 3:02 
AnswerRe: HOW TO Create a Summary Row For a Windows Form DataGrid by Using C# ???? Pin
Mazdak2-Jan-04 3:46
Mazdak2-Jan-04 3:46 
AnswerRe: HOW TO Create a Summary Row For a Windows Form DataGrid by Using C# ???? Pin
Heath Stewart2-Jan-04 5:45
protectorHeath Stewart2-Jan-04 5:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.