Commit fa40177f by Luis Gangas

[ADD] agregado de pdfcreator

parent b2fb3515
......@@ -5,6 +5,8 @@
*/
package trismegistoplanilla.utilities;
import com.itextpdf.text.Anchor;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
......@@ -81,7 +83,19 @@ public class PdfCreator {
.replace("@distritoFirma", distrito)
.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();
}
......@@ -92,7 +106,7 @@ public class PdfCreator {
public static boolean crearPdfContratoTiempoParcial(JSONObject json) throws IOException, DocumentException {
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.getInstance(documento, new FileOutputStream("D:\\contratoPDF.pdf"));
// MyFooter event = new MyFooter();
......@@ -116,9 +130,7 @@ public class PdfCreator {
List<String> template = getTemplateContrato(2);
String lineas = "";
for (String linea : template) {
lineas += linea;
}
lineas = template.stream().map((linea) -> linea).reduce(lineas, String::concat);
lineas = lineas
.replace("@br", "\n")
......@@ -130,7 +142,21 @@ public class PdfCreator {
.replace("@distritoFirma", distrito)
.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();
}
......
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