Introduction

The latest How To topics are available in the K2 Five User Guide or the K2 Cloud User Guide’s How to section.

This Knowledge Base article describes how to create a PDF file using the PDF Converter in an Advanced SmartObject.

Audience
  • Developers
  • Form Designers
Required Knowledge
  • Advanced SmartObjects
  • Views and Forms
  • Rules
  • Controls
  • Workflow

Example Scenario

In the scenario below we are using a Form in a workflow and then using the Create PDF from URL method of the PDF Converter to create a PDF file from a URL specified in the workflow. The PDF file is then attached to an E-mail and sent to the recipient.

Follow the steps below to set up the scenario:

  1. Create an Advanced SmartObject called PDF from URL
  2. On the Details screen select Advanced SmartObject and select the option Allow this SmartObject to be used in Workflows
  3. Click Next
  4. On the Properties and Methods screen, drag the Create PDF from URL method of the PDF Converter Service Object onto the canvas as shown below
    Image
  5. On the Default ServiceObject method bindings screen, click Create All
    Image
  6. Click Next
  7. The ServiceObject method binding is listed. Click Finish
    Image
  8. Finish the SmartObject
  9. Create another SmartObject to be used for creation of the PDF, for example Building.
  10. Auto generate an Item View and a Form from the Building SmartObject
  11. Right click the Form in the Category tree and select Properties.
  12. Copy the Runtime URL of the Form
  13. Design a workflow using the Form
  14. On the Data Fields screen of the Workflow Settings, create a Data Field of Type String as shown below. The Type used here should correlate to the PDF Converter ID which is of Type Text.  
    Image
  15. Finish the wizard
  16. Select the SmartObjects tab at the top of the Workflow Designer
  17. Select the PDF from URL SmartObject and then drag the Create PDF From URL PDF From URL SmartObject onto the canvas 
    Image
  18. Provide details on the input properties screen and paste the URL copied previously in the URL String field.   
    Note:
    URL String - This is the entire URL that you are attempting to access
    URL Base- The base value of your URL. If the URL you’re aiming at contains any parameters, they should be included in the above “URL string” value, but excluded from the value provided here.
    Image
  19. Click Next
  20. On the return properties screen, map the id Data Field to the ID Property Value  
    Image
  21. Finish the wizard
  22. Create an Outcome called Complete
  23. Drag the Send E-mail event onto the Complete outcome. Provide details and then drag the PDF Load method into the Attachments field as shown below  
    Image
  24. On the Load PDFFile screen, expand the Inline Functions node in the Context Browser and drag the To Integer function into the ID field. We need to convert the id of the Data Field into an Integer as the PDF created is saved as a Number 
    Image
  25. Drag the id Data Field into the Value field.
    Image
  26. Click OK and OK again.
  27. The PDF Load method is displayed in the Attachments field. Finish the wizard 
    Image
  28. The workflow represent the following:
    Image
  29. Save and deploy the workflow
  30. Run the Form and capture the required details then click the Create button 
    Image
  31. The E-mail is sent to the recipient with the PDF attached
    Image
  32. Open the PDF to view the details captured. Note that no details have been captured since we used the Create PDF from URL method which creates the PDF file upon load of the page.   
    Image

See the following topic in the K2 smartforms Help Guide for more information about the PDF Converter:

K2 smartforms > K2 Designer > SmartObjects > Creating SmartObjects > Define Properties and Methods > Advanced SmartObject > PDF Converter