Base64 Visualization

HI i have an api-call where i get a base64 string in the response - this base64 string is a valid pdf and i would like to show the pdf directly in the visualization tab.

### POST-RESPONSE ###
const template = `
<div style="max-width: 700px; margin: 0 auto;">
  <h3>PDF Preview from Response</h3>
  {{#if pdfData}}
    <iframe id="pdfFrame" width="100%" height="600" style="border:1px solid #ccc;" src="data:application/pdf;base64,{{pdfData}}"></iframe>
    <p><b>Filename:</b> {{filename}}<br><b>MIME Type:</b> {{mime_type}}</p>
    <p><b>Base64 Data Length:</b> {{base64Length}}</p>
    <a id="downloadLink" href="data:application/pdf;base64,{{pdfData}}" download="{{filename}}" style="display:inline-block;margin:10px 0;padding:8px 16px;background:#007bff;color:#fff;text-decoration:none;border-radius:4px;">Download PDF</a>
    {{#unless hasData}}
      <p style='color: red;'><b>Warning:</b> PDF base64 data is missing or empty!</p>
    {{/unless}}
  {{else}}
    <p>No PDF data found in response.</p>
  {{/if}}
</div>
`;

const json = pm.response.json();
const result = json.results?.[0] || {};
const pdfData = result.data || null;
const base64Length = pdfData ? pdfData.length : 0;
const hasData = !!(pdfData && pdfData.length > 0);

pm.visualizer.set(template, {
  pdfData: pdfData,
  filename: result.filename || "output.pdf",
  mime_type: result.mime_type || "application/pdf",
  base64Length: base64Length,
  hasData: hasData
});

### RESPONSE ###
{“custom_result_data”: null,“job_id”: 370959,“job_status”: 8,“message”: “Job finished successfully with trace”,“results”: [{“data”: “BASE64_RESPONSE”,“filename”: “output.pdf”,“mime_type”: “application/pdf”}]}

so i created a post-response script but somehow, it still doesnt show the pdf - can you help me?

Try instead of

{{#if pdfData}}

{{#unless hasData}}
Warning: PDF base64 data is missing or empty!
{{/unless}}
{{else}}

No PDF data found in response.

{{/if}}

use

{{#if hasData}}

{{else}}

Warning: PDF base64 data is missing or empty!

{{/if}}