06-04-2024, 10:17 AM
(06-04-2024, 10:01 AM)bplus Wrote: i think this is better
Code: (Select All)$Color:32
$Resize:Smooth
'Resize is so we can drag/resize the screen so it fits on a monitor
PrintScreen = _NewImage(850, 1100, 32) 'to represent an 8.5" x 11" sheet of paper
Screen PrintScreen
f& = _LoadFont("arial.ttf", 18)
_Font f&
File$ = _OpenFileDialog$("Choose file to Print", _CWD$, "*.*", "Any File")
Open File$ For Binary As #1
If _FileExists(File$) = 0 Then System
Cls , White, PrintScreen
Color Black, 0
height = Int(_Height / _FontHeight(f&) - 3)
page = 1
fname$ = Mid$(File$, 1, _InStrRev(File$, ".") - 1)
Print: Print
Do
Line Input #1, temp$
'PCopy 0, 1
nline = nline + 1
Print nline; temp$
If CsrLin >= height Then 'we probably scrolled the page. Rip off this sheet of paper and start a new page!
'PCopy 1, 0
'_PrintImage PrintScreen
_SaveImage fname$ + Str$(page) + ".PNG", PrintScreen
page = page + 1
Sleep 'A break so we can see which page we just printed
Cls , White, PrintScreen
'Print temp$ ' why print again
Print: Print
End If
Loop Until EOF(1)
'PCopy 1, 0
_SaveImage fname$ + Str$(page) + ".PNG", PrintScreen
Sleep
Close
Cls , White, PrintScreen
Print "Files ready"
The problem with what you see there, @bplus , is if that last line contains more characters than can print on a single line.
Let's say your font allows for 100 characters to be printed on a single line. If that last line is 105 characters, it's going to fall down to the next line on the page -- which qill trigger QB64's automatic page scrolling....
You've just cut off the first line on that page as it scrolled out of existence before you could print it to your printer!
-- And that's why it does the PCOPY to the point BEFORE that last line was printed, and then moves it to the top of the next page.