Using a Form I'm creating one or more tickets (notes documents) at the backend using lotusscript, and when user clicks a button "Print Tickets", I want to loop through those created tickets and print them one by one through a thermal printer. As yet, I don't see anything for notes backend document for printing, though notes allows to print "frontend" document (NotesUIDocument), but that's not useful in this particular scenario. Please help.
How to print a notes backend document using lotusscript?
367 Views Asked by user1575786 AtThere are 3 best solutions below
On
You can access applications like Microsoft Word and Excel through the CreateObject function. Most of the VBA objects and methods then become available to lotusscript. We use a word document template and then loop through all the bookmarks. Each bookmark is given the same name as the field name we want to print. You can then use the print method to print out the document to the printer. We create PDFs this way.
So if you have Word also installed on your PC, you can do it that way too.
On
Ok I managed somehow to print the doc at the backend after having created the ticket doc(s) like this:
Set TicketDoc = db.CreateDocument
TicketDoc.Form = "Ticket"
TicketDoc.TicketNo = CurrTicketNo
TicketDoc.TicketDate = CurrDate
...
Call TicketDoc.Save(True, False)
Call workspace.EditDocument( True , TicketDoc )
The last line opens the ticket doc for edit (though we don't need it to be edited) so that we can access its frontend events.
Now in the opened ticket's Postopen() event I just placed this code:
Call Source.Print(1,1,1, False, "printername")
Call Source.Close()
So what it does, it prints the ticket and immediately gets closed.
Unfortunately, there is (currently) no native way to print Notes documents in the background. I had a similar requirement years ago, and the solution I came up with was to use a third-party tool to convert the Notes document to a PDF in the background, then send the resulting PDF directly to the printer. I used a tool called N2PDF, and later another similar tool which I cannot recall the name on at the moment.
I blogged about N2PDF back in 2010 To print the PDF, I created a Lotussscript library you can find here on my blog.
Below is a sample code of how to print a Notes document on a specified printer.
Good luck!