Khalil Meg
Khalil Meg

Reputation: 781

how to download google docs document exported as pdf from terminal using wget or curl

I'm trying to download my master thesis from google docs as a pdf file..

The ui method (pdf > download > PDF document) fails because of internet connection and the size of the document which is quite big.

I want to download it using wget command from a Linux server which had a good internet connection, I tried a lot of solutions such this one, but they didn't work..

any help please!

Upvotes: 0

Views: 803

Answers (1)

Jacques-Guzel Heron
Jacques-Guzel Heron

Reputation: 2598

If your server can access the user interface of Docs I strongly recommend you to download the PDF with it to save complexity. If the server doesn't offer that option you could use this curl command below to capture Files.export() from Drive API.

curl \
  'https://www.googleapis.com/drive/v3/files/{DOC ID}/export?mimeType=application%2Fpdf' \
  --header 'Authorization: Bearer {ACCESS TOKEN}' \
  --header 'Accept: application/json' \
  --compressed >> Doc.pdf

You'll need an access token for a single use, so could use OAuth 2.0 Playground to generate one by selecting the https://www.googleapis.com/auth/drive scope and clicking on Exchange authorization code for tokens.

Upvotes: 2

Related Questions