Generacion de PDF por JS-html2pdf(no se puede seleccionar texto)

parent f24f57f8
......@@ -98,7 +98,11 @@ public class PostulanteRRHHController {
model.addAttribute("institucionesEducativas", institucionRepository.findAll());
model.addAttribute("estadoP", EstadoPostulante.values());
model.addAttribute("convocatoriaC", cargoRepo.findAll());
Page<Postulante> postulantesPag = post.postulantesMultiFiltro(nombre == null || nombre.trim().isEmpty() ? new TypedParameterValue(StringType.INSTANCE,null) : new TypedParameterValue(StringType.INSTANCE,"%"+nombre+"%"),dispo, lvlEng, lvlTec, tecId, instId,cargoId,page,estado,convId);
Page<Postulante> postulantesPag = post.postulantesMultiFiltro(
nombre == null || nombre.trim().isEmpty() ?
new TypedParameterValue(StringType.INSTANCE,null) :
new TypedParameterValue(StringType.INSTANCE,"%"+nombre+"%"),
dispo, lvlEng, lvlTec, tecId, instId,cargoId,page,estado,convId);
List<Postulante> postulantes = postulantesPag.getContent();
List<PostulanteListaDTO> postulantesDTO = new ArrayList<>();
......@@ -129,6 +133,17 @@ public class PostulanteRRHHController {
return "detallepostulante";
}
// @GetMapping({"/pdfPostulante/{postulanteId}"})
// public String getPostulantePdf(Model model, @PathVariable("postulanteId") Long postulanteId) {
// Postulante p = post.findById(postulanteId).orElse(null);
// model.addAttribute("postulante",p);
// model.addAttribute("cvId", fileRepo.getIdByPostulante(p));
// model.addAttribute("estadoP", EstadoPostulante.values());
// return "detallepostulante2";
//
// }
@PostMapping({"/postulantes/{postulanteId}"})
public String setPostulanteEstado(@ModelAttribute Postulante postulante, BindingResult result, @PathVariable("postulanteId") Long postulanteId) {
//post.setPostulanteEstadoAndComentario(postulante.getEstadoPostulante(),postulante.getComentarioRRHH(), postulante.getId());
......
......@@ -7,6 +7,7 @@
<layout:extends name="layouts/base.jsp">
<layout:put block="contents" type="REPLACE">
<div id="element-to-print">
<h2 style="text-align: center;">
DETALLE POSTULANTE
</h2>
......@@ -130,9 +131,10 @@
</div>
</div>
<hr>
<div class="row">
<div class="row" id="buttonRow" style="display: block">
<div class="col">
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#estadoModalLong">Agregar observacion</button>
<button id="pdf" type="button" class="btn btn-primary">PDF</button>
</div>
<c:choose>
......@@ -382,9 +384,31 @@
</div>
</div>
</div>
</div>
<layout:put block="scripts" type="APPEND">
<script src="../valEdad.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js" integrity="sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
document.querySelector('#pdf').addEventListener("click", async ()=>{
var buttonsRow = document.querySelector('#buttonRow');
var element = document.getElementById('element-to-print');
var opt = {
margin: 1,
filename: 'myfile.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2 },
jsPDF: { unit: 'in', format: 'a1', orientation: 'portrait' }
};
buttonsRow.style.display = "none";
await html2pdf().set(opt).from(element).toPdf().save();
console.log('xd');
buttonsRow.style.display = "block";
})
<%--location.replace("/postulantes/${postulante.id}/")--%>
</script>
</layout:put>
......
......@@ -234,12 +234,13 @@
function buscarPagina(nro){
nro--
const aBuscar = 'nroPagina='+nro
if(!location.search) location.search = "?"+aBuscar
if(!location.search) location.search = aBuscar
const inicial = location.search.search(aBuscar);
if(inicial==-1){//si no se encuentra y hay otros queries
location.search = "&"+aBuscar
location.search += "&"+aBuscar;
}
location.search.replace('nroPagina=',aBuscar)
console.log(location.search)
}
const tecId = document.querySelector("#tecId");
const lvlTec = document.querySelector("#lvlTec");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment