Best way to create a PDF file from read-binary returned from a GET API call

I’m trying to connect Rossum with Airtable and I need to retrieve the PDF from Rossum so I can upload it to Airtable. Rossum doesn’t allow me to download the file with the URL even after I get a token. When I GET the file content, its shows up as what I’ve figured out is read-binary(it starts with %PDF-1.4). I need to create a PDF file from this and store it with a publicly accessible URL that I can pass so that Airtable can download it.

If I store it in the TMP, will it be publicly accessible? Is there some kind of parameter I can put on the GET request to give me a file instead of the code? Is the only option to run a code step to create my PDF? (I’m just getting into this and I don’t know what I don’t know!). Thanks

Im trying to achieve the same kind of thing. Did you ever figure this out?

Hello @rcollins, @joe1,

Apologize for the late response. I think if you got the binary, then you can save it as a file into the /tmp dir. I would not recommend you to depend on Pipedream’s /tmp dir, as it is a temporary storage and will be deleted anytime, I would suggest you to upload it to a Cloud Storage provider such as Google Drive.

Hi @vunguyenhung,

I’ve managed to write the binary to a pdf document which saves in the /tmp dir and then uploads to google cloud storage. However the pdf document that gets uploaded always only contains blank pages. Do you know why this might be?

The code I’m using:

import fs from "fs";
import { file } from 'tmp-promise';

export default defineComponent({
  async run({ steps, $ }) {
    const { path, cleanup } = await file({ name: 'test.pdf' });
    const binaryData = steps.get_request.$return_value; // My binary data
    await fs.promises.writeFile(path, Buffer.from(binaryData));
  }
});

Hi @joe1,

However the pdf document that gets uploaded always only contains blank pages. Do you know why this might be?

I think it might because the binary returned by Rossum is in a custom PDF format, the next action is to contact their customer support to see how you can use the binary data returned from their API. Asking them for a demo if possible :pray:

I think I’ve gotten to the same point as @joe1 . Through what feels like 100 ChatGPT edits of the code. If I make the same GET request in Postman, it gives me a regular PDF. I am able to see the same binary code but it “renders” the PDF in a preview and I can download the PDF and it’s normal. It will time out when I think I’ve got the code right.