Hi All,
I am trying to fill up a pdf form using this code:
PdfStamper stamper = new PdfStamper(reader, fout);
AcroFields form_pdf = stamper.getAcroFields();
Map<String, String> map =
pdfFormsVO.getPdfMapingObj();
//map is the object which all the key value pair for the pdf field names
and corresponding values
try {
if (map != null) {
Set<String> set = map.keySet();
Iterator<String> iterator =
set.iterator();
while (iterator.hasNext()) {
String key =
iterator.next();
String val =
map.get(key);
if (val == null ||
val.equalsIgnoreCase("null")) {
val = "";
}
System.out
.println("key: " + key + " value: " + val);
form_pdf.setField(key,
val);
System.out.println("done setting the key value pair");
}
stamper.setFormFlattening(true);
stamper.close();
}
} catch (DocumentException e) {
logger
.info("****************************************************************************************************");
logger.info("The error message is : " +
e.getMessage());
e.printStackTrace();
logger
.info("****************************************************************************************************");
}
the code seems to work fine for the first 6-7 field and after that it throws
an exception which is shown below:
22:16:50,986 INFO [PDFUtilityAction]
****************************************************************************************************
22:16:50,986 INFO [PDFUtilityAction] The error message is : Font
'KozMinPro-Regular' with 'UniJIS-UCS2-H' is not recognized.
22:16:50,986 ERROR [STDERR] ExceptionConverter:
22:16:50,987 ERROR [STDERR] com.itextpdf.text.DocumentException: Font
'KozMinPro-Regular' with 'UniJIS-UCS2-H' is not recognized.
22:16:50,987 ERROR [STDERR] at
com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:689)
22:16:50,987 ERROR [STDERR] at
com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:596)
22:16:50,987 ERROR [STDERR] at
com.itextpdf.text.pdf.BaseFont.createFont(BaseFont.java:431)
22:16:50,987 ERROR [STDERR] at
com.itextpdf.text.pdf.DocumentFont.<init>(DocumentFont.java:137)
22:16:50,987 ERROR [STDERR] at
com.itextpdf.text.pdf.AcroFields.decodeGenericDictionary(AcroFields.java:575)
22:16:50,987 ERROR [STDERR] at
com.itextpdf.text.pdf.AcroFields.getAppearance(AcroFields.java:713)
22:16:50,987 ERROR [STDERR] at
com.itextpdf.text.pdf.AcroFields.getAppearance(AcroFields.java:791)
22:16:50,987 ERROR [STDERR] at
com.itextpdf.text.pdf.AcroFields.setField(AcroFields.java:1347)
22:16:50,987 ERROR [STDERR] at
com.itextpdf.text.pdf.AcroFields.setField(AcroFields.java:1288)
22:16:50,987 ERROR [STDERR] at
com.jctaylor.breg.action.PDFUtilityAction.testpdf(PDFUtilityAction.java:123)
22:16:50,987 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
22:16:50,987 ERROR [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
22:16:50,987 ERROR [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
22:16:50,987 ERROR [STDERR] at
java.lang.reflect.Method.invoke(Method.java:597)
22:16:50,987 ERROR [STDERR] at
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:163)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:249)
22:16:50,988 ERROR [STDERR] at
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
22:16:50,988 ERROR [STDERR] at
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
It only happens in one page, same code is working for another 5-6 pdf pages.
I tried very hard but not able to rectify the issue.
Any help will be highly appreciated in this regard. I tried to upgrade the
itext from 2.1.7 to the latest 5.0.1 but didnt help.
--
View this message in context:
http://old.nabble.com/ITEXT-throws-exception-while-filling-up-the-pdf-forms-tp28023143p28023143.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
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/