Questions tagged [printdocument]

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

276 questions
49
votes
3 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
  • 65,640
  • 30
  • 189
  • 218
46
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
  • 10,844
  • 10
  • 54
  • 97
34
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,707
  • 6
  • 22
  • 25
33
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
  • 337
  • 1
  • 3
  • 5
32
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…
jp2code
  • 24,618
  • 35
  • 140
  • 254
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,037
  • 15
  • 37
  • 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
  • 883
  • 1
  • 13
  • 18
8
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,069
  • 5
  • 12
  • 27
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,432
  • 4
  • 46
  • 66
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
  • 89,489
  • 28
  • 156
  • 207
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
  • 5,523
  • 14
  • 43
  • 71
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

How to print PDF in UWP without loosing quality after rasterization to PNG

After some investigation of printing in UWP I've highlighted: No native way to print PDF document directly from your app without redirecting this task to Edge or other similar program. There is a way to print XAML Elements (Image for example) using…
6
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…
Nathan
  • 819
  • 3
  • 9
  • 18
6
votes
1 answer

How to jump to the next page in a PrintDocument?

I have an application that prints how many bar codes you want, but if the amount of bar codes is bigger than the size of the PrintDocument it doesn't jump to the next page. I'd like to know how can I add more pages or write in the next page of a…
Zignd
  • 6,246
  • 11
  • 34
  • 57
1
2 3
18 19