Am 07.07.2015 um 13:20 schrieb Roberto Nibali:
Hi
On Mon, Jul 6, 2015 at 10:14 PM, Tilman Hausherr <[email protected]>
wrote:
Am 06.07.2015 um 18:15 schrieb Maruan Sahyoun:
There will be an issue with the test template when you set the Name and
Prename field as the field definition is incomplete (the font resource is
missing) which will lead to an exception
java.io.IOException: Could not find font: /Courier
The easiest would be to correct the template. If that's not possible we
could help you building a short workaround. But as the template you
provided was only a quick mock up and not the real one the final template
might not have the issue.
I have managed to write a TestNG class using the newest
PDFBox-2.0.0-SNAPSHOT jar und include your source code. Now, I'm getting
this error above as well. So far so good!
I just tried a quick and dirty solution, I changed
PDAppearanceString.getFont(), the "if (font == null)" segment is new:
public PDFont getFont() throws IOException
{
COSName name = getFontResourceName();
PDFont font = defaultResources.getFont(name);
if (font == null)
{
if ("Courier".equals(name.getName()))
{
COSDictionary dict = new COSDictionary();
dict.setName(COSName.BASE_FONT, "Courier");
dict.setName(COSName.NAME, "Courier");
dict.setName(COSName.SUBTYPE, "Type1");
dict.setName(COSName.TYPE, "Font");
font = PDFontFactory.createFont(dict);
}
}
// todo: handle cases where font == null with special mapping
logic (see PDFBOX-2661)
if (font == null)
{
throw new IOException("Could not find font: /" +
name.getName());
}
return font;
}
Where would I need to do this? In my code, it won't work, since
getFontResourceName() and defaultResources.getFont() or not known.
@Override also does not seem to work. With this I'm stuck at the moment.
This was meant to be a change in PDFBox itself, I assumed you were
building from source.
But in the meantime you wrote me that you don't get the font problem
with your production PDF, so the issue is moot.
Tilman
Now I was able to set the text fields
(Roberto: in the file I sent to you earlier, uncomment
"newTextField.setValue(textField.getValue());")
I did, however this prompts me with the above error, since I can't find a
place where to put the getFont() code. When commented, I can reproduce your
results and the resulting PDF does have the checkboxes set!!!! :)
Will keep trying ...
Thanks for the tremendous help.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]