This project converts PDF files to Markdown format using Google Drive API. It uploads a PDF file to Google Drive, converts it to a Google Doc, and then exports it as a Markdown file.
- Node.js installed on your machine
- A Google Cloud Platform account
- A Google Drive API enabled project
- A service account with access to Google Drive API
-
Clone this repository to your local machine.
-
Install dependencies:
pnpm install
-
Create a
keys.json
file in the root directory of the project with your service account credentials. -
Create a new Google Drive folder and share it with the service account email address found in your
keys.json
file. This step is crucial for the service account to have the necessary permissions. -
Place your PDF file in the project root and name it
sample-invoice.pdf
, or update the code to use your desired filename.
Run the script using the following command:
pnpm dev
The script will:
- Upload the PDF file to Google Drive
- Convert it to a Google Doc
- Export the Google Doc as a Markdown file
- Save the Markdown file as
sample-invoice.md
in the project root
You can modify the src/index.ts
file to change:
- Input and output file names
- Google Drive folder location
- Timing and logging preferences
If you encounter permission issues, make sure:
- The Google Drive API is enabled in your Google Cloud Console
- The service account has the necessary permissions
- You've shared the Google Drive folder with the service account email