# Save PDF response body as local file using Postman collection \[\*\*Write Response to File\*\*\] DOSEN'T work

**URL:** <https://community.postman.com/t/save-pdf-response-body-as-local-file-using-postman-collection-write-response-to-file-dosent-work/39230>\
**Category:** Help Hub\
**Created:** [September 19, 2022, 8:10am UTC](https://community.postman.com/t/save-pdf-response-body-as-local-file-using-postman-collection-write-response-to-file-dosent-work/39230 "2022-09-19T08:10:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![science-specialist-6](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@science-specialist-6](https://community.postman.com/u/science-specialist-6)\
**Post date:** [September 19, 2022, 8:10am UTC](https://community.postman.com/t/save-pdf-response-body-as-local-file-using-postman-collection-write-response-to-file-dosent-work/39230/1 "2022-09-19T08:10:33Z")

</div>

Hi!  
I need to save a PDF response as a local file and for that I used [[**Write Response to File**]](https://www.postman.com/postman/workspace/postman-answers/collection/3407886-888860dd-9e3c-4537-a78e-1c3f3db7535c?ctx=documentation) and it works fine for those two Dummy files (Dummy Request 1 and Dummy Request 2) comming with the collection. But for my request it creates a pdf file:

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/e/e6d99756f54bc5da3de6671a8784f14337ab0fca.png)  
but the file is blank when you open it.

My response body is a invoice which looks like this:

 ![PDFresponse](https://us1.discourse-cdn.com/getpostman/original/2X/f/fb98df573ad692e2560e71872831dd35a3ecd4eb.png)

And The opts for the server:  
let dataToFile = {  
requestName: request.name || request.url,  
fileExtension: ‘pdf’,  
mode: ‘writeFile’, // Change this to any function of the fs library of node to use it.  
uniqueIdentifier: false,  
responseData: pm.response.text()  
};  
pm.sendRequest({  
url: ‘[http://localhost:3000/write](http://localhost:3000/write)’,  
method: ‘POST’,  
header: ‘Content-Type:application/json’,  
body: {  
mode: ‘raw’,  
raw: JSON.stringify(dataToFile)  
}  
}, function(err, res) {  
console.log(res);  
});

Just to mention if I change header: ‘Content-Type:application/json’, to ‘Content-Type:application/pdf’ it dosen’t works att all.

Thank you very much in advance!
