List of usage examples for com.itextpdf.text.pdf PdfPCell PdfPCell
public PdfPCell()
PdfPCell
. From source file:com.softwaremagico.tm.pdf.complete.skills.CompleteSkillsTable.java
License:Open Source License
private static PdfPCell getFirstColumnTable(CharacterPlayer characterPlayer, String language, Stack<PdfPCell> learnedSkillsRows) throws InvalidXmlElementException { float[] widths = { 4f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);/*www.j a v a 2 s.c o m*/ table.addCell(createTitle(getTranslator().getTranslatedText("naturalSkills"), FadingSunsTheme.SKILLS_TITLE_FONT_SIZE)); if (characterPlayer == null) { for (AvailableSkill skill : AvailableSkillsFactory.getInstance().getNaturalSkills(language)) { table.addCell(createSkillElement(characterPlayer, skill, FadingSunsTheme.SKILLS_LINE_FONT_SIZE, MAX_SKILL_COLUMN_WIDTH)); table.addCell(createSkillLine(SKILL_VALUE_GAP, FadingSunsTheme.SKILLS_LINE_FONT_SIZE)); } } else { for (AvailableSkill skill : characterPlayer.getNaturalSkills()) { table.addCell(createSkillElement(characterPlayer, skill, FadingSunsTheme.SKILLS_LINE_FONT_SIZE, MAX_SKILL_COLUMN_WIDTH)); table.addCell(createSkillValue(characterPlayer.getSkillTotalRanks(skill), characterPlayer.isSkillSpecial(skill) || characterPlayer.hasSkillTemporalModificator(skill), characterPlayer.hasSkillModificator(skill), FadingSunsTheme.SKILLS_LINE_FONT_SIZE)); } } table.addCell(createTitle(getTranslator().getTranslatedText("learnedSkills"), FadingSunsTheme.SKILLS_TITLE_FONT_SIZE)); int totalRows = Math.min(getTotalLearnedSkillsToShow(language), ROWS - (2 * TITLE_ROWSPAN) - SkillsDefinitionsFactory.getInstance().getNaturalSkills(language).size()); for (int i = 0; i < totalRows; i++) { // Two columns: skill and value. table.addCell(learnedSkillsRows.pop()); table.addCell(learnedSkillsRows.pop()); } PdfPCell cell = new PdfPCell(); setCellProperties(cell); cell.addElement(table); cell.setVerticalAlignment(Element.ALIGN_TOP); return cell; }
From source file:com.softwaremagico.tm.pdf.complete.skills.CompleteSkillsTable.java
License:Open Source License
private static PdfPCell getSecondColumnTable(CharacterPlayer characterPlayer, String language, Stack<PdfPCell> learnedSkillsRows) throws InvalidXmlElementException { float[] widths = { 4f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);/*from www .ja va 2 s .co m*/ PdfPCell cell = new PdfPCell(); setCellProperties(cell); for (int i = 0; i < ROWS; i++) { // Two columns: skill and value. table.addCell(learnedSkillsRows.pop()); table.addCell(learnedSkillsRows.pop()); } cell.addElement(table); cell.setVerticalAlignment(Element.ALIGN_TOP); return cell; }
From source file:com.softwaremagico.tm.pdf.complete.skills.CompleteSkillsTable.java
License:Open Source License
private static PdfPCell getThirdColumnTable(CharacterPlayer characterPlayer, String language, Stack<PdfPCell> learnedSkillsRows) throws InvalidXmlElementException { float[] widths = { 4f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);//w ww .j ava2 s . c o m PdfPCell cell = new PdfPCell(); setCellProperties(cell); for (int i = 0; i < ROWS - OCCULTISM_ROWS; i++) { // Two columns: skill and value. table.addCell(learnedSkillsRows.pop()); table.addCell(learnedSkillsRows.pop()); } // Add Occultism table PdfPTable occultismTable = new OccultismTable(characterPlayer, language); PdfPCell occulstimCell = new PdfPCell(); // setCellProperties(occulstimCell); // occulstimCell.setRowspan(widths.length); occulstimCell.setRowspan(OCCULTISM_ROWS); occulstimCell.setColspan(2); occulstimCell.addElement(occultismTable); occulstimCell.setVerticalAlignment(Element.ALIGN_BOTTOM); occulstimCell.setPadding(0); table.addCell(occulstimCell); cell.addElement(table); cell.setVerticalAlignment(Element.ALIGN_TOP); return cell; }
From source file:com.softwaremagico.tm.pdf.complete.skills.CounterTable.java
License:Open Source License
protected PdfPCell space(int rowspan) { PdfPCell emptyCell = new PdfPCell(); emptyCell.setRowspan(rowspan); emptyCell.setBorder(0); return emptyCell; }
From source file:com.softwaremagico.tm.pdf.small.info.CharacterBasicsReducedTableFactory.java
License:Open Source License
private static PdfPCell getFirstColumnTable(CharacterPlayer characterPlayer) { float[] widths = { 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);//from w w w . j a v a 2s.co m table.addCell(createField(characterPlayer, "name", FadingSunsTheme.CHARACTER_SMALL_BASICS_FONT_SIZE)); table.addCell(createField(characterPlayer, "gender", FadingSunsTheme.CHARACTER_SMALL_BASICS_FONT_SIZE)); table.addCell(createField(characterPlayer, "age", FadingSunsTheme.CHARACTER_SMALL_BASICS_FONT_SIZE)); PdfPCell cell = new PdfPCell(); setCellProperties(cell); cell.addElement(table); return cell; }
From source file:com.softwaremagico.tm.pdf.small.info.CharacterBasicsReducedTableFactory.java
License:Open Source License
private static PdfPCell getSecondColumnTable(CharacterPlayer characterPlayer) { float[] widths = { 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);/*from w ww .ja v a 2 s . com*/ table.addCell(createField(characterPlayer, "race", FadingSunsTheme.CHARACTER_SMALL_BASICS_FONT_SIZE)); table.addCell(createField(characterPlayer, "faction", FadingSunsTheme.CHARACTER_SMALL_BASICS_FONT_SIZE)); table.addCell(createField(characterPlayer, "rank", FadingSunsTheme.CHARACTER_SMALL_BASICS_FONT_SIZE)); PdfPCell cell = new PdfPCell(); setCellProperties(cell); cell.addElement(table); return cell; }
From source file:com.softwaremagico.tm.pdf.small.skills.LearnedSkillsTable.java
License:Open Source License
private static PdfPCell getSkillsColumnTable(CharacterPlayer characterPlayer, String language) throws InvalidXmlElementException { float[] widths = { 4f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);/*from w w w .j av a 2 s . com*/ table.getDefaultCell().setBorder(0); table.addCell(createCompactTitle(getTranslator().getTranslatedText("learnedSkills"), FadingSunsTheme.CHARACTER_SMALL_SKILLS_TITLE_FONT_SIZE)); int added = 0; if (characterPlayer != null) { for (AvailableSkill skill : characterPlayer.getLearnedSkills()) { if (characterPlayer.getSkillTotalRanks(skill) > 0) { table.addCell(createSkillElement(characterPlayer, skill, FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE, MAX_SKILL_COLUMN_WIDTH)); table.addCell(createSkillValue(characterPlayer.getSkillTotalRanks(skill), characterPlayer.isSkillSpecial(skill) || characterPlayer.hasSkillTemporalModificator(skill), characterPlayer.hasSkillModificator(skill), FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE)); added++; } } } if (characterPlayer == null) { for (int i = added; i < ROWS; i++) { table.addCell(CustomPdfTable.createEmptyElementLine(GAP, MAX_SKILL_COLUMN_WIDTH)); table.addCell(CustomPdfTable.createEmptyElementLine(GAP, MAX_SKILL_RANK_WIDTH)); } } else { for (int i = added; i < ROWS; i++) { table.addCell(CustomPdfTable.createEmptyElementLine(" ", MAX_SKILL_COLUMN_WIDTH)); table.addCell(CustomPdfTable.createEmptyElementLine(" ", MAX_SKILL_RANK_WIDTH)); } } PdfPCell cell = new PdfPCell(); setCellProperties(cell); cell.addElement(table); cell.setVerticalAlignment(Element.ALIGN_TOP); return cell; }
From source file:com.softwaremagico.tm.pdf.small.skills.NaturalSkillsTable.java
License:Open Source License
private static PdfPCell getSkillsColumnTable(CharacterPlayer characterPlayer, String language) throws InvalidXmlElementException { float[] widths = { 4f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);/*from ww w . j ava 2 s .com*/ table.getDefaultCell().setBorder(0); table.addCell(createCompactTitle(getTranslator().getTranslatedText("naturalSkills"), FadingSunsTheme.CHARACTER_SMALL_SKILLS_TITLE_FONT_SIZE)); if (characterPlayer == null) { for (AvailableSkill skill : AvailableSkillsFactory.getInstance().getNaturalSkills(language)) { table.addCell(createSkillElement(null, skill, FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE, MAX_SKILL_COLUMN_WIDTH)); table.addCell( createSkillLine(SKILL_VALUE_GAP, FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE)); } } else { for (AvailableSkill skill : characterPlayer.getNaturalSkills()) { table.addCell(createSkillElement(characterPlayer, skill, FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE, MAX_SKILL_COLUMN_WIDTH)); table.addCell(createSkillValue(characterPlayer.getSkillTotalRanks(skill), characterPlayer.isSkillSpecial(skill) || characterPlayer.hasSkillTemporalModificator(skill), characterPlayer.hasSkillModificator(skill), FadingSunsTheme.CHARACTER_SMALL_SKILLS_LINE_FONT_SIZE)); } } PdfPCell cell = new PdfPCell(); setCellProperties(cell); cell.addElement(table); cell.setVerticalAlignment(Element.ALIGN_TOP); return cell; }
From source file:com.softwaremagico.tm.pdf.small.SmallPartySheet.java
License:Open Source License
@Override protected void createContent(Document document) throws Exception { initializeTableContent();//from www . ja v a2 s.c om for (CharacterPlayer characterPlayer : party.getMembers()) { createCharacterPDF(document, characterPlayer); } if (party.getMembers().size() % 2 > 0) { mainTable.addCell(new PdfPCell()); } document.add(mainTable); }
From source file:com.thelinh.gui.PreviewExam.java
private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed if (this.txtExamCode.getText().equals("")) { JOptionPane.showMessageDialog(this, "Hy nhp m ?"); } else {// w ww . j a v a 2 s . c o m JFileChooser fc = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("PDF files (*.pdf)", "pdf"); fc.setFileFilter(filter); int rt = fc.showSaveDialog(this); if (rt == JFileChooser.APPROVE_OPTION) { String filepath = fc.getSelectedFile().getPath(); if (filepath.indexOf(".") == -1) { filepath = filepath + ".pdf"; } String dafilepath = (new StringBuffer(filepath)).insert(filepath.length() - 4, ".da").toString(); try { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(filepath)); document.open(); // Add title Paragraph p = new Paragraph("Tr?ng ?i h?c Bch Khoa H Ni", timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(5); document.add(p); p = new Paragraph("?? thi mn " + this.lbSubject.getText(), timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(25); document.add(p); p = new Paragraph( "Ng?i ra ?: " + Controller.getCurrentAdmin().getAdminName() + ", Ngy ra ?: " + (new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())), times_15); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(5); document.add(p); p = new Paragraph("M ?: " + this.txtExamCode.getText() + " Th?i gian lm bi: " + spTime.getValue().toString() + " pht", timesBold_15); p.setSpacingAfter(25); document.add(p); for (int i = 0; i < this.questionList.size(); i++) { Question question = this.questionList.get(i); ArrayList<Answer> answerList = AnswerSql .getAnswersByQuestionId(question.getQuestionId().trim()); Phrase questionNumber = new Phrase("Cu " + (i + 1) + ": ", timesBold_15); Phrase questionContent = new Phrase(question.getQuestion(), times_15); Paragraph questionTitle = new Paragraph(); questionTitle.add(questionNumber); questionTitle.add(questionContent); document.add(questionTitle); PdfPTable table = new PdfPTable(2); for (int j = 0; j < answerList.size(); j++) { Answer ans = answerList.get(j); Phrase cap = new Phrase(Character.toString((char) (j + 65)) + ". ", timesBold_15); Phrase answerContent = new Phrase(ans.getAnswer(), times_15); Phrase elem = new Phrase(); elem.add(cap); elem.add(answerContent); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setPhrase(elem); cell.setFixedHeight(25); table.addCell(cell); } document.add(table); } document.close(); // if (Desktop.isDesktopSupported()) { // try { // File myFile = new File(filepath); // Desktop.getDesktop().open(myFile); // } catch (IOException ex) { // // no application registered for PDFs // System.out.println(ex.toString()); // } // } document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(dafilepath)); document.open(); // Add title p = new Paragraph("Tr?ng ?i h?c Bch Khoa H Ni", timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(5); document.add(p); p = new Paragraph("?? thi mn " + this.lbSubject.getText(), timesBold_25); p.setAlignment(Element.ALIGN_CENTER); p.setSpacingAfter(25); document.add(p); p = new Paragraph( "Ng?i ra ?: " + Controller.getCurrentAdmin().getAdminName() + ", Ngy ra ?: " + (new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())), times_15); p.setAlignment(Element.ALIGN_LEFT); p.setSpacingAfter(5); document.add(p); p = new Paragraph("M ?: " + this.txtExamCode.getText() + " Th?i gian lm bi: " + spTime.getValue().toString() + " pht", timesBold_15); p.setSpacingAfter(25); document.add(p); for (int i = 0; i < this.questionList.size(); i++) { Question question = this.questionList.get(i); ArrayList<Answer> answerList = AnswerSql .getAnswersByQuestionId(question.getQuestionId().trim()); Phrase questionNumber = new Phrase("Cu " + (i + 1) + ": ", timesBold_15); Phrase questionContent = new Phrase(question.getQuestion(), times_15); Paragraph questionTitle = new Paragraph(); questionTitle.add(questionNumber); questionTitle.add(questionContent); document.add(questionTitle); PdfPTable table = new PdfPTable(2); for (int j = 0; j < answerList.size(); j++) { Answer ans = answerList.get(j); Phrase cap = new Phrase(Character.toString((char) (j + 65)) + ". ", timesBold_15); Phrase answerContent = null; if (ans.getYesNo()) { answerContent = new Phrase(ans.getAnswer(), timesBold_15); } else { answerContent = new Phrase(ans.getAnswer(), times_15); } Phrase elem = new Phrase(); elem.add(cap); elem.add(answerContent); PdfPCell cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); cell.setPhrase(elem); cell.setFixedHeight(25); table.addCell(cell); } document.add(table); } document.close(); } catch (FileNotFoundException | DocumentException ex) { Logger.getLogger(PreviewExam.class.getName()).log(Level.SEVERE, null, ex); } } } }