Load CSV document with options

GroupDocs.Conversion provides CsvLoadOptions 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:

const loadOptions = new groupdocs.conversion.CsvLoadOptions()
loadOptions.setConvertDateTimeData(true)
loadOptions.setConvertNumericData(true)

const outputPath = "ConvertCsvByConvertingDateTimeAndNumericData.pdf"

const converter = new groupdocs.conversion.Converter("sample.csv", loadOptions)
const convertOptions = new groupdocs.conversion.PdfConvertOptions()

console.log(`CSV document converted successfully to ${outputPath} (converting dateTime & numeric data)`)
converter.convert(outputPath, convertOptions)

Specify delimiter

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

const loadOptions = new groupdocs.conversion.CsvLoadOptions()
loadOptions.setSeparator(",")

const outputPath = `ConvertCsvBySpecifyingDelimiter.pdf`

const converter = new groupdocs.conversion.Converter("sample.csv", loadOptions)
const convertOptions = new groupdocs.conversion.PdfConvertOptions()

console.log(`CSV document converted successfully to ${outputPath} (specifying delimiter)`)
converter.convert(outputPath, convertOptions)

Specify encoding

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

const loadOptions = new groupdocs.conversion.CsvLoadOptions()
loadOptions.setEncoding("Shift_JIS")

const outputPath = `ConvertCsvBySpecifyingEncoding.pdf`

const converter = new groupdocs.conversion.Converter("sample.csv", loadOptions)
const convertOptions = new groupdocs.conversion.PdfConvertOptions()

console.log(`CSV document converted successfully to ${outputPath} (encoding specified)`)
converter.convert(outputPath, convertOptions)