Bug 494785

Summary: itext: *.afm files missing from com.lowagie.text.pdf.fonts?
Product: [Fedora] Fedora Reporter: Need Real Name <karlcz>
Component: itextAssignee: Orcan Ogetbil <oget.fedora>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 10CC: aph, jochen, nelash_jindal14, oget.fedora
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 1.41-15.fc10 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-04-13 19:36:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
a dummy form data file to test with
none
A patch none

Description Need Real Name 2009-04-08 04:29:59 UTC
Description of problem:

I tried to use the recently returned pdftk with its fill_form command to insert some data into a PDF form. It throws an exception which implies some resources are missing from itext, and my naive googling suggests this is a build error of some kind (but I'm not expert on itext).

Version-Release number of selected component (if applicable):

itext-2.1.5-1.fc10.x86_64
(and pdftk-1.41-13.fc10.x86_64)

How reproducible:

Always in my attempts.

Steps to Reproduce:
1. obtain a PDF and matching FDF file
2. pdftk foo.pdf fill_form foo.fdf output foo-filled.pdf
3.
  
Actual results:

Helvetica-Bold not found as resource. (The *.afm files must exist as resources in the package com.lowagie.text.pdf.fonts)
Helvetica not found as resource. (The *.afm files must exist as resources in the package com.lowagie.text.pdf.fonts)
Unhandled Java Exception:
com.lowagie.text.DocumentException: Helvetica not found as resource. (The *.afm files must exist as resources in the package com.lowagie.text.pdf.fonts)
   at com.lowagie.text.pdf.Type1Font.<init>(itext-2.1.5.jar.so)
   at com.lowagie.text.pdf.BaseFont.createFont(itext-2.1.5.jar.so)
   at com.lowagie.text.pdf.BaseFont.createFont(itext-2.1.5.jar.so)
   at com.lowagie.text.pdf.BaseFont.createFont(itext-2.1.5.jar.so)
   at com.lowagie.text.pdf.BaseField.getRealFont(itext-2.1.5.jar.so)
   at com.lowagie.text.pdf.TextField.getAppearance(itext-2.1.5.jar.so)
   at com.lowagie.text.pdf.AcroFields.getAppearance(itext-2.1.5.jar.so)
   at com.lowagie.text.pdf.AcroFields.setField(itext-2.1.5.jar.so)
   at com.lowagie.text.pdf.AcroFields.setField(itext-2.1.5.jar.so)
   at com.lowagie.text.pdf.AcroFields.setFields(itext-2.1.5.jar.so)


Expected results:

Should not throw an exception.

Additional info:

Comment 1 Orcan Ogetbil 2009-04-08 04:59:23 UTC
No, those files are there.

[orcan@desitter ~]$ unzip -l /usr/share/java/itext-2.1.5.jar|grep Helvetica
    72096  01-01-80 00:00   com/lowagie/text/pdf/fonts/Helvetica-Bold.afm
    72192  01-01-80 00:00   com/lowagie/text/pdf/fonts/Helvetica-BoldOblique.afm
    77443  01-01-80 00:00   com/lowagie/text/pdf/fonts/Helvetica-Oblique.afm
    77343  01-01-80 00:00   com/lowagie/text/pdf/fonts/Helvetica.afm
[orcan@desitter ~]$


I could try to reproduce your results if only I knew what an FDF file was. (and where I could find one.)

Comment 2 Need Real Name 2009-04-08 14:16:45 UTC
Created attachment 338715 [details]
a dummy form data file to test with

Downloading http://www.irs.gov/pub/irs-pdf/f1040.pdf and this attachment allows the bug to be repeated by running:

pdftk f1040.pdf fill_form data-f1040.fdf output f1040-filled.pdf

The expected result would be the form with the dummy values entered into its fields, rather than an exception about fonts.

Comment 3 Orcan Ogetbil 2009-04-08 14:30:03 UTC
Okay, now I confirmed the bug. Let's see what we can do about it.

Comment 4 Orcan Ogetbil 2009-04-08 17:59:48 UTC
I made some scratch builds with a fix. Could you test it?

For F-10:
http://koji.fedoraproject.org/koji/taskinfo?taskID=1285736

For F-11:
http://koji.fedoraproject.org/koji/taskinfo?taskID=1285741

Comment 5 Need Real Name 2009-04-09 06:52:03 UTC
I tried pdftk-1.41-15.fc10.x86_64.rpm and it now works for me using the same test that failed previously.

Comment 6 Andrew Haley 2009-04-09 17:11:21 UTC
Created attachment 338948 [details]
A patch

Comment 7 Fedora Update System 2009-04-09 19:04:04 UTC
pdftk-1.41-15.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/pdftk-1.41-15.fc10

Comment 8 Orcan Ogetbil 2009-04-09 19:21:00 UTC
karlcz, 
the above update that I submitted is slightly different than what you downloaded. The scratch build you tested had those font metric files (.afm) hardcoded in the pdftk binary, which was not the best solution.

Andrew's patch, however, sets the proper classpath to itext, so that pdftk uses those font metrics from the itext.jar file.

In the end both solutions will work equally well. Andrew's solution (which is in the above update) is more elegant, as it doesn't include .afm files that don't belong to pdftk. 

For your information.

Comment 9 Fedora Update System 2009-04-13 19:36:49 UTC
pdftk-1.41-15.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 10 Nelash 2009-05-06 05:19:11 UTC
problem:

 i have tried pdftk with its add command to insert some data into a PDF document. It throws an exception which implies some resources are missing from itext, and my naive googling suggests this is a build error of some kind (but I'm not expert on itext).


iText 2.1.5 (by lowagie.com)
Helvetica not found as resource. (The *.afm files must exist as resources in the package core.com.lowagie.text.pdf.fonts)
Exception in thread "main" ExceptionConverter: java.io.IOException: The document has no pages.
	at core.com.lowagie.text.pdf.PdfPages.writePageTree(PdfPages.java:117)
	at core.com.lowagie.text.pdf.PdfWriter.close(PdfWriter.java:1153)
	at core.com.lowagie.text.pdf.PdfDocument.close(PdfDocument.java:820)
	at core.com.lowagie.text.Document.close(Document.java:480)
	at helloworld.main(helloworld.java:25)


Expected result:should not throw any exception

Comment 11 Orcan Ogetbil 2009-05-06 05:28:21 UTC
Nelash,
Could you post the output of your
   rpm -q itext pdftk bouncycastle-mail
Thanks!

Comment 12 Nelash 2009-05-07 06:09:29 UTC
 Thanks for replying oran..

here i am forwading you my small program.since i am a beginer so statring with small programs..

Document document = new Document();
try {
PdfWriter.getInstance(document,
new FileOutputStream("HelloWorld.pdf"));
document.open();
document.add(
new Paragraph("Hello World"));
} catch (Exception e) {
// handle exception
}
document.close();

its output is:

Helvetica not found as resource. (The *.afm files must exist as resources in the package core.com.lowagie.text.pdf.fonts)
Exception in thread "main" ExceptionConverter: java.io.IOException: The document has no pages.
	at core.com.lowagie.text.pdf.PdfPages.writePageTree(PdfPages.java:117)
	at core.com.lowagie.text.pdf.PdfWriter.close(PdfWriter.java:1153)
	at core.com.lowagie.text.pdf.PdfDocument.close(PdfDocument.java:820)
	at core.com.lowagie.text.Document.close(Document.java:480)
	at helloworld.main(helloworld.java:28)


please provide me its solution

Comment 13 Orcan Ogetbil 2009-05-07 08:14:06 UTC
Nelash, I really need the "rpm -q itext pdftk bouncycastle-mail" output that I said in comment #11 to help you.

It's always good to report the Fedora and the program versions when you are reporting bugs.

Comment 14 Nelash 2009-05-08 03:56:01 UTC
ORCAN



i have already told u that i am a begineer..
si i don't know wats that..
i mean wat is "rpm -q itext pdftk bouncycastle-mail"

Comment 15 Orcan Ogetbil 2009-05-08 04:19:07 UTC
You have to open a terminal, and type
   rpm -q itext pdftk bouncycastle-mail
Then push ENTER. It will give you an output. Copy and paste that output here.

Comment 16 Nelash 2009-05-08 10:50:15 UTC
orcan u are talking for redhat os but i want to work with windows..
so could u tell me abt hw to solve this prob in windows xp and eclipse xml editor.

Comment 17 Andrew Haley 2009-05-08 10:59:00 UTC
Nelash, this is the Red Hat bug database.  It exists for bugs in Red Hat and Fedora systems.

I think the problem you are having is probably due to itext or pdftk not having been built correctly, but as I have no idea where you got them from it's very hard to know for certain.

Comment 18 Nelash 2009-05-11 06:10:17 UTC
andrew can u tell does this itext work with windows xp or not?

and can you forward me the link from where i can download itext..

is there any one known to you who could help in solving this prob. in windows..?