How to Export a PDF from Google Doc and Import it into Airtable?

This topic was automatically generated from Slack. You can find the original thread here.

Hi there, anyone has an idea, how i can export a pdf from google doc to import it into airtable? in make you get an export variant that ends up with “.pdf”. pipedream only offers what google offers and this seems to be the link with the document id. my problem is, that airtable does not work with it.

Hi, I think your question is a great case for Pipedream bot to help. I’ll pass your question to the Pipedream bot now. Please feel free to ask it any question

Hi there, anyone has an idea, how i can export a pdf from google doc to import it into airtable? in make you get an export variant that ends up with “.pdf”. pipedream only offers what google offers and this seems to be the link with the document id. my problem is, that airtable does not work with it.

To export a PDF from Google Docs and import it into Airtable, you can follow these steps in a Pipedream workflow: 1. Use the Google Drive API to export the Google Doc as a PDF. You’ll need the document ID for this step. Here’s an example code snippet for exporting the Google Doc as a PDF: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google: { type: "app", app: "google", }, documentId: { type: "string", label: "Google Document ID", }, }, async run({ steps, $ }) { const response = await axios($, { method: "GET", url: `https://www.googleapis.com/drive/v3/files/${this.documentId}/export`, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, params: { mimeType: "application/pdf", }, responseType: "arraybuffer", }); return { pdfData: response.data.toString("base64") }; }, }); 2. Use the Airtable API to upload the PDF as an attachment to a record. You’ll need the Airtable API key, base ID, and table name for this step. Here’s an example code snippet for uploading the PDF to Airtable: ``` import { axios } from “@pipedream/platform”; export default defineComponent({ props: { airtableApiKey: { type: “string”, label: “Airtable API Key”, }, baseId: { type: “string”, label: “Airtable Base ID”, }, tableName: { type: “string”, label: “Airtable Table Name”, }, pdfData: { type: “string”, label: “PDF Data (Base64 Encoded)”, }, }, async run({ steps, $ }) { const response = await axios($, { method: “POST”, url: https://api.airtable.com/v0/${this.baseId}/${encodeURIComponent(this.tableName)}, headers: { Authorization: Bearer ${this.airtableApiKey}, “Content-Type”: “application/json”, }, data: { fields: { Attachments: [ { url: `data:application/pdf

I would like to use Pipedream’s existing Google Doc and Airtable actions instead of code action

Sure, you can use Pipedream’s existing Google Docs and Airtable actions to achieve your goal. Here’s a step-by-step guide: 1. Create a new Pipedream workflow. 2. Add a Google Docs action to your workflow. Search for “Google Docs” in the actions panel and select the “Export Google Doc” action. 3. Configure the “Export Google Doc” action by providing the required Google Document ID and selecting “application/pdf” as the export format. 4. Add an Airtable action to your workflow. Search for “Airtable” in the actions panel and select the “Create record” action. 5. Configure the “Create record” action by providing your Airtable API Key, Base ID, and Table Name. In the fields section, add a new field for Attachments and use the following format for the URL: data:application/pdf;base64,${steps.export_google_doc.outputs.pdfData}. Replace export_google_doc with the actual step name of the “Export Google Doc” action if it’s different. This workflow will export the Google Doc as a PDF and upload it as an attachment to a new record in the specified Airtable table.

Pipedream doesn’t have “Export Google Doc” action

You’re right, Pipedream doesn’t have a specific “Export Google Doc” action. However, you can still achieve this by using a custom code step with the Google Drive API to export the Google Doc as a PDF. Here’s a code snippet that you can use in a Pipedream code step: import { axios } from "@pipedream/platform"; export default defineComponent({ props: { google: { type: "app", app: "google", }, documentId: { type: "string", label: "Google Document ID", }, }, async run({ steps, $ }) { const response = await axios($, { method: "GET", url: `https://www.googleapis.com/drive/v3/files/${this.documentId}/export`, headers: { Authorization: `Bearer ${this.google.$auth.oauth_access_token}`, }, params: { mimeType: "application/pdf", }, responseType: "arraybuffer", }); return { pdfData: response.data.toString("base64") }; }, }); This code step exports the Google Doc as a PDF and returns the PDF data as a base64-encoded string. You can then use this data to upload the PDF to Airtable using the “Create record” action. In the Attachments field, use the following format for the URL: data:application/pdf;base64,${steps.export_google_doc.outputs.pdfData}. Replace export_google_doc with the actual step name of the code step if it’s different.

Hi , I think @U05A7KLNALC answer makes sense, would you mind giving it a try?

I’m glad the answer makes sense to you. However, as an AI language model, I’m unable to execute code or create workflows directly. You can follow the provided code snippet and instructions to implement the solution in your own Pipedream workflow. If you have any questions or need further assistance, feel free to ask.

hi , thanks for your help. i already did all this. the problem is, that google only outputs something in the format export=download?id=blablabla … in airtable i cannot upload it successfully. i need a real pdf file. make provides this, maybe by doing some things at their webservers, i don´t know. i tried the whole day - supported by chatGPT - and now my workaround is to upload it via sftp (in make) to a website and download it from there. but of course a not really elegant way…