You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Rajeev Menon <ra...@gmail.com> on 2014/10/27 13:17:12 UTC

Access denied error at PDType1Font.TIMES_ROMAN

Hi,

I get the access denied error in the code "PDType1Font.TIMES_ROMAN".
Interestingly, this code work with another PDF file.

Another question: How do I find the string width of a custom font which is
not defined in the PDType1Font.java?

HTTP JVM:  java.lang.RuntimeException:
java.security.AccessControlException: Access denied
(java.lang.reflect.ReflectPermission suppressAccessChecks)
HTTP JVM:  at
org.apache.pdfbox.pdmodel.font.PDType1CFont.load(PDType1CFont.java:386)
HTTP JVM:  at
org.apache.pdfbox.pdmodel.font.PDType1CFont.<init>(PDType1CFont.java:104)
HTTP JVM:  at
org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:162)
HTTP JVM:  at
org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:92)
HTTP JVM:  at
org.apache.pdfbox.pdmodel.PDResources.getFonts(PDResources.java:203)
HTTP JVM:  at
org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.getFontAndUpdateResources(PDAppearance.java:439)
HTTP JVM:  at
org.apache.pdfbox.pdmodel.interactive.form.PDAppearance.setAppearanceValue(PDAppearance.java:268)
HTTP JVM:  at
org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.setValue(PDVariableText.java:131)
HTTP JVM:  at templates.PDFForm.fillPDF(PDFForm.java:87)
-------------------------Error encountered at the 3rd line in the following
lines of code------------------------------------------
if (fldPD!=null) {
    if (isMultiline(fldPD)) {
        fldPD.setValue(this.insertLinebreaks(fldPD, entryData.getValue(),
PDType1Font.TIMES_ROMAN, 10));
    } else {
        fldPD.setValue(entryData.getValue());
    }
}
------------------------Font is used below--------------------------

float width = font.getStringWidth(text.substring(start, i)) / 1000 *
fontSize;

Thanks,
Rajeev.