Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active June 15, 2023 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/e7836763c0ea85cdb50c9cf4f34c40d6 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/e7836763c0ea85cdb50c9cf4f34c40d6 to your computer and use it in GitHub Desktop.
Convert CSV to PDF or PDF to CSV Programmatically using C# VB.NET
// Initialize TxtLoadOptions class object
Aspose.Cells.TxtLoadOptions option = new Aspose.Cells.TxtLoadOptions();
option.Separator = ',';
// Load the input CSV file
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(dataDir + "Test.csv" , option);
// Save output PDF file
workbook.Save(dataDir + "Sample.pdf", Aspose.Cells.SaveFormat.Pdf);
// Initialize ExcelSaveOptions class object
ExcelSaveOptions options = new ExcelSaveOptions();
// Set format as CSV
options.Format = ExcelSaveOptions.ExcelFormat.CSV;
// Load input PDF file
Document pdfDocument = new Document("Sample.pdf");
// Save output CSV file
pdfDocument.Save("Sample.csv", options);
@saurav100-coder
Copy link

image
i'm getting error here

@amjad-sahi
Copy link

@saurav100-coder,

Your referred blog is old and in newer versions of Aspose.PDF for .NET API, "ConversionEngine" does not exist in ExcelSaveOptions. That's why you are getting compile time errors. Please remove the relevant line of code as it is not needed anymore. Please try the (updated) code segment, I have used fully qualified naming when defining objects for your reference:
e.g.
Sample code:

// Initialize ExcelSaveOptions class object
Aspose.Pdf.ExcelSaveOptions options = new Aspose.Pdf.ExcelSaveOptions();

// Set format as CSV
options.Format = Aspose.Pdf.ExcelSaveOptions.ExcelFormat.CSV;

// Load input PDF file
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document("Sample.pdf");

// Save output CSV file
pdfDocument.Save("Sample.csv", options); 

Let us know if you still have any issue.

Should you have further queries or issue, we also encourage you to post in the dedicated forums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment