# Base64 Visualization

**URL:** <https://community.postman.com/t/base64-visualization/86286>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [October 28, 2025, 7:42am UTC](https://community.postman.com/t/base64-visualization/86286 "2025-10-28T07:42:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsepa3](https://avatars.discourse-cdn.com/v4/letter/n/b782af/32.png) [@nsepa3](https://community.postman.com/u/nsepa3)\
**Post date:** [October 28, 2025, 7:42am UTC](https://community.postman.com/t/base64-visualization/86286/1 "2025-10-28T07:42:46Z")

</div>

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.

```auto
### 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?

---

<div class="post-metadata">

**Author:** ![stryderhiryu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/stryderhiryu/32/34043_2.png) [@stryderhiryu](https://community.postman.com/u/stryderhiryu)\
**Post date:** [October 28, 2025, 8:45am UTC](https://community.postman.com/t/base64-visualization/86286/2 "2025-10-28T08:45:53Z")

</div>

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}}
