use of com.itextpdf.layout.element.AreaBreak in project i7js-highlevel by itext.
the class DivProperties method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
Style style = new Style();
style.setBackgroundColor(ColorConstants.YELLOW).setBorder(new SolidBorder(0.5f));
document.add(createNewDiv().addStyle(style).setWidth(350).setHorizontalAlignment(HorizontalAlignment.CENTER).setTextAlignment(TextAlignment.CENTER).setDestination("Top"));
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
document.add(createNewDiv().setRotationAngle(Math.PI / 18).setFont(font).setFontSize(8).setFontColor(ColorConstants.RED));
document.add(createNewDiv().setWidth(350).setHyphenation(new HyphenationConfig("en", "uk", 3, 3)).setKeepWithNext(true));
document.add(createNewDiv().setWidth(UnitValue.createPercentValue(70)).setKeepTogether(true));
document.add(createNewDiv().setHeight(350).setBackgroundColor(ColorConstants.YELLOW).setAction(PdfAction.createGoTo("Top")).setRelativePosition(10, 10, 50, 10));
document.add(new AreaBreak());
document.add(createNewDiv().setFixedPosition(100, 400, 350));
document.add(new AreaBreak());
document.add(createNewDiv().setBackgroundColor(ColorConstants.YELLOW).setMarginBottom(10));
document.add(createNewDiv().setBackgroundColor(ColorConstants.LIGHT_GRAY).setPaddingLeft(20).setPaddingRight(50));
document.add(createNewDiv().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewDiv().setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.add(createNewDiv().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewDiv().setBackgroundColor(ColorConstants.LIGHT_GRAY).setMargin(50).setPadding(30));
document.add(createNewDiv().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewDiv().setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.close();
}
use of com.itextpdf.layout.element.AreaBreak in project i7js-highlevel by itext.
the class ListSeparatorProperties method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
Style style = new Style();
style.setBackgroundColor(ColorConstants.YELLOW);
document.add(createNewSeparator().addStyle(style).setDestination("Top"));
document.add(new Paragraph("test"));
document.add(createNewSeparator().setWidth(300).setHorizontalAlignment(HorizontalAlignment.CENTER));
document.add(createNewSeparator().setMargin(10).setVerticalAlignment(VerticalAlignment.BOTTOM).setBorder(new SolidBorder(0.5f)));
document.add(createNewSeparator().setMargin(10).setWidth(300));
document.add(createNewSeparator().setMargin(10).setRelativePosition(10, 10, 50, 10));
document.add(createNewSeparator().setMargin(10).setWidth(UnitValue.createPercentValue(50)));
document.add(createNewSeparator().setMargin(10).setWidth(50).setAction(PdfAction.createGoTo("Top")));
document.add(createNewSeparator().setFixedPosition(100, 200, 350));
document.add(new AreaBreak());
document.add(createNewSeparator().setBackgroundColor(ColorConstants.YELLOW).setMarginBottom(10));
document.add(createNewSeparator().setBackgroundColor(ColorConstants.LIGHT_GRAY).setPaddingLeft(20).setPaddingRight(50));
document.add(createNewSeparator().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewSeparator().setBackgroundColor(ColorConstants.LIGHT_GRAY).setMarginBottom(50));
document.add(createNewSeparator().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewSeparator().setBackgroundColor(ColorConstants.LIGHT_GRAY).setMargin(50).setPadding(30));
document.add(createNewSeparator().setBackgroundColor(ColorConstants.YELLOW));
document.add(createNewSeparator().setBackgroundColor(ColorConstants.LIGHT_GRAY));
document.close();
}
use of com.itextpdf.layout.element.AreaBreak in project digilib by robcast.
the class PDFStreamWorker method renderPDF.
/**
* @throws DocumentException
* @throws InterruptedException
* @throws ExecutionException
* @throws IOException
* @throws ImageOpException
*/
protected OutputStream renderPDF() throws InterruptedException, ExecutionException, IOException, ImageOpException {
long start_time = System.currentTimeMillis();
// create document object
PdfWriter writer = new PdfWriter(outstream);
PdfDocument pdfdoc = new PdfDocument(writer);
doc = new Document(pdfdoc, PageSize.A4);
logger.debug("PDF: {} doc.open()ed ({}ms)", outstream, (System.currentTimeMillis() - start_time));
// add title page
PDFTitlePage titlepage = new PDFTitlePage(job_info);
titlepage.createPage(doc);
// add pages
NumRange pgs = job_info.getPages();
for (int p : pgs) {
// start new page
doc.add(new AreaBreak());
logger.debug("PDF: adding Image {} to {}", p, outstream);
// copy request and set page number (as new Parameter)
DigilibRequest pageRequest = new DigilibRequest(dlConfig, job_info);
pageRequest.put("pn", new Parameter("pn", p, p));
// create ImageJobInformation
ImageJobDescription iji = ImageJobDescription.getRawInstance(pageRequest, job_info.getDlConfig());
iji.prepareScaleParams();
addImage(doc, iji);
logger.debug("PDF: done adding Image {} to {}", p, outstream);
}
logger.debug("PDF: done adding all Images to {}", outstream);
doc.close();
logger.debug("PDF: {} doc.close() ({}ms)", outstream, (System.currentTimeMillis() - start_time));
writer.flush();
writer.close();
return outstream;
}
use of com.itextpdf.layout.element.AreaBreak in project betca-tpv-spring by miw-upm.
the class PdfTag24Builder method addTag24.
public PdfTag24Builder addTag24(String description, String code) {
assert description != null;
assert code != null;
if ((tag24 % 24) == 0) {
if (tag24 > 0) {
this.getDocument().add(new AreaBreak(AreaBreakType.NEXT_PAGE));
}
this.prepareTags24();
}
Cell cell = new Cell();
cell.setPaddingTop(10);
cell.setMinHeight(84.2F);
cell.setBorder(Border.NO_BORDER);
cell.setTextAlignment(TextAlignment.CENTER);
cell.add(description);
if (!code.isEmpty()) {
BarcodeEAN barcode = new BarcodeEAN(this.getDocument().getPdfDocument());
barcode.setCodeType(BarcodeEAN.EAN13);
barcode.setCode(code.trim());
Image barcodeImage = new Image(barcode.createFormXObject(this.getDocument().getPdfDocument()));
barcodeImage.setWidthPercent(70);
barcodeImage.setHorizontalAlignment(HorizontalAlignment.CENTER);
cell.add(barcodeImage);
}
this.getTable().addCell(cell);
this.getDocument().add(this.getTable());
tag24++;
return this;
}
use of com.itextpdf.layout.element.AreaBreak in project i7js-highlevel by itext.
the class C02E09_JekyllHydeV5 method createPdf.
public void createPdf(String dest) throws IOException {
// Initialize PDF document
PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
// Initialize document
Document document = new Document(pdf);
// Set column parameters
float offSet = 36;
float gutter = 23;
float columnWidth = (PageSize.A4.getWidth() - offSet * 2) / 2 - gutter;
float columnHeight = PageSize.A4.getHeight() - offSet * 2;
// Define column areas
Rectangle[] columns = { new Rectangle(offSet, offSet, columnWidth, columnHeight), new Rectangle(offSet + columnWidth + gutter, offSet, columnWidth, columnHeight) };
document.setRenderer(new ColumnDocumentRenderer(document, columns));
PdfFont font = PdfFontFactory.createFont(StandardFonts.TIMES_ROMAN);
PdfFont bold = PdfFontFactory.createFont(StandardFonts.HELVETICA_BOLD);
document.setTextAlignment(TextAlignment.JUSTIFIED).setFont(font).setHyphenation(new HyphenationConfig("en", null, 3, 3));
BufferedReader br = new BufferedReader(new FileReader(SRC));
String line;
Paragraph p;
boolean title = true;
AreaBreak nextPage = new AreaBreak(AreaBreakType.NEXT_PAGE);
while ((line = br.readLine()) != null) {
p = new Paragraph(line);
if (title) {
p.setFont(bold).setFontSize(12);
title = false;
} else {
p.setFirstLineIndent(36);
}
if (line.isEmpty()) {
document.add(nextPage);
title = true;
}
document.add(p);
}
br.close();
// Close document
document.close();
}
Aggregations