Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

299
Vistas
google drive api, export google slide as power point (ppt or pptx) - node.js

I want to use the google apis to download a google slide as a power point presentation (ppt or pptx) to our node.js server. I have setup google drive api, and I have created a slide in my drive folder. I'm trying to use drive.files.export to download the slide, but since a slide isn't really a thing on windows or mac, I am trying to convert it to power point by setting the mimeType to application/vnd.ms-powerpoint:

  const { drive } = await Google.getInstance();
  const fileId = 'SomeLongTemplateId';
  const fileName = 'test slide processing';
  console.log('exporting ppt');
  const ppt = await drive.files.export(  // report.js:343
    { fileId, mimeType: 'application/vnd.ms-powerpoint' },
    { responseType: 'arraybuffer' }
  );
  return Buffer.from(ppt.data);

However, this throws and error and doesn't seem to work:

error: {
    message: ArrayBuffer {
      [Uint8Contents]: <7b 0a 20 22 65 72 72 6f 72 22 3a 20 7b 0a 20 20 22 65 72 72 6f 72 73 22 3a 20 5b 0a 20 20 20 7b 0a 20 20 20 20 22 64 6f 6d 61 69 6e 22 3a 20 22 67 6c 6f 62 61 6c 22 2c 0a 20 20 20 20 22 72 65 61 73 6f 6e 22 3a 20 22 62 61 64 52 65 71 75 65 73 74 22 2c 0a 20 20 20 20 
22 6d 65 73 73 61 67 65 22 3a 20 ... 195 more bytes>,
      byteLength: 295
    },
    stack: 'Error: [object ArrayBuffer]\n' +
      '    at Gaxios._request (C:\\Users\\rasmu\\Documents\\triggerz\\triggerz\\node_modules\\gaxios\\build\\src\\gaxios.js:129:23)\n' +
      '    at processTicksAndRejections (internal/process/task_queues.js:95:5)\n' +
      '    at async JWT.requestAsync (C:\\Users\\rasmu\\Documents\\triggerz\\triggerz\\node_modules\\google-auth-library\\build\\src\\auth\\oauth2client.js:345:18)\n' +
      '    at async processionSlide (C:\\Users\\rasmu\\Documents\\triggerz\\triggerz\\entity-access\\src\\act\\report.js:343:15)'
  },

Unfortunately, it doesn't really say what the problem is, but it definitely doesn't work. I have also tried exporting as pptx using the mimeType application/vnd.openxmlformats-officedocument.presentationml.presentation but this gave a similar error.

I am used to export pdf's using this technique, and it works like a charm, the only difference is that I export a doc (google docs) and use the mimeType application/pdf

In the web UI of google drive, I can right-click on the slide and choose "download" this, downloads a pptx file that I can open with both MS power point and Libre office. - so it would surprise me a lot is the google node.js api library can't export in the same manner.

Any ideas how I can export a slide as a presentation that works on windows/mac ?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can try replacing you responseType to stream as recommended in this reference: google api nodejs client [Help] Google Drive export example not working

const ppt = await drive.files.export(  // report.js:343
    { fileId, mimeType: 'application/vnd.ms-powerpoint' },
    { responseType: 'stream' }
  )

One workaround that I could suggest if the solution above still fails is to use Drive.Files.Get, Get the file resource you your Google Slide file using its file id. Then get the exportLinks of your preferred mimeType.

Sample (API explorer):

enter image description here

Response:

{
 "name": "Untitled presentation",
 "exportLinks": {
  "application/vnd.oasis.opendocument.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=13vwP4xQ_nVAHCPCuXI3GQKhMJrQ5goTfX7mh6qP5fKM&exportFormat=odp&resourcekey=0-nwpcI7sa0wRmreOT5Z6RJg",
  "application/pdf": "https://docs.google.com/feeds/download/presentations/Export?id=13vwP4xQ_nVAHCPCuXI3GQKhMJrQ5goTfX7mh6qP5fKM&exportFormat=pdf&resourcekey=0-nwpcI7sa0wRmreOT5Z6RJg",
  "application/vnd.openxmlformats-officedocument.presentationml.presentation": "https://docs.google.com/feeds/download/presentations/Export?id=13vwP4xQ_nVAHCPCuXI3GQKhMJrQ5goTfX7mh6qP5fKM&exportFormat=pptx&resourcekey=0-nwpcI7sa0wRmreOT5Z6RJg",
  "text/plain": "https://docs.google.com/feeds/download/presentations/Export?id=13vwP4xQ_nVAHCPCuXI3GQKhMJrQ5goTfX7mh6qP5fKM&exportFormat=txt&resourcekey=0-nwpcI7sa0wRmreOT5Z6RJg"
 }
}
  • Access the export link using application/vnd.openxmlformats-officedocument.presentationml.presentation as key. Download the file using the link.
about 4 years ago · Juan Pablo Isaza Denunciar

0

Issue and workaround:

Unfortunately, it seems that in the current stage, when I saw the exportFormats with "About: get" of Drive API, the mimeType of application/vnd.google-apps.presentation (Google Slides) can be exported to the following mimeTypes.

"application/vnd.google-apps.presentation": [
  "application/vnd.oasis.opendocument.presentation",
  "application/pdf",
  "application/vnd.openxmlformats-officedocument.presentationml.presentation",
  "text/plain"
],

By this, it seems that when the export method is used, Google Slides cannot be exported as application/vnd.ms-powerpoint. By this, when I tested this, the error occurs. But from above exportFormats, it is found that when the mimeType of application/vnd.openxmlformats-officedocument.presentationml.presentation is used, the Google Slides can be exported as PPTX.

But from your question, you say as follows.

Unfortunately, it doesn't really say what the problem is, but it definitely doesn't work. I have also tried exporting as pptx using the mimeType application/vnd.openxmlformats-officedocument.presentationml.presentation but this gave a similar error.

When I tested your script using the mimeType of application/vnd.openxmlformats-officedocument.presentationml.presentation, no error occurs. So please modify your script as follows and test it again.

Modified script:

const fileId = 'SomeLongTemplateId';
const fileName = "test slide processing";
console.log("exporting ppt");
const ppt = await drive.files.export(
  {
    fileId: fileId,
    mimeType: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
  },
  { responseType: "arraybuffer" }
);
fs.writeFile("sample.pptx", Buffer.from(ppt.data), (err) => {
  if (err) console.log(err);
});

// return Buffer.from(ppt.data);
  • When I tested this modified script, I could confirm that the file of sample.pptx can be created and the file can be opened as PPTX file.

Reference:

  • About: get
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda