[
https://issues.apache.org/jira/browse/PDFBOX-5402?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17512596#comment-17512596
]
Matthew Bayer commented on PDFBOX-5402:
---------------------------------------
{code:kotlin}
import org.apache.pdfbox.cos.COSName
import org.apache.pdfbox.pdmodel.PDDocument
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertDoesNotThrow
import java.io.IOException
import java.nio.file.Files
import java.nio.file.Paths
import java.util.HashSet
import kotlin.io.path.div
class WingdingsTest {
@Test
fun `test for wingdings`() {
// Get Wingdings.pdf from current working directory
val path = Paths.get("").toAbsolutePath() / "Wingdings.pdf"
val testChar = '*'
val testSet = HashSet<COSName>()
val inMemoryPdf =
PDDocument.load(Files.newInputStream(path).buffered(64 * 1024))
assertDoesNotThrow {
inMemoryPdf.use { document ->
for (page in document.pages) {
val resources = page.resources
for (name in resources.fontNames) {
val font = resources.getFont(name)
try {
if (font.encode(testChar.toString()) != null)
testSet.add(name)
} catch (expected: IOException) {
// handled
} catch (expected: IllegalArgumentException) {
// handled
} catch (expected: UnsupportedOperationException) {
// handled
}
// NPE not handled
}
}
}
}
}
}
{code}
> POCIDFontType2 (Wingdings) encode throws a NullPointerException
> ---------------------------------------------------------------
>
> Key: PDFBOX-5402
> URL: https://issues.apache.org/jira/browse/PDFBOX-5402
> Project: PDFBox
> Issue Type: Bug
> Components: FontBox
> Affects Versions: 2.0.21, 2.0.22, 2.0.23, 2.0.24, 2.0.25
> Environment: PDFBox 2.0.25 used via a gradle plugin (has been tested
> as far back as PDFBox 2.0.21)
> Reporter: Matthew Bayer
> Priority: Major
> Attachments: Wingdings.pdf
>
>
> Problem;
> * It is known that wingdings based fonts do not support encoding from
> https://issues.apache.org/jira/browse/PDFBOX-4714. However it is unexpected
> that a call to encode on a wingdings POCIDFontType2 returns a
> NullPointerException.
> Notes:
> * The issue seems to lie within PDFont POCIDFontType2
> * The POCIDFontType2 encode function is only known to throw IOException or
> UnsupportedOperationException(s)
> * Please see the attached test file with the font in question that causes
> the NullPointerException to be thrown
> * Stacktrace:
> {code:java}
> java.lang.NullPointerException
> at
> org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:359)
> at
> org.apache.pdfbox.pdmodel.font.PDType0Font.encode(PDType0Font.java:424)
> at org.apache.pdfbox.pdmodel.font.PDFont.encode(PDFont.java:333)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]