-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tsx
114 lines (110 loc) · 2.96 KB
/
main.tsx
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import { createRoot } from 'react-dom/client';
import React, { useEffect, useRef, useState } from 'react';
import {
AllowedInteraction,
ContextMenuItem,
LoadFailedEventArgs,
Annotation,
BookmarkView,
Inject,
LinkAnnotation,
Magnification,
Navigation,
PdfViewerComponent,
Print,
TextSearch,
TextSelection,
ThumbnailView,
Toolbar,
} from '@syncfusion/ej2-react-pdfviewer';
import { Tooltip } from '@syncfusion/ej2-popups';
import ptBR from './pt-BR.json';
import {
enableRipple,
L10n,
loadCldr,
setCulture,
registerLicense,
} from '@syncfusion/ej2-base';
import {
toolbarSettings,
annotationMouseOver,
annotationMouseLeave,
} from './helper';
import { LoadBase64PDF } from './base64document';
registerLicense(
'ORg4AjUWIQA/Gnt2VVhiQlFadVlJXGFWfVJpTGpQdk5xdV9DaVZUTWY/P1ZhSXxRdkJiWH1dcHdUQWBZUEI='
);
enableRipple(true);
// Carrega as linguagens dos componentes syncfusion.
L10n.load(ptBR);
setCulture('pt');
export function PdfViewerFunctionComponent() {
let viewer: PdfViewerComponent;
const tooltip: Tooltip = new Tooltip({
mouseTrail: true,
opensOn: 'Custom',
});
useEffect(() => {
viewer.load(LoadBase64PDF(), null);
}, []);
return (
<div>
{/* Render the PDF Viewer */}
<PdfViewerComponent
ref={(scope) => {
viewer = scope;
}}
id="container"
serviceUrl="https://ej2services.syncfusion.com/production/web-services/api/pdfviewer"
documentLoadFailed={(args: LoadFailedEventArgs) => {
console.log('Falha no Load', args);
}}
toolbarSettings={toolbarSettings}
style={{
height: '100vh',
}}
interactionMode="Pan"
isThumbnailViewOpen
isCommandPanelOpen
isAnnotationToolbarOpen
hyperlinkOpenState="NewTab"
dateTimeFormat={'yyyy-MM-dd HH:mm:ss'}
annotationMouseover={annotationMouseOver(tooltip)}
annotationMouseLeave={annotationMouseLeave(tooltip)}
stickyNotesSettings={{
allowedInteractions: [
AllowedInteraction.Move,
AllowedInteraction.Select,
AllowedInteraction.PropertyChange,
AllowedInteraction.Delete,
],
}}
contextMenuSettings={{
contextMenuItems: [
ContextMenuItem.Properties,
ContextMenuItem.Comment,
ContextMenuItem.Delete,
],
}}
>
<Inject
services={[
Toolbar,
Magnification,
Navigation,
Annotation,
LinkAnnotation,
ThumbnailView,
BookmarkView,
TextSelection,
TextSearch,
Print,
]}
/>
</PdfViewerComponent>
</div>
);
}
const root = createRoot(document.getElementById('root'));
root.render(<PdfViewerFunctionComponent />);