convedo Tech Talk

Covid-19/Coronavirus Releated Solutions We're here to help

    Create a PDF document from a Rich Text control in OpenText MBPM 9.x

    OpenText MBPM 9 HTML to PDFRecently one of our Opentext MBPM customers asked us how to produce a PDF document from data entered into a Rich Text control. We have implemented this functionality into other Metastorm processes in the past and today I thought it would be a good time to share with you a little snippet to get you started.

    .Net PDF Library

    There are multiple .Net libraries available on the market to create PDF documents. We have worked successfully with Aspose and iTextSharp on several projects. The snippet we share with you is using the free available iTextSharp library. If you want to take our snippet further you can find many samples how to use the library by searching for "iTextSharp" with the search engine of your choice.

    Richt Text to PDF

    The Rich Text control has been added to Metastorm in version 9. The Metastorm Rich Text control allows content to be edited, formatted and spell-checked for English, French, and German languages. The control is supplied with a toolbar containing a set of options which provide basic editing functionality such as cut, copy, paste, find and replace, undo/redo etc. The Rich Text control is usuall bound to a Memo variable and its content is stored as HTML.

    In order to produce a PDF document from this HTML content it is required to pass the variable content to a function which then produces the PDF, in this sample, with the iTextSharp .Net library. Follow the 3 simple steps to get started:

    1.) Copy .Net Library

    Copy the iTextSharp.dll file into the following locations:

    • [Metastorm]\Deployment\CustomLib
    • [Metastorm]\Designer\CustomLib
    • [Metastorm]\Engine\DotNetBin

    2.) Create Server Side Script

    A sample implementation of the method could look like the following:

        public static void CreatePDF(string text, string SaveAs)
          iTextSharp.text.Document document = new iTextSharp.text.Document();
            iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(SaveAs, FileMode.Create));
            iTextSharp.text.html.simpleparser.HTMLWorker hw =
             new iTextSharp.text.html.simpleparser.HTMLWorker(document);
            hw.Parse(new StringReader(text));

    Make sure you add the System.IO namespace to your Server Side Script in order for the sample code to work.

    3.) Use the CreatePDF method

    The above Server Side Script code will promote the method in the MBPM Designer Expression Builder and the Visual Script Toolbox and allows HTML code to be saved as a PDF document on the file system. The last step would be to select this method from the Expression Build or drag the Create PDF activity into your Visual Script in one of the Event Handler e.g. "When Button Pressed".

    I hope you can take some useful information away. As always we would like hear your thoughts on this. You can download the full OpenText MBPM 9.3 Solution (including the iTextSharp.dll) below:

    Download Rich Text to PDF Demo Solution

    Any questions regarding this please feel free to contact us directly.

    Metastorm BPM Health Check


    Topics: OpenText MBPM- Metastorm BPM- Metastorm Controls- Metastorm Designer- Metastorm v9- Metastorm Shortcuts

    Previous Post

    Getting Started with Business Process Management (BPM)

    Next Post

    How good is your OpenText MBPM v9 Knowledge? [Quiz]

    7 steps to bpm success

    Free Whitepaper: 7 Steps to BPM Success

    A Pragmatic Approach to Leveraging BPM Technology for Business Success

    This whitepaper provides the reader with a 7 Step model that seeks to suggest ways in which organisations can maximise their business returns. The model sets out to blend the benefits of non-technology approaches with the more technological ones.

    Download Whitepaper Now

    Have a project in mind?

    We'd love to chat with you and find out how we can help solve your process and automation challenges.

    Get in touch with us


    Get all the latest updates on Intelligent Automation.

    Fill out the form below to subscribe to the convedo newsletter.

    Subscribe to Email Updates

    100% Privacy. No Spam.

    Recommended Reading

    Posts by Tag

    See all

    Start Delivering Business Applications Faster.

    Start Your Digital Transformation Journey Now