Connecting Tech Pros Worldwide Forums | Help | Site Map

PaperSource setting in VB.NET Print Application

Fred Nelson
Guest
 
Posts: n/a
#1: Nov 20 '05
Hi:

I'm trying to write a program that will print envelopes using a HP Laserjet
4 that has three trays. In the future this program will work with other
printers so I don't want to "hard code" (or send raw output) to accomplish
this.

I'm trying to figure out how to set the PaperSource property and haven't had
any luck! I've searched MSDN and Google and can't find a single example.

If anyone knows how to do this I would GREATLY appreciate it - I've tried
everything!

Thanks,

Fred



CJ Taylor
Guest
 
Posts: n/a
#2: Nov 20 '05

re: PaperSource setting in VB.NET Print Application


It's really really confusing... here are some samples... ignroe the
iPrinterType (this is something that I use specifically in the program. but
you actually have to check for the enumeration type and set it to that based
on the printers availiblity.

for Each papSource In _printDoc.PrinterSettings.PaperSources

If papSource.Kind = Printing.PaperSourceKind.AutomaticFeed Then

_printDoc.DefaultPageSettings.PaperSource = papSource

Exit For

End If

Next

If (iPrintertype = 0) Then

For Each papSize In _printDoc.PrinterSettings.PaperSizes

If papSize.Kind = Printing.PaperKind.Letter Then

_printDoc.DefaultPageSettings.PaperSize = papSize

Exit For

End If

Next

ElseIf (iPrintertype = 1) Then

For Each papSize In _printDoc.PrinterSettings.PaperSizes

If papSize.Kind = Printing.PaperKind.Ledger Or papSize.Kind =
Printing.PaperKind.Standard11x17 Then

_printDoc.DefaultPageSettings.PaperSize = papSize

Exit For

End If

Next

End If

"Fred Nelson" <fred@smartybird.com> wrote in message
news:OY2KFgt2DHA.2032@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi:
>
> I'm trying to write a program that will print envelopes using a HP[/color]
Laserjet[color=blue]
> 4 that has three trays. In the future this program will work with other
> printers so I don't want to "hard code" (or send raw output) to accomplish
> this.
>
> I'm trying to figure out how to set the PaperSource property and haven't[/color]
had[color=blue]
> any luck! I've searched MSDN and Google and can't find a single example.
>
> If anyone knows how to do this I would GREATLY appreciate it - I've tried
> everything!
>
> Thanks,
>
> Fred
>
>[/color]


Fred Nelson
Guest
 
Posts: n/a
#3: Nov 20 '05

re: PaperSource setting in VB.NET Print Application


CJ:

Thanks very much for your help - I will study this code intently!

Thanks,

Fred


"CJ Taylor" <nospam@blowgoats.com> wrote in message
news:100b90c5pp08eac@corp.supernews.com...[color=blue]
> It's really really confusing... here are some samples... ignroe the
> iPrinterType (this is something that I use specifically in the program.[/color]
but[color=blue]
> you actually have to check for the enumeration type and set it to that[/color]
based[color=blue]
> on the printers availiblity.
>
> for Each papSource In _printDoc.PrinterSettings.PaperSources
>
> If papSource.Kind = Printing.PaperSourceKind.AutomaticFeed Then
>
> _printDoc.DefaultPageSettings.PaperSource = papSource
>
> Exit For
>
> End If
>
> Next
>
> If (iPrintertype = 0) Then
>
> For Each papSize In _printDoc.PrinterSettings.PaperSizes
>
> If papSize.Kind = Printing.PaperKind.Letter Then
>
> _printDoc.DefaultPageSettings.PaperSize = papSize
>
> Exit For
>
> End If
>
> Next
>
> ElseIf (iPrintertype = 1) Then
>
> For Each papSize In _printDoc.PrinterSettings.PaperSizes
>
> If papSize.Kind = Printing.PaperKind.Ledger Or papSize.Kind =
> Printing.PaperKind.Standard11x17 Then
>
> _printDoc.DefaultPageSettings.PaperSize = papSize
>
> Exit For
>
> End If
>
> Next
>
> End If
>
> "Fred Nelson" <fred@smartybird.com> wrote in message
> news:OY2KFgt2DHA.2032@TK2MSFTNGP09.phx.gbl...[color=green]
> > Hi:
> >
> > I'm trying to write a program that will print envelopes using a HP[/color]
> Laserjet[color=green]
> > 4 that has three trays. In the future this program will work with other
> > printers so I don't want to "hard code" (or send raw output) to[/color][/color]
accomplish[color=blue][color=green]
> > this.
> >
> > I'm trying to figure out how to set the PaperSource property and haven't[/color]
> had[color=green]
> > any luck! I've searched MSDN and Google and can't find a single[/color][/color]
example.[color=blue][color=green]
> >
> > If anyone knows how to do this I would GREATLY appreciate it - I've[/color][/color]
tried[color=blue][color=green]
> > everything!
> >
> > Thanks,
> >
> > Fred
> >
> >[/color]
>
>[/color]


Fred Nelson
Guest
 
Posts: n/a
#4: Nov 20 '05

re: PaperSource setting in VB.NET Print Application


CJ:

Thanks again for your help. If you have a second could you check to see if
I have this set up correctly (I'm not in the office with the 3 tray printer
or I'd test it.)

If I needed to print a document to an envelope then I would perform the
following AFTER selecting the printer:

--------------
Dim papSource As System.Drawing.Printing.PaperSource

For Each papSource In PrintDocument1.PrinterSettings.PaperSources

If papSource.Kind = PaperSourceKind.Envelope Then
PrintDocument1.DefaultPageSettings.PaperSource = papSource
Exit For
End If

Next
------------

If the user had selected a printer without an envelope feeder then it would
just default to the main tray - that is what I want it to do.

Am I correct or still missing something!

Thanks,

Fred


"CJ Taylor" <nospam@blowgoats.com> wrote in message
news:100b90c5pp08eac@corp.supernews.com...[color=blue]
> It's really really confusing... here are some samples... ignroe the
> iPrinterType (this is something that I use specifically in the program.[/color]
but[color=blue]
> you actually have to check for the enumeration type and set it to that[/color]
based[color=blue]
> on the printers availiblity.
>
> for Each papSource In _printDoc.PrinterSettings.PaperSources
>
> If papSource.Kind = Printing.PaperSourceKind.AutomaticFeed Then
>
> _printDoc.DefaultPageSettings.PaperSource = papSource
>
> Exit For
>
> End If
>
> Next
>
> If (iPrintertype = 0) Then
>
> For Each papSize In _printDoc.PrinterSettings.PaperSizes
>
> If papSize.Kind = Printing.PaperKind.Letter Then
>
> _printDoc.DefaultPageSettings.PaperSize = papSize
>
> Exit For
>
> End If
>
> Next
>
> ElseIf (iPrintertype = 1) Then
>
> For Each papSize In _printDoc.PrinterSettings.PaperSizes
>
> If papSize.Kind = Printing.PaperKind.Ledger Or papSize.Kind =
> Printing.PaperKind.Standard11x17 Then
>
> _printDoc.DefaultPageSettings.PaperSize = papSize
>
> Exit For
>
> End If
>
> Next
>
> End If
>
> "Fred Nelson" <fred@smartybird.com> wrote in message
> news:OY2KFgt2DHA.2032@TK2MSFTNGP09.phx.gbl...[color=green]
> > Hi:
> >
> > I'm trying to write a program that will print envelopes using a HP[/color]
> Laserjet[color=green]
> > 4 that has three trays. In the future this program will work with other
> > printers so I don't want to "hard code" (or send raw output) to[/color][/color]
accomplish[color=blue][color=green]
> > this.
> >
> > I'm trying to figure out how to set the PaperSource property and haven't[/color]
> had[color=green]
> > any luck! I've searched MSDN and Google and can't find a single[/color][/color]
example.[color=blue][color=green]
> >
> > If anyone knows how to do this I would GREATLY appreciate it - I've[/color][/color]
tried[color=blue][color=green]
> > everything!
> >
> > Thanks,
> >
> > Fred
> >
> >[/color]
>
>[/color]


CJ Taylor
Guest
 
Posts: n/a
#5: Nov 20 '05

re: PaperSource setting in VB.NET Print Application


I tested mine on a 5 feeder tray printer and set my paper source to
automatic feeder, and then my paper SIZE to the envelope. Honestly, who has
an envelope feeder anymore?

Thats right... no one...

[expect many replies of 'we use one']

So, set your paper size, your feeder (esepically if its pro/copier/printer
super machine like it sounds like with 3 trays) will take care of the rest.

Thats what I did at least. =)

-CJ
"Fred Nelson" <fred@smartybird.com> wrote in message
news:%23GZYcOu2DHA.3468@TK2MSFTNGP11.phx.gbl...[color=blue]
> CJ:
>
> Thanks again for your help. If you have a second could you check to see[/color]
if[color=blue]
> I have this set up correctly (I'm not in the office with the 3 tray[/color]
printer[color=blue]
> or I'd test it.)
>
> If I needed to print a document to an envelope then I would perform the
> following AFTER selecting the printer:
>
> --------------
> Dim papSource As System.Drawing.Printing.PaperSource
>
> For Each papSource In PrintDocument1.PrinterSettings.PaperSources
>
> If papSource.Kind = PaperSourceKind.Envelope Then
> PrintDocument1.DefaultPageSettings.PaperSource = papSource
> Exit For
> End If
>
> Next
> ------------
>
> If the user had selected a printer without an envelope feeder then it[/color]
would[color=blue]
> just default to the main tray - that is what I want it to do.
>
> Am I correct or still missing something!
>
> Thanks,
>
> Fred
>
>
> "CJ Taylor" <nospam@blowgoats.com> wrote in message
> news:100b90c5pp08eac@corp.supernews.com...[color=green]
> > It's really really confusing... here are some samples... ignroe the
> > iPrinterType (this is something that I use specifically in the program.[/color]
> but[color=green]
> > you actually have to check for the enumeration type and set it to that[/color]
> based[color=green]
> > on the printers availiblity.
> >
> > for Each papSource In _printDoc.PrinterSettings.PaperSources
> >
> > If papSource.Kind = Printing.PaperSourceKind.AutomaticFeed Then
> >
> > _printDoc.DefaultPageSettings.PaperSource = papSource
> >
> > Exit For
> >
> > End If
> >
> > Next
> >
> > If (iPrintertype = 0) Then
> >
> > For Each papSize In _printDoc.PrinterSettings.PaperSizes
> >
> > If papSize.Kind = Printing.PaperKind.Letter Then
> >
> > _printDoc.DefaultPageSettings.PaperSize = papSize
> >
> > Exit For
> >
> > End If
> >
> > Next
> >
> > ElseIf (iPrintertype = 1) Then
> >
> > For Each papSize In _printDoc.PrinterSettings.PaperSizes
> >
> > If papSize.Kind = Printing.PaperKind.Ledger Or papSize.Kind =
> > Printing.PaperKind.Standard11x17 Then
> >
> > _printDoc.DefaultPageSettings.PaperSize = papSize
> >
> > Exit For
> >
> > End If
> >
> > Next
> >
> > End If
> >
> > "Fred Nelson" <fred@smartybird.com> wrote in message
> > news:OY2KFgt2DHA.2032@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > Hi:
> > >
> > > I'm trying to write a program that will print envelopes using a HP[/color]
> > Laserjet[color=darkred]
> > > 4 that has three trays. In the future this program will work with[/color][/color][/color]
other[color=blue][color=green][color=darkred]
> > > printers so I don't want to "hard code" (or send raw output) to[/color][/color]
> accomplish[color=green][color=darkred]
> > > this.
> > >
> > > I'm trying to figure out how to set the PaperSource property and[/color][/color][/color]
haven't[color=blue][color=green]
> > had[color=darkred]
> > > any luck! I've searched MSDN and Google and can't find a single[/color][/color]
> example.[color=green][color=darkred]
> > >
> > > If anyone knows how to do this I would GREATLY appreciate it - I've[/color][/color]
> tried[color=green][color=darkred]
> > > everything!
> > >
> > > Thanks,
> > >
> > > Fred
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Fred Nelson
Guest
 
Posts: n/a
#6: Nov 20 '05

re: PaperSource setting in VB.NET Print Application


CJ:

Thanks again for all the help. I don't have one of them here however I have
a customer with two rather large printers so I will need to road test it
with their stuff.

Fred

"CJ Taylor" <nospam@blowgoats.com> wrote in message
news:100bfae2rskgf8@corp.supernews.com...[color=blue]
> I tested mine on a 5 feeder tray printer and set my paper source to
> automatic feeder, and then my paper SIZE to the envelope. Honestly, who[/color]
has[color=blue]
> an envelope feeder anymore?
>
> Thats right... no one...
>
> [expect many replies of 'we use one']
>
> So, set your paper size, your feeder (esepically if its pro/copier/printer
> super machine like it sounds like with 3 trays) will take care of the[/color]
rest.[color=blue]
>
> Thats what I did at least. =)
>
> -CJ
> "Fred Nelson" <fred@smartybird.com> wrote in message
> news:%23GZYcOu2DHA.3468@TK2MSFTNGP11.phx.gbl...[color=green]
> > CJ:
> >
> > Thanks again for your help. If you have a second could you check to see[/color]
> if[color=green]
> > I have this set up correctly (I'm not in the office with the 3 tray[/color]
> printer[color=green]
> > or I'd test it.)
> >
> > If I needed to print a document to an envelope then I would perform the
> > following AFTER selecting the printer:
> >
> > --------------
> > Dim papSource As System.Drawing.Printing.PaperSource
> >
> > For Each papSource In[/color][/color]
PrintDocument1.PrinterSettings.PaperSources[color=blue][color=green]
> >
> > If papSource.Kind = PaperSourceKind.Envelope Then
> > PrintDocument1.DefaultPageSettings.PaperSource =[/color][/color]
papSource[color=blue][color=green]
> > Exit For
> > End If
> >
> > Next
> > ------------
> >
> > If the user had selected a printer without an envelope feeder then it[/color]
> would[color=green]
> > just default to the main tray - that is what I want it to do.
> >
> > Am I correct or still missing something!
> >
> > Thanks,
> >
> > Fred
> >
> >
> > "CJ Taylor" <nospam@blowgoats.com> wrote in message
> > news:100b90c5pp08eac@corp.supernews.com...[color=darkred]
> > > It's really really confusing... here are some samples... ignroe the
> > > iPrinterType (this is something that I use specifically in the[/color][/color][/color]
program.[color=blue][color=green]
> > but[color=darkred]
> > > you actually have to check for the enumeration type and set it to that[/color]
> > based[color=darkred]
> > > on the printers availiblity.
> > >
> > > for Each papSource In _printDoc.PrinterSettings.PaperSources
> > >
> > > If papSource.Kind = Printing.PaperSourceKind.AutomaticFeed Then
> > >
> > > _printDoc.DefaultPageSettings.PaperSource = papSource
> > >
> > > Exit For
> > >
> > > End If
> > >
> > > Next
> > >
> > > If (iPrintertype = 0) Then
> > >
> > > For Each papSize In _printDoc.PrinterSettings.PaperSizes
> > >
> > > If papSize.Kind = Printing.PaperKind.Letter Then
> > >
> > > _printDoc.DefaultPageSettings.PaperSize = papSize
> > >
> > > Exit For
> > >
> > > End If
> > >
> > > Next
> > >
> > > ElseIf (iPrintertype = 1) Then
> > >
> > > For Each papSize In _printDoc.PrinterSettings.PaperSizes
> > >
> > > If papSize.Kind = Printing.PaperKind.Ledger Or papSize.Kind =
> > > Printing.PaperKind.Standard11x17 Then
> > >
> > > _printDoc.DefaultPageSettings.PaperSize = papSize
> > >
> > > Exit For
> > >
> > > End If
> > >
> > > Next
> > >
> > > End If
> > >
> > > "Fred Nelson" <fred@smartybird.com> wrote in message
> > > news:OY2KFgt2DHA.2032@TK2MSFTNGP09.phx.gbl...
> > > > Hi:
> > > >
> > > > I'm trying to write a program that will print envelopes using a HP
> > > Laserjet
> > > > 4 that has three trays. In the future this program will work with[/color][/color]
> other[color=green][color=darkred]
> > > > printers so I don't want to "hard code" (or send raw output) to[/color]
> > accomplish[color=darkred]
> > > > this.
> > > >
> > > > I'm trying to figure out how to set the PaperSource property and[/color][/color]
> haven't[color=green][color=darkred]
> > > had
> > > > any luck! I've searched MSDN and Google and can't find a single[/color]
> > example.[color=darkred]
> > > >
> > > > If anyone knows how to do this I would GREATLY appreciate it - I've[/color]
> > tried[color=darkred]
> > > > everything!
> > > >
> > > > Thanks,
> > > >
> > > > Fred
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread