Questions tagged [printdocument]

Defines a reusable object that sends output to a printer, when printing from a Windows Forms application.

289 questions
50
votes
2 answers

Why is Graphics.MeasureString() returning a higher than expected number?

I'm generating a receipt and am using the Graphics object to call the DrawString method to print out the required text. graphics.DrawString(string, font, brush, widthOfPage / 2F, yPoint, stringformat); This works fine for what I needed it to do. I…
Brandon
  • 68,708
  • 30
  • 194
  • 223
49
votes
3 answers

How to find the actual printable area? (PrintDocument)

Why is finding out this magic Rectangle so difficult? In the OnPrintPage event I have PrintPageEventArgs and I am trying to draw using the Graphics within the bounds of the maximum printable area. I have tried using PageBounds, PrintableArea,…
Trevor Elliott
  • 11,292
  • 11
  • 63
  • 102
37
votes
7 answers

Printing image with PrintDocument. how to adjust the image to fit paper size

In C#, I am trying to print an image using PrintDocument class with the below code. The image is of size 1200 px width and 1800 px height. I am trying to print this image in a 4*6 paper using a small zeebra printer. But the program is printing only…
Happy
  • 1,767
  • 6
  • 22
  • 26
37
votes
2 answers

System.Drawing.Brush from System.Drawing.Color

I'm developing a WinForm Printing application for our company. When the document is printed, I need to take the System.Drawing.Color property of each Control on the document and create a System.Drawing.Brush object to draw it. Is there a way to…
user153923
34
votes
4 answers

Can I disable the printing page x of y dialog?

I am developing a full screen kiosk application using c#. I need to print tickets and receipts. I use the PrintDocument class for the printing. Printer prints perfectly, but i need to disable the pop-up dialog shown during printing. I heard it can…
Krankoloji
  • 347
  • 1
  • 3
  • 5
9
votes
1 answer

Showing Print Preview in C#

Right now, I'm trying to build my form on a PrintDocument, but the only way for me to see where stuff is actually appearing on the page is to print a paper. It works, but I have a lot of stuff I need to add, and I'd rather not waste tons of paper.…
Nathan
  • 1,287
  • 6
  • 15
  • 32
8
votes
6 answers

how to set to default printer

How do you set PrintDocument.PrinterSettings.PrinterName to be the default printer? I am not talking about setting the default printer in the operating system. Rather, I am talking about setting the PrintDocument object so that it prints to the…
Craig Johnston
  • 7,467
  • 16
  • 40
  • 47
8
votes
3 answers

Is there a better way to get the page count from a PrintDocument than this?

This is the best I've come up with: public static int GetPageCount( PrintDocument printDocument ) { printDocument.PrinterSettings.PrintFileName = Path.GetTempFileName(); printDocument.PrinterSettings.PrintToFile = true; int count = 0; …
Jonathan Mitchem
  • 953
  • 3
  • 13
  • 18
8
votes
2 answers

C# PrintDocument Changed event

My issue is that I've created an "extended" RichTextBox control that uses native API to add many RichEdit features that are missing from the standard control (ie: modifying a single font property on a selection w/o changing the other font…
Cory Charlton
  • 8,868
  • 4
  • 48
  • 68
8
votes
2 answers

Typesetting text with .NET

I'm writing a WinForms .NET program that needs to lay some text out on a page (with a few basic geometric/vector graphics). Is there an equivalent of OS X's Core Graphics and/or Core Text? So far, I am just using a PrintDocument and using the…
dreamlax
  • 93,976
  • 29
  • 161
  • 209
7
votes
2 answers

Printing Forms using PrintDocument

I'm trying MSDN's example of printing using PrintDocument, but it's not going so well. I've got it all to compile, but when I hit print, a "Fax Sending Settings" window pops up. Is this supposed to happen? Im trying to print, not send a fax! What…
Nat
  • 890
  • 3
  • 11
  • 23
6
votes
2 answers

How to print html in C#

I would like to print a file using PrintDocument in C#. The file is simple HTML (I need it because I need the text in the file to be located in specific places within the page.) My question is, how do I print the file so it will not print the HTML…
MoShe
  • 6,197
  • 17
  • 51
  • 77
6
votes
1 answer

C# PrintDocument and Printer Status

I am trying to get the printer status of a PointOfSale printer using the following code: Hashtable properties = new Hashtable(); ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win2_Printer"); foreach…
6
votes
0 answers

The data area passed to a system call is too small upon printing c#

I have a window service the prints certain documents with image using the PrintDocument class. Occasionally, I'm encountering this error upon printing "The data area passed to a system call is too small" and the image on the report was not printed.…
6
votes
1 answer

C# - How to programmatically print an existing PDF file using PrintDocument

I want to print an existing pdf file a second time with a pdf printer. I try to use PrintDocument. But how do I tell PrintDocument the name of the existing document?? Thanks in advance!
Jocelyn
  • 133
  • 1
  • 1
  • 10
1
2 3
19 20