Hi everybody,
I'm trying to merge two pdf templates into a PDF on a JSP, both were created
with adobe pro and both have a form that's filled with dynamic information,
the problem i've found is that in the preview it's ok, but in several pc's
when i try to print it i do not get the same result.
I've tried to "force" the page size to LETTER but i get the same result, i'm
guessing my code has a mistake. Does anybody know a solution to this?, any
help or information about it would be appreciated.
<%...@page import="java.io.*,
com.lowagie.text.*,
com.lowagie.text.pdf.*,
try{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfCopyFields copy = new PdfCopyFields(baos);
PdfReader plantilla;
ByteArrayOutputStream buffer;
PdfStamper stamp;
AcroFields form;
plantilla = new PdfReader(application.getRealPath("TEMP1.pdf"));
buffer = new ByteArrayOutputStream();
stamp = new PdfStamper(plantilla, buffer);
form = stamp.getAcroFields();
/*SOME FILLING*/
form.setField("FIELD","VALUE");
stamp.setFormFlattening(true);
stamp.close();
copy.addDocument(new PdfReader(buffer.toByteArray()));
buffer.close();
plantilla = new
PdfReader(application.getRealPath("TEMP2.pdf"));
buffer = new ByteArrayOutputStream();
stamp = new PdfStamper(plantilla, buffer);
form = stamp.getAcroFields();
/*SOME FILLING*/
form.setField("FIELD","VALUE");
stamp.setFormFlattening(true);
stamp.close();
copy.addDocument(new PdfReader(buffer.toByteArray()));
buffer.close();
copy.close();
PdfWriter test = copy.getWriter();
test.setPageSize(PageSize.LETTER);
response.reset();
response.setContentType( "application/pdf" );
response.setHeader("Expires", "0");
response.setHeader("Cache-Control","must-revalidate, post-check=0,
pre-check=0");
response.setHeader("Pragma", "public");
byte[] bytes = baos.toByteArray();
response.setContentLength(bytes.length);
javax.servlet.ServletOutputStream servletoutputstream =
response.getOutputStream();
servletoutputstream.write(bytes);
servletoutputstream.flush();
servletoutputstream.close();
} catch(Exception ex) {
ex.printStackTrace();
}
%>
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/Print-Issue-tp2274577p2274577.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/