Jump to content
  • Automation Services Custom Task: Split PDF

    This article provides the process to add a custom task that will split PDF files that are generated


    Spotfire has a great feature to automate tasks: Spotfire Automation Services

    You can, for example, automate basic tasks like:

    1. Open a report (Analysis file),
    2. Apply bookmarks to this report,
    3. Export this as PDF,
    4. Send an e-mail notification to the users.

    Default tasks (version 7.9) are the following:



    This article provides the process to add a custom task that will split PDF files that are generated

    But, why?

    Let's start with a simplified version of the previous job:

    1. Open a report (Analysis file),
    2. Export this as PDF.

    The result will be one single PDF file with several pages with, depending on your configuration, one tab (page) or one visualization per PDF page:



    That works great, but... what if I would like to have one PDF file per page? Or one PDF file per visualization?

    That was a requirement from one of our customers. So... let's see how this can be achieved!


    Create a custom Spotfire Automation Services task

    Let's start with the best solution: Implementing a custom Automation Services task. 

    I will not go into all the details of implementing custom tasks as it is very well documented (Down links here). I will rather focus on the task itself and the blocking points I had to face while implementing it.

    Presentation of task

    Once the custom package is installed, a new task is available.



    The options of the task are pretty easy to understand:



    • Input file: The path to the PDF file to split. Usually, this is the same path as "Destination path" of the "Export to PDF" task
    • Output folder: The path to the folder where the split files will be located. This folder will be created if it does not exist
    • Method of split: The method to apply to split the PDF. Currently, only one method is supported, that is "page". This split will generate one PDF file per page in the input PDF file.
    • Delete input after split: Whether or not the input PDF file should be deleted once the task has been executed successfully.

    Encountered issues during the implementation

    • Signing

    When deploying without signing the package, this error was thrown:

     The value 'Spotfire.AutomationServicesPDFSplit, Version=, Culture=neutral, PublicKeyToken=null' is not a valid AssemblyName

    The package needs to be signed to solve this issue. (See here for more info and https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-sign-an-assembly-with-a-strong-name).

    • Package builder SHA256

    While opening PackageBuilder, I received the following error:




    Spotfire is currently working on solving the issue but the workaround is to open PackageBuilderSettings.xml in C:\Users\Administrator\AppData\Local\TIBCO\Spotfire\<version>\Settings and to remove the tags Sha256="false".



    To create this new task, 3 projects have been created:

    1. PdfSharp: This folder contains the source code of the PDFSharp library as the version used for this project is not yet available as a dll binary
    2. Spotfire.AutomationServicesPDFSplit: The project that contains the actual PDF split feature. It references the PdfSharp project. 
    3. Spotfire.AutomationServicesPDFSplit.Forms: the project that contains the "user interface" (i.e.: The form displayed when adding the task)

    Sources are attached to this page. (Version 1.0.1).

    Spotfire package

    Spotfire package is attached to this page.

    Package Builder configuration

    Note that in order to work and to be deployable on a node, the package must have been configured as "Any Client" for the parameter "Intended Client". Do not forget to include the mandatory librairies of the projects.



    Release notes

    Date Version Notes
    03/08/2017 v.1.0.2 Update of GUID, assembly information and name change of Tasks and View classes.
    02/08/2017 v.1.0.1 Initial version

    Documentation & links

    Creating a Spotfire extension in Visual Studio: https://docs.tibco.com/pub/sfire_dev/area/doc/html/GUID-6B640903-E110-41EF-A231-C12587A0E91A.html

    Configuring and running the debugger for Spotfire Analyst extensions: https://docs.tibco.com/pub/sfire_dev/area/doc/html/GUID-4AA5D61A-1EE1-4760-82A7-C7FF5DD88C29.html

    PDFSharp library source code: https://sourceforge.net/projects/pdfsharp/files/pdfsharp/PDFsharp%201.50%20%28beta%204%29/

    Split PDF using PDFSharp: http://www.pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=37&Itemid=44



    User Feedback

    Recommended Comments

    There are no comments to display.

  • Create New...