' print a SB source file (or any text file)
' mind the current IP adress of the PC !
'
do input "filename ?": f$ ! until file_exists(f$)
do
file f$ readline dt$
t$ &= dt$ & chr$(10)
until file_end(f$)
eprt(t$)
end
def eprt(t$)
dim h$(3)
h$(1) = "content-type:text/html"
h$(2) = "content-length:"&len(t$)
HTTP "192.168.2.11" HEADER h$ POST t$ ' IP adress of PC
end def
Have you tried this by accessing your printer's WIFI IP address?
As soon as Comcast fixes my 2.4gHz ID, I can see if I can print directly to the printer via WIFI.
My printer does not work on the 5Ghz service.
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
No, the printer is not accessed directly. The HTTP post from the SB program is sent to the local IP adress of the PC (via WiFi), where it is catched by a small webserver applet. This server sents the string in the post to the printer which is cabled to the PC, using a Notepad command. Other methods (i.e. networkprinter) may be possible but would require an adaptation in the Python webserver program.
It's all in the "other topics" thread about direct printing.
That's right. I did copy that program as well as the one from rbytes. I was just thinking since my network my printer has its own IP address accessible via WIFI just maybe the applet can either be bypassed, or converted into the P5 posted here awhile back so it is part of SB program.
No, the printer is not accessed directly. The HTTP post from the SB program is sent to the local IP adress of the PC (via WiFi), where it is catched by a small webserver applet. This server sents the string in the post to the printer which is cabled to the PC, using a Notepad command. Other methods (i.e. networkprinter) may be possible but would require an adaptation in the Python webserver program.
It's all in the "other topics" thread about direct printing.
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
If you want to pursue the subject, it might be better that you discuss the topic with my son. He is far more capable than me , on PC and on Mac. He also sometimes makes an app for iOS, using the SDK.
His email is listed in the Python applet, and he told me that he is willing to discuss the matter.
Succes with it .
I had a couple of printing glitches this morning that I thought I should share. I had a small program for which I wanted a code printout. I sent it to the printserver a couple of times, with no response. Since I had some internet issues earlier today and had rebooted my modem/router, I suspected that my tablet IP address had been dynamically reassigned. I ran ipconfig and discovered that it had. Only the last of the 4 sets of digits had changed slightly, but since they didn't match the setting in my SB program, nothing could print.
I fixed the IP address in my SB code, then printed the program. The font was huge! It took 4 pages to hold all of the text.
I opened Notepad on my PC tablet and checked the font setting. It was Courier, 24 points! I set it to Arial 12, sent the file to the printserver again and now the printing looked great and required just two pages.
I still don't know why my Notepad's font size setting was so large. I did find that if you open Notepad before you print, set your desired font name and point size, then close it, your text will print with that setting. If you leave Notepad open, the print server will not function.
You may prefer to use a monospaced font if you are printing columns, tables, or anything else that requires horizontal alignment. The only standard Windows monospaced fonts are Courier New (has serifs) and Lucida Sans Typewriter (no serifs).
In Windows10 (on the PC, i don't know about a Windows tablet), Notepad will remember the last setting of the font and fontsize as default. Former versions of Windows didn't, and the registry had to be edited to define the default font.
When i send an ascii text directly to my (WiFi capable) printer from the iPad, i get a large font size as well. I don't know where it is chosen, in the iPad or in the printer.
That led me to use the webserver solution via the PC with Notepad using the current default font and fontsize.
Thanks. I just moved to a new house in August, and after a heavy box crushed my foot and a fever put me in the hospital twice, I'll be unpacking my office and setting up all my computer equipment. Should take 1-2 weeks.
I'll email him once I start testing this and other options I may come up with. Right now I don't have a PC. I'm all MAC at the moment. But I plan to finally pick up a custom PC I had made for me by the end of October.
I'm eager to see this work as it would help my cosmology and physicist I work with. One complaint they have is the cumbersome way they need to perform to print results from the apps I write for them .
If you want to pursue the subject, it might be better that you discuss the topic with my son. He is far more capable than me , on PC and on Mac. He also sometimes makes an app for iOS, using the SDK.
His email is listed in the Python applet, and he told me that he is willing to discuss the matter.
Succes with it .
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)
Henk, my previous post referred to the printserver technique you posted, based on Michiel's python program. I think it is a great solution. Thanks to both of you.
It would be worthwhile developing a little help sheet to cover some of the do's, dont's and helpful tips.
Here are some I have collected:
1. If the pc print server doesn't respond, you have probably had a change in the PC's IP address caused by dynamic ip assignment. You need to run ipconfig, get the new ip address and update it in the SB program.
2. Before sending a print job, open Notepad on the PC and set the font name and size. Those will then be applied to your subsequent print jobs.
3. Any font can be used, but for column alignment, monospaced fonts are the best choice. In Windows, use Courier New or Lucida Sans Typewriter (there are other choices for Courier and Lucida, but they are proportionally spaced.)
4. A suggested font size for good readability with minimum use of paper is 11.
5. Notepad has a default header and footer, which is why you see "report.tx" printed at the top of each page and a line number at the bottom.
6. You can set or remove the header and footer by selecting File/Page Setup. The link Input Values will open a web page showing the codes you can use in the header and footer input fields. Leave the fields blank if you don't want them to appear.
7. Be sure to close Notepad before sending a print job. If it is left open, it will block the http command from the iPad and your job won't print.
I discovered a few more things today by experimentation.
By changing this line in the python code, you can get some some interesting variations:
os.system("notepad /p report.txt")
1. If you make a copy of the .py file and remove the "/p" on the above line, the print command sent from the iPad will open report.txt in Notepad and leave it open for editing, rather than opening it briefly, printing and closing. That will give you a chance to proofread, edit and/or change the font name and size if desired. Printing can then be done with the File/Print menu option.
2. If you make a copy of file 1 above, and change "notepad" to "write", the print command from the iPad will open report.txt in WordPad and leave it open for editing. ("write.exe" is the name of the executable file for WordPad.) WordPad has rich text editing capability, allowing a lot of enhancements to a basic text file, such as bold, italics, underline, multiple font name and/or size changes within the document, colored text, text alignment, insertion of images and drawings, etc.
I have three shortcuts now on my PC desktop, one for the original python printserver program, and one for each of the preview/edit options.
Good idea, Richard.
I will collect all relevant texts and code pieces and put it in one document. Maybe Ton will add that to his SB manual or at least mention the possibility of direct printing and point to it.