Workflow Soluiton

 View Only
  • 1.  HTML Merge with images

    Posted Mar 23, 2009 03:11 PM
    Hello,

    I have text, html and images to combine together into a pdf file. I've tried using the HTML merge capability but it does n't render the image into the document. what would be the proper method for combining these together to make a document (PDF) that I can store as a record.

    Thanks

    Cary


  • 2.  RE: HTML Merge with images
    Best Answer

    Posted Apr 16, 2009 05:31 PM
    This can be done...it first depends on where the image is coming from, and that is usually either from within the process (e.g. an end-user is given an InputFile component which allows them to upload an image), or from a pre-determined location (like you want the same image to be embedded into each of your PDFs).

    Let's assume the image is coming from the process itself (the first scenario). So on a Form Builder, there is an InputFile component and the end-user uploads an image file, and let's say we store that in a variable called MyImage. After that step, add a WriteFile component, which will allow us to save the file to a location on the Workflow server, which will later allow us to point to that file in our HTML. In the WriteFile component, choose the Relative To Project Directory radio button, which will write the image file at runtime to the root of the project directory, e.g. C:\Program Files\Altiris\Workflow Designer\WorkflowDeploy\Release\<VirtualDirectoryName>. Assuming that you will end up publishing the project (as opposed to running this in the debugger), we should have a predictable URL which will point to the file in this folder, e.g. http://<WorkflowServerIPAddressOrDomainName>/<VirtualDirectoryName>/<FileName>.

    Now that we know the file will be at that location, we can point to the file in our MergeHTML component.  To do so:

        a) In the Advanced Text Creator, click on HTML Elements.  Drag an Image Element over onto the right-hand side.
        b) At the bottom, click on Source to edit the HTML more directly.
        c)  In the HTML source, you should see a new tag that looks like this:  <IMG src="">   That's a standard HTML tag to insert an image onto a web page.
        d)  As you can guess, src is looking for the source of the image, i.e. its location.  We know the location will be a combation of two variables, which is the physical file location on the Worfklow server + the name of the file.  Those are both stored in variables...BaseURLToProject and MyImage.FileName respectively.  While in this "source" mode, you can drag variables from the Data list directly into the raw HTML.  They will resolve at runtime.  So, you can drag those two variables inside of the quotes for "src", and that should work for you.
        e) Of course, now, you can write your PDF using the HTMLToPDF and then WriteFile components in succession.

    If this doesn't work, make sure it's not something little like your BaseProjectToURL doesn't end in a slash or doesn't have a port number or something.  You should see the file getting copied to the project directory and you should be able to verify that it's there and can be hit with the full URL.  Also keep in mind permissions to do things like writing a file, especially with a published project where the Workflow is running under a limited ASPNET account.  Also keep in mind we haven't done anything to control the size of the image...you may end up with an image that is too big for the PDF and doesn't look right.  Good luck...