Trying to figure out how to create this document

I have no experience with XML/XSL… but I will look into that option.
HTML might work as well. I think I can brush the cobwebs out… been about a decade since I messed with it.

Var xmlReport As New XmlDocument
Var root As XmlNode

' Function(s) / Logic...


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<article lang="">
<para>Gift Certificate for: Laura Croft!From: Been Needy</para>
<para>In the Amount of: $10.00</para>
<para>
<inlinegraphic fileref="embedded:Image1" width="6.2417inch" depth="7.2283inch"/>
</para>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para>Balance: $___________.        </para>
<para>Date Used:                              </para>
<para>Cashier:                                   </para>
<para/>
<para>Balance: $___________.        </para>
<para>Date Used:                              </para>
<para>Cashier:                                   </para>
<para/>
<para>Balance: $___________.        </para>
<para>Date Used:                              </para>
<para>Cashier:                                   </para>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para/>
<para>Validation Code: Laur20200726-0806</para>
<para> Laur20200726-0806</para>
<para>Purchase Date: 2020-07-26</para>
<para>Purchase Time: 08:06:32</para>
</article>

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?

Document…

you want to save that? In what format? or is just printing?

dont bother, it is really bad

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.

This is what I am trying to create/print.

Well, if is just printing, first of all, dont waste your time with “reports”, also, no need of XML, SVG, HTML, PDF or any other thing.

Just draw the page directly to the printer, check the samples in
Printing and reporting - Printing

In linux, happens also with 32 bit apps or only 64?

Printing and reporting - Printing

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.

https://www.dropbox.com/s/vxezqren8bw01hy/ForJohnXML.zip?dl=0

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.

Thanks! I’ll poke at it tomorrow when I am fresh.

Julian,
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! :slight_smile: :rofl:

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).

Linux Mint - Firefox

See http://kb.mozillazine.org/Links_to_local_pages_do_not_work (gotta rush, dinner in oven, no time to fire up vm atm)

Enjoy dinner! I’m eating lunch working on figuring out the print part of the equation now…

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.

What file? You said you did not need to save a file.

Okay, ,

This is the code to call shell and execute the bash script below…

// Variable declarations...
Var cmdPrn As String
Var shTerm As New Shell

// Function(s)...
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 )
Else
  MessageBox( "Error " + Str( shTerm.ErrorCode ) )
End If

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.

Try it as Shell.ExecuteModes.Synchronous

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.

Use the full path to html2ps. Remember, shells don’t inherit your full PATH.

Did you chmod 755 the script? I’ve not used linux in 20 years, I have it working here, I don’t really know what else to suggest.

Hmm, its working from a web url, let me figure out how to allow it to read from local