Load CSV document with options

GroupDocs.Conversion provides the CsvLoadOptions class to give you control over how the source CSV document will be processed. The following options could be set:

Control behavior of converting date/time and numeric data

The following code snippet shows how to convert a CSV document and control the way the date/time and numeric data have been processed:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.CsvLoadOptions;
...
CsvLoadOptions loadOptions = new CsvLoadOptions();
loadOptions.setConvertDateTimeData(true);
loadOptions.setConvertNumericData(true);

Converter converter = new Converter("sample.csv", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);

Specify delimiter

The following code snippet shows how to convert a CSV document and specify the delimiter:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.CsvLoadOptions;
...
CsvLoadOptions loadOptions = new CsvLoadOptions();
loadOptions.setSeparator(',');

Converter converter = new Converter("sample.csv", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);

Specify encoding

The following code snippet shows how to convert a CSV document and specify the encoding:

import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.load.CsvLoadOptions;
...
CsvLoadOptions loadOptions = new CsvLoadOptions();
loadOptions.setEncoding(java.nio.charset.Charset.forName("shift_jis"));

Converter converter = new Converter("sample.csv", loadOptions);
PdfConvertOptions options = new PdfConvertOptions();
converter.convert("converted.pdf", options);