Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Jun 06, 2022 4:36 am

Currently trying out the Spire PDF product, A trial License is provided by the licensing agent

When testing PDF conversion to Word (or any other format) , an error occurs and the conversion fails
Code: Select all
Exception in thread "main" com.spire.pdf.packages.sprgcu: Neutral cultures cannot be used in formatting and parsing and therefore cannot be set as the thread's current culture
   at com.spire.pdf.packages.sprgit.spr⌼▅(Thread.java:374)
   at com.spire.pdf.packages.sprygh.spr╗┉(Unknown Source)
   at com.spire.pdf.packages.sprygh.spr”‣(Unknown Source)
   at com.spire.pdf.packages.sprlbo.spr™∭(Unknown Source)
   at com.spire.pdf.packages.sprddo.spr▉╋(Unknown Source)
   at com.spire.pdf.packages.sprddo.spr︴╸(Unknown Source)
   at com.spire.pdf.packages.sprddo.spr㈭⃟╋(Unknown Source)
   at com.spire.pdf.PdfDocumentBase.spr▒∭(Unknown Source)
   at com.spire.pdf.PdfDocumentBase.save(Unknown Source)
   at com.spire.pdf.PdfDocument.saveToFile(Unknown Source)


Lang: zh_CN
OS: MacOS Monterey
JAVA Version: Zulu Openjdk 1.8.0_332 aarch64

Test Code:
Code: Select all
        PdfDocument doc = new PdfDocument();
        doc.loadFromFile("/Users/jiangxin/Downloads/Spire.PDF for Java _ News & Releases.pdf");

        doc.saveToFile("WordToPDF.docx", FileFormat.DOCX);


Spire PDF Dependency:
Code: Select all
        <dependency>
            <groupId>e-iceblue</groupId>
            <artifactId>spire.pdf</artifactId>
            <version>5.5.0</version>
        </dependency>

xiaokongwu
 
Posts: 4
Joined: Mon Jun 06, 2022 4:23 am

Mon Jun 06, 2022 5:50 am

I should have found the problem...
Since my system environment is in English, but the pdf is in Chinese, after setting the Chinese parameters for the JVM, the conversion can work normally.
Code: Select all
-Duser.language=zh -Duser.country=CN


But the PDF used for conversion may be in English or Chinese. If it is in English, do I still need to set the JVM to English?

xiaokongwu
 
Posts: 4
Joined: Mon Jun 06, 2022 4:23 am

Mon Jun 06, 2022 10:11 am

Hello,

Thanks for your inquiry.

Based on the error information, I suggest that you first try to set the following code before doing the conversion.

Code: Select all
//Set default locale

Locale newLocale = Locale.ROOT;

Locale.setDefault(newLocale);


By the way, we are a Chinese company. So, if we are the same, we can communicate directly in Chinese.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.PDF

cron