From 3eb7e9e3db0b8c66465896d9c27bcac184d40e58 Mon Sep 17 00:00:00 2001 From: Daseul Kim Date: Fri, 27 Jun 2025 14:50:11 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A7=80=EB=B6=95=EC=9E=AC=EC=A0=81?= =?UTF-8?q?=ED=95=A9=EC=84=B1=20pdf=20=EC=83=9D=EC=84=B1=EC=8B=9C=EA=B0=84?= =?UTF-8?q?=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/suitable/pdf/route.ts | 17 +++++++++ src/components/pdf/SuitablePdf.tsx | 61 ++++++++++++++++-------------- 2 files changed, 50 insertions(+), 28 deletions(-) diff --git a/src/app/api/suitable/pdf/route.ts b/src/app/api/suitable/pdf/route.ts index ccef573..af17c53 100644 --- a/src/app/api/suitable/pdf/route.ts +++ b/src/app/api/suitable/pdf/route.ts @@ -93,12 +93,14 @@ async function createSuitablePdf(request: NextRequest): Promise { /* pdf 생성 : mainId 100개씩 청크로 나누기 */ const CHUNK_SIZE = 100 const pdfBuffers: Uint8Array[] = [] + const createTime = formatDateString() for (let i = 0; i < suitable.length; i += CHUNK_SIZE) { const chunk = suitable.slice(i, i + CHUNK_SIZE) const content = React.createElement( Document, null, React.createElement(SuitablePdf, { + createTime, data: chunk, fileTitle: fileTitle, firstPage: i === 0, @@ -127,6 +129,21 @@ async function createSuitablePdf(request: NextRequest): Promise { } } +/** + * @description 날짜 포맷팅 + * @returns 날짜 포맷팅된 문자열 + */ +const formatDateString = () => { + const now = new Date() + const year = now.getFullYear() + const month = now.getMonth() + 1 + const day = now.getDate() + const hours = now.getHours() + const minutes = now.getMinutes() + + return `${year}年${month}月${day}日 ${hours}:${minutes.toString().padStart(2, '0')}` +} + /** * @description PDF 버퍼 병합 * @param buffers 병합할 PDF 버퍼 diff --git a/src/components/pdf/SuitablePdf.tsx b/src/components/pdf/SuitablePdf.tsx index e82c1e9..2d38b0a 100644 --- a/src/components/pdf/SuitablePdf.tsx +++ b/src/components/pdf/SuitablePdf.tsx @@ -47,9 +47,9 @@ const styles = StyleSheet.create({ display: 'flex', flexWrap: 'wrap', flexDirection: 'row', - gap: 20 + gap: 20, }, - tableCard:{ + tableCard: { width: '48.7%', }, tableTitWrap: { @@ -58,7 +58,7 @@ const styles = StyleSheet.create({ alignItems: 'center', marginBottom: 5, }, - tableTit:{ + tableTit: { fontSize: 8, fontWeight: 500, fontFamily: 'NotoSansJP', @@ -66,11 +66,11 @@ const styles = StyleSheet.create({ }, tableTit01: { paddingRight: 6, - borderRight: '1px solid #101010' + borderRight: '1px solid #101010', }, tableTit02: { padding: '0 6', - borderRight: '1px solid #101010' + borderRight: '1px solid #101010', }, tableTit03: { paddingLeft: 6, @@ -100,7 +100,7 @@ const styles = StyleSheet.create({ color: '#fff', backgroundColor: '#18B490', border: '1px solid #18B490', - textAlign: 'center' + textAlign: 'center', }, tableTd: { display: 'flex', @@ -113,10 +113,10 @@ const styles = StyleSheet.create({ border: '1px solid #CBCBCB', padding: 3, }, - marginL:{ + marginL: { marginLeft: -1, }, - marginT:{ + marginT: { marginTop: -1, }, footer: { @@ -134,20 +134,17 @@ const styles = StyleSheet.create({ }, }) -const formatDateString = () => { - const now = new Date() - const year = now.getFullYear() - const month = now.getMonth() + 1 - const day = now.getDate() - const hours = now.getHours() - const minutes = now.getMinutes() - - return `${year}年${month}月${day}日 ${hours}:${minutes.toString().padStart(2, '0')}` -} - -export default function SuitablePdf({ data, fileTitle, firstPage }: { data: Suitable[]; fileTitle: string; firstPage: boolean }) { - const createTime = formatDateString() - +export default function SuitablePdf({ + createTime, + data, + fileTitle, + firstPage, +}: { + createTime: string + data: Suitable[] + fileTitle: string + firstPage: boolean +}) { return ( {/* Intro Section */} @@ -185,19 +182,27 @@ export default function SuitablePdf({ data, fileTitle, firstPage }: { data: Suit {/* Table Header */} 金具タイプ - 金具名 + 金具名 設置可否 - 備考 + 備考 {/* Table Body */} {JSON.parse(item.detail)?.map((subItem: SuitableDetail) => ( - {item.roofShCd} - {subItem.trestleMfpcCd} - {subItem.trestleManufacturerProductName} - {subItem.memo} + + {item.roofShCd} + + + {subItem.trestleMfpcCd} + + + {subItem.trestleManufacturerProductName} + + + {subItem.memo} + ))}