浏览代码

pdf render show

amenpunk 2 年之前
父节点
当前提交
c185a0889e
共有 3 个文件被更改,包括 36 次插入24 次删除
  1. 1 1
      src/Components/Home/Candidato.jsx
  2. 4 4
      src/Components/Modal/EditPlaza.js
  3. 31 19
      src/Pages/Resultados.jsx

+ 1 - 1
src/Components/Home/Candidato.jsx

@@ -6,7 +6,7 @@ import {
6 6
 } from '@mui/material';
7 7
 import {
8 8
   CheckBox as CheckBoxIcon,
9
-  FmdBad as FmdBadIcon,
9
+  // FmdBad as FmdBadIcon,
10 10
   NewReleases as NewReleasesIcon
11 11
 } from '@mui/icons-material'
12 12
 import { useNavigate } from 'react-router-dom'

+ 4 - 4
src/Components/Modal/EditPlaza.js

@@ -74,15 +74,15 @@ function Edit(props) {
74 74
   const auth = useSelector((state) => state.token)
75 75
   const queryClient = useQueryClient()
76 76
   let { visible, toggle } = props
77
-  const [puestoSup, setPuestoSup] = React.useState('');
77
+  // const [puestoSup, setPuestoSup] = React.useState('');
78 78
 
79 79
   const [open, setOpen] = React.useState(false);
80 80
   const [tab, setTab] = React.useState(0);
81 81
   const [checklist, setChecklist] = React.useState([]);
82 82
 
83
-  const changePuestoSup = (event) => {
84
-    setPuestoSup(event.target.value);
85
-  };
83
+  // const changePuestoSup = (event) => {
84
+  //   setPuestoSup(event.target.value);
85
+  // };
86 86
 
87 87
   const addPrueba = (check, id) => {
88 88
     let tests = getValues("tests")

+ 31 - 19
src/Pages/Resultados.jsx

@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react';
2 2
 import { useParams } from 'react-router-dom'
3 3
 import { Service } from '../Utils/HTTP';
4 4
 import { useSelector } from 'react-redux';
5
-import { Button  } from '@mui/material'
5
+import { Button, Box, Paper } from '@mui/material'
6 6
 import { Document, Page, pdfjs } from 'react-pdf/dist/esm/entry.webpack';
7 7
 // import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
8 8
 import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
@@ -18,27 +18,35 @@ const MyDocument = (props) => {
18 18
   const [pageNumber, setPageNumber] = useState(1);
19 19
 
20 20
   function onDocumentLoadSuccess({ numPages }) {
21
-    console.log('numero de pagians',numPages)
21
+    console.log('numero de pagians', numPages)
22 22
     setNumPages(numPages);
23 23
   }
24 24
 
25
-  function onLoadError(error){
25
+  function onLoadError(error) {
26 26
     console.log('error: ', error)
27 27
   }
28 28
 
29 29
   return (
30 30
     <div>
31
-      <div>
32
-        <Button  onClick={() =>setPageNumber(pageNumber + 1)} >
31
+      <div className="pdf_controls">
32
+        <Button variant="contained" onClick={() => pageNumber > 1 ? setPageNumber(pageNumber - 1) : null} >
33
+          Anterior
34
+        </Button>
35
+        <Button style={{ margin: 5 }} variant="contained" onClick={() => pageNumber + 1 <= numPages   ? setPageNumber(pageNumber + 1) : null} >
33 36
           Siguiente
34 37
         </Button>
38
+
39
+        <p>
40
+          Página {pageNumber} de {numPages}
41
+        </p>
42
+
43
+      </div>
44
+
45
+      <div className="Example__container__document">
46
+        <Document renderMode="canvas" file={pdf.data} onLoadSuccess={onDocumentLoadSuccess} onLoadError={onLoadError}>
47
+          <Page width={800} pageNumber={pageNumber} loading={<Cargando />} />
48
+        </Document>
35 49
       </div>
36
-      <Document renderMode="canvas" file={pdf.data} onLoadSuccess={onDocumentLoadSuccess} onLoadError={onLoadError}>
37
-        <Page  pageNumber={pageNumber} loading={<Cargando/>} />
38
-      </Document>
39
-      <p>
40
-        Page {pageNumber} of {numPages}
41
-      </p>
42 50
     </div>
43 51
   )
44 52
 };
@@ -55,7 +63,7 @@ export function Resultados() {
55 63
     let url = `/report/cleaverResult/${id}?output=pdf`
56 64
     let rest = new Service(url);
57 65
 
58
-    pdfjs.GlobalWorkerOptions.workerSrc =  `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
66
+    pdfjs.GlobalWorkerOptions.workerSrc = `https://cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
59 67
 
60 68
     rest
61 69
       .getBlob(auth.token)
@@ -67,13 +75,17 @@ export function Resultados() {
67 75
   return (
68 76
     <div className="content-section">
69 77
       <div className="main">
70
-        <h1>Resultados {id}</h1>
71
-        <hr />
72
-        {
73
-          pdf ?
74
-            <MyDocument pdf={pdf} />
75
-            : <div> <h5> loading...</h5></div>
76
-        }
78
+        <Box sx={{ width: '100%' }}>
79
+          <Paper elevation={0} sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
80
+            <h1>Resultados {id}</h1>
81
+            <hr />
82
+            {
83
+              pdf ?
84
+                <MyDocument pdf={pdf} />
85
+                : <div> <h5> loading...</h5></div>
86
+            }
87
+          </Paper>
88
+        </Box>
77 89
       </div>
78 90
     </div>
79 91
   )