-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHTML2PrintComponent.js
More file actions
31 lines (26 loc) · 1.25 KB
/
Copy pathHTML2PrintComponent.js
File metadata and controls
31 lines (26 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React, { useRef, useState, useEffect } from "react";
import parse from 'html-react-parser';
import ReactToPrint from "react-to-print";
import { ActionButton, CompoundButton, DefaultButton, IIconProps, PrimaryButton } from '@fluentui/react';
import '../css/AppStyles.css';
function App({ appContext }) {
const componentRef = useRef();
const buttonElement = appContext.parameters.ButtonAppearence.raw === 'Primary' ?
<PrimaryButton id="btnHtml2Print" disabled={ appContext.mode.isControlDisabled }>{ appContext.parameters.ButtonText.raw }</PrimaryButton> :
<DefaultButton id="btnHtml2Print" disabled={ appContext.mode.isControlDisabled }>{ appContext.parameters.ButtonText.raw }</DefaultButton>
return(
<React.Fragment>
<ReactToPrint
trigger={ () => buttonElement }
content={ () => componentRef.current }
/>
<div className="pagebreak full-table">
{ document.title = appContext.parameters.DefaultFilename.raw }
<div ref={ componentRef }>
{ parse(appContext.parameters.CustomCss.raw + appContext.parameters.HTMLCode.raw) }
</div>
</div>
</React.Fragment>
);
}
export default App;