我有下一个问题:
有什么想法吗?
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Chapter;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.List;
import com.itextpdf.text.ListItem;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Section;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
public class DeckOf52Cards {
public static void main(String[] args) throws DocumentException,IOException {
Document generatePDF = new Document();
FileOutputStream someName = new FileOutputStream("DeckOf52Cards.pdf");
PdfWriter.getInstance(generatePDF, someName);
generatePDF.open();
BaseFont downloaded = BaseFont.createFont("Burn outfade away.ttf",BaseFont.IDENTITY_H,true);
Font[] someStyle = {
new Font(downloaded, 40, 0, new BaseColor (0,0,0)),
new Font(downloaded, 40, 0, new BaseColor(255,0,0))
};
PdfPTable table = new PdfPTable(4);
String[] ranks ={"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
char[] suits = {'\u2660','\u2663','\u2666','\u2665'};
for (int i = 0; i < ranks.length; i++) {
for (int j = 0; j < suits.length; j++) {
if (suits[j] == '\u2666' || suits[j] == '\u2665') {
table.addCell(new Paragraph(suits[j] + ranks[i] + "",someStyle[0]));
}
else {
table.addCell(new Paragraph(ranks[i] + suits[j] + "",someStyle[1]));
}
}
}
generatePDF.add(table);
generatePDF.close();
}
}