Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

feat: add page numbers to pdfs

Brad Barbin8c6cd45bd827
diff --git a/packages/documents/src/pdf/IssuePDF.tsx b/packages/documents/src/pdf/IssuePDF.tsx
index 5519171812..b33646ba8d 100644
--- a/packages/documents/src/pdf/IssuePDF.tsx
+++ b/packages/documents/src/pdf/IssuePDF.tsx
@@ -3,7 +3,7 @@ import type { JSONContent } from "@carbon/react";
import { Text, View } from "@react-pdf/renderer";
import { createTw } from "react-pdf-tailwind";
import type { PDF } from "../types";
-import { Footer, Header, Note, Summary, Template } from "./components";
+import { Header, Note, Summary, Template } from "./components";
type ListItem = {
id: string;
@@ -99,6 +99,7 @@ const IssuePDF = ({
keywords: meta?.keywords ?? "issue report",
subject: meta?.subject ?? "Issue Report"
}}
+ footerLabel={`Issue #${nonConformance.nonConformanceId}`}
>
<View>
<Header title={title} company={company} />
@@ -442,7 +443,6 @@ const IssuePDF = ({
</View>
)}
</View>
- <Footer nonConformanceId={nonConformance.nonConformanceId} />
</Template>
);
};
diff --git a/packages/documents/src/pdf/KanbanLabelPDF.tsx b/packages/documents/src/pdf/KanbanLabelPDF.tsx
index c72a0e75aa..e4c2f26e5d 100644
--- a/packages/documents/src/pdf/KanbanLabelPDF.tsx
+++ b/packages/documents/src/pdf/KanbanLabelPDF.tsx
@@ -1,6 +1,7 @@
import { Document, Image, Page, Text, View } from "@react-pdf/renderer";
import { createTw } from "react-pdf-tailwind";
import { generateQRCode } from "../qr/qr-code";
+import Footer from "./components/Footer";
interface KanbanLabel {
id: string;
@@ -226,6 +227,7 @@ const KanbanLabelPDF = ({
</View>
))}
</View>
+ <Footer />
</Page>
))}
</Document>
diff --git a/packages/documents/src/pdf/ProductLabelPDF.tsx b/packages/documents/src/pdf/ProductLabelPDF.tsx
index f1e7829b86..188772bfd2 100644
--- a/packages/documents/src/pdf/ProductLabelPDF.tsx
+++ b/packages/documents/src/pdf/ProductLabelPDF.tsx
@@ -2,6 +2,7 @@ import type { LabelSize, ProductLabelItem } from "@carbon/utils";
import { Document, Image, Page, Text, View } from "@react-pdf/renderer";
import { createTw } from "react-pdf-tailwind";
import { generateQRCode } from "../qr/qr-code";
+import Footer from "./components/Footer";
interface ProductLabelProps {
items: ProductLabelItem[];
@@ -206,6 +207,7 @@ const ProductLabelPDF = ({ items, labelSize }: ProductLabelProps) => {
})}
</View>
))}
+ <Footer />
</Page>
))}
</Document>
diff --git a/packages/documents/src/pdf/components/Footer.tsx b/packages/documents/src/pdf/components/Footer.tsx
index b1c68f49be..048fbc092c 100644
--- a/packages/documents/src/pdf/components/Footer.tsx
+++ b/packages/documents/src/pdf/components/Footer.tsx
@@ -10,10 +10,10 @@ const tw = createTw({
});
interface FooterProps {
- nonConformanceId: string;
+ label?: string;
}
-const Footer = ({ nonConformanceId }: FooterProps) => {
+const Footer = ({ label }: FooterProps) => {
return (
<View style={tw("absolute bottom-0 left-0 right-0 px-10 pb-5")} fixed>
<View
@@ -21,7 +21,7 @@ const Footer = ({ nonConformanceId }: FooterProps) => {
"flex flex-row justify-between items-center text-sm text-gray-500"
)}
>
- <Text>Issue #{nonConformanceId}</Text>
+ <Text>{label ?? ""}</Text>
<Text
render={({ pageNumber, totalPages }) =>
`${pageNumber} of ${totalPages}`
diff --git a/packages/documents/src/pdf/components/Template.tsx b/packages/documents/src/pdf/components/Template.tsx
index 1d886f9be6..a49366e030 100644
--- a/packages/documents/src/pdf/components/Template.tsx
+++ b/packages/documents/src/pdf/components/Template.tsx
@@ -1,10 +1,15 @@
import { Document, Font, Page, StyleSheet } from "@react-pdf/renderer";
import type { PropsWithChildren } from "react";
import type { Meta } from "../../types";
+import Footer from "./Footer";
-type TemplateProps = PropsWithChildren<{ title: string; meta: Meta }>;
+type TemplateProps = PropsWithChildren<{
+ title: string;
+ meta: Meta;
+ footerLabel?: string;
+}>;
-const Template = ({ title, meta, children }: TemplateProps) => {
+const Template = ({ title, meta, footerLabel, children }: TemplateProps) => {
Font.register({
family: "Inter",
fonts: [
@@ -48,6 +53,7 @@ const Template = ({ title, meta, children }: TemplateProps) => {
>
<Page size="A4" style={styles.body}>
{children}
+ <Footer label={footerLabel} />
</Page>
</Document>
);