printdocument

Graphics.DrawString center in printdocument width

你。 提交于 2019-12-02 06:03:12
I'm attempting to center a string on a printdocument. I've done the following with an image and it works but doesn't seem to work the same with a string. Here is the code that I used to center the image e.Graphics.DrawImage(logo, (e.MarginBounds.Width / 2) - (logo.Width / 2), height); The text i'm trying to center is being supply from a Tab in a TabControl using (var sf = new StringFormat()) { height = logo.Height + 15; sf.LineAlignment = StringAlignment.Center; sf.Alignment = StringAlignment.Center; e.Graphics.DrawString(tabData.Text, new Font(this.Font.Name, 10), new SolidBrush(tabData

What does Hasmorepages PrintPageEventArgs property do exactly?

此生再无相见时 提交于 2019-12-02 05:04:43
问题 I am trying to understand what Hasmorepages PrintPageEventArgs property is, why would you use it and how does it work. MSDN Library doesn't really have a good explanation. All they say is that if you set it to true, printpage event is called again. Is that mean the event loops on itself without leaving or leaves and calls itself again or relies on you to call the printpage event again? I am just trying to understand PrintPageEventArgs.hasmorepages property. Any hints or help will be greatly

Printing multiple pages with printdocument

陌路散爱 提交于 2019-12-01 12:59:43
问题 I'm making program, which: After you select few rows in datagridview it checks if 1 or more was selected. If one, print two copies of report on one page(One report = half page) If more: Print two reports per page, printing as much as needed pages. Problem is, my code prints 4531456453 pages of same report(first and second row) :/ Basic example of code: yPos = 0 Do While tmpI < mydatagridview.SelectedRows.Count - 1 For Each selectedrow As DataGridViewRow In mydatagridview.SelectedRows Dim data

Can I disable the printing page x of y dialog?

喜你入骨 提交于 2019-11-29 01:05:12
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 be disabled with Printers and Faxes in control panel, but i do not have Printers and Faxes in control panel. Can i disable the dialog shown? If i could, how can i do it? I believe setting your PrintDocument 's PrintController to StandardPrintController should solve this. PrintDocument printDocument = new PrintDocument(); PrintController

ASP.NET IIS server side printing fails

醉酒当歌 提交于 2019-11-28 00:21:22
I'm building an ASP.NET application that requires printing using PrintDocument method: PrintDocument.Print() Printing works properly in development env with IIS express. when publishing it to an intranet IIS server, printing fails, which I think is caused by permission issue for aspnet working process. I tried to do the following with no success: I created an application pool in integrated pipeline mode for an admin local user with load user profile option set to true I moved the application to the new created application pool I added <identity impersonate="true" username="username" password="

System.Drawing.Brush from System.Drawing.Color

强颜欢笑 提交于 2019-11-27 22:43:44
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 convert the System.Drawing.Color value to a System.Drawing.Brush value? NOTE: I've tried looking into the System.Windows.Media.SolidColorBrush() method, but it does not seem to be helpful. Use the SolidBrush class: using (SolidBrush brush = new SolidBrush(yourColor)) { // ... } Why not the GDI+ brush? http://msdn.microsoft.com/en-us/library/system

How to print a text file on thermal printer using PrintDocument?

一世执手 提交于 2019-11-27 05:22:25
I'm creating an application using C# with Winforms and now I need to print the receipt of sale on a thermal printer. To do this I'm creating a text file and reading it to print using the PrintDocument but I cannot do this because I don't know how to configure paper size, align text center on the paper, and others configurations. When I do print the text file is printed, but all messy, and after the end print the paper isn't stopping. How could I do this ? trying. private PrintDocument printDocument = new PrintDocument(); private static String RECEIPT = Environment.CurrentDirectory + @"

How to find the actual printable area? (PrintDocument)

半世苍凉 提交于 2019-11-26 23:56:33
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, Graphics.VisibleClipBounds, etc. All fail to consistently get the drawing area, especially when switching from Landscape to Portrait layout. PrintableArea does not seem to ever change when you switch from Landscape to Portrait. I have also noticed that there is a difference in how Graphics.VisibleClipBounds is set depending on if I'm doing a print preview

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

纵饮孤独 提交于 2019-11-26 18:24:53
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 always knew what I was printing out, so I could manually trim any strings so it would fit properly on 80mm receipt paper. Then I had to add an extra bit of functionality that would make this more flexible. The user could pass in strings that would be added to the bottom. Since I didn't know what they were going to put, I just created my own word wrap

How to print a text file on thermal printer using PrintDocument?

巧了我就是萌 提交于 2019-11-26 17:33:32
问题 I'm creating an application using C# with Winforms and now I need to print the receipt of sale on a thermal printer. To do this I'm creating a text file and reading it to print using the PrintDocument but I cannot do this because I don't know how to configure paper size, align text center on the paper, and others configurations. When I do print the text file is printed, but all messy, and after the end print the paper isn't stopping. How could I do this ? trying. private PrintDocument