# Write Responses To File PDF example Not Working

**URL:** <https://community.postman.com/t/write-responses-to-file-pdf-example-not-working/60645>\
**Category:** Help Hub\
**Tags:** local-files, pdf\
**Created:** [May 3, 2024, 8:04pm UTC](https://community.postman.com/t/write-responses-to-file-pdf-example-not-working/60645 "2024-05-03T20:04:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickboehm](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nickboehm](https://community.postman.com/u/nickboehm)\
**Post date:** [May 3, 2024, 8:04pm UTC](https://community.postman.com/t/write-responses-to-file-pdf-example-not-working/60645/1 "2024-05-03T20:04:14Z")

</div>

So the question has been asked a few times, but I have tried all the documentation regarding Write Responses To File, testing with dummy requests, and my team is getting the same error listed in

> [@Save PDF response body as local file using Postman collection \[\*\*Write Response to File\*\*\] DOSEN'T work](https://community.postman.com/t/save-pdf-response-body-as-local-file-using-postman-collection-write-response-to-file-dosent-work/39230):
>
> 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: but the file is blank when you open it. My response body is a invoice which looks like this: And The opts for the server: let dataToFile = { requestName: request.name || request.url, fileExtension: ‘pdf’, mode: ‘write…

Does anyone have any help that they can give on this? For this, we have an API endpoint that will give us a binary or PDF conversion of the output much like Dummy Request 1. The Write Responses To File collection postscript works and will export the JSON. The issue seems to be trying to get it to save as a pdf in Dummy Request 1. Looking at my terminal when the postscript runs from Dummy Request 1, I see the following Error [ERR\_INVALID\_ARG\_TYPE]: The “data” argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined. Dummy Request 2 has an output.

Can anyone assist on getting Dummy Request 1 working as the URL may no longer point to a valid PDF anymore. Despite that, the case linked above using the same tools also has the same issue on their end, specifically around PDF being written to the local server.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [June 2, 2024, 8:05pm UTC](https://community.postman.com/t/write-responses-to-file-pdf-example-not-working/60645/2 "2024-06-02T20:05:11Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
