From 69d71535b231a707b22cbb6f14c6ca906f13c72e Mon Sep 17 00:00:00 2001 From: Kubosaka Date: Fri, 11 Aug 2023 14:33:08 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=E3=82=B3=E3=83=BC=E3=83=89=E6=95=B4?= =?UTF-8?q?=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/utils/createPurchaseOrderPdf.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/view/next-project/src/utils/createPurchaseOrderPdf.ts b/view/next-project/src/utils/createPurchaseOrderPdf.ts index 305f0be6..618ddae9 100644 --- a/view/next-project/src/utils/createPurchaseOrderPdf.ts +++ b/view/next-project/src/utils/createPurchaseOrderPdf.ts @@ -9,6 +9,10 @@ export const createPurchasOrderFormPdf = async ( ) => { const pdfDoc = await PDFDocument.create(); pdfDoc.registerFontkit(fontkit); + // A4サイズのpdf作成 + const page = pdfDoc.addPage([595.28, 841.89]); + const { width, height } = page.getSize(); + // フォント「ナス」 const fontData = await pdfDoc.embedFont( await (await fetch('./fonts/Nasu-Regular.ttf')).arrayBuffer(), @@ -34,12 +38,10 @@ export const createPurchasOrderFormPdf = async ( return fontSizes[0]; } }; - // A4サイズのpdf作成 - const page = pdfDoc.addPage([595.28, 841.89]); - const { width, height } = page.getSize(); - //フォントのサイズ const fontSizes = [12, 24]; + + // 内容の作成ここから page.drawText('資料番号', { x: 25, y: height - 35, @@ -447,10 +449,9 @@ export const createPurchasOrderFormPdf = async ( }); } }); - + // 内容の作成ここまで // 生成されたPDFデータを取得 const pdfBytes = await pdfDoc.save(); - // Blobを作成 const blob = new Blob([pdfBytes], { type: 'application/pdf' }); return blob;