You can use as @David-Kucsai told in comment @david.kucsai/react-pdf-table

or without using

Example

Data

const data = {
  id: "5df3180a09ea16dc4b95f910",
  items: [
    {
      sr: 1,
      desc: "desc1",
      xyz: 5,
    },
    {
      sr: 2,
      desc: "desc2",
      xyz: 6,
    },
  ],
};

app.js

import React, { Component, Fragment } from "react";
import { PDFViewer } from "@react-pdf/renderer";
import Table from "./components/reports/Table";
import data from "./data";

class App extends Component {
  render() {
    return (
      <Fragment>
        <PDFViewer width="1000" height="600">
          <Table data={data} />
        </PDFViewer>
      </Fragment>
    );
  }
}

export default App;

Table.js

import React from "react";
import { Page, Document, StyleSheet } from "@react-pdf/renderer";
import ItemsTable from "./ItemsTable";

const styles = StyleSheet.create({
  page: {
    fontSize: 11,
    flexDirection: "column",
  },
});

const Table = ({ data }) => (
  <Document>
    <Page size="A4" style={styles.page}>
      // ...
      <ItemsTable data={data} />
      // ...
    </Page>
  </Document>
);

export default Table;

ItemsTable.js

import React from "react";
import { View, StyleSheet } from "@react-pdf/renderer";
import TableRow from "./TableRow";

const styles = StyleSheet.create({
  tableContainer: {
    flexDirection: "row",
    flexWrap: "wrap",
  },
});

const ItemsTable = ({ data }) => (
  <View style={styles.tableContainer}>
    {/*<TableHeader />*/}
    <TableRow items={data.items} />
    {/*<TableFooter items={data.items} />*/}
  </View>
);

export default ItemsTable;

TableRow.js

import React, { Fragment } from "react";
import { Text, View, StyleSheet } from "@react-pdf/renderer";

const styles = StyleSheet.create({
  row: {
    flexDirection: "row",
    alignItems: "center",
  },
  description: {
    width: "60%",
  },
  xyz: {
    width: "40%",
  },
});

const TableRow = ({ items }) => {
  const rows = items.map((item) => (
    <View style={styles.row} key={item.sr.toString()}>
      <Text style={styles.description}>{item.desc}</Text>
      <Text style={styles.xyz}>{item.xyz}</Text>
    </View>
  ));
  return <Fragment>{rows}</Fragment>;
};

export default TableRow;

For more information check Generate Dynamic PDF Invoices Using React and React-PDF

Answer from Yash on Stack Overflow
🌐
GitHub
github.com › diegomura › react-pdf › issues › 3002
Add support for rowspan and colspan attributes · Issue #3002 · diegomura/react-pdf
December 18, 2024 - Please describe. The library currently does not support rendering HTML <table> elements with rowspan and colspan attributes. This limitation makes it challenging to render complex tables in PDFs where cells need to span multiple rows or columns.
Published   Dec 18, 2024
🌐
Reddit
reddit.com › r/reactjs › converting html content from rich text editor to a pdf, react-pdf/renderer. specifically because of rowspan and colspan
r/reactjs on Reddit: Converting HTML content from rich text editor to a PDF, react-pdf/renderer. Specifically because of rowSpan and colSpan
August 16, 2023 - I'm using react-pdf/renderer to generate pdfs from a variety of user inputs problem is some of those inputs come from a rich text editor. The problem is react-pdf-html the library recommended appears not to pass rowSpan and colSpan meaning merged cells are unrecognised.
🌐
Syncfusion
ej2.syncfusion.com › react › documentation › grid › pdf-export › pdf-export
Pdf export in React Grid component | Syncfusion
import { ColumnDirective, ColumnsDirective, GridComponent } from '@syncfusion/ej2-react-grids'; import { Inject, PdfExport, Toolbar } from '@syncfusion/ej2-react-grids'; import * as React from 'react'; import { data } from './datasource'; function App() { let grid; const toolbar = ['PdfExport']; const toolbarClick = (args) => { if (args.item.id === 'Grid_pdfexport') { grid.pdfExport(); } } const queryCellInfo = (args) => { let data = args.data.OrderID; switch (data) { case 10248: if (args.column.field === 'CustomerID') { args.rowSpan = 2; } break; case 10250: if (args.column.field === 'Custome
Top answer
1 of 4
19

You can use as @David-Kucsai told in comment @david.kucsai/react-pdf-table

or without using

Example

Data

const data = {
  id: "5df3180a09ea16dc4b95f910",
  items: [
    {
      sr: 1,
      desc: "desc1",
      xyz: 5,
    },
    {
      sr: 2,
      desc: "desc2",
      xyz: 6,
    },
  ],
};

app.js

import React, { Component, Fragment } from "react";
import { PDFViewer } from "@react-pdf/renderer";
import Table from "./components/reports/Table";
import data from "./data";

class App extends Component {
  render() {
    return (
      <Fragment>
        <PDFViewer width="1000" height="600">
          <Table data={data} />
        </PDFViewer>
      </Fragment>
    );
  }
}

export default App;

Table.js

import React from "react";
import { Page, Document, StyleSheet } from "@react-pdf/renderer";
import ItemsTable from "./ItemsTable";

const styles = StyleSheet.create({
  page: {
    fontSize: 11,
    flexDirection: "column",
  },
});

const Table = ({ data }) => (
  <Document>
    <Page size="A4" style={styles.page}>
      // ...
      <ItemsTable data={data} />
      // ...
    </Page>
  </Document>
);

export default Table;

ItemsTable.js

import React from "react";
import { View, StyleSheet } from "@react-pdf/renderer";
import TableRow from "./TableRow";

const styles = StyleSheet.create({
  tableContainer: {
    flexDirection: "row",
    flexWrap: "wrap",
  },
});

const ItemsTable = ({ data }) => (
  <View style={styles.tableContainer}>
    {/*<TableHeader />*/}
    <TableRow items={data.items} />
    {/*<TableFooter items={data.items} />*/}
  </View>
);

export default ItemsTable;

TableRow.js

import React, { Fragment } from "react";
import { Text, View, StyleSheet } from "@react-pdf/renderer";

const styles = StyleSheet.create({
  row: {
    flexDirection: "row",
    alignItems: "center",
  },
  description: {
    width: "60%",
  },
  xyz: {
    width: "40%",
  },
});

const TableRow = ({ items }) => {
  const rows = items.map((item) => (
    <View style={styles.row} key={item.sr.toString()}>
      <Text style={styles.description}>{item.desc}</Text>
      <Text style={styles.xyz}>{item.xyz}</Text>
    </View>
  ));
  return <Fragment>{rows}</Fragment>;
};

export default TableRow;

For more information check Generate Dynamic PDF Invoices Using React and React-PDF

2 of 4
9

Thanks goes to Yash for the detailed answer given. This is what I ended up creating after seeing your example.

The main trick to create a "table" is to use fixed width columns on each row.

Note: Make the parent container width: '100%' (table in this case) if you want to have your rows add up beyond 100% without overflowing/growing the parent. I would still recommend you try to have your total width add to 100% though, but the example below shows otherwise.

import { StyleSheet, Text, View } from '@react-pdf/renderer'
import PropTypes from 'prop-types'

const styles = StyleSheet.create({
  table: {
    width: '100%',
  },
  row: {
    display: 'flex',
    flexDirection: 'row',
    borderTop: '1px solid #EEE',
    paddingTop: 8,
    paddingBottom: 8,
  },
  header: {
    borderTop: 'none',
  },
  bold: {
    fontWeight: 'bold',
  },
  // So Declarative and unDRY 
  col1: {
    width: '27%',
  },
  col2: {
    width: '15%',
  },
  col3: {
    width: '15%',
  },
  col4: {
    width: '20%',
  },
  col5: {
    width: '27%',
  },
})

const ReportTable = ({ data, maximumDays }) => {
  return (
    <View style={styles.table}>
      <View style={[styles.row, styles.bold, styles.header]}>
        <Text style={styles.col1}>Name</Text>
        <Text style={styles.col2}>Start Date</Text>
        <Text style={styles.col3}>End Date</Text>
        <Text style={styles.col4}>Days</Text>
        <Text style={styles.col5}>Info</Text>
      </View>
      {data.map((row, i) => (
        <View key={i} style={styles.row} wrap={false}>
          <Text style={styles.col1}>
            <Text style={styles.bold}>{row.lastName}</Text>, {row.firstName}
          </Text>
          <Text style={styles.col2}>{row.startDate}</Text>
          <Text style={styles.col3}>{row.endDate}</Text>
          <Text style={styles.col4}>
            <Text style={styles.bold}>{row.days}</Text> of{' '}
            {maximumDays}
          </Text>
          <Text style={styles.col5}>{row.info}</Text>
        </View>
      ))}
    </View>
  )
}

ReportTable.propTypes = {
  data: PropTypes.array.isRequired,
  maximumDays: PropTypes.number.isRequired,
}

export default ReportTable

Top answer
1 of 1
3

React-pdf library is not supported any other components if you downloading pdf. In case you wanted use tables more then once, you can create your own conponent Table, for example as here

<Page style={styles.page} size="A4" wrap>
    <View style={styles.table}>
          <View style={[styles.row, styles.header]}>
              <Text style={[styles.headerText, styles.cell]}>Column 1 Header</Text>
              <Text style={[styles.headerText, styles.cell]}>Column 2 Header</Text>
              <Text style={[styles.headerText, styles.cell]}>Column 3 Header</Text>
              <Text style={[styles.headerText, styles.cell]}>Column 4 Header</Text>
          </View>
          <View style={[styles.row]}>
            <Text style={[styles.cell]}>Column 1 Row 1</Text>
            <Text style={[styles.cell]}>Column 2 Row 1</Text>
            <Text style={[styles.cell]}>Column 3 Row 1</Text>
            <Text style={[styles.cell]}>Column 4 Row 1</Text>
          </View>
    </View>
</Page>

or if you need more dynamic data,

const styles = StyleSheet.create({
    em:{
    fontStyle: 'bold'
}, 
table: {
    width: '100%',
    borderWidth: 2,
    display: 'flex',
    flexDirection: 'column',
    marginVertical: 12
},
tableRow:{
    display: 'flex',
    flexDirection: 'row',
},
cell: {
    borderWidth: 1,
    display: 'flex',
    justifyContent: 'center',
    alignContent: 'center',
    textAlign: 'center',
    flexWrap: 'wrap'
}
    })   

    const Table = ({children, col, th}) => (
        <View style={styles.table}>
            {children.map((row, ind) =>
                <View key={ind} style={[styles.tableRow, th && ind === 0 ? styles.em: {}]}>
                    {row.map((cell, j) =>
                        <View key={j} style={[styles.cell, {width:col[j], height: 40}]}>
                            {
                                typeof(cell) === 'string' || typeof(cell) === 'number' ? 
                                <Text>{cell}</Text> : cell
                            }
                        </View>
                    )}
                </View>
            )}
        </View>
    )

//using like this
<Table
    th
    col={['20%', '60%', '20%']}
    children={[
      ['TH1', 'TH2, 'TH3'],
      ['1', '2', '3'],
      ['4', '5', 6'],
      ['7', '8', '9']
    ]} />
🌐
GitHub
github.com › diegomura › react-pdf › issues › 487
Table examples for newbies · Issue #487 · diegomura/react-pdf
February 12, 2019 - Most of the Automated PDFs that i have come across contain lot of Tables. I know i can't use HTML Tables in this. Given the power of flex boxes this should be very much achievable. It would be ...
Published   Feb 12, 2019
🌐
GitHub
github.com › Chagall › react-pdf-table-example › issues › 1
Example with row span and column span · Issue #1 · Chagall/react-pdf-table-example
In addition to the simple table it would be really cool if you can add an example for a table with rowspan and a column span
Published   Mar 18, 2021
Author   kishaningithub
🌐
CodeSandbox
codesandbox.io › s › react-pdf-tables-o1wp2
react-pdf-tables - CodeSandbox
April 22, 2020 - react-pdf-tables using @react-pdf/renderer, @testing-library/jest-dom, @testing-library/react, @testing-library/user-event, react, react-dom, react-scripts
Published   Apr 22, 2020
Find elsewhere
🌐
npm
npmjs.com › package › @ag-media › react-pdf-table
@ag-media/react-pdf-table - npm
Because there's no such thing in react-pdf, this has to be "emulated" with negative margins. This is especially painfull for non-default border styles (e.g.
      » npm install @ag-media/react-pdf-table
    
Published   May 15, 2025
Version   2.0.3
Author   AG Media
🌐
GitHub
github.com › diegomura › react-pdf
GitHub - diegomura/react-pdf: 📄 Create PDF files using React
import React from 'react'; import { Document, Page, Text, View, StyleSheet } from '@react-pdf/renderer'; // Create styles const styles = StyleSheet.create({ page: { flexDirection: 'row', backgroundColor: '#E4E4E4', }, section: { margin: 10, padding: 10, flexGrow: 1, }, }); // Create Document Component const MyDocument = () => ( <Document> <Page size="A4" style={styles.page}> <View style={styles.section}> <Text>Section #1</Text> </View> <View style={styles.section}> <Text>Section #2</Text> </View> </Page> </Document> );
Starred by 16.2K users
Forked by 1.3K users
Languages   TypeScript 83.1% | JavaScript 16.8%
🌐
npm
npmjs.com › package › react-pdf
react-pdf - npm
Display PDFs in your React app as easily as if they were images.. Latest version: 10.2.0, last published: 2 months ago. Start using react-pdf in your project by running `npm i react-pdf`. There are 988 other projects in the npm registry using react-pdf.
      » npm install react-pdf
    
Published   Oct 09, 2025
Version   10.2.0
Author   Wojciech Maj
🌐
Syncfusion
ej2.syncfusion.com › react › documentation › grid › row › row-spanning
Row spanning in React Grid component | Syncfusion
The rowSpan attribute is used to specify the number of rows that the current cell should span.
🌐
React-pdf
react-pdf.org
React-pdf
React renderer for creating PDF files on the browser and server
🌐
Medium
kartikbudhraja.medium.com › generating-dynamic-pdfs-with-react-a-step-by-step-guide-ab755995c3cd
Generating Dynamic PDFs with React. A Step-by-Step Guide.
September 14, 2023 - Generating Dynamic PDFs with React. A Step-by-Step Guide. Overview - In this article, we will explore the dynamic world of PDF generation with react-pdf in React. From the basics of the library to …
🌐
GitHub
github.com › wojtekmaj › react-pdf
GitHub - wojtekmaj/react-pdf: Display PDFs in your React app as easily as if they were images.
Display PDFs in your React app as easily as if they were images. - wojtekmaj/react-pdf
Starred by 10.7K users
Forked by 981 users
Languages   TypeScript 94.3% | CSS 5.6% | HTML 0.1%
🌐
DEV Community
dev.to › finallynero › generating-pdf-documents-in-react-using-react-pdf-4ka7
React PDF: Generating Pdf documents in React Using React-pdf - DEV Community
August 8, 2019 - So in the tutorial, I will try to explain briefly how react-pdf works and also walk you through how to generate PDf from an array of objects.. Tagged with react, webdev, tutorial, javascript.
🌐
PrimeReact
primereact.org › datatable
PrimeReact | React UI Component Library
Columns can be grouped within a Row component and groups can be displayed at header and footer using headerColumnGroup, footerColumnGroup properties. Number of cells and rows to span are defined with the colSpan and rowSpan properties of a Column.
🌐
PSPDFKit
pspdfkit.com › blog › sdk › create pdfs with react
How to Create a PDF with React
November 17, 2024 - Regardless of what you’re trying to create — invoices, sales contracts, or certificates — you’ll often end up in need of a method for programmatically assembling PDF documents. In this article, we’ll examine a popular React-based solution that can be used to generate PDFs by using a declarative API: react-pdf(opens in a new tab) by Diego Muracciole(opens in a new tab).