我想用Java创建CV构建器,但没有找到任何用于垂直对齐PDF文本的代码。。。。我的意思是说知道如何水平对齐或设置文本,但不知道如何垂直对齐文本
Document document =new Document();
PdfWriter.getInstance(document,new FileOutputStream("templet2.pdf"));
String SelectTemplet="lightgreen"; //value which select templet
document.open();
//字体属性字体F1 =新字体(Font.FontFamily.COURIER,35,Font.BOLD,BaseColor.WHITE);字体F2 =新字体(Font.FontFamily.COURIER,15,Font.BOLD,BaseColor.BLACK);字体F3 =新字体(Font.FontFamily.COURIER,10,Font.NORMAL,BaseColor.BLACK);
//PARAGRAPH
Paragraph FirstName =new Paragraph("MUHAMMAD SHAHMIR KHAN",F1);
Paragraph Space1 =new Paragraph(" ");
Paragraph ProfessionalT =new Paragraph("PROFESSIONAL SUMMARY : ",F2);
String summary="I'm a simple person who try to easy other people live ";
Paragraph ProfessionalC =new Paragraph(" "+summary,F3);
Paragraph WorkExperienceT =new Paragraph("WORK EXPERIENCE :",F2);
String CompanyNameC="Ali express",day="04",year="2016",dayTill="05",yearTill="2017",PostT1="Senior software developer";
Paragraph Date =new Paragraph(" "+day+"/"+year+" - "+dayTill+"/"+yearTill,F3);
Paragraph CompanyNameT =new Paragraph("COMPANY NAME : "+CompanyNameC,F3);
Paragraph PostT =new Paragraph("POST : "+PostT1,F3);
Paragraph WorkExperienceT2 =new Paragraph("WORK EXPERIENCE :",F2);
String CompanyNameC2="Ali baba",day2="09",year2="2017",dayTill2="12",yearTill2="2019",PostT12="Senior software developer";
Paragraph Date2 =new Paragraph(" "+day2+"/"+year2+" - "+dayTill2+"/"+yearTill2,F3);
Paragraph CompanyNameT2 =new Paragraph("COMPANY NAME : "+CompanyNameC,F3);
Paragraph PostT2 =new Paragraph("POST : "+PostT1,F3);
String CompanyNameC6="Ali baba",day6="09",year6="2017",dayTill6="12",yearTill6="2019",PostT16="Senior software developer";
Paragraph Date6 =new Paragraph(" "+day6+"/"+year6+" - "+dayTill6+"/"+yearTill6,F3);
Paragraph CompanyNameT6 =new Paragraph("COMPANY NAME : "+CompanyNameC,F3);
Paragraph PostT6 =new Paragraph("POST : "+PostT16,F3);
Paragraph EducationT =new Paragraph("EDUCATION :",F2);
String day3="20",year3="2016",dayTill3="30",yearTill3="2018",instritution="NUST",degree="softwere engenering";
Paragraph Date3 =new Paragraph(" "+day3+"/"+year3+" - "+dayTill3+"/"+yearTill3,F3);
Paragraph Education1 =new Paragraph(instritution+","+degree,F3);
//education number 2
String day4="20",year4="2016",dayTill4="30",yearTill4="2018",instritution2="NUST",degree2="softwere engenering";
Paragraph Date4 =new Paragraph(" "+day4+"/"+year4+" - "+dayTill4+"/"+yearTill4,F3);
Paragraph Education2 =new Paragraph(instritution2+","+degree2,F3);
//education number 3
String day5="20",year5="2016",dayTill5="30",yearTill5="2018",instritution3="NUST",degree3="softwere engenering";
Paragraph Date5 =new Paragraph(" "+day5+"/"+year5+" - "+dayTill5+"/"+yearTill5,F3);
Paragraph Education3 =new Paragraph(instritution3+","+degree3,F3);
Paragraph Softskill =new Paragraph("SOFT SKILLS :",F2);
String skilla="Communication",skillb="Project manager",skillc="Fast typing",skilld="Time management",skille="Team player";
Paragraph skill1 =new Paragraph(" • "+skilla,F3);
Paragraph skill2 =new Paragraph(" • "+skillb,F3);
Paragraph skill3 =new Paragraph(" • "+skillc,F3);
Paragraph skill4 =new Paragraph(" • "+skilld,F3);
Paragraph skill5 =new Paragraph(" • "+skille,F3);
//ALLIGMENT
FirstName.setAlignment(Element.ALIGN_CENTER);
Date.setAlignment(Element.ALIGN_RIGHT);
Date2.setAlignment(Element.ALIGN_RIGHT);
Date3.setAlignment(Element.ALIGN_RIGHT);
Date4.setAlignment(Element.ALIGN_RIGHT);
Date5.setAlignment(Element.ALIGN_RIGHT);
Date6.setAlignment(Element.ALIGN_RIGHT);
document.add(FirstName);
document.add(Space1);
document.add(Space1);
document.add(Space1);
document.add(ProfessionalT);
document.add(Space1);
document.add(ProfessionalC);
document.add(Space1);
document.add(Space1);
document.add(WorkExperienceT);
document.add(Space1);
document.add(Date);
document.add(CompanyNameT);
document.add(PostT);
document.add(Space1);
document.add(Date6);
document.add(CompanyNameT6);
document.add(PostT6);
document.add(Space1);
document.add(Date2);
document.add(CompanyNameT2);
document.add(PostT2);
document.add(Space1);
document.add(Space1);
document.add(EducationT);
document.add(Space1);
document.add(Date3);
document.add(Education1);
document.add(Space1);
document.add(Date4);
document.add(Education2);
document.add(Space1);
document.add(Date5);
document.add(Education3);
document.add(Space1);
document.add(Softskill);
document.add(Space1);
document.add(skill1);
document.add(skill2);
document.add(skill3);
document.add(skill4);
//document.add(skill5);
//add image
Image img1 = Image.getInstance("C:\\Users\\user\\Desktop\\project\\pics\\cv1\\pink.png");
img1.setAbsolutePosition(0f, 360f);//this control the image verticallly and horizontaly
img1.scaleToFit(700, 1000f);//this increase the size but in square order
document.add(img1);
//add LINE
Image img2 = Image.getInstance("C:\\Users\\user\\Desktop\\project\\pics\\cv1\\LINEPINK2.png");
img2.setAbsolutePosition(-25f, 620f);//this control the image verticallly and horizontaly
img2.scaleToFit(700, 1000f);//this increase the size but in square order
document.add(img2);
//add LINE
Image img3 = Image.getInstance("C:\\Users\\user\\Desktop\\project\\pics\\cv1\\LINEPINK2.png");
img3.setAbsolutePosition(-25f, 525f);//this control the image verticallly and horizontaly
img3.scaleToFit(700, 1000f);//this increase the size but in square order
document.add(img3);
//add LINE
Image img4 = Image.getInstance("C:\\Users\\user\\Desktop\\project\\pics\\cv1\\LINEPINK2.png");
img4.setAbsolutePosition(-25f, 280f);//this control the image verticallly and horizontaly
img4.scaleToFit(700, 1000f);//this increase the size but in square order
document.add(img4);
//add LINE
Image img5 = Image.getInstance("C:\\Users\\user\\Desktop\\project\\pics\\cv1\\LINEPINK2.png");
img5.setAbsolutePosition(-25f, 94f);//this control the image verticallly and horizontaly
img5.scaleToFit(700, 1000f);//this increase the size but in square order
document.add(img5);
//endding LINE
Image img6 = Image.getInstance("C:\\Users\\user\\Desktop\\project\\pics\\cv1\\pink.png");
img6.setAbsolutePosition(-25f, -570f);//this control the image verticallly and horizontaly
img6.scaleToFit(700, 1000f);//this increase the size but in square order
document.add(img6);
document.close();