Question T12903
Visible to All Users

The header text appears above the header image when exporting a survey to a raw PDF

created 2 years ago (modified 2 years ago)

[Ticket cloned from T12849: SurveyJS PDF Creator questions - Render Text and Images in the Header and Footer section]

Thank you so much for the detailed explanation and examples.

I tested it and this works great using the "save" method, but when I try the "raw" method, the background image doesn't draw.

Comments (1)

    Hello Prashant,
    I tested my demo and noticed that the text appears above the image when exporting a survey to raw PDF (example).

    We will research this issue and post updates in the following GitHub thread: https://github.com/surveyjs/survey-pdf/issues/233.

    If you face another issue with exporting custom header content to raw PDF, please feel free to update this thread with a sample.

    Thank you

    Please look forward to our updates.

    Answers approved by surveyjs Support

    created 2 years ago

    Hello Prashant,
    The surveyPDF.save function returns a Promise. When a function returns a Promise, it means that the function is asynchronous and will not immediately return a value, but will instead return a Promise object that represents a future value. To correctly save a PDF document raw content in this case, you need to use the then() method of the Promise object to register a callback function that will be called when the Promise is resolved. Please update your code as follows to resolve the issue:

    JavaScript
    surveyPDFModel.save(filename).then(() => { surveyPDFModel.raw("bloburl").then(function(bloburl) { const a = document.createElement("a"); a.href = bloburl; a.download = "surveyViaBlob.pdf"; document.body.appendChild(a); a.click(); }); })

    The updated example is available at https://plnkr.co/edit/a4dzWSdzy7BDOkCn?preview.

    Let me know if you have any questions or require further assistance.

    Thanks