11 Replies Latest reply on May 17, 2018 7:24 AM by Muthulingam-EnQuest

    PrintOut to PDF-file


      Hi all,


      I'm looking for a solution to print a Process Book-display to a PDF file, ...


      I already did try this via the VB-Display.PrintOut() method, but a window to select a printer pops up.  This is not really what I'm looking for,  I would like a solution that the display is saved automaticly as PDF without any user interaction.


      Can anyone help me out ?  Thanks.

        • Re: PrintOut to PDF-file


          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



            • Re: PrintOut to PDF-file

              How about saving the display as SVG and using an open source tool to convert SVG to PDF?

                • Re: PrintOut to PDF-file

                  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.





                    • Re: PrintOut to PDF-file

                      Sorry for the late reply, but thanks to all for the info.  As soon as I've a working solution I will post it.   

                        • Re: PrintOut to PDF-file

                          Hi All,


                          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









                            • Re: PrintOut to PDF-file

                              Thanks for closing the loop! I'm sure it'll help other folks when they find and read this thead

                              • Re: PrintOut to PDF-file

                                Hi Axel, can you give us the sample VBA Code you used to PrintOut as PDF and to bypass the Save As to Prompt?



                                Best Regards,


                                Muthulingam Ramiah

                                  • Re: PrintOut to PDF-file

                                    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


                                    End Sub


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

                                            AddPageNumber objPDF



                                    1 of 1 people found this helpful
                        • Re: PrintOut to PDF-file

                          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.