Shikha Gupta
Shikha Gupta

Reputation: 19

Creating a ppt or pptx blob from byteArray in typescript/angular 2

I need to convert my byteArray response into ppt Blob Object to create a .ppt/.pptx file in Angular 2. I am able to convert to image and pdf formats. But I need specifically for ppt and pptx formats.

var blob = new Blob(resp, {type: 'application/pdf'});

AS above, what is the type to be given for ppt or pptx conversion?

Please mention if I need to add more details.

Upvotes: 0

Views: 4389

Answers (2)

Bullsized
Bullsized

Reputation: 607

If someone finds this and wants to typify it in someway for TypeScript, here's my approach:

export type ReportGenerationFormat = 'PPT' | 'WORD' | 'PDF';

interface ReportFileType {
  extension: string;
  mimeType: string;
}

/**
 * File name extensions and their MIME Types.
 * PPT is a proprietary format before PowerPoint 2007.
 * PPTX is an open format since PowerPoint 2007.
 * PDF is self-explanatory.
 * DOC is a Microsoft document before Word 2007.
 * DOCX is a Microsoft Word document.
 */
export const ReportFileTypes: Record<string, ReportFileType> = {
  PPT: { extension: '.ppt', mimeType: 'application/vnd.ms-powerpoint' },
  PPTX: { extension: '.pptx', mimeType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation' },
  PDF: { extension: '.pdf', mimeType: 'application/pdf' },
  DOC: { extension: '.doc', mimeType: 'application/msword' },
  DOCX: { extension: '.docx', mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' },
};

And then all you have to do is import that constant and utilise it with the fileType, like so: ReportFileTypes[fileType].mimeType

Upvotes: 0

Badacadabra
Badacadabra

Reputation: 8507

You are looking for Microsoft PowerPoint MIME Types:

  • .ppt (proprietary format before PowerPoint 2007)

application/vnd.ms-powerpoint

  • .pptx (open format since PowerPoint 2007)

application/vnd.openxmlformats-officedocument.presentationml.presentation

Upvotes: 3

Related Questions