Created
April 15, 2014 08:58
-
-
Save cristiandley/10715432 to your computer and use it in GitHub Desktop.
CREAR PDF en LOtUS SSJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
| | |
| IMPORTO PAQUETES | |
| | |
*/ | |
importPackage(com.itextpdf); | |
importPackage(java.io); | |
/* | |
| | |
| INI | |
| | |
*/ | |
var con = facesContext.getExternalContext(); | |
var response:com.ibm.xsp.webapp.XspHttpServletResponse = con.getResponse(); | |
/* | |
| | |
| SETEO LAS VARIABLES DE HEADER PARA QUE EL NAVEGADOR LEA EL TIPO DE DATO | |
| | |
*/ | |
response.setContentType("application/pdf"); | |
response.setHeader("Cache-Control", "no-cache"); | |
response.setDateHeader("Expires", -1); | |
response.setHeader( "Content-Disposition", "attachment; filename=\"test.pdf\"" ); | |
/* | |
| | |
| SETEO EL STREAM DE DATOS | |
| | |
*/ | |
var newPDF:com.itextpdf.text.Document = new com.itextpdf.text.Document(); | |
var writer = com.itextpdf.text.pdf.PdfWriter.getInstance(newPDF,response.getOutputStream()); | |
var htmlWorker = new com.itextpdf.text.html.simpleparser.HTMLWorker(newPDF); | |
/* | |
| | |
| ABRO EL PDF Y SETEO CABECERA | |
| | |
*/ | |
newPDF.open(); | |
newPDF.addAuthor("Autor"); | |
newPDF.addCreationDate(); | |
newPDF.addCreator("IBM Lotus Domino V8.5.3 :iText Library"); | |
newPDF.addTitle("Titulo"); | |
/* | |
| | |
| EJEMPLO PARRAFO | |
| | |
*/ | |
var holaMundo = new com.itextpdf.text.Paragraph("Hola Mundo") | |
holaMundo.setAlignment(com.itextpdf.text.Element.ALIGN_RIGHT); | |
newPDF.add(holaMundo); | |
/* | |
| | |
| UNA FRASE | |
| | |
*/ | |
newPDF.add(new com.itextpdf.text.Phrase("Frase...")); | |
/* | |
| | |
| CIERRO CON. | |
| | |
*/ | |
newPDF.close(); | |
writer.close(); | |
facesContext.responseComplete(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment