Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Printing in Different paper size

Printing in Different paper size

Scheduled Pinned Locked Moved C#
csharpquestion
14 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I IntegraSoft

    Has someone print in .Net a custom papersize?. I have tried, and the only size that print is the standard size, 8.5" x 11". What do I need to do to change the papersize? Carlos Eduardo Hernandez P.

    E Offline
    E Offline
    eggie5
    wrote on last edited by
    #2

    I don't know how to change it. But, was this not answered in the last 24 hours? Click "Search comments" above, i'm pretty sure your answer is there. Good Luck. /\ |_ E X E GG

    I 1 Reply Last reply
    0
    • E eggie5

      I don't know how to change it. But, was this not answered in the last 24 hours? Click "Search comments" above, i'm pretty sure your answer is there. Good Luck. /\ |_ E X E GG

      I Offline
      I Offline
      IntegraSoft
      wrote on last edited by
      #3

      it dindnt. I am just trying to open a new thread so other people can comment on this. It has not work yet. Carlos Eduardo Hernandez P.

      E 1 Reply Last reply
      0
      • I IntegraSoft

        it dindnt. I am just trying to open a new thread so other people can comment on this. It has not work yet. Carlos Eduardo Hernandez P.

        E Offline
        E Offline
        eggie5
        wrote on last edited by
        #4

        alright... I put "paper size" in there and found a bunch of stuff... /\ |_ E X E GG

        1 Reply Last reply
        0
        • I IntegraSoft

          Has someone print in .Net a custom papersize?. I have tried, and the only size that print is the standard size, 8.5" x 11". What do I need to do to change the papersize? Carlos Eduardo Hernandez P.

          M Offline
          M Offline
          Mazdak
          wrote on last edited by
          #5

          http://www.codeproject.com/script/comments/forums.asp?forumid=1649&select=703627&df=100&fr=51#xx703450xx[^] Mazy No sig. available now.

          1 Reply Last reply
          0
          • I IntegraSoft

            Has someone print in .Net a custom papersize?. I have tried, and the only size that print is the standard size, 8.5" x 11". What do I need to do to change the papersize? Carlos Eduardo Hernandez P.

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #6
            1. Do not keep posting the same question - we do not like that here and if you didn't get answers the first 1000 times, you probably won't get one at all (but might find more spam in your inbox!)
            2. What I gave you should work (the link that Mazdak sent you). If it doesn't, you need to reply to that thread and - as I stated in the message - research the problem instead of just guessing and asking other people!

            -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

            I 1 Reply Last reply
            0
            • H Heath Stewart
              1. Do not keep posting the same question - we do not like that here and if you didn't get answers the first 1000 times, you probably won't get one at all (but might find more spam in your inbox!)
              2. What I gave you should work (the link that Mazdak sent you). If it doesn't, you need to reply to that thread and - as I stated in the message - research the problem instead of just guessing and asking other people!

              -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

              I Offline
              I Offline
              IntegraSoft
              wrote on last edited by
              #7

              Sorry. But I have research enough, and it is not in the .net help, it is, but it doesnt work. Your example and Mazdak'a didnt work also. Maybe you should try what you post. When I help someone in a problem, I tried to help them completly not half way. Thanks. Carlos Eduardo Hernandez P.

              H 1 Reply Last reply
              0
              • I IntegraSoft

                Sorry. But I have research enough, and it is not in the .net help, it is, but it doesnt work. Your example and Mazdak'a didnt work also. Maybe you should try what you post. When I help someone in a problem, I tried to help them completly not half way. Thanks. Carlos Eduardo Hernandez P.

                H Offline
                H Offline
                Heath Stewart
                wrote on last edited by
                #8

                The examples in the MSDN documentation don't work? I hardly doubt that, because they have been tested and have been in public sight for several years now. I'm sure someone wouldn't noticed and alerted Microsoft, especially since they have such an easy documentation bug link at the bottom! And as I have sound countless times - post WHY enumerating the PaperSizes didn't work! What exceptions where thrown, if any? It is possible that the printer does not support that paper size! It is, after all, a rather large piece of paper - if the printer tray doesn't support it, it will use the default! So, write a simple application that enumerates and displays the valid PaperSizes that it supports and see, or debug your code and check the state of objects after lines that don't seem to have an effect. If you keep asking the same question, you'll get the same answer - so provide us with more details and what exceptions - if any - are being thrown, or example snippets of code showing that you are trying what we have written and where the exception is being thrown. I assure you that enumerating PrinterSettings.PaperSizes works! Tell us why it's not working for you!

                -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                I 1 Reply Last reply
                0
                • H Heath Stewart

                  The examples in the MSDN documentation don't work? I hardly doubt that, because they have been tested and have been in public sight for several years now. I'm sure someone wouldn't noticed and alerted Microsoft, especially since they have such an easy documentation bug link at the bottom! And as I have sound countless times - post WHY enumerating the PaperSizes didn't work! What exceptions where thrown, if any? It is possible that the printer does not support that paper size! It is, after all, a rather large piece of paper - if the printer tray doesn't support it, it will use the default! So, write a simple application that enumerates and displays the valid PaperSizes that it supports and see, or debug your code and check the state of objects after lines that don't seem to have an effect. If you keep asking the same question, you'll get the same answer - so provide us with more details and what exceptions - if any - are being thrown, or example snippets of code showing that you are trying what we have written and where the exception is being thrown. I assure you that enumerating PrinterSettings.PaperSizes works! Tell us why it's not working for you!

                  -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                  I Offline
                  I Offline
                  IntegraSoft
                  wrote on last edited by
                  #9

                  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); }

                  H 1 Reply Last reply
                  0
                  • I IntegraSoft

                    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); }

                    H Offline
                    H Offline
                    Heath Stewart
                    wrote on last edited by
                    #10

                    If you created a form called "MIPAPEL" (which I guess is supposed to be "MYPAPER"), why did you pass "CUSTOM" for the name of the form in the PaperSize constructor? Try passing "MYPAPER"/"MYPAPEL" and see if that works.

                    -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                    I 1 Reply Last reply
                    0
                    • H Heath Stewart

                      If you created a form called "MIPAPEL" (which I guess is supposed to be "MYPAPER"), why did you pass "CUSTOM" for the name of the form in the PaperSize constructor? Try passing "MYPAPER"/"MYPAPEL" and see if that works.

                      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                      I Offline
                      I Offline
                      IntegraSoft
                      wrote on last edited by
                      #11

                      I try that before sending the example and it doesnt work, The PaperSize only have one constructor, ant it ask for the name of the papaer, and the width, and height. I put the same thing and it ignores it. One of my problems is solved, because with the enumertion I could manually create the form and use it in my code. But what I need is to be able to create a new paper size, and use it. In the code I sent you, there was a mistake, the line that calls the querypagemethod take it out. Thanks. Carlos Eduardo Hernandez P.

                      H 1 Reply Last reply
                      0
                      • I IntegraSoft

                        I try that before sending the example and it doesnt work, The PaperSize only have one constructor, ant it ask for the name of the papaer, and the width, and height. I put the same thing and it ignores it. One of my problems is solved, because with the enumertion I could manually create the form and use it in my code. But what I need is to be able to create a new paper size, and use it. In the code I sent you, there was a mistake, the line that calls the querypagemethod take it out. Thanks. Carlos Eduardo Hernandez P.

                        H Offline
                        H Offline
                        Heath Stewart
                        wrote on last edited by
                        #12

                        Look here: http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=PrintDocument+PaperSize+custom[^]. It does work. You could be right about the server forms configured on the system, but the PageSetupDialog doesn't seem to mind. If you solved the problem of printing an A3 form by enumerating the PaperSizes like I said a while back, great. If you're trying to print something else customized, it's possible the printer (or maybe even the print server) might not support it. There were some examples of setting custom paper sizes in the google link I gave you. If they don't work for you, either you have a botched .NET installation (which I doubt, because many other things would be wrong), or your printer has problems or limitations. I have a Lexmark myself and I am not particular crazy about it (what can I say, it was free). Have you tried a different printer?

                        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                        I 1 Reply Last reply
                        0
                        • H Heath Stewart

                          Look here: http://www.google.com/search?sourceid=navclient&ie=UTF-8&oe=UTF-8&q=PrintDocument+PaperSize+custom[^]. It does work. You could be right about the server forms configured on the system, but the PageSetupDialog doesn't seem to mind. If you solved the problem of printing an A3 form by enumerating the PaperSizes like I said a while back, great. If you're trying to print something else customized, it's possible the printer (or maybe even the print server) might not support it. There were some examples of setting custom paper sizes in the google link I gave you. If they don't work for you, either you have a botched .NET installation (which I doubt, because many other things would be wrong), or your printer has problems or limitations. I have a Lexmark myself and I am not particular crazy about it (what can I say, it was free). Have you tried a different printer?

                          -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                          I Offline
                          I Offline
                          IntegraSoft
                          wrote on last edited by
                          #13

                          Thanks, I found what I was looking. But if you have read it, you have noticed that what I was asking cannot be done with C#, not completly. There is an example on how to add the form using c++ code, and then with that form, use it in c# to print the custom size. So I assume the custom size option using the papersize constructor only works on Windows 98 or before. Carlos Eduardo Hernandez P.

                          H 1 Reply Last reply
                          0
                          • I IntegraSoft

                            Thanks, I found what I was looking. But if you have read it, you have noticed that what I was asking cannot be done with C#, not completly. There is an example on how to add the form using c++ code, and then with that form, use it in c# to print the custom size. So I assume the custom size option using the papersize constructor only works on Windows 98 or before. Carlos Eduardo Hernandez P.

                            H Offline
                            H Offline
                            Heath Stewart
                            wrote on last edited by
                            #14

                            integrasoft wrote: So I assume the custom size option using the papersize constructor only works on Windows 98 or before. That's probably a safe assumption. Just P/Invoke the method(s) you need to save from having to write a native DLL.

                            -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups