// Create a new file data source for the input PDF file. var inputDataSource = new FileDataSource(inputPath); // Create a new file data source for the optimized output PDF file. var outputDataSource = new FileDataSource("sample_optimized.pdf"); // Create a new instance of OptimizeOptions. var opt = new OptimizeOptions(); // Add the input and output data sources to the optimize options. opt.AddInput(inputDataSource); opt.AddOutput(outputDataSource); // Create a new instance of Optimizer. var optimizer = new Optimizer(); // Process the optimization using the optimize options. optimizer.Process(opt);