Setting paper size in code VB.net 2008

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Hi All

Using VB.net 2008, windows forms application on Windows XP SP2

I need to set the paper size when printing to an 80mm Epson docket printer
using windows drivers

Some customers have invoices with many items on it and once past 297mm, the
rest are lost (not printed)

If I set a custom size within the printer driver (in printers and faxes)
then all works fine. If not then the roll cuts off at 297mm, regardless of
the custom size set in code, which is the default standard papersize length


I have tried the following... which DOES NOT WORK

frmpos.pd.PrintController = New StandardPrintController
frmpos.pd.DefaultPageSettings.Margins.Left = 10

frmpos.pd.DefaultPageSettings.Margins.Right = 10

frmpos.pd.PrinterSettings.DefaultPageSettings.Margins.Left = 10

frmpos.pd.PrinterSettings.DefaultPageSettings.Margins.Right = 10

Dim pkCustomSize1 As New PaperSize("New Long Roll", 315, 2000)

frmpos.pd.PrinterSettings.DefaultPageSettings.PaperSize = pkCustomSize1

frmpos.pd.DefaultPageSettings.PaperSize = pkCustomSize1

AddHandler frmpos.pd.PrintPage, AddressOf frmpos.pd_RePrintPage

frmpos.pd.Print()

RemoveHandler frmpos.pd.PrintPage, AddressOf frmpos.pd_RePrintPage



Regards

Steve
 
Hi Steve,

Firstly, you should set the page settings that are used as defaults for all
pages to be printed through the PrintDocument.DefaultPageSettings property.
Secondly, you should set PageSettings.PaperSize property for the page to a
VALID PaperSize, available through the PrinterSettings.PaperSizes
collection.

So the first step to solve the problem is to add a custom paper size in the
Printing Preferences dialog for the printer you're using.

The second step is to get the PaperSizeCollection from the
PrintDocument.PrinterSettings.PaperSizes property and loop through it to
find the custom paper size you want and then set this custom paper size to
the PrintDocument.DefaultPageSettings.PaperSize property.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
PrinterSettings.PaperSizes

Printersettings object and Papersizes collection is not available in VBA. How do I do it in VBA, access 2003. I have successfully received a combo box with printer names. Now, on printer name change, I need to:

Private Sub cmbPrinter_Change()
Dim P As Printer
Application.Printer = Application.Printers(Me.cmbPrinter)
P = Application.Printer
cmbPaperSize = ""
For Each PaperSize In P.PaperSizes
cmbPaperSize.AddItem P.PaperSize
Next
End Sub

but there is no papersize/size object (only a property) and no PaperSizes collection.

Any help is apprec.

Thanks

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng
 
wade polk said:
Printersettings object and Papersizes collection is not available in VBA.
How do I do it in VBA, access 2003. I have successfully received a combo
box with printer names. Now, on printer name change, I need to:

Private Sub cmbPrinter_Change()
Dim P As Printer
Application.Printer = Application.Printers(Me.cmbPrinter)
P = Application.Printer
cmbPaperSize = ""
For Each PaperSize In P.PaperSizes
cmbPaperSize.AddItem P.PaperSize
Next
End Sub

but there is no papersize/size object (only a property) and no PaperSizes
collection.

As VBA is more similar to Classic VB than to VB.NET, I suggest to post your
question to an appropriate group in the 'microsoft.public.access[.*]'
hierarchy.
 
Linda Liu[MSFT];12229535 said:
Hi Steve,

Firstly, you should set the page settings that are used as defaults for all
pages to be printed through the PrintDocument.DefaultPageSettings property.
Secondly, you should set PageSettings.PaperSize property for the page to a
VALID PaperSize, available through the PrinterSettings.PaperSizes
collection.

So the first step to solve the problem is to add a custom paper size in the
Printing Preferences dialog for the printer you're using.

The second step is to get the PaperSizeCollection from the
PrintDocument.PrinterSettings.PaperSizes property and loop through it to
find the custom paper size you want and then set this custom paper size to
the PrintDocument.DefaultPageSettings.PaperSize property.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Hello!
Please write or link me a sample code. I'd like to print a .rpt file from VB.net, but I can't find a sample. I've read your posts and tried to use but it still not work.
What's wrong with it?

prDoc.PrinterSettings.PrinterName = My.Settings.PrinterName
prDoc.PrinterSettings.DefaultPageSettings.Landscape = True
For Each pSize As PaperSize In prDoc.PrinterSettings.PaperSizes
If pSize.PaperName = "MyPaper" Then
prDoc.DefaultPageSettings.PaperSize = pSize
Exit For
End If
Next
prDoc.DocumentName = My.Settings.ReportFolder & "\pro.rpt"
prDoc.PrinterSettings.PrintFileName = My.Settings.ReportFolder & "\pro.rpt"
prDoc.Print()

Thx
 
Back
Top