Home » VB.NetRSS

Print document - setting paper size and printable area

Dear Sir,

I'm printing a document thru the printdocument.   But the problem is that after the page is printed paper goes up to the default page height ie; 11 inches.

I've done the following coding. still the problem persists. Can u suggest me a way out.

Dim
pkCustomSize1 AsNew System.Drawing.Printing.PaperSize("Custom Paper Size", 800, 600)

'paper size required is 8 inches width & 6 inches height

PrintDocument1.PrinterSettings.DefaultPageSettings.PaperSize = pkCustomSize1

with regards,
wilfi

 

4 Answers Found

 

Answer 1

Dear Sir, 


I want my matter to be printed in a size of 8 inches width & 6 inches height. i have done the folllowing code for the same.

Dim
pkCustomSize1 AsNew System.Drawing.Printing.PaperSize("Custom Paper Size", WidthInInches, HeightInInches)

PrintDocument1.PrinterSettings.DefaultPageSettings.PaperSize = pkCustomSize1

but the problem is that papersize gets changed and printable area remains the same old default 11 inches.   i find that the printable area cann't be set( being read only). It may be because of this that, my paper moves the entire 11 inches after printing the matter.

can u suggest me a way out.

with regards,
wilfi

 

Answer 2

Wilfi said:

I'm printing a document thru the printdocument. But the problem is that after the page is printed paper goes up to the default page height ie; 11 inches.

I've done the following coding. still the problem persists. Can u suggest me a way out.

Dim
pkCustomSize1 AsNew System.Drawing.Printing.PaperSize("Custom Paper Size", 800, 600)

'paper size required is 8 inches width & 6 inches height

PrintDocument1.PrinterSettings.DefaultPageSettings.PaperSize = pkCustomSize1


Hi wilfi,

Welcome to MSDN forums!

Here are two suggestions for you to try:
1. Firstly open Control Panel -> "Printer and Fax", manually add a custom paper type: "Custom Paper Size" with 8in * 6 in
Then code sample:

ForEach psize As PaperSize In PrintDocument1.PrinterSettings.PaperSizes  
Ifpsize.PaperName="Custom Paper Size"Then
  PrintDocument1.PrinterSettings.DefaultPageSettings.PaperSize=psize
  PrintDocument1.DefaultPageSettings.PaperSize=psize
EndIf
Nextpsize


2. There is one extender print control named FormPrintHelperComponent for you to set page size, paper margin and paper orientation, which makes printing a form quick, easy, and flexible.

Check this document for detail: http://www.codeproject.com/KB/printing/MCLFormPrintControl.aspx

Best regards,

Martin Xie

 

Answer 3

Don't have any idea how this relates to Power Packs, but try this:

Imports System.Drawing.Printing  
PublicClass Form1  
DimWithEvents PD AsNew PrintDocument  
Dim PPD AsNew PrintPreviewDialog  
PrivateSub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click  
    PPD.Document = PD  
    PD.DefaultPageSettings.PaperSize = New PaperSize("Custom", 800, 600)  
    PPD.ShowDialog()  
EndSub
PrivateSub PD_PrintPage(ByVal sender As System.ObjectByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PD.PrintPage  
    MessageBox.Show(e.PageSettings.PrintableArea.ToString)  
EndSub
EndClass
 

Answer 4

{$content}

I'm a beginner,  It's difficult for me to understand the sample, Could you give more explanation on it? Any related guide to learn? Thank you!
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter