.NET Framework Bookmark and Share   
 index > .NET Base Class Library > How to set the paper type?
 

How to set the paper type?

Hi,
I am using printdocument object to print my document.
I want to set the paper type to letter head.
Is there any option to set the paper type to
Letter Head in C#

Thanks,
Karthi
karthik
vgvKarthik
What problem are you having? Post the code you use to set thePaperSize.

Your code should look something like this:

foreach(PaperSizePSinPrintDocument1.PrinterSettings.PaperSizes)
{
if(PS.ToString()==PaperSizeStringReturnedFromPrintDialog)
{
PrintDocument1.DefaultPageSettings.PaperSize=PS;
break;
}
}
JohnWein
"Letter head" is likely the tray you've loaded letterhead into.

Take a look at the PrintDocument's PrinterSettings property under PaperSources. Create an algorithm to choose the proper one, and set it's value to the value PaperSource under the document's DefaultPageSettings property.

Something like this, although you'll have to figure out which paper source to use, and this is completely dependent on your printer and it's setup.

document.DefaultPageSettings.PaperSource = document.PrinterSettings.PaperSources[0];


David Morton - http://blog.davemorton.net/
David M Morton
Hi,
I am able to set the printer tray from the application.
But the tray is loaded with different paper type.

E.g if i am sending plain type and the tray is looking
for letter head, my document didn't get printed.
so i need to set the paper type from the application itself.

Thanks.
karthik
vgvKarthik
Select the PaperSize you want using the PrintDialog. To set it programmatically, copy the info returned by the PrintDialog in the Document's DefaultPageSettings.PaperSize property. Use it to set the PaperSize in code.
JohnWein
Hi,
The print dialog--> print preferences having the options to select the page type to letter head.
But i am not able to use that inside the code.
Is there anyway todirectly controlprint preferencesdialog inside the C# code.

Thanks,


karthik
vgvKarthik
What problem are you having? Post the code you use to set thePaperSize.

Your code should look something like this:

foreach(PaperSizePSinPrintDocument1.PrinterSettings.PaperSizes)
{
if(PS.ToString()==PaperSizeStringReturnedFromPrintDialog)
{
PrintDocument1.DefaultPageSettings.PaperSize=PS;
break;
}
}
JohnWein

You can use google to search for other answers

Custom Search

More Threads

• Unmanaged DLL
• Peek data from Serial Port class
• Read events by Source and Time from EventLog
• System.IO.Directory.GetFiles
• Contols Docking Problem
• LINQ and DataContext - Context does not have access to Entityies
• BC2017: could not find library
• Tuff one, reference selector...
• using Graphics.CopyFromScreen in a service
• reading a text file.