printdocument

Easiest way to add a Header and Footer to a Printing.PrintDocument (.Net 2.0)?

What's the easiest way to add a header and footer to a .Net PrintDocument object, either pragmatically or at design-time? Specifically I'm trying to print a 3rd party grid control (Infragistics GridEx v4.3), which takes a PrintDocument object and draws itself into it. The resulting page just contains the grid and it's contents - howeve...

Sharing one PrintDocument instance

In my WinForms app, data can be printed on many locations. Everytime the user wants to print, I create a new PrintDocument instance, which is used for the current print job and then disposed. Everything is working, but the Print dialog is always set back to the default printer and its default parameters. If another printer is selected, t...

How can I flip/rotate a PrintDocument in .NET ?

I have a document that I want to be flipped / rotated 180 degrees when printed. (This is due to the orientation of label stock in the printer). There is a property PrintDocument.PrinterSettings.LandscapeAngle but it is read only. I think this property is influenced by the printer driver and therefore not 'settable'. Is there a nice w...

Weird error printing PrintDocument object in .NET

I have a Winforms application that generates its own PrintDocument object for printing. It works fine in XP and Windows 7 with my own testing, but one user has been getting the following exception in Vista when they select the print command with an open document: ************** Exception Text ************** System.ArgumentException: Han...

Issues with XPSDocumentWriter and PrintDialog.PrintDocument

Our company is developing an application (WPF, targeted to .NET 3.5) with the WPF Diagramming Components from MindFusion.Apparently, printing and saving XPS Documents results in various errors on different systems. I reduced the problem to a single sample XPS Document created from our application.I'll first give an overview of the conce...

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 always knew what I was printing out, so I could manually trim any strings so it would fi...

How can I process an image in .NET for a full-page print with a quality like Windows Photo Gallery does it?

I'm writing a printing routing in C#, using the .NET PrintDocument class, handling the OnPrintPage event. I've managed to maximize the margins and print the Image in landscape mode, but it simply does not look as good as when I print the same image file from Windows Photo Gallery (formerly Windows Picture and Fax Viewer), the default im...

PrintDocument (c#) ignores printer configuration

Hi I've got a few logical printers configured and pointing to the same physical printer. Each logical printer is configured with a specific input and output tray. Opening a document, e.g. a pdf, and printing to any one of these printers results in a correct input/ouput print. However i've developed a windows service (win2003) and when i...

send PrindDocument to another form

hi, i want send printDocument to second form to showing that in printPreviewControl which placed in second form. form1 code defined printDocument class with public access in form1 public System.Drawing.Printing.PrintDocument printDocument; form2 code private void Form2_Load(object sender, EventArgs e) { Form1 form1 = new Fo...

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 properties, word wrap to a printer [like WordPad], etc.). As part of the control I expose a PrintDoc...

BeginPrint event and dataGridView problem

hi, I have a dataGridView on the form and thats have many columns and rows. Now I want draw dataGrid column and rows to printDocument and then print. But when BeginPrint event of printDocument is in running, gridView columns and rows is empty, although it is not. What is mistake? private void printDocument_BeginPrint(object sender, Syst...

PrintDocument.Print() throws a Win32Exception

Hi, I'm getting a strange exception from the following code: var printDialog = new PrintDialog(); printDialog.ShowDialog(); var printDocument = new PrintDocument { DefaultPageSettings = { Landscape = true, PrinterSettings = new PrinterSettings { PrinterName = printDialog.PrintQueue.Name } } }; var updateRe...

Choosing Correct papersize when printing with .NET PrintDocument

When I am looping through each page I need to decide the size of a page and choose what size to print it in. is there an easy way to determine what size they are suppose to be? right now i was going by the ratio of width and height. If ratio >= 1.64 && ratio <= 1.65 Then Legal Size, If ratio >= 1.29 && ratio <= 1.30 The Letter Size. b...

Show all pages of PrintDocument on PrintPreviewControl

I'm having trouble creating multiple pages in a PrintDocument and displaying them within a PrintPreviewControl. I can create a single page easily enough, but stringing together multiple pages is eluding me. I'm going to eventually draw several pages of stuff using GDI, but I can't get something like this to work as expected. private P...

Set WinForms RichTextBox as the source of a PrintDocument

I want to print the contents of a RichTextBox, so I am trying make a PrintDocument out of the RichTextBox. But I dont find a way to convert a simple RichTextBox to a PrintDocument. Any ideas? ...

Bulk Printing from application in .net?

Hi, I'm working on a project for my companies intranet which requires that multiple attached documents to the main DTO of the project need to be autoprinted in the background. The problem is it's a web project and I want the printing to be done under the surface. Now because it's on an intranet only certain people can use it and I can s...

Encoding Problem In PrintDocument When Using Dot Matrix Printer

Hi, I have prepared a text to print with dot matrix printer. The text contains turkish characters like ü,ğ, etc. When I send this text to the dot matrix printer with .net' s PrintDocument class, the turkish characters on the printed document does not appear correctly. But when I send the same text to Laser printer, there is no problem...

Active printer problem in Printing word document through VB.net

Hi My printer name is \\abc\First Floor A-Block its taking name \abc\First Floor A-Block on NE04:. How should i print it Private oWord As Word.Application Dim lobjDoc As Word.Document Dim strFolder as String Dim pd As New PrintDocument Dim strPrintername as String oWord = CreateObject("Word.Application") oWord.DisplayAlerts = Word.Wd...

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; printDocument.PrintController = new StandardPrintController(); printDocument.Prin...

Setting the preferences in SIlverlight PrintDocument

I'm using PrintDocument in Silverlight. I'm printing the Silverlight DataGrid in Silverlight page. When I'm printing it only half of the DataGrid is getting printed....so Can I set the preferences for PrintDocument anywhere. I would like to print it as a Landscape type. Thank you. ...