already did try this via the VB-Display.PrintOut() method
We've tried to use it for quick printing, but this pop-up window doesn't satisfy our customer. So we've forced to implement custom VB-code (inside our ProcessBook add-in, but we've also a VBA prototype). This code open a new MS Word document, then copy-paste selected trends from ProcessBook display and then optionally run Print method from Word. This way is not so simple, but I don't know another workaround
How about saving the display as SVG and using an open source tool to convert SVG to PDF?
I have had a bit of time playing with printing stuff from code and I know it is sometimes hard to have preview, and print functions defined in code.
However I do not think it would be possible to by-pass all of the printing dialogs if you go the route of the windows printing services.
I would recommend you go for a custom library that can save the file as PDF by itself instead of going the windows printing services way, I found an article for an application I know (PDFCreator) that has the neccesary exposure, the example works and is done in VBA for Excel, adapting it to ProcessBook should not be that hard, take a look at it and let me know if you find it usefull.
Sorry for the late reply, but thanks to all for the info. As soon as I've a working solution I will post it.
well I promised you to give feedback. (Better late than never). I used a VB Class to create the PDF myself and it's working fine now.
A lot of info you can find here => http://www.vb6.us/tutorials/visual-basic-tutorial-pdf
Thanks for closing the loop! I'm sure it'll help other folks when they find and read this thead
Hi Axel, can you give us the sample VBA Code you used to PrintOut as PDF and to bypass the Save As to Prompt?
1 of 1 people found this helpful
Not sure if this will help ... but do find some code snippets below,
only methods provided by the PDF Class (see link above) were used.
A file name will be specified at document creation ... it will create an empty PDF file.
After data has been added to the PDF you can just close it. No "Save As"-prompt should be there.
Sub PDFNewDoc(ByRef objPDF, strFile As String)
Dim strFileName As String
' Set the PDF title and filename
objPDF.PDFTitle = strFile
objPDF.PDFFileName = NamedValueGet("PathTemp") + strFile
' We must tell the class where the PDF fonts are located
objPDF.PDFLoadAfm = NamedValueGet("PathFonts")
' View the PDF file after we create it
objPDF.PDFView = False
' Set the file properties
objPDF.PDFSetLayoutMode = LAYOUT_DEFAULT
objPDF.PDFFormatPage = FORMAT_A4
objPDF.PDFOrientation = ORIENT_PORTRAIT
objPDF.PDFSetUnit = UNIT_PT
' Begin PDF document
... do you PDF thing ...
' End Of Document (Number Of Pages)
objPDF.PDFSetTextColor = vbBlack
objPDF.PDFSetFont FONT_ARIAL, CInt(intFontSize), FONT_BOLD
PDFElement objPDF, 30, intYPos, intFontSize, "End of Document. (Total Number of Pages:" + CStr(objPDF.PDFGetPageNumber) + ")"
' End our PDF document (this will save it to the filename)
Hi Axel, we finally used a the following code to Save/ Print as PDF:
Displays.PrintTo ("Adobe PDF")
We also did the following settings:
- Set the Default Printer to Adobe PDF
- Set Adobe Security settings to: None
- Set the Paper Size: A3 and Set the Layout: Landscape
- Set the destination Folder
It worked beautifully, thanks Axel.
I know its almost a 5 year old post, but in case someone need to get pass the print dialog box; you could use the Trend.[_xPrintOut] function. It's not documented but its working fine for me. It will print the display with the last printer settings.