Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature Pad - Export a Signature to PDF instead of a question name (e.g., 'signature') #376

Open
JaneSjs opened this issue Nov 2, 2023 · 2 comments
Assignees
Labels
enhancement user issue An issue or bug reported by users

Comments

@JaneSjs
Copy link
Contributor

JaneSjs commented Nov 2, 2023

return questionName;

User Issue: T15237 - COMO DESCARGAR LAS PDF Y EXCEL CON IMAGENES
https://surveyjs.answerdesk.io/internal/ticket/details/T15237

Tabulator appears as follows:
image

Current output after exporting a Tabulator to PDF:
image

Expected output: signature images appear in PDF.

@JaneSjs JaneSjs added enhancement user issue An issue or bug reported by users labels Nov 2, 2023
@tsv2013 tsv2013 self-assigned this Nov 7, 2023
@tsv2013
Copy link
Member

tsv2013 commented Nov 16, 2023

I used the following code:

        if(question instanceof QuestionSignaturePadModel) {
          return this.currentDownloadType === "pdf" && !!dataCell ? `<img-${question.signatureWidth}-${question.signatureHeight}>${dataCell}` : questionName;
        }

in the accessorDownload function.
And this code in the defaultDownloadOptions:

        didParseCell: function(data) {
          if (data && data.cell.raw.content) {
            const hasImagePrefix = (data.cell.raw.content || "").substring(0, 5) === "<img-";
            if(hasImagePrefix) {
              data.cell.height = 200;
            }
          }
        },
        willDrawCell: function(data) {
          if (data && data.cell.raw.content) {
            const hasImagePrefix = (data.cell.raw.content || "").substring(0, 5) === "<img-";
            if(hasImagePrefix) {
              const imagePreficIndex = data.cell.raw.content.indexOf(">");
              const imageUrl = data.cell.raw.content.substring(imagePreficIndex+1);
              if(!!imageUrl) {
                const dims = data.cell.raw.content.substring(5, imagePreficIndex).split("-");
                // var dim = data.cell.height - data.cell.padding("vertical");
                doc.addImage(imageUrl, data.cell.x, data.cell.y, Number.parseInt(dims[0]), Number.parseInt(dims[1]));
                data.cell.contentWidth = data.cell.width;
                data.cell.contentHeight = Number.parseInt(dims[1]);
                data.row.maxCellHeight = Object.keys(data.row.cells).reduce((a, key) => Math.max(a, data.row.cells[key].height), 0);
                data.row.height = data.row.maxCellHeight;
                return false;
              }
            }
          }
        }

But I still have the problem: table row height still remains large (as it was calculated for lerge base64 text). Right now I've not found a quick solution for it.

tsv2013 pushed a commit that referenced this issue Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement user issue An issue or bug reported by users
Projects
None yet
Development

No branches or pull requests

2 participants