Java Conversion to PDF from text and CSV files do not support UTF-8 encoding

Standard UTF-8 encoding in text and CSV files is not supported in groupdocs-conversion 23.6.1.
Library throws Exception “java.nio.charset.IllegalCharsetNameException: Unicode (UTF-8)”

Sample code
val csvLoadOptions = new CsvLoadOptions();
csvLoadOptions.setEncoding(StandardCharsets.UTF_8);

val txtLoadOptions = new TxtLoadOptions();
txtLoadOptions.setEncoding(StandardCharsets.UTF_8);

loadOptionsProvider = … //csvLoadOptions or txtLoadOptions

val converter = new Converter(() -> inputStream, loadOptionsProvider);
val convertOptions = new PdfConvertOptions();
converter.convert(() -> outputStream, convertOptions);

@mariusz.laciak

Please share following details and we’ll look into this issue:

  • Development environment details (e.g. Windows, Linux) with version
  • Problematic/source file

OS: Windows 11 Pro (22H2)
JAVA: Eclipse Temurin / Adoptium. jdk-17.0.8.1+1
test-files.zip (3.8 KB)

Source code:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.licensing.License;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.CsvLoadOptions;
import com.groupdocs.conversion.options.load.TxtLoadOptions;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.charset.StandardCharsets;
import lombok.val;

public class Utf8Test {
    public static void main(String[] args) throws Exception{
        val licenseFile = new File(args[0]);
        val csvFile = new File(args[1]);
        val txtFile = new File(args[2]);

        val convertDocLicense = new License();
        convertDocLicense.setLicense(
                new FileInputStream(licenseFile));

        val csvLoadOptions = new CsvLoadOptions();
        csvLoadOptions.setEncoding(StandardCharsets.UTF_8);

        val txtLoadOptions = new TxtLoadOptions();
        txtLoadOptions.setEncoding(StandardCharsets.UTF_8);

        val convertOptions = new PdfConvertOptions();

        val csvInputStream = new FileInputStream(csvFile);
        val csvOutputStream = new FileOutputStream("csv2pdf.pdf");
        val csvConverter = new Converter(() -> csvInputStream, () -> csvLoadOptions);
        csvConverter.convert(() -> csvOutputStream, convertOptions);

        val txtInputStream = new FileInputStream(txtFile);
        val txtOutputStream = new FileOutputStream("txt2pdf.pdf");
        val txtConverter = new Converter(() -> txtInputStream, () ->  txtLoadOptions);
        txtConverter.convert(() -> txtOutputStream, convertOptions);
    }
}

@mariusz.laciak
Thanks for sharing additional details. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CONVERSIONJAVA-2117

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@mariusz.laciak

We tried to reproduce the issue at our end using the provided code but cannot reproduce it. Could you please share a sample Maven project and steps to reproduce the issue?

A post was split to a new topic: Word to PDF UTF-8 encoding support