List of usage examples for com.itextpdf.text PageSize A4
Rectangle A4
To view the source code for com.itextpdf.text PageSize A4.
Click Source Link
From source file:util.ImageExample.java
public ImageExample(Calendar date, int settings, ArrayList<String> courses, String time, String eventAddress, int totalPrice, String comments, boolean kunde) throws Exception { this.date = date; this.settings = settings; this.courses = courses; this.time = time; this.eventAddress = eventAddress; this.totalPrice = totalPrice; this.comments = comments; this.fileName = ""; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ge.getAllFonts();// w ww. ja v a2s .c om FontFactory.register("C:/Windows/Fonts/ARLRDBD.TTF", "Arial Rounded"); Font font = FontFactory.getFont("Arial Rounded", 22, Font.NORMAL, new BaseColor(51, 102, 102)); Document document = new Document(); System.out.println("Pdf creation startet"); try { if (kunde) { fileName = "grill" + new SimpleDateFormat("dd. MMMMM yyyy hhmm").format(date.getTime()) + ".pdf"; } else { fileName = "grill" + new SimpleDateFormat("dd. MMMMM yyyy hhmm").format(date.getTime()) + "Prisliste.pdf"; } FileOutputStream file = new FileOutputStream(new File("C:/Users/Mark/Desktop", fileName)); PdfWriter writer = PdfWriter.getInstance(document, file); document.open(); Image img = Image.getInstance("src/pictures/cirkles.png"); img.scaleToFit(277, 277); img.setAbsolutePosition(40, PageSize.A4.getHeight() - img.getHeight()); document.add(img); Chunk chunk = new Chunk("Grillmester 'Frankie'", font); chunk.setCharacterSpacing(3); Paragraph header = new Paragraph(chunk); header.setAlignment(Element.ALIGN_RIGHT); header.setSpacingBefore(15); document.add(header); Paragraph title = new Paragraph( "Tilbud angende d. " + new SimpleDateFormat("dd. MMMMM yyyy").format(date.getTime()) + ".", new Font(Font.FontFamily.TIMES_ROMAN, 20, Font.BOLD)); title.setAlignment(Element.ALIGN_LEFT); title.setIndentationLeft(235); title.setSpacingBefore(100); title.setLeading(17); document.add(title); Paragraph subtitle = new Paragraph("(Arrangement til " + settings + " personer).", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.ITALIC)); subtitle.setAlignment(Element.ALIGN_LEFT); subtitle.setIndentationLeft(235); subtitle.setLeading(17); document.add(subtitle); Paragraph body = new Paragraph("\n\nDer er aftalt:\n\n", new Font(Font.FontFamily.TIMES_ROMAN, 18)); body.setAlignment(Element.ALIGN_LEFT); body.setIndentationLeft(235); body.setLeading(17); for (String course : courses) { body.add(course + "\n\n"); } body.add("\nServeres klokken " + time + " i " + eventAddress + "."); document.add(body); Paragraph ending = new Paragraph("\n\n\nPris: " + totalPrice + ",-kr.", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); ending.setAlignment(Element.ALIGN_LEFT); ending.setIndentationLeft(235); ending.setLeading(17); document.add(ending); if (!comments.equals("null")) { if (!comments.equals("")) { Paragraph comment = new Paragraph("\n\nKommentarer\n" + comments, new Font(Font.FontFamily.TIMES_ROMAN, 18)); comment.setAlignment(Element.ALIGN_LEFT); comment.setIndentationLeft(235); comment.setLeading(17); document.add(comment); } } Image footerImg = Image.getInstance("src/pictures/grillmester.png"); footerImg.scaleToFit(210, 210); footerImg.setAbsolutePosition(40, 40); document.add(footerImg); Image img2 = Image.getInstance("src/pictures/Contact.png"); img2.scaleToFit(250, 250); img2.setAbsolutePosition(20, PageSize.A4.getHeight() - img.getHeight() - 250); document.add(img2); document.close(); System.out.println("Pdf finish"); } catch (Exception e) { e.printStackTrace(); System.out.println(e.getLocalizedMessage()); } }
From source file:Utility.PDFDemo.java
public void cretePDF(String name, String rpor) throws FileNotFoundException { try {/* w w w.jav a 2 s . c om*/ //Create document for pdf Document doc = new Document(); //PDF writer to write into document PdfWriter docwriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { // //file path //String path = "docs/" + name; docwriter = PdfWriter.getInstance(doc, new FileOutputStream(rpor + ".pdf")); } catch (DocumentException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } //document header attributes doc.addAuthor("CHED CU"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Grant Monitor"); doc.addTitle(rpor); doc.setPageSize(PageSize.A4.rotate()); //This sets page size to A4 and orientation to Landscape //doc.setPageSize(PageSize.A4); doc.setMargins(30f, 30f, 20f, 20f); //open document doc.open(); //Creating a paragraphs and chunks Paragraph pp = new Paragraph("Cocoa Health And Extension", forTitle); pp.setAlignment(Element.ALIGN_CENTER); Paragraph palaglapgh = new Paragraph("(Cocobod)", bfBold12); palaglapgh.setAlignment(Element.ALIGN_CENTER); Chunk chk = new Chunk("From GIS Office, Accra", bfBold12); chk.setUnderline(.1f, -2f); // 0.1 thickness and -2 position Paragraph underText = new Paragraph(chk); underText.setAlignment(Element.ALIGN_CENTER); Chunk chuk1 = new Chunk("Lot No:", bfBold12); chuk1.setUnderline(.1f, -2f); Chunk chuk2 = new Chunk(name, bfBold12); Paragraph regionText = new Paragraph(rpor, bfBold12); regionText.setAlignment(Element.ALIGN_CENTER); String rporx = ""; // ResultSet dir = manager.PDFdemos(name); // try { // if (dir.next()) { // rporx = dir.getString(12); // // } // } catch (SQLException ex) { // Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); // } Paragraph regionTexts = new Paragraph(rporx, bfBold12); regionText.setAlignment(Element.ALIGN_CENTER); //add the PDF table to the paragraph //palaglapgh.add(table); //Table Generation block regionText.add(reports()); //SECTION TO ADD ELEMENTS TO PDF // add the paragraph to the document doc.add(pp); //doc.add(Chunk.NEWLINE); //Adds a new blank line doc.add(palaglapgh); doc.add(underText); doc.add(chuk1); doc.add(chuk2); //Current Date and time insertion Paragraph newDate = new Paragraph(new Date().toString(), bf12); newDate.setAlignment(Element.ALIGN_RIGHT); doc.add(newDate); doc.add(regionTexts); doc.add(regionText); //close the document doc.close(); //close the writer docwriter.close(); } catch (DocumentException ex) { Logger.getLogger(PDFDemo.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:utils.pdf.cv_templates.Template1.java
public void createPdf(String path, User user, List<String> personalCharacteristics, List<Skill> skills) throws DocumentException, IOException { document = new Document(PageSize.A4); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();/* w w w. java 2s .c o m*/ //CONTENIDO addImageBackgroundTop(); addImageBackgroundBottom(); addImageTelephone(); addImageAddress(); addImageEmail(); addImageLine(); addImageLine1(); addImageLine2(); addImageLine3(); addImageLine4(); addImageLine5(); //IMAGE addImage(user); //DATOS PERSONALES addPersonalInformation(user); //SKILLS addSkills(user, personalCharacteristics, skills); //STUDIES addStudies(user); //EXPERIENCE if (!user.currentSituation.professionalExperienceList.isEmpty()) { addProfessionalExperience(user.currentSituation.professionalExperienceList); } //PROGRAMS if (!user.softwareList.isEmpty()) { addSoftware(user.softwareList); } //Studies and courses addAllTitle(user.languages, user.courses); //CERRAR DOCUMENTO document.close(); }
From source file:utils.pdf.cv_templates.Template1.java
private void addImageBackgroundTop() throws DocumentException, IOException { Image back_img = Image.getInstance(BACK_IMAGE); back_img.setAbsolutePosition((PageSize.A4.getWidth() - back_img.getScaledWidth()) / 2, (PageSize.A4.getHeight() - back_img.getScaledHeight()) / 2); back_img.setAbsolutePosition(0, 823); document.add(back_img);//from ww w.ja v a 2 s.c o m }
From source file:utils.pdf.cv_templates.Template1.java
private void addImageBackgroundBottom() throws DocumentException, IOException { Image back_img = Image.getInstance(BACK_IMAGE); back_img.setAbsolutePosition((PageSize.A4.getWidth() - back_img.getScaledWidth()) / 2, (PageSize.A4.getHeight() - back_img.getScaledHeight()) / 2); back_img.setAbsolutePosition(0, 0);/*from w ww. j a v a 2s . com*/ document.add(back_img); }
From source file:utils.pdf.cv_templates.Template2.java
public void createPdf(String path, User user, List<String> personalCharacteristics, List<Skill> skills) throws DocumentException, IOException { document = new Document(PageSize.A4); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();// www.j a v a 2 s . c o m //CONTENIDO addImageTelephone(); addImageEmail(); //IMAGE addImage(user); //DATOS PERSONALES addPersonalInformation(user); //SKILLS addSkills(user, personalCharacteristics, skills); //STUDIES addStudies(user); //EXPERIENCE if (!user.currentSituation.professionalExperienceList.isEmpty()) { addProfessionalExperience(user.currentSituation.professionalExperienceList); } //PROGRAMS if (!user.softwareList.isEmpty()) { addSoftware(user.softwareList); } //Studies and courses addAllTitle(user.languages, user.courses); //CERRAR DOCUMENTO document.close(); }
From source file:utils.pdf.cv_templates.Template3.java
public void createPdf(String path, User user, List<String> personalCharacteristics, List<Skill> skills) throws DocumentException, IOException { document = new Document(PageSize.A4); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();/*from w w w .ja va2 s. co m*/ //CONTENT //IMAGES addBackgroundImage(); addLineImage(); //PERSONAL INFORMATION addPersonalInformation(user); //STUDIES addAcademicExperience(user); //EXPERIENCE if (!user.currentSituation.professionalExperienceList.isEmpty()) { addProfessionalExperience(user.currentSituation.professionalExperienceList); } //PROGRAMS if (!user.softwareList.isEmpty()) { addSoftware(user.softwareList); } //LANGUAGES if (!user.languages.isEmpty()) { addLanguages(user.languages); } //SKILLS if (!personalCharacteristics.isEmpty() && !skills.isEmpty()) { addSkills(user, personalCharacteristics, skills); } //CLOSE DOCUMENT document.close(); }
From source file:utils.pdf.cv_templates.Template3.java
private void addBackgroundImage() throws DocumentException, IOException { Image back_img = Image.getInstance(BACK_IMAGE); back_img.setAbsolutePosition((PageSize.A4.getWidth() - back_img.getScaledWidth()) / 2, (PageSize.A4.getHeight() - back_img.getScaledHeight()) / 2); document.add(back_img);//from w w w. j a v a2 s . c o m }
From source file:utils.pdf.cv_templates.Template4.java
public void createPdf(String path, User user, List<String> personalCharacteristics, List<Skill> skills) throws DocumentException, IOException { document = new Document(PageSize.A4); PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();// w w w .ja v a 2 s . c o m //CONTENIDO //IMAGE addImage(user); //DATOS PERSONALES addPersonalInformation(user); //STUDIES addStudies(user); //EXPERIENCE if (!user.currentSituation.professionalExperienceList.isEmpty()) { addProfessionalExperience(user.currentSituation.professionalExperienceList); } //PROGRAMS if (!user.softwareList.isEmpty()) { addSoftware(user.softwareList); } //COURSES if (!user.courses.isEmpty()) { addCourses(user.courses); } //LANGUAGES if (!user.languages.isEmpty()) { addLanguage(user.languages); } //SKILLS addSkills(user, personalCharacteristics, skills); //CERRAR DOCUMENTO document.close(); }
From source file:utils.PrintUtils.java
public static void printAnnualReportNote(Annee annee, Trimesteannee trimesteannee, Classe classe, ClasseElementevaluation classeElementevaluation, List<Eleveanneeclasse> eleveanneeclasses, List<Trimesteannee> trimesteannees, List<Sequenceannee> sequenceannees, ClasseElementevaluationFacadeLocal classeElementevaluationFacadeLocal, PlanningEvaluationFacadeLocal planningEvaluationFacadeLocal, EvaluationFacadeLocal evaluationFacadeLocal, SequenceanneeFacadeLocal sequenceanneeFacadeLocal) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); String fichier = "proces_verbal_note" + "_" + annee.getCode() + "-" + annee.getCodefin() + "_" + classe.getNom() + ".pdf"; Document rapport = new Document(PageSize.A4.rotate()); PdfWriter.getInstance(rapport, new FileOutputStream( Utilitaires.path + "/" + Utilitaires.repertoireParDefaultNotesAnnuel + "/" + fichier)); rapport.open();//w ww. j a v a 2 s . c o m rapport.add(new Paragraph("Anne Scolaire : " + annee.getCode() + " / " + annee.getCodefin())); rapport.add(new Paragraph("Classe : " + classe.getNom())); rapport.add( new Paragraph("Unit Evaluation : " + classeElementevaluation.getElementevaluation().getNom())); rapport.add(new Paragraph("Periode : " + annee.getCode() + " - " + annee.getCodefin())); rapport.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(2 + sequenceannees.size()); table.setWidthPercentage(100); table.addCell(PrintUtils.createPdfPCell("PROCES VERBAL ANNUEL DES NOTES ", 2 + sequenceannees.size(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("ELEVES", 2, true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))).setRowspan(2); table.addCell(PrintUtils.createPdfPCell("NOTES", sequenceannees.size(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); for (Trimesteannee t : trimesteannees) { table.addCell(PrintUtils.createPdfPCell("" + t.getIdtrimestre().getNom(), sequenceanneeFacadeLocal.getByTrimestre(t.getIdtrimestrean()).size(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); } table.addCell(PrintUtils.createPdfPCell("MATRICULE", true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("NOM(S) ET PRENOM(S)", true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); for (Sequenceannee s : sequenceannees) { table.addCell(PrintUtils.createPdfPCell("" + s.getIdsequence().getNom(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); } for (Eleveanneeclasse e : eleveanneeclasses) { table.addCell(PrintUtils.createPdfPCell("" + e.getEleve().getMatricule(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); table.addCell(PrintUtils.createPdfPCell("" + e.getEleve().getNom() + " " + e.getEleve().getPrenom(), true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); for (Sequenceannee s1 : sequenceannees) { String r = findNote1(e, s1, classeElementevaluation, classeElementevaluationFacadeLocal, planningEvaluationFacadeLocal, evaluationFacadeLocal); table.addCell(PrintUtils.createPdfPCell("" + r, true, new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL))); } } rapport.add(table); rapport.close(); }