Bug 494785 - itext: *.afm files missing from com.lowagie.text.pdf.fonts?
itext: *.afm files missing from com.lowagie.text.pdf.fonts?
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: itext (Show other bugs)
10
All Linux
low Severity medium
: ---
: ---
Assigned To: Orcan Ogetbil
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-04-08 00:29 EDT by Need Real Name
Modified: 2009-05-11 02:10 EDT (History)
4 users (show)

See Also:
Fixed In Version: 1.41-15.fc10
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-04-13 15:36:58 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
a dummy form data file to test with (7.44 KB, text/plain)
2009-04-08 10:16 EDT, Need Real Name
no flags Details
A patch (1.25 KB, patch)
2009-04-09 13:11 EDT, Andrew Haley
no flags Details | Diff

  None (edit)
Description Need Real Name 2009-04-08 00:29:59 EDT
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 00:59:23 EDT
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 10:16:45 EDT
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 10:30:03 EDT
Okay, now I confirmed the bug. Let's see what we can do about it.
Comment 4 Orcan Ogetbil 2009-04-08 13:59:48 EDT
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 02:52:03 EDT
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 13:11:21 EDT
Created attachment 338948 [details]
A patch
Comment 7 Fedora Update System 2009-04-09 15:04:04 EDT
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 15:21:00 EDT
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 15:36:49 EDT
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 01:19:11 EDT
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 01:28:21 EDT
Nelash,
Could you post the output of your
   rpm -q itext pdftk bouncycastle-mail
Thanks!
Comment 12 Nelash 2009-05-07 02:09:29 EDT
 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 04:14:06 EDT
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-07 23:56:01 EDT
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 00:19:07 EDT
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 06:50:15 EDT
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 06:59:00 EDT
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 02:10:17 EDT
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..?

Note You need to log in before you can comment on or make changes to this bug.