I don’t know if this is possible, but I am trying to create the attached document from code. But I am stumped on how to do it. I thought I might be able to do it with the report module but I can’t seem to get that sorted (going to head back into that option again shortly…) at the moment.
It doesn’t have to be a PDF file but the formatting and layout are what I am trying to attain. And I just don’t know how.
My other option is to create either a LibreOffice document (already did, just have to link to output and print) or LibreOffice Calc file and load the data from my application and open the document/spreadsheet for review and printing.
I did this with an EPOS many moons ago, spit out some simple xml with the data of the fields in and have an xsl that transforms the page into essentially html and 4x the image so its nice and high rez for printing.
Okay the above is the XML that creates the Gift Certificate (sans the variable fields which I will get to AFTER getting the XML coded in xojo… the example is kind of confusing to me. Julian, since you have experience can you please help me?
The image of the Gift Certificate is what I want to be able to print with 7 fields to be updated from entry made by the user. I have a Window (I call them Forms) that allows the user to input the required data (three entries), the remaining three entries are auto-generated by Modules I have that are called when needed. The 7th entry is a copy of one but formatted as a BarCode.
I want the user to be able to enter the data required then press a button called print and have the Gift Certificate print out. I was informed of a way to use XML or HTML to do this… but now I am more confused as to how I create the XML file in xojo. I was told that I can have the file exported out and then use a command line function to print the document. That I have already sorted out. But how to create the document for printing is where I am utterly lost.
I tried using the report feature of xojo, but I can’t figure out how to connect the report to the data AND there is a print bug with Linux based systems that doesn’t allow for the Printer Dialog to appear, so I have to either write the report to file and command line print it or print the report without preview or printer dialog.
Since we only have 1 printer, that’s not a problem.
In the image below the areas highlighted RED and YELLOW are variable fields that will change with each new gift certificate.
Here you go John. You’ll need to TextOutputStream the 1.xml file out and send it to the printer. If you generate it next to joyfulheart.xsl it’ll find the xsl and turn it into your page. You’ll just need to change bg.jpg for a png which will scale (vector) or a 4x dimension png bitmap/jpeg that will be forced into the image and give a nice high res output on the printer.
If you want some info on producing barcodes at runtime without a plugin, see here
This then gets around all printing issues in Xojo and can be printed/converted to a PDF if required to be emailed to a customer.
I got the xml file to write out with the variables as needed, but when I open to view (I know printing is my goal, wanted to see the output first) I don’t see the image or data. I have the xsl and png files in the same directory as you noted.
I’m going to try sending it to the printer without a dialog box and see what explodes!
If you are trying to view this in Safari on the mac, you’ll need to go into Safari Preferences>Advanced>Show Develop menu in menu bar (at bottom) then in the Develop menu, click on Disable Local File Restrictions (8th from bottom).
Ivan, I looked at the printing examples and none of them showed how to write a file directly to the printer. They all have examples opening the printer dialog, which doesn’t work in Linux. (known bug). So the only solution I have available at the moment is to create a file on disk and then use the CLI to initiate the print.
This is the code to call shell and execute the bash script below…
// Variable declarations...
Var cmdPrn As String
Var shTerm As New Shell
shTerm.ExecuteMode = Shell.ExecuteModes.Asynchronous
shTerm.Execute( "/home/ian/Documents/The\ Nursery/Gift\ Certs/./ConvertPrint.go" )
If shTerm.ErrorCode = 0 Then
MessageBox( shTerm.Result.ToText )
MessageBox( "Error " + Str( shTerm.ErrorCode ) )
This is the bash script that I created (simple really) to convert the html file I created into a PDF and print it.
#!/bin/bash #wkhtmltopdf --quiet Gift\ Certificate.html Gift\ Certificate.pdf
html2ps Gift\ Certificate.html | lp #lp Gift\ Certificate.pdf
rm -Rf *.html
rm -Rf *.pdf
This is the simple bash script I have that works great if I run it from the terminal. But when I use Shell to call it, the script prints a blank page and stops there. The .html and .pdf are not removed and an error is thrown. So is there something wrong with how I am calling the bash script?
Also I realize you started me on the path of xml and xlst, but I couldn’t for the life of me finger out how to get it to print. So I used the HTML idea you gave me and that works great. BUT if I use the lp command to print the HTML file it prints the code… not the formatted document.
Nerp… just spits out a blank page and doesn’t complete the script.
I remember in RealBASIC being able to run bash scripts without issue… what changed?
Yeah this isn’t making any sense at all. If I run the script by either clicking on it or from a terminal it works exactly as I want. BUT if I issue the command from my App then I get a blank page and the PDF is not created nor are the two rm statements executed… but the print command does… for a blank page.