1 2 Previous Next 15 Replies Latest reply on Jun 15, 2018 1:33 AM by Mark Fraser

    Automate pdf printing of reports

    Ruby McFakey

      Does anyone know how to use tabcmd (a Tableau utility)?

       

      I would like to use it to automate the printing of 30+ reports (essentially the same report but with different filters for each (line of business) x (state) x (reporting month)).

        • 1. Re: Automate pdf printing of reports
          Jeff Strauss

          yep, you should be able to build lob, state, reporting months into the report as parameters that are then applied onto the filters.  Then use tabcmd export workbook/view?LOB=x&STATE=y&MM=z

          • 2. Re: Automate pdf printing of reports
            ankit.narula

            Hi,

             

            You can try using below command:

             

            cd C:\Program Files\Tableau\Tableau Server\10.0\bin

            tabcmd login -s http:// -t Site -u username -p Password

            tabcmd get "/views/Path/Filename.pdf"?Filter=Value1 -f "Path to Save\Filename.pdf"

            tabcmd get "/views/Path/Filename.pdf"?Filter=Value2 -f "Path to Save\Filename.pdf"

             

            However to use this you have to put all the values of Filters one by one i.e in your case 30 values of filter.

            It's a workaround or a solution I am not sure but worked for me.

             

            Hope it will work for you.

             

            Thanks

            • 3. Re: Automate pdf printing of reports
              Mark Fraser

              Hi Ruby

               

              As has been suggested it is possible, i do something similar to what you want to do

               

              But first - what is your setup? i.e. do you have desktop & server? and if so, what version?

              FYI - tabcmd can only be used with server... if you only have desktop, that won't work

               

              assuming you have server:

              You would need to write a batch file (i can provide an example, that is what ankit has provided, and what jeff is referencing) < this would automatically log into server, get what you want and put it somewhere, you can add multiple lines to do different workbooks/ filter combos

              How you write the tabcmd will affect what is downloaded and in which format (workbook, pdf, excel, csv)

               

              you said automate the printing of the report... do you mean, print to pdf?

               

              Cheers

              Mark

              • 4. Re: Automate pdf printing of reports
                Ruby McFakey

                Hi Mark,

                 

                I actually haven't figured out how to even get on to tabcmd. I do have access to my team's tableau server and have published a few reports on there, but have no idea how to get onto tabcmd. We've currently got Tableau 9.2 desktop.

                 

                Can you please put instructions for writing a batch file? I have limited knowledge but as far as I can work out, a batch file is a set of commands that are to be executed in succession, basically a program, but with command prompt commands? I assume I write it in notepad and just save it with some batch file extension?

                 

                Yes print to pdf as per both the above commenters' code.

                 

                Thanks so much for your help.

                 

                Ruby

                • 5. Re: Automate pdf printing of reports
                  Nancy priya

                  Use tabcmd to sign in to Tableau Server

                  Step 1

                  Click the Start button, and select All Programs > Accessories. Right-click the Command Prompt and select Run as administrator.

                  Step 2

                  Type one of the commands below, depending on where the tabcmd utility is running from. If you are running the tabcmd utility from the same machine as Server

                  • cd C:\Program Files\Tableau\Tableau Server\<version>\bin
                  • cd C:\Program Files (x86)\Tableau\Tableau Server\<version>\bin

                  If you are running the tabcmd utility on a separate machine from Server:

                  • cd C:\Program Files\Tableau\Tableau Server\<version>\extras\Command Line Utility
                  • cd C:\Program Files (x86)\Tableau\Tableau Server\<version>\extras\Command Line Utility

                  Note: Replace <version> with the version of Tableau Server you are running.

                  Step 3

                  Type the following command:tabcmd login -s http://<host>:<port> -u <username> -p <password>Notes:

                  • Replace <host> and <port> with your specific hostname and port.
                  • Replace the <username> and <password> with a valid Tableau Server username and password for someone who has publishing rights.

                  If the command is executed successfully, you will see something similar to the following example:C:\tli>tabcmd login -s http://tableauserver:80 -u admin -p password===== Creating new session
                  ===== Server: http://myserver
                  =====   Username: admin
                  ===== Connecting to the server...
                  =====   Signing in...
                  =====   Auto-sign in to site: Default
                  ===== Creating new session
                  =====   Server: http://myserver
                  =====   Username: admin
                  ===== Connecting to the server...
                  ===== Signing in...
                  ===== Succeeded
                  ===== Succeeded

                  Use tabcmd to generate a PDF of a Tableau view

                  To test generating a PDF, type the following command:tabcmd get "<url-of-view>.pdf" -f "<filename>.pdf"Notes:

                  • Replace <url-of-view> with the view's URL path after it has been published.
                  • In versions of Tableau Server earlier than 9.0, ensure that you append <url-of-view> with ".pdf", as in the example above. In Tableau Server 9.0 and later, you do not have to include the filename extension with the <url-of-view> value for PDF files; the command infers that you want a PDF file from the name you provide in the -f parameter.
                  • Replace <filename> with the name you want to give to the generated PDF file.

                  For example, the tabcmd command can look like this:tabcmd get "/views/Wow/SummaryReports.pdf" -f "progressReport.pdf"If the PDF generates successfully, tabcmd places the PDF file "progressReport.pdf" in the current working directory.Note: For Tableau Server 8.1 through 8.3, ensure that you do not include the hash tag (#) and number at the end of the URL. For Tableau Server 9.0 and later, do not include ":iid=<n>."

                  Use tabcmd to send email messages

                  While the tabcmd by itself cannot send email messages, if you are using Tableau Server 8.0 and later, you can configure email alerts if there is a system failure or subscriptions that allow users to subscribe to their favorite views. For more information about these features, refer to theConfigure Alerts and Subscriptions  topic in the Server Online Help. Alternatively, you can easily add this functionality through scripting. Many applications and scripting languages are available, and you can combine the printing automation of tabcmd with practically any other logic. Two examples illustrate this capability.This example uses email shareware called febootimail.exe (search the Web for "febootimail" for more information). This program allows full control over aspects of the e-mail generation.Here is an example that sends as an e-mail attachment the PDF progress report you generated in the last example.tabcmd login -s http://tableauserver:80 -u admin -p admintabcmd get "/views/Wow/SummaryReports.pdf" -f "progressReport.pdf"febootimail.exe -SMTP yourSMTPhost.yourcompany.com -TO "recipient1@yourcompany.com; recipient2@yourcompany.com;recipient3@yourcompany.com" -FROM sender@yourcompany.com -SUBJECT "Generated Tableau View - Tableau Server Automated Alert System (TSAAS)" -ATTACH " C:\Program Files\Tableau\Tableau Command Line\progressReport.pdf" -BODY"this is the text of the body"Note: For Tableau Server 8.1 through 8.3, ensure that you do not include the hash tag (#) and number at the end of the URL. For Tableau Server 9.0 and later, do not include ":iid=<n>."If you install febootimail and review its help files, you can note the following:

                  • Instead of typing the e-mail addresses of recipients using the TO tag, you can refer to a file.
                  • Instead of typing the e-mail body using the BODY tag, you can specify an HTMLFILE tag.
                  • You can attach multiple files.

                  These features provide control over the Tableau generation and e-mail process. Many other applications and scripting languages also have this type of support.

                  Send formatted email with an embedded image

                  Tabcmd can generate PNG files, and febootimail.exe can send HTML e-mail. The febootimail help says that the HTML file must be in the same directory as febootimail.

                  Here is an example script:

                  tabcmd login -s http://tableauserver:80 -u admin -p admin

                  tabcmd get "/views/Wow/SummaryReports.png" -f "progressReport.png"

                  febootimail.exe -SMTP yourSMTPhost.yourcompany.com -TO "recipient1@yourcompany.com; recipient2@yourcompany.com;recipient3@yourcompany.com" -FROM sender@yourcompany.com -SUBJECT "Generated Tableau View - Tableau Server Automated Alert System (TSAAS)" - -HTMLFILE "emailbody.html"

                  Note: For Tableau Server 8.1 through 8.3, ensure that you do not include the hash tag (#) and number at the end of the URL. For Tableau Server 9.0 and later, do not include ":iid=<n>."

                  Notice that the BODY tag has been replaced by an HTMLFILE tag. Because tabcmd can auto-generate a PNG image, you can reference that image in the body of an HTML email template. Here is a simple version of this HTML file:

                  <html>

                  <head><title>Email Alert</title></head>

                  <body><img src="progressReport.png"></body>

                  </html>

                  3 of 3 people found this helpful
                  • 6. Re: Automate pdf printing of reports
                    ankit.narula

                    Hi,

                     

                    Copy the below text and change the path and file name as per your requirement:

                     

                    cd C:\Program Files\Tableau\Tableau Server\9.2\bin

                    tabcmd login -s http:// -t Site -u username -p Password

                    tabcmd get "/views/Path/Filename.pdf"?Filter=Value1 -f "Path to Save\Filename.pdf"

                    tabcmd get "/views/Path/Filename.pdf"?Filter=Value2 -f "Path to Save\Filename.pdf"

                    Put that in a notepad and save as .bat file.

                     

                    Then go to programmes->cmd->run as administrator->paste this and check the location 'Path to save'

                     

                    Thanks

                    • 7. Re: Automate pdf printing of reports
                      Ruby McFakey

                      Hi Ankit,

                       

                      Thank you for that answer.

                       

                      The folder "Tableau Server" doesn't exist for me. I'm not sure why but it may be because we download the application through an SCCM that comes from online - our IT department has to approve our downloading of Tableau as well as other software.

                      • 8. Re: Automate pdf printing of reports
                        ankit.narula

                        Hi,

                         

                        I think in this case Mark can help you better because I am not aware of those technicalities.

                        @Mark Fraser Please help.

                         

                        Thanks

                        • 9. Re: Automate pdf printing of reports
                          Sankarmagesh Rajan

                          hi Ruby,

                           

                          We can access tableau server from any machine via tabcmd. Please ask your client to get info reg tableau server version.

                           

                          same version of tabcmd install in your machine.

                           

                          Create one batch file and add tabcmd login, get or export pdf commands, tabcmd stop in one single notepad and save it as .bat file.

                           

                          Use the windows task scheduler and create new task to add this bat file for scheduling.

                           

                          Refer full details here

                          Email Subscriptions

                           

                          Thanks

                          sankar

                          • 10. Re: Automate pdf printing of reports
                            Mark Fraser

                            @All

                            Please take note of Ruby's reply to me...

                            Ruby McFakey wrote:


                            I actually haven't figured out how to even get on to tabcmd. I do have access to my team's tableau server and have published a few reports on there, but have no idea how to get onto tabcmd. We've currently got Tableau 9.2 desktop.

                            From it, I imagine (i dont know) that Ruby is new to Server administration and tabcmd in particular
                            therefore in order to really help we need to first understand what the issue is, then provide some basic initial instructions... Simply pasting from existing help files is not helpful.

                             

                             

                            @Ruby

                            there are 2 main tableau products - desktop & server

                            desktop is used to connect to data & create content

                            server is used to share content and to manage updates, security etc.

                            tabcmd is software bundled with server which allows administrators to automate certain server activities such as exports, it doesn't need to be installed on the server PC, but it does need access the server installation

                             

                            Now the basics are out the way -

                            batch files (.bat) > you are correct, you would write it in notepad, and save with file extension of .bat

                            the batch file is made up of a series of commands, which can be found here >> tabcmd Commands

                            you can have 1 command, 10 or 50 doesn't matter, they process in order, from the top down, the order is important

                             

                            an example - I would strongly advise to start, go no further than trying to log in...

                             

                            @ECHO OFF                                                                                                                   < turn off visible system messages

                            ECHO Processing.....                                                                                                        < show 'processing' instead

                             

                            cd /D C:\                                                                                                                             < change the directory to the C drive (we need the location of the server installation, it could well be on another PC)

                            cd C:\tabcmd\Command Line Utility                                                                                     < now in the C drive go to the location of the tabcmd.exe file (as above)

                            tabcmd logout                                                                                                                       < you dont need this, but i use it, just in case i was still logged in

                            tabcmd login -s http://our server.com -u mark --password-file pwd.txt                              < the login (my password is saved in a local text file rather than passed for security)

                             

                            Next steps -

                            Your first step is to get access to the machine that server is installed

                            copy tabcmd folder and install it on your local PC

                            only then, start with the batch file stuff - i would strongly advise just trying to at least login first, once you have established connection then the real fun can start

                             

                            I'll stop there - if/ when you need further help, let me know

                             

                            Cheers

                            Mark

                            2 of 2 people found this helpful
                            • 11. Re: Automate pdf printing of reports
                              Ruby McFakey

                              Hi Mark,

                               

                              Thank you so much for that. I have had the person with the server installed on their machine send me the tabcmd installer. I am just getting IT to approve the install now. I think I know where to go from here based on all the answers but will let you know if I have any other trouble. Thank you!

                               

                              Cheers,

                              Ruby

                              • 12. Re: Automate pdf printing of reports
                                Mark Fraser

                                Hi Ruby

                                 

                                Great, you're now on the right track

                                I would advise, get the tabcmd installation done and then initially just try logging in... to server via tabcmd - that way you can be sure all your connections/ usernames/ passwords are OK - then you can start the more interesting stuff.

                                (I forgot to mention - every time your server is updated, you should also update tabcmd  - its a good idea to keep them aligned, its always bundled with server)

                                 

                                The below is for you, but also for anyone that stumbles on this thread.

                                I taught myself (through need), so I'll share some tips to hopefully help you and others...

                                 

                                Once you have got the login sorted via batch, you'd then be looking at these functions export &/or get

                                Here is a working example of mine - (the bit in italics is also above)

                                 

                                @ECHO OFF

                                ECHO Processing.....

                                 

                                cd /D C:\

                                cd C:\tabcmd\Command Line Utility

                                tabcmd logout

                                tabcmd login -s http://our.server.com -u mark --password-file pwd.txt

                                 

                                tabcmd export "ReleaseList/BEReleaseList" --pdf --pagesize a4 --pagelayout landscape --width 1800 --height 1200 -f "X:\markf\BE_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%.pdf" --timeout 60

                                tabcmd export "ReleaseList/NLReleaseList" --pdf --pagesize a4 --pagelayout landscape --width 1800 --height 1200 -f "X:\markf\NL_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%.pdf" --timeout 60

                                tabcmd logout

                                 

                                I'm exporting 2 worksheets (one after the other, remember order matters, top down) called BEReleaseList & NLReleaseList

                                I'm exporting as PDF, in a4, landscape, i have defined height & width, then a place to save (the bit in bold is going to automatically put today's date (from the server) on the end of the file, so i know when the PDFs were created but also so next week when i redo the export, I don't overwrite the originals (they will have different names) ) < clever eh?

                                i also add a time out, just in case it overruns

                                 

                                You can stop there... but my end users want page numbers, logos and other stuff

                                So I use a program called PDFill (others available - i wanted a command line PDF editor), because its command line based, i can add it to the same batch file..

                                 

                                Here is the full thing... (as before the bit in italics, is above)

                                FYI. :: < this is a comment in a batch file (always a good idea to add comments!!)

                                 

                                @ECHO OFF

                                ECHO Processing.....

                                 

                                cd /D C:\

                                cd C:\tabcmd\Command Line Utility

                                tabcmd logout

                                tabcmd login -s http://ourserver.com -u mark --password-file pwd.txt

                                tabcmd export "ReleaseList/BEReleaseList" --pdf --pagesize a4 --pagelayout landscape --width 1800 --height 1200 -f "X:\markf\BE_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%.pdf" --timeout 60

                                tabcmd export "ReleaseList/NLReleaseList" --pdf --pagesize a4 --pagelayout landscape --width 1800 --height 1200 -f "X:\markf\NL_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%.pdf" --timeout 60

                                tabcmd logout

                                 

                                :: above I use --pdf function as I am exporting a view, if we export the whole workbook the function should be --fullpdf

                                 

                                "C:\Program Files (x86)\PlotSoft\PDFill\PDFill.exe"  HeadFoot  "X:\markf\BE_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%.pdf"  "X:\markf\BE_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%_v2.pdf"  1 1 5 5 5 5  "Page <<1>> of <<N>>" -align 2 -pageOffset 0 -fontEncode "Western" -fontName "Calibiri" -fontStyle 0 -fontSize 8.0 -rgbFontColor "128 128 128"

                                DEL /F /S /Q /A "X:\markf\BE_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%.pdf"

                                "C:\Program Files (x86)\PlotSoft\PDFill\PDFill.exe"  WatermarkImage "X:\markf\BE_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%_v2.pdf"  "X:\markf\BE_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%.pdf"  "M:\Huisstijl & DTP\logo's\logo_300.png"  25 25 0  -positionFlag 1 -left 15 -bottom 10 -flagOrder 1

                                DEL /F /S /Q /A "X:\markf\BE_Release List_%date:~-4,4%%date:~-7,2%%date:~-10,2%_v2.pdf"

                                 

                                ECHO ON

                                 

                                Note - I have only included steps for the first (its just a repeat) I now have 2 different PDFs with different names (+ today's date)

                                The next steps - i open the PDF, add page numbers, i then save is as v2 < this is important

                                Next i delete the original - i now only have v2

                                now i reopen v2, and a logo, i now save it back as the original name (remember we deleted it in the earlier step)

                                I then delete v2 to tidy up,          < i actually do this twice, one for each PDF, but only included one, you get the idea

                                finally i turn system messages back on (otherwise they would stay off permanently)

                                Output: i'm left with the file, with its original name, but now with page numbers, logos etc.

                                 

                                I then send it via email using blat, also in the command line... (same batch file) but i think the above is enough for now

                                 

                                Hope that's clear & useful

                                 

                                Cheers

                                Mark

                                1 of 1 people found this helpful
                                • 13. Re: Automate pdf printing of reports
                                  Nancy priya

                                  cd C:\Program Files\Tableau\Tableau Server\10.0\bin

                                  tabcmd login -s http:// -t Site -u username -p Password

                                  tabcmd get "/views/Path/Filename.pdf"?Filter=Value1 -f "Path to Save\Filename.pdf"

                                  tabcmd get "/views/Path/Filename.pdf"?Filter=Value2 -f "Path to Save\Filename.pdf"

                                   

                                  However to use this you have to put all the values of Filters one by one i.e in your case 30 values of filter.

                                  It's a workaround or a solution I am not sure but worked for me.

                                   

                                  Hope it will work for you.

                                  • 14. Re: Automate pdf printing of reports
                                    Rachel Yau

                                    Hi Mark,

                                     

                                    Thanks a lot for sharing these. They works perfectly!

                                     

                                    Just want ask - is it possible to print 2 dashboards (in the same workbook) in one PDF?

                                     

                                    Kind Regards,

                                    RY

                                    1 2 Previous Next