Home > OS >  ngx-print doesn't Print AngularMaterial component Styles
ngx-print doesn't Print AngularMaterial component Styles

Time:11-09

I have Material Table With header and Footer cell in it. I am using ngx-print(version - 1.2.1)to print the table, If I add

[useExistingCss]="true"

it Shows blank page or no style at all.and with

styleSheetFile="custom.scss"

it is same issue. I have Created Stakblitz With material table enter image description here

CodePudding user response:

Just remove id = "print-section" from table tag and adds new parent div to table tag with id = "print-section"` , This is how it works here.

Demo in this Stackblitz

<div id="print-section">
  <table
    mat-table
    [dataSource]="transactions"
     >
      .........
   </table>
</div>

EDIT

if above is not working then you can add your custom css with useExistingCss too just like below..

  <button mat-button  color="primary" printSectionId="print-section" 
     ngxPrint [useExistingCss]="true" styleSheetFile="assets/custom.scss">
     PrintWithCustomScss
 </button>

and then you have to put your custom css file inside asset folder.

  • Related