diff --git a/apps/server/src/modules/files-storage/interface/preview-input-mime-types.enum.ts b/apps/server/src/modules/files-storage/interface/preview-input-mime-types.enum.ts index 495096c8359..20c24b65fd1 100644 --- a/apps/server/src/modules/files-storage/interface/preview-input-mime-types.enum.ts +++ b/apps/server/src/modules/files-storage/interface/preview-input-mime-types.enum.ts @@ -8,4 +8,5 @@ export enum PreviewInputMimeTypes { IMAGE_HEIF = 'image/heif', IMAGE_TIFF = 'image/tiff', IMAGE_WEBP = 'image/webp', + APPLICATION_PDF = 'application/pdf', } diff --git a/apps/server/src/shared/infra/preview-generator/preview-generator.service.ts b/apps/server/src/shared/infra/preview-generator/preview-generator.service.ts index 72dac25f076..a12fed2517d 100644 --- a/apps/server/src/shared/infra/preview-generator/preview-generator.service.ts +++ b/apps/server/src/shared/infra/preview-generator/preview-generator.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@nestjs/common'; import { GetFile, S3ClientAdapter } from '@shared/infra/s3-client'; import { Logger } from '@src/core/logger'; +import { PreviewInputMimeTypes } from '@src/modules/files-storage/interface'; import { subClass } from 'gm'; import { PassThrough } from 'stream'; import { PreviewFileOptions, PreviewOptions, PreviewResponseMessage } from './interface'; @@ -45,6 +46,10 @@ export class PreviewGeneratorService { const preview = this.imageMagick(original.data); + if (original.contentType === PreviewInputMimeTypes.APPLICATION_PDF) { + preview.selectFrame(0); + } + if (width) { preview.resize(width, undefined, '>'); }