Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: update convert_pages to track portrait mode
Marc Seitza70de19f352b
diff --git a/pages/api/mupdf/convert-page.ts b/pages/api/mupdf/convert-page.tsindex 2e0a94d6..9abdb395 100644--- a/pages/api/mupdf/convert-page.ts+++ b/pages/api/mupdf/convert-page.ts@@ -61,6 +61,22 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {let page = doc.loadPage(pageNumber - 1); // 0-based page index+ if (pageNumber === 1) {+ // get the orientation of the document and update document version+ const bounds = page.getBounds();+ const [ulx, uly, lrx, lry] = bounds;++ const width = Math.abs(lrx - ulx);+ const height = Math.abs(lry - uly);++ const isVertical = height > width;++ await prisma.documentVersion.update({+ where: { id: documentVersionId },+ data: { isVertical },+ });+ }+// get linksconst links = page.getLinks();const embeddedLinks = links.map((link: any) => link.getURI());diff --git a/prisma/migrations/20240520000000_add_vertical_to_document_version/migration.sql b/prisma/migrations/20240520000000_add_vertical_to_document_version/migration.sqlnew file mode 100644index 00000000..32c3803d--- /dev/null+++ b/prisma/migrations/20240520000000_add_vertical_to_document_version/migration.sql@@ -0,0 +1,3 @@+-- AlterTable+ALTER TABLE "DocumentVersion" ADD COLUMN "isVertical" BOOLEAN NOT NULL DEFAULT false;+diff --git a/prisma/schema.prisma b/prisma/schema.prismaindex b12c59e7..a7553a0d 100644--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@ -158,6 +158,7 @@ model DocumentVersion {storageType DocumentStorageType @default(VERCEL_BLOB)numPages Int? // This should be a reference to the number of pages in the documentisPrimary Boolean @default(false) // Indicates if this is the primary version+ isVertical Boolean @default(false) // Indicates if the document is vertical (portrait) or not (landscape)fileId String? // This is the file ID of the OpenAI File APIpages DocumentPage[]hasPages Boolean @default(false) // Indicates if the document has pages