Commit fa40177f by Luis Gangas

[ADD] agregado de pdfcreator

parent b2fb3515
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
*/ */
package trismegistoplanilla.utilities; package trismegistoplanilla.utilities;
import com.itextpdf.text.Anchor;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document; import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException; import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element; import com.itextpdf.text.Element;
...@@ -81,18 +83,30 @@ public class PdfCreator { ...@@ -81,18 +83,30 @@ public class PdfCreator {
.replace("@distritoFirma", distrito) .replace("@distritoFirma", distrito)
.replace("@ruc", ruc); .replace("@ruc", ruc);
documento.add(new Paragraph(lineas)); Phrase phrase = new Phrase();
Paragraph paragraph = new Paragraph();
Font underlineFont = new Font(Font.FontFamily.HELVETICA, 15, Font.UNDERLINE);
Font paragraphFont = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL);
Chunk underlineChunk = new Chunk("CONTRATO DE TRABAJO POR NECESIDADES DEL MERCADO", underlineFont);
phrase.add(underlineChunk);
paragraph.add(phrase);
paragraph.setAlignment(Element.ALIGN_CENTER);
documento.add(paragraph);
documento.add(Chunk.NEWLINE);
documento.add(Chunk.NEWLINE);
documento.add(new Paragraph(lineas, paragraphFont));
documento.close(); documento.close();
} }
return respuesta; return respuesta;
} }
public static boolean crearPdfContratoTiempoParcial(JSONObject json) throws IOException, DocumentException { public static boolean crearPdfContratoTiempoParcial(JSONObject json) throws IOException, DocumentException {
boolean respuesta = false; boolean respuesta = false;
Document documento = new Document(PageSize.A4.rotate(), 5, 5, 5, 5); Document documento = new Document(PageSize.A4.rotate(), 100, 100, 30, 30);
// PdfWriter writer = PdfWriter.getInstance(documento, response.getOutputStream()); // PdfWriter writer = PdfWriter.getInstance(documento, response.getOutputStream());
PdfWriter.getInstance(documento, new FileOutputStream("D:\\contratoPDF.pdf")); PdfWriter.getInstance(documento, new FileOutputStream("D:\\contratoPDF.pdf"));
// MyFooter event = new MyFooter(); // MyFooter event = new MyFooter();
...@@ -116,9 +130,7 @@ public class PdfCreator { ...@@ -116,9 +130,7 @@ public class PdfCreator {
List<String> template = getTemplateContrato(2); List<String> template = getTemplateContrato(2);
String lineas = ""; String lineas = "";
for (String linea : template) { lineas = template.stream().map((linea) -> linea).reduce(lineas, String::concat);
lineas += linea;
}
lineas = lineas lineas = lineas
.replace("@br", "\n") .replace("@br", "\n")
...@@ -130,7 +142,21 @@ public class PdfCreator { ...@@ -130,7 +142,21 @@ public class PdfCreator {
.replace("@distritoFirma", distrito) .replace("@distritoFirma", distrito)
.replace("@ruc", ruc); .replace("@ruc", ruc);
documento.add(new Paragraph(lineas)); Phrase phrase = new Phrase();
Paragraph paragraph = new Paragraph();
Font underlineFont = new Font(Font.FontFamily.HELVETICA, 15, Font.UNDERLINE);
Font paragraphFont = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL);
Chunk underlineChunk = new Chunk("CONTRATO DE TRABAJO EN REGIMEN DE TIEMPO PARCIAL", underlineFont);
phrase.add(underlineChunk);
paragraph.add(phrase);
paragraph.setAlignment(Element.ALIGN_CENTER);
documento.add(paragraph);
documento.add(Chunk.NEWLINE);
documento.add(Chunk.NEWLINE);
documento.add(new Paragraph(lineas, paragraphFont));
documento.close(); documento.close();
} }
......
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