react-to-print icon indicating copy to clipboard operation
react-to-print copied to clipboard

Border top and bottom

Open HumanMu opened this issue 11 months ago • 1 comments

@MatthewHerbst I am trying to print a multi page component and calling the pageStyle automatically adding the header and footer which is very nice. But all the css that I am adding to the pageStyle get ignored beside of margin and padding which working fine.

But I want to add a border line at the bottom and the top of the every page which get ignored no matter using the global.css or inline css. Here is my code. I have tried and searched at the last two days but couldnt come across a solution yet:

import ReactToPrint from 'react-to-print';
  export function handleExportPdf (componentRef: React.RefObject<HTMLDivElement> ) {  
    return(
      <ReactToPrint
        bodyClass="print-agreement"
        content={() => componentRef.current}
        copyStyles={true}
        pageStyle={
          `@page {
            size: A4 portrait; 
            margin: 0.2in;
            border{
              border: 1px solid black;
            } 
          }
  
          @media print {
            body {
              margin: 0;
            }}`
          }
        trigger={() => (
          <button className="btn btn-primary"> Print </button>
        )}
      />
    )
  }

Thnk in advance

HumanMu avatar Mar 13 '24 10:03 HumanMu