diff --git a/src/api/config.ts b/src/api/config.ts index 72689ea..8a3f1f4 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -265,5 +265,5 @@ export const HIDDEN_FORM_FIELDS = [ ]; export const SELECT_OPTION_LIMIT = 200; -export const PDF_MAX_SKUS_PER_CHUNK = 20; +export const PDF_MAX_SKUS_PER_CHUNK = 50; diff --git a/src/screens/DailySalesReportPage.tsx b/src/screens/DailySalesReportPage.tsx index 736b508..c66417c 100644 --- a/src/screens/DailySalesReportPage.tsx +++ b/src/screens/DailySalesReportPage.tsx @@ -48,7 +48,11 @@ export function DailySalesReportPage() { }, []); const generatePdfDoc = () => { - const doc = new jsPDF('landscape'); + const totalSkus = reportData?.response?.headers?.reduce((acc: number, h: any) => acc + (h.skus?.length || 0), 0) || 0; + const maxSkusOnPage = Math.min(totalSkus, PDF_MAX_SKUS_PER_CHUNK); + const requiredWidth = Math.max(297, (maxSkusOnPage + 3) * 12 + 40); + + const doc = new jsPDF({ orientation: 'landscape', format: [requiredWidth, 210] }); const pageWidth = doc.internal.pageSize.getWidth(); const centerX = pageWidth / 2; const rightMargin = pageWidth - 14;