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

    Introduction

    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:

     

    Screenshot2022-11-06at10_44_13AM.png.c6fe5f67058db5f9ebd146e245249900.png

    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:

     

    Screenshot2022-11-06at10_44_21AM.png.8ab521ea4c9fb74ca2db07a62152373a.png

    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!

    Solution

    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.

     

    Screenshot2022-11-06at10_44_34AM.thumb.png.3ead98088daa56bb939bd8f13597cace.png

    The options of the task are pretty easy to understand:

     

    Screenshot2022-11-06at10_44_42AM.png.a9edb7e92fe0859a8e4c804a72e17c74.png

    • 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=1.0.0.0, 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:

     

    Screenshot2022-11-06at10_44_53AM.png.f0112ab62107420537b0c9d69894aea0.png

     

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

    Sources

    Projects

    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.

     

    Screenshot2022-11-06at10_45_17AM.thumb.png.7300ba57266c722ce9deedcf4ece1805.png

    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

    spotfireautomationservicespdfsplit.forms_1.0.2.zip

    automation_services_pdf_split_1.0.2.spk_.zip


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...