Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Mar 21, 2024 7:11 am

Hi.
I tried to convert word to pdf using Free Spire.Doc for Java(Version:5.2.0)
but I couldn't create a pdf file.
My region is Korea/Korean and my encoding type is UTF-8.

Code: Select all
import com.spire.doc.Document;
import com.spire.doc.ToPdfParameterList;

public class WordToPDF {
    public static void main(String[] args) {
        //Create a Document instance
        Document doc = new Document();
         //Load a sample Word document
        doc.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.docx");

        //Create a ToPdfParameterList instance
        ToPdfParameterList ppl=new ToPdfParameterList();

        //Embed all fonts in the PDF document
        ppl.isEmbeddedAllFonts(true);

        //Remove the hyperlinks and keep the character formats
        ppl.setDisableLink(true);

        //Set the output image quality as 40% of the original image. 80% is the default setting.
        doc.setJPEGQuality(40);

        //Save the document as PDF
        doc.saveToFile("output/ToPDF.pdf", ppl);
    }
}


[error]
Exception in thread "main" class com.spire.office.packages.sprKmD: 'MS949' is not a supported encoding
com.spire.office.packages.sprYkd.spr (rlc:693)
com.spire.office.packages.sprGFe.spr (Unknown Source)
com.spire.office.packages.sprGFe.spr (Unknown Source)
com.spire.office.packages.sprGFe.spr (Unknown Source)
com.spire.office.packages.sprGFe.spr (Unknown Source)
com.spire.office.packages.sprGce.spr (Unknown Source)
com.spire.office.packages.sprGce.spr (Unknown Source)
com.spire.office.packages.sprWBe.spr (Unknown Source)
com.spire.office.packages.sprWBe.spr (Unknown Source)
com.spire.office.packages.sprNZD.spr (Unknown Source)
com.spire.office.packages.sprWBe.spr (Unknown Source)
com.spire.office.packages.sprWBe.spr (Unknown Source)
com.spire.office.packages.sprWBe.spr (Unknown Source)
com.spire.office.packages.sprWBe.spr (Unknown Source)
com.spire.office.packages.sprWBe.spr (Unknown Source)
com.spire.office.packages.sprMae.spr (Unknown Source)
com.spire.office.packages.sprHge.spr (Unknown Source)
com.spire.office.packages.sprHge.spr (Unknown Source)
com.spire.office.packages.sprHge.spr (Unknown Source)
com.spire.office.packages.spryNe.spr (Unknown Source)
com.spire.doc.Document.spr (Unknown Source)
com.spire.doc.Document.loadFromFile(Unknown Source)
[/error]

jhahn1215
 
Posts: 4
Joined: Thu Mar 21, 2024 1:03 am

Thu Mar 21, 2024 7:55 am

Hello,

Thank you for contacting.
To help us investigate your issue accurately, please share us with your input Word file for reference. You can attach it here or send it to this email: [email protected]. Thanks in advance.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Thu Mar 21, 2024 8:04 am

I uploaded input file.
thank you.

jhahn1215
 
Posts: 4
Joined: Thu Mar 21, 2024 1:03 am

Thu Mar 21, 2024 8:56 am

Hello,

Thanks for your file.
Can you open the document you provided in Microsoft Word? I will receive an error message when I open it (as shown in the screenshot). We are unable to convert files with inherent issues, hope you can understand.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Thu Mar 21, 2024 11:08 am

sorry
I upload again.
I think it is a problem about encoding..

jhahn1215
 
Posts: 4
Joined: Thu Mar 21, 2024 1:03 am

Fri Mar 22, 2024 2:43 am

Hello,

Thanks for providing your file.
I tested your file with the latest Free Spire.Doc for Java Version:5.2.0, but did not reproduce your issue. This is my executable .jar file, please run it directly on your side.
If the issue persists, please share us with your system information(e.g:Windows 10) and your JDK version(e.g:JDK1.8). Thanks in advance.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Fri Mar 22, 2024 4:17 am

I tested on linux server, and it succeed.
but the file created is wrong..
i attached the output file.. wrong characters only.. :(

jhahn1215
 
Posts: 4
Joined: Thu Mar 21, 2024 1:03 am

Fri Mar 22, 2024 5:47 am

Hello,

Thanks for your reply.
Sorry, I couldn't find your result document in the attachment. Is the font currently displayed incorrectly? Does the system include the "Malgun Gothic" font? If not, please install this font and try again. Looking forward to your feedback.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.Doc