Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / March 2007

Tip: Looking for answers? Try searching our database.

Printing in VB .NET on Pocket PC

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex - 21 Mar 2007 12:50 GMT
Hello,

I'm writing an application in VB .NET to run on a Pocket PC Device (HP iPaq)
and  at one point, it's supposed to print a text file. After searching the
Internet, I found that I should use System.Drawing.Printing.PrintDocument for
printing.

Apart from the fact that I'm not quite sure how to use PrintDocument, I
haven't been able to experiment at all, because I can't even find
System.Drawing.Printing . It says that the namespace cannot be found.

Is there something I should import or add to the project properties to make
the Printing object accessible? I don't suppose anybody would have any code
samples on how to use PrintDocument on a Pocket PC application?

Any help will be greatly appreciated! Thanks in advance,

Alex
Ginny Caughey [MVP] - 21 Mar 2007 13:00 GMT
Alex,

It sounds like you found a solution for the desktop, not for a PocketPC.

The easiest way I've found to print to a specific printer connected by some
sort of serial connection is to use the SerialPort class to send the output
to that printer. (You just write a line at a time from the text file.) For
support for a range of printers, there is a 3rd party product called
PrinterCE from FieldSoft that is popular.

Signature

Ginny

> Hello,
>
[quoted text clipped - 18 lines]
>
> Alex
Alex - 22 Mar 2007 10:05 GMT
Hi Ginny,

Thanks for your reply. I'll look into the PrinterCE software. I was thinking
more like a Bluetooth printer connected to a PDA. I guess there is no way to
do this directly from VB?

Thanks,

Alex

> Alex,
>
[quoted text clipped - 28 lines]
> >
> > Alex
Milsnips - 22 Mar 2007 11:40 GMT
Hi there,

i just finished a project using vb.net to print from windows mobile 5 to a
usb blutooth printer adapter via serial port. here is the code i use (i
compile the printable content into a text file, then send it to the serial
port - code example below:

-----------------------
Sub SendToSerial(ByVal filename As String)
           Dim p As System.IO.Ports.SerialPort
           Dim fs As IO.StreamReader
           Dim portname As String = "COM6:"
           Dim sendValue As String = ""

           Try
               p = New System.IO.Ports.SerialPort(portname)
               p.WriteTimeout = 500
               p.ReadTimeout = 500

               Try
                   p.Open()
                   fs = New IO.StreamReader(filename)
                   Do Until fs.EndOfStream
                       sendValue = fs.ReadLine
                       p.WriteLine(sendValue)
                   Loop
                   fs.Close()
               Catch ex As Exception
                   MsgBox(ex.Message)
               Finally
                   fs = Nothing
                   If p.IsOpen Then p.Close()
                   p.Dispose()
                   p = Nothing
               End Try
           Catch ex As Exception
               MessageBox.Show(ex.Message)
           End Try
           p = Nothing
       End Sub
-----------------------
hope it helps.
regards,
Paul

> Hi Ginny,
>
[quoted text clipped - 45 lines]
>> >
>> > Alex
Ginny Caughey [MVP] - 22 Mar 2007 12:45 GMT
Alex,

As Paul says, it works fine. Bluetooth printers appear as serial devices.
The main difference I find with Bluetooth printers is that I need to delay
somewhat longer after printing each line to allow the printer to keep up.

Signature

Ginny

> Hi Ginny,
>
[quoted text clipped - 45 lines]
>> >
>> > Alex
Milsnips - 22 Mar 2007 13:33 GMT
Yes Ginny, i forgot to mention that. Im using a BlueTake BT200 blutooth
printer adapter (32k cache) connected to an Epson LX300+ (i think 4kb or 8kb
cache) so if the file i'm sending is larger than what the cache can handle,
i add the line:

Threading.Sleep(1000) //sleep for 1 second after it has passed x bytes of
datatransfer, then i reset that counter and continue

regards,
Paul

> Alex,
>
[quoted text clipped - 52 lines]
>>> >
>>> > Alex
Ginny Caughey [MVP] - 22 Mar 2007 14:44 GMT
Paul,

Yes, very important. I usually just delay maybe 100 ms after each line, but
in any case, it is possible to overrun the buffer on all the printers I've
tried.

Signature

Ginny

> Yes Ginny, i forgot to mention that. Im using a BlueTake BT200 blutooth
> printer adapter (32k cache) connected to an Epson LX300+ (i think 4kb or
[quoted text clipped - 68 lines]
>>>> >
>>>> > Alex
Milsnips - 22 Mar 2007 15:33 GMT
Hey Ginny,

While i'm still on the topic, i am currently printing only text files, but
i'd like to incorporate barcode image or/and company logo image into my
printouts (eg. invoice with company logo on top and scannable barcode on the
bottom).

I guess this depends on the printer's support for printing graphics, which i
think most of the Epxon LX printers can print out.
Any ideas on how i'd go about passing a graphic to be printed via serial
port?

thanks,
Paul

> Paul,
>
[quoted text clipped - 75 lines]
>>>>> >
>>>>> > Alex
Ginny Caughey [MVP] - 22 Mar 2007 16:04 GMT
Paul,

You need to use printer specific codes to turn the barcode printing on and
off, but once you know what the output stream is supposed to look like, you
just send that out the port like you do your regular text.

Signature

Ginny

> Hey Ginny,
>
[quoted text clipped - 90 lines]
>>>>>> >
>>>>>> > Alex
Milsnips - 22 Mar 2007 16:11 GMT
Ok, i'll give that a go and see how i come along.
Thanks for your help.

regards,
Paul

> Paul,
>
[quoted text clipped - 96 lines]
>>>>>>> >
>>>>>>> > Alex
Alex - 23 Mar 2007 15:10 GMT
Hi Paul & Ginny,

I just wanted to thank you for all your help. I'm actually still waiting for
the bluetooth card for the HP printer so I haven't been able to test it.

Thanks again,

Alex

> Ok, i'll give that a go and see how i come along.
> Thanks for your help.
[quoted text clipped - 102 lines]
> >>>>>>> >
> >>>>>>> > Alex

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.