-none- 2007-09-08 - By Paulo Soares
Back I think I was looking at the wrong place. Try:
PdfReader pdfCoverReader = new PdfReader("C:\\hihi.pdf"); <-- this is the flattened form
PdfImportedPage pip = _pdfWriter.getImportedPage(pdfCoverReader, 1);
Image foo = Image.getInstance(pip);
foo.setAbsolutePosition(0, 0);
_pdfDocument.add(foo);
_pdfDocument.newPage();
Paulo
-- -- Original Message -- -- From: "Gerold Krommer" <Gerold.Krommer@(protected)> To: "Post all your questions about iText here" <itext-questions@(protected)> Sent: Saturday, September 08, 2007 12:58 PM Subject: Re: [iText-questions] Is a flattened form special?
Hi Paolo,
thanks for looking into this. I have attached the original form from LC 7, the result of the filling and flattening and below is the function that is used for filling, flattening and appending to the document.
Nevermind my funny namings :-)
If I have time this weekend I will try to reproduce it with a small code sample.
Thanks for the exellent work.
private void printFolderCoverSheet (com.filenet.wcm.api.Folder folder, PdfOutline outline, int numDocs){
PdfOutline tmpOutline;
try {
PdfReader reader = new PdfReader("FolderPrintCoverSheet.pdf");
PdfStamper stamper = new PdfStamper(reader,
new FileOutputStream("C:\\hihi.pdf"));
/**
* @(protected) better naming convention
*/
AcroFields form = stamper.getAcroFields();
HashMap fields = form.getFields();
String key;
for (Iterator i = fields.keySet().iterator(); i.hasNext(); ) {
key = (String) i.next();
// We retrieve a field name from the acro form. Field name is defined as the last character sequence in the name hierarchy
// which contains a [] at the end
String acroFieldName = key.substring(key.lastIndexOf(".")+1,key.lastIndexOf("["));
System.out.print(acroFieldName + ": ");
switch (form.getFieldType(key)) {
case AcroFields.FIELD_TYPE_TEXT: // We only look at fields of type text
try{
form.setField(key, getFolderProperty(folder, acroFieldName)); //getFolderProperty retrieves a property value from the folder with the same name property as the acro field name
} catch (PropertyNotFoundException pnf){
// Explicitly do nothing when the property is not found.
}
}
}
reader.close();
stamper.setFormFlattening(true);
stamper.close();
//Append just created PDF to the output stream
PdfReader pdfCoverReader = new PdfReader("C:\\hihi.pdf");
PdfImportedPage pip = _pdfWriter.getImportedPage(pdfCoverReader, 1);
Image foo = Image.getInstance(pip);
_pdfDocument.add(foo);
_pdfDocument.newPage();
}
catch (DocumentException de) {
System.out.println(de.getMessage());
}
catch (IOException ioe) {
System.out.println(ioe.getMessage());
}
}
/DI Gerold Krommer
Manager Pre- und Postsales
ASTRON Business Services G.m.b.H., Vienna, Austria
Tel.: +43 1 585 31 90-22
Fax: +43 1 585 31 90-15
CONFIDENTIAL NOTICE: The contents of this message, including any attachments, are confidential and are intended solely for the use of the person or entity to whom the message was addressed. If you are not the intended recipient of this message, please be advised that any dissemination, distribution, or use of the contents of this message is strictly prohibited. If you received this message in error, please notify the sender. Please also permanently delete all copies of the original message and any attached documentation. Thank you.
__ ____ ____ ____ ____ ____ ____
Von: itext-questions-bounces@(protected) [mailto:itext-questions-bounces@(protected)] Im Auftrag von Paulo Soares Gesendet: Freitag, 07. September 2007 16:58 An: Post all your questions about iText here Betreff: Re: [iText-questions] Is a flattened form special?
Can you post hihi.pdf?
Paulo
__ ____ ____ ____ ____ ____ ____
From: itext-questions-bounces@(protected) [mailto:itext-questions-bounces@(protected)] On Behalf Of Gerold Krommer Sent: Friday, September 07, 2007 9:17 AM To: itext-questions@(protected) Subject: [iText-questions] Is a flattened form special?
I am using iText 2.0.4 to create a single document out of many document contained in a DMS repository. This works flawlessly. Some of the documents in the DMS are already PDF and inclusion of them is no problem.
To separate the documents I insert a cover sheet with some information about the following document (date created, owner , whathaveyou) and use a static PDF form (created in LC Designer 7) to fill in the fields.
Then I flatten the single page form and want to include it in my output stream. The same code that works with other PDFs gives me an empty page and absolutely no error.
This is the absolutely trivial code snippet which I basically copied from 'iText in Action' which I'm a proud owner of.
PdfReader pdfCoverReader = new PdfReader("C:\\hihi.pdf"); <-- this is the flattened form
PdfImportedPage pip = _pdfWriter.getImportedPage(pdfCoverReader, 1);
Image foo = Image.getInstance(pip);
_pdfDocument.add(foo);
_pdfDocument.newPage();
Since this works in other places, this makes me wonder if there is something special about the flattened forms.
/DI Gerold Krommer
Manager Pre- und Postsales
ASTRON Business Services G.m.b.H., Vienna, Austria
Tel.: +43 1 585 31 90-22
Fax: +43 1 585 31 90-15
CONFIDENTIAL NOTICE: The contents of this message, including any attachments, are confidential and are intended solely for the use of the person or entity to whom the message was addressed. If you are not the intended recipient of this message, please be advised that any dissemination, distribution, or use of the contents of this message is strictly prohibited. If you received this message in error, please notify the sender. Please also permanently delete all copies of the original message and any attached documentation. Thank you.
__ ____ ____ ____ ____ ____ ____
Aviso Legal: Esta mensagem ? destinada exclusivamente ao destinat?rio. Pode conter informa??o confidencial ou legalmente protegida. A incorrecta transmiss?o desta mensagem n?o significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. ? proibido a qualquer pessoa que n?o o destinat?rio de usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
> -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ > iText-questions mailing list > iText-questions@(protected) > https://lists.sourceforge.net/lists/listinfo/itext-questions > Buy the iText book: http://itext.ugent.be/itext-in-action/ >
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|