Record extraction to PDF

Hi all,

Is there an easy way to generate a PDF from a record, for example, while displaying a record then using a related action a pdf could be generated which later can be printed.

Thank you.

OriginalPostID-257250

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    @vasilisg i don't think, we have any direct approach to do this, we have a Shared Component named as 'Excel Tools' having a smart service named as 'Export SQL data to Excel', which can retrieve the data from and database and can push the same into Excel, now here we need to do some workaround in order to create a smart service which can convert Excel to PDF, if you are succeeded then pass the excel as an input to the created smart service and you can achieve your required one.

    => Here the most challenging thing is to create a Smart Service which can convert a Excel File to PDF

    Hope this will give you an idea about how to start with, to achieve your requirement
  • @Vasilisg @Alok adding to above comment we have a Dynamic Document Generator shared component to convert any document to PDF,
    if you have found any alternate suggestions please do share with us
  • 0
    Certified Lead Developer
    You could use forum.appian.com/.../summary to create a word document and then convert that to PDF. Creating the word doc may take some time depending on the complexity of your record
  • 0
    Certified Lead Developer
    Hi Vasilis,

    Firstly try to create a docx using the below smart service which will contain all the required data from the record.
    forum.appian.com/.../summary

    Now using the generated docx as an input to the below smart service you can convert it into a pdf.
    forum.appian.com/.../summary

    After generating pdf you can remove the docx if there is no need of having it and using a document link you can download the generated pdf.
    Hope this helps you.
  • Thank you all for the responses.

    The mothod of creating word templates is known, the thing is that in cases where there are many different templates (records) with 60 or so fields this is:

    a) very time comsuming
    b) valnurable to changes
    c) overall difficult to support

    I am towards @aloks176 suggestion where fields are generated automatically. I have not (yet) set up the inputs of that smart service successfully, could anyone provide me with an example?.
  • 0
    Certified Lead Developer
    @Vasiling You could use iText API to create a pdf file in java and use Apache POI to access the data in the MS-EXCEL file. If you combine both, you could convert your excel file.

    => So you can combine iText and Apache POI API together while creating the Smart Service

    The required parameters could be:

    1. existingExcelFile (Type: File)
    2. replaceExisting (Type: Boolean)
    3. saveInto (Type: Folder)


    whereas the output can be the generated document

    Alternatively You can try AsposeCells for Java which allows you to convert Excel file to PDF in Java applications while building Smart Service for Excel to PDF

    Now coming to code snippet for AsposeCells in java, you can do something as follow:-
    =======================================================================
    //Instantiate a new workbook with excel file path
    Workbook workbook = new Workbook("F:\\\\FileTemp\\\\Book1.xls"); //here you could refer KC Document i.e. existingExcelFile input

    //Save the document in Pdf format
    workbook.save("F:\\\\FileTemp\\\\MyPdfFile.pdf", FileFormatType.PDF); //Here you could refers saveInto
    ======================================================================

    Hope this will help you to take a initiative in order to build a Smart Service to convert Dynamically Generated Excel to PDF

    Thanks
  • 0
    Certified Lead Developer
    @vasilisg If you want to build the smart service in order to convert Excel into PDF, then you can use the attached java code followed by Appian Annotations that will be needed to prepare input and output parameters, however before using the attached example, you need to download few jar files and set it under classpath, those are:-

    ======================================================
    dom4j-1.6.1.jar
    itextpdf-5.4.0.jar
    log4j-1.2.17.jar
    poi-3.9.jar
    poi-ooxml-3.5-beta5.jar
    poi-ooxml-3.6-20100309.jar
    poi-ooxml-schemas-3.7-beta1.jar
    xmlbeans-2.5.0.jar
    xmlbeans-xmlpublic-2.4.0.jar
    =====================================================

    And then follow the attached Java code and convert the code according to your requirement.
    Also attached the output of the attached Java file, which is generating Excel to PDF successfully.

    Hope this will help you to build the Smart Service Successfully.


    ExcelToPDF.java


  • We have the same requirement. The only way I've found that could possibly work would be to run a headless browser (i.e. PhantomJS) to manage the authentication and navigate to the record. From there you can either directly print to PDF using PhantomJS or retrieve the HTML and use another library to manage the conversion to PDF. Headless browser authentication is required because most HTML to PDF conversion libraries available only support HTTP Authentication. Unfortunately Appian does not support HTTP Authentication for Records at the moment.
  • well, unfortunately the appian we work with is cloud based so custom development solutions are out of the question, but thank you for your input, it may be helpful for others....

    Once again our hands are tied. Now hours of developement would have to be utilized to create these meaningless doc templates....
  • It is possible to develop custom plugins that can be deployed to your cloud environment.