I am using a template for a certificate, and a Name and Date are added
and saved. The texts are added without any problems. When the new "PDF" is saved on a directory, it is saved as a generic file and when opened, prompts the user to select a program to open it. Please tell me what is missing in this code:
PdfReader reader = new PdfReader(filePath);
Document pdfDoc = new Document(PageSize.A4.rotate());
PdfWriter writer = PdfWriter.getInstance(pdfDoc, new FileOutputStream(outFile));
dateManipulator dM = new dateManipulator();
PdfImportedPage page;
int x, y, z;
pdfDoc.open();
PdfContentByte cb = writer.getDirectContent();
BaseFont bf = BaseFont.createFont(BaseFont.TIMES_BOLDITALIC, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
Color c = new Color(0, 0, 0);
Font f = new Font(bf, 40, 2, c);
Font f2 = new Font(bf, 24, 2, c);
x = 410;
y = 408;
pdfDoc.newPage();
page = writer.getImportedPage(reader, 1);
Document pdfDoc = new Document(PageSize.A4.rotate());
PdfWriter writer = PdfWriter.getInstance(pdfDoc, new FileOutputStream(outFile));
dateManipulator dM = new dateManipulator();
PdfImportedPage page;
int x, y, z;
pdfDoc.open();
PdfContentByte cb = writer.getDirectContent();
BaseFont bf = BaseFont.createFont(BaseFont.TIMES_BOLDITALIC, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
Color c = new Color(0, 0, 0);
Font f = new Font(bf, 40, 2, c);
Font f2 = new Font(bf, 24, 2, c);
x = 410;
y = 408;
pdfDoc.newPage();
page = writer.getImportedPage(reader, 1);
cb.addTemplate(page, 0, -1, 1, 0, 25, 600);
Chunk ch = new Chunk(cnname, f);
ch.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 0, c);
Phrase phrase = new Phrase(22, ch);
ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, phrase, x, 325 , 0); //275
String strDate = dM.returnMonth(todaysDate) + " " + dM.returnSuffix(todaysDate) + ", " + dM.returnYear(todaysDate);
Chunk ch2 = new Chunk(strDate, f2);
Phrase phrase2 = new Phrase(22, ch2);
ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, phrase2, y, 235, 0);
Chunk ch = new Chunk(cnname, f);
ch.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 0, c);
Phrase phrase = new Phrase(22, ch);
ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, phrase, x, 325 , 0); //275
String strDate = dM.returnMonth(todaysDate) + " " + dM.returnSuffix(todaysDate) + ", " + dM.returnYear(todaysDate);
Chunk ch2 = new Chunk(strDate, f2);
Phrase phrase2 = new Phrase(22, ch2);
ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, phrase2, y, 235, 0);
pdfDoc.close();
------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
