Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
trismegisto-planilla
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Luis Gangas
trismegisto-planilla
Commits
fa40177f
Commit
fa40177f
authored
Nov 22, 2018
by
Luis Gangas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] agregado de pdfcreator
parent
b2fb3515
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
7 deletions
+33
-7
PdfCreator.java
src/java/trismegistoplanilla/utilities/PdfCreator.java
+33
-7
No files found.
src/java/trismegistoplanilla/utilities/PdfCreator.java
View file @
fa40177f
...
@@ -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
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment