0

I have seen many discussions on how to display a PDF file within a embedded form ( User Task ) But realised camunda does not support this. Are there any solutions?

I have tried using IFrame, Object, embed , and directly linking to a variable did not work ?

1 Answer 1

1

My solution is to fetch the variable and convert to a blob as follows:

HTML

<embed  class="col-sm-12" style="height:100vh;width:100%" type="application/pdf" id="pdf-frame">

JS

  <script cam-script type="text/javascript">


camForm.on('form-loaded', function () {
        fetch("http://localhost:8181/camunda/api/engine/engine/default/task/" + camForm.taskId + "/variables/ACORD_FORM/data").then(function (response) {
            return response.blob();
        }).then(function (myBlob) {
            var objectURL = URL.createObjectURL(myBlob);
            document.querySelector('#pdf-frame').src = '';
            document.querySelector('#pdf-frame').src = objectURL;
            objectURL = URL.revokeObjectURL(myBlob);
        });

});
</script>
Sign up to request clarification or add additional context in comments.

2 Comments

Hi, i've recently tried your solution, but unfortunately it is not working as expected. The pdf is not parsed correctly. Did you update your solution ?. What was the version of camunda you where using ? Thank you in advance
Hi @aless239, this was using version 7.13. For non related reasons, I changed the way I treat a PDF. I created a custom function to upload a PDF to base64 then save it to a camunda process variable. I then convert the base64 to a blob.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.