We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Setting Locale for Aspose PDF library

When trying to convert a PDF to PDF/A file using java PDF library we get an Exception that the Locale is not supported.

Looking through the documentation we found the following which looked promising to set the Locale explicitly:

com.aspose.pdf.LocaleOptions.setLocale(Locale(“de”, “CH”))

However, even after calling this at the beginning, we still get the error. So it looks like this is not working. What is the correct way of explicitly setting the Locale locally for the PDF library. We want to avoid having to set the Locale globally in the JVM.


Could you please attach your input PDF along with code example that you are using to reproduce the same issue at our end? We will investigate the issue and provide you more information on it.

Here the code sample we are using. It is written in Kotlin. I hope it is still usable for you.

fun convertPDFtoPDFA(content: ByteArray) {
logger().debug(“global locale: ${Locale.getDefault()}”)
com.aspose.pdf.LocaleOptions.setLocale(Locale(“de”, “CH”))
val document = com.aspose.pdf.Document(
val outputLogStream = ByteArrayOutputStream()
document.convert(outputLogStream, com.aspose.pdf.PdfFormat.PDF_A_2B, com.aspose.pdf.ConvertErrorAction.None)
val outputLog = outputLogStream.toByteArray()
logger().debug(“outputLog: ${String(outputLog, Charsets.UTF_8)}”)
val pdfStream = ByteArrayOutputStream()

Running it on our end gives the following log entries and exceptions:

global locale: en_CH

com.aspose.pdf.internal.imaging.coreexceptions.ImageLoadException: Image loading failed.
at com.aspose.pdf.internal.imaging.Image.lI(Unknown Source)
at com.aspose.pdf.internal.imaging.Image.b(Unknown Source)
at com.aspose.pdf.internal.imaging.Image.d(Unknown Source)
at com.aspose.pdf.internal.imaging.Image.load(Unknown Source)
at com.aspose.pdf.internal.l11u.l0p.(Unknown Source)
at com.aspose.pdf.internal.l10u.l0if.lf(Unknown Source)
at com.aspose.pdf.internal.l10u.ly.l1k(Unknown Source)
at com.aspose.pdf.internal.l10u.ly.lt(Unknown Source)
at com.aspose.pdf.internal.l10u.l0if.l0t(Unknown Source)
at com.aspose.pdf.internal.l10u.ly.lI(Unknown Source)
at com.aspose.pdf.ADocument.lI(Unknown Source)
at com.aspose.pdf.Document.lI(Unknown Source)
at com.aspose.pdf.ADocument.convertInternal(Unknown Source)
at com.aspose.pdf.Document.convertInternal(Unknown Source)
at com.aspose.pdf.ADocument.convert(Unknown Source)
at com.aspose.pdf.Document.convert(Unknown Source)
at io.prc.kili.common.aspose.AsposeHelper.convertPDFtoPDFA(AsposeHelper.kt:169)

Caused by: com.aspose.pdf.internal.imaging.internal.Exceptions.ArgumentException: Culture Name: en-CH is not a supported culture
at com.aspose.pdf.internal.imaging.internal.p572.z25.lI(Unknown Source)
at com.aspose.pdf.internal.imaging.internal.p572.z25.(Unknown Source)
at com.aspose.pdf.internal.imaging.internal.p572.z25.m1(Unknown Source)
at com.aspose.pdf.internal.imaging.system.Threading.Thread.getCurrentCulture(Unknown Source)
at com.aspose.pdf.internal.imaging.internal.p572.z25.m7(Unknown Source)
at com.aspose.pdf.internal.imaging.internal.p558.z48.m2(Unknown Source)
at com.aspose.pdf.internal.imaging.fileformats.jpeg.JFIFData.a(Unknown Source)
at com.aspose.pdf.internal.imaging.internal.p489.z45.m1(Unknown Source)
at com.aspose.pdf.internal.imaging.internal.p489.z45.lI(Unknown Source)
at com.aspose.pdf.internal.imaging.internal.p489.z45.load(Unknown Source)
… 138 common frames omittedQuellensteuer BS_Tarif 2021.pdf (743.1 KB)


We have logged this problem in our issue tracking system as PDFJAVA-41249. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as PDFJAVA-41249) have been fixed in Aspose.PDF for Java 22.2.