FBWinPrint 0.10

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

I tried FBWinPrint with the first example on a network attached printer. The printer dialog comes up fine, I select the printer, and then it finishes normally. However, nothing ever appears on the printer. Will this program work with network attached printers?
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

phishguy wrote:I tried FBWinPrint with the first example on a network attached printer. The printer dialog comes up fine, I select the printer, and then it finishes normally. However, nothing ever appears on the printer. Will this program work with network attached printers?
FBWinPrint uses the Windows API so I would think it would not matter as long as the printer works from your system. There may be issues with scaling your images that the original version does not take into account. Look further down the thread for a solution for that.

-Vince
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

I also tried the code from Antoni. It didn't print either. I did notice his code displays the printer path and it seems like the end of the printer path/name is truncated. Perhaps there isn't enough string space allocated.
Zippy
Posts: 1295
Joined: Feb 10, 2006 18:05

Post by Zippy »

phishguy wrote:I also tried the code from Antoni. It didn't print either. I did notice his code displays the printer path and it seems like the end of the printer path/name is truncated. Perhaps there isn't enough string space allocated.
See:

Code: Select all

Function PrinterObj.Dialog() As String 
Dim PName As ZString *60
Try enlarging PName, you are probably correct it's too small?

Prob should be MAX_PATH.
Last edited by Zippy on Jan 30, 2010 17:54, edited 1 time in total.
Zippy
Posts: 1295
Joined: Feb 10, 2006 18:05

Post by Zippy »

@Vince

Is there a simple method or can you add the facility to bypass the printer dialog to let the print go to the defualt printer without user intervention?
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

Zippy wrote:@Vince

Is there a simple method or can you add the facility to bypass the printer dialog to let the print go to the defualt printer without user intervention?
@Zippy
There is no need to call the printer dialog method unless you want to change printer settings. The handle to the printer will be the one set as default.

Also, I translated a function from Microsoft to send raw data to a printer. I posted it to the Beginner forum in response to someone wanting to do that.

-Vince
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

Hmm, that wasn't it. The path still cuts off. Here's what I get.

\\HOME-D590260AB9\HP Color Las
0 \\HOME-D590260AB9\HP Color Las 0 0
Zippy
Posts: 1295
Joined: Feb 10, 2006 18:05

Post by Zippy »

vdecampo wrote: <snip>
There is no need to call the printer dialog method unless you want to change printer settings. The handle to the printer will be the one set as default.
<snip>
Thanks.
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

phishguy wrote:Hmm, that wasn't it. The path still cuts off. Here's what I get.

\\HOME-D590260AB9\HP Color Las
0 \\HOME-D590260AB9\HP Color Las 0 0
Did you change all of the occurances of String * 60? There are at least two, one under Constructor PrinterObj() and under PrinterObj.Dialog().

-Vince
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

I left out the printer dialog selection and it works ok now because that is my default printer. Evidently there is some issue with the printername/path getting truncated in the print dialog.

<edit>
Here is the correct path without using the print dialog.

\\HOME-D590260AB9\HP Color LaserJet 2600n
Zippy
Posts: 1295
Joined: Feb 10, 2006 18:05

Post by Zippy »

I tested using GetDefaultPrinter and a network printer with a longer name:

\\Zippy\hp deskjet 5550 series on Zippy

[That's really the \\host\printer name. Heh.]

and it truncates to 30 characters using this code:

Code: Select all

#include once "windows.bi"
#include once "win/winspool.bi"

dim pname as zstring *120
dim n as integer

getdefaultprinter(null,@n)
print "Need: ";n
'
getdefaultprinter(@pname,@n)
print pname,len(pname),n

sleep
leaving pname as:

\\Zippy\hp deskjet 5550 series

I can't test-print to that network printer ATM , unfortunately (other problems).
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

Using Zippy's code I get:


Need: 42
\\HOME-D590260AB9\HP Color LaserJet 2600n 41 42


As you can see, I get the full string.
Zippy
Posts: 1295
Joined: Feb 10, 2006 18:05

Post by Zippy »

phishguy wrote:Using Zippy's code I get:


Need: 42
\\HOME-D590260AB9\HP Color LaserJet 2600n 41 42


As you can see, I get the full string.
Groan.
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

UPDATE!
'************************************************************************
' FBWinPrint v 0.14 - Windows Printing Library for FreeBASIC
' by Vincent DeCampo
'
' Rev 0.14 (01/30/2010)
'
' - Increased length of printer pathname to MAX_PATH
' - Added routines to send raw data to printer
'
' Rev 0.13 - Mods by Antoni 10/19/2009
'
' - Corrected bug with PrintBox color
' - Changed PageWidth and PageHeight properties to use the printable size of the sheet
' - Addded scaling to PrintBox, PrinBMP and PrintWindow to make them printer independent
' - Tested with HP4000 and Panasonic DPC322 printers and PDF and Djvu converters
Special thanks to Antoni for adding the image scaling!

Download FBWinPrint
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

@vdecampo

Thanks for the update. Unfortunately, the path still gets truncated if I use the .dialog function. It works fine if I don't use it.
Post Reply