Author |
Topic: Printer issue (Read 430 times) |
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Printer issue
« Thread started on: Jan 2nd, 2016, 3:00pm » |
|
Sounds like Richard has just retired :'(
Big thanks to the immense amount of work he has put in over the years ;D
So I guess I must throw this open to anyone.
The following code simply reproduces a general problem I am having printing out the contents of graphics windows under certain circumstances in landscape mode.
The program should print out a black cross, but on my computer/printer it just spits out a blank sheet. On my neighbour's computer/printer it prints the cross but also prints a vertical black bar down the page.
I don't have a clue why this should be.
Here's the code:
Code:
nomainwin
WindowWidth=769
WindowHeight=994
graphicbox #main.gfx,0,40,763,922
open "Test" for window_nf as #main
print #main.gfx, "setfocus"
print #main.gfx, "vertscrollbar on 0 576"
print #main.gfx, "color black"
print #main.gfx, "backcolor white"
print #main.gfx, "size 5"
print #main.gfx, "down"
print #main.gfx, "line 0 0 742 1496"
print #main.gfx, "line 742 0 0 1496"
print #main.gfx, "flush"
printerdialog
print #main.gfx, "print 2088"
close #main
end
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline
Gender:
Posts: 210
|
|
Re: Printer issue
« Reply #1 on: Jan 2nd, 2016, 3:58pm » |
|
Try to put white box whole page size before printing anything else.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Printer issue
« Reply #2 on: Jan 4th, 2016, 10:52am » |
|
You mean like this?
Code: nomainwin
WindowWidth=769
WindowHeight=994
graphicbox #main.gfx,0,40,763,922
open "Test" for window_nf as #main
print #main.gfx, "setfocus"
print #main.gfx, "vertscrollbar on 0 576"
print #main.gfx, "color white"
print #main.gfx, "backcolor white"
print #main.gfx, "down"
print #main.gfx, "place 0 0"
print #main.gfx, "boxfilled 742 1496"
print #main.gfx, "color black"
print #main.gfx, "size 5"
print #main.gfx, "line 0 0 742 1496"
print #main.gfx, "line 742 0 0 1496"
print #main.gfx, "flush"
printerdialog
print #main.gfx, "print 2088"
close #main
end
Had no effect :(
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
Re: Printer issue
« Reply #3 on: Jan 4th, 2016, 12:45pm » |
|
If you are trying to print a landscape cross then your x should be longer than your y. You are drawing a tall narrow cross. In landscape printing you should draw it 1496,742 and print it with size 1496. Then it will fill the landscape page.
The printer paper needs set to landscape as well.
|
« Last Edit: Jan 4th, 2016, 12:47pm by Rod » |
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Printer issue
« Reply #4 on: Jan 4th, 2016, 2:01pm » |
|
Well this is just an example. It comes from my program for generating and printing rotas. The rotas can be of any dimension... long and squat, tall and thin. My program needs to print them as large as will fit onto the paper in either landscape or portrait but without changing the rota's aspect ratio.
The program works very well in most cases, but seems to have a problem occasionally. Below is the actual code from the program:
Code: printerdialog
if PrinterName$="" then return
!hDCprt = @prthdc%
calldll #gdi32, "GetDeviceCaps", hDCprt as ulong, _HORZRES as long, width as long
calldll #gdi32, "GetDeviceCaps", hDCprt as ulong, _VERTRES as long, height as long
if pixhgt/pixwth<=height/width then
pr=pixwth
else
pr=pixhgt*width/height
end if
print #main.gfx, "print ";pr
return
Where pixwth/pixhgt are the width and height of the graphics box and width/height is the paper size/orientation.
I suppose I could try to make the canvas the same aspect ratio as the paper, but as I don't know ahead of time whether the user will print in landscape or portrait that might be tricky. But worth a test.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Printer issue
« Reply #5 on: Jan 4th, 2016, 3:15pm » |
|
Okay, tried changing the box size to:
"boxfilled 2088 1496"
which makes the graphics area the same aspect ratio as my paper in landscape, but no dice. My printer is still spitting out the paper without printing anything. Haven't had a chance to test it on my neighbour's PC yet to see if the black bar disappears (their system does actually print it out, but usually with a black bar).
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
Re: Printer issue
« Reply #6 on: Jan 4th, 2016, 5:31pm » |
|
print out the variables to debug :
pixwth,pixhgt,width,height
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Printer issue
« Reply #7 on: Jan 4th, 2016, 6:46pm » |
|
Pixwth=742 Pixhgt=1496 Width=3349 Height=2399
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
Re: Printer issue
« Reply #8 on: Jan 5th, 2016, 10:34am » |
|
Your original code printed just fine on my printer and no black bar. So I would start to check if your print drivers are up to date.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Printer issue
« Reply #9 on: Jan 5th, 2016, 7:12pm » |
|
Rod, did you print in landscape mode?
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
Re: Printer issue
« Reply #10 on: Jan 6th, 2016, 08:18am » |
|
Ok, sorry I had enlarged the graphicbox and not realized the significance.
My printer returns 4125 x 2892 for width and height using those sizes for the graphicbox eliminates the black bar.
Try your own parameters
Code:nomainwin
WindowWidth=769
WindowHeight=994
graphicbox #main.gfx,0,40,2892,4125
open "Test" for window_nf as #main
print #main.gfx, "setfocus"
print #main.gfx, "vertscrollbar on 0 576"
print #main.gfx, "color white"
print #main.gfx, "backcolor white"
print #main.gfx, "down"
print #main.gfx, "place 0 0"
print #main.gfx, "boxfilled 2892 4125"
print #main.gfx, "color black"
print #main.gfx, "size 5"
print #main.gfx, "line 0 0 742 1496"
print #main.gfx, "line 742 0 0 1496"
print #main.gfx, "flush"
printerdialog
print #main.gfx, "print 2892"
close #main
end
More to investigate I think but out of time right now.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Printer issue
« Reply #11 on: Jan 6th, 2016, 2:40pm » |
|
Hi Rod, thanks for giving it a try. This works for me also and if I set the print resolution to 2088 I get the printout I expected. This gives me something to work with. Maybe I can now find the exact setting and reason that is causing the problem.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Printer issue
« Reply #12 on: Jan 12th, 2016, 1:58pm » |
|
The following code prints out...
Code: nomainwin
WindowWidth=769
WindowHeight=994
graphicbox #main.gfx,0,40,1571,2088
open "Test" for window_nf as #main
print #main.gfx, "setfocus"
print #main.gfx, "color black"
print #main.gfx, "backcolor white"
print #main.gfx, "size 5"
print #main.gfx, "down"
print #main.gfx, "line 0 0 742 1496"
print #main.gfx, "line 742 0 0 1496"
print #main.gfx, "flush"
printerdialog
print #main.gfx, "print 2088"
close #main
...but reducing the graphics box width by one pixel causes my printer to just eject the page...
Code: WindowWidth=769
WindowHeight=994
graphicbox #main.gfx,0,40,1570,2088
open "Test" for window_nf as #main
print #main.gfx, "setfocus"
print #main.gfx, "color black"
print #main.gfx, "backcolor white"
print #main.gfx, "size 5"
print #main.gfx, "down"
print #main.gfx, "line 0 0 742 1496"
print #main.gfx, "line 742 0 0 1496"
print #main.gfx, "flush"
printerdialog
print #main.gfx, "print 2088"
close #main
end
My neighbour's system prints out under both conditions so it is definitely my printer drivers, which are up-to-date, but still obviously flaky. We are talking WinXP and 12 year-old drivers.
Strange though.
|
|
Logged
|
|
|
|
Rod
Full Member
member is offline
Gender:
Posts: 110
|
|
Re: Printer issue
« Reply #13 on: Jan 12th, 2016, 5:33pm » |
|
Ok so it needs more investigation. But I am a bit confused as to why you choose the parameters that you do.
The X parameter is the driver, the width. The size parameter determines how many pixels are spread across the width of the printed page whether it is portrait or landscape. Portrait will obviously be taller landscape wider So why do you say print 2088 when your drawing is 742 wide?
Using the 1.4142 ratio for A4 paper on 742 pixel width would give you 1049 pixels down the page on A4 portrait, not 1496.
Try drawing within the expected dimensions.
|
« Last Edit: Jan 12th, 2016, 6:30pm by Rod » |
Logged
|
|
|
|
Monkfish
Full Member
member is offline
Gender:
Posts: 104
|
|
Re: Printer issue
« Reply #14 on: Jan 12th, 2016, 6:50pm » |
|
Hi Rob, these dimensions were just an example of dimensions that were causing the problem. In my actual application the size of my graphics box is set to the size of the graphics loaded at the time. This can have any aspect ratio. I can't make the graphics box the same size as A4 because the user could print in portraite or landscape. Also, if the graphics is too large to fit on the screen then the app window is scaled to fit the maximum desktop work area and scrollbars are added as required to scroll the graphics box. If the graphics box is made larger than the graphics themselves (to fit to an A4 format) I was having trouble with the scrollbars being pushed outside the visible app window.
|
|
Logged
|
|
|
|
|