Save Excel into PDF with Standard or Minimum Size with C++
By default, Aspose.Cells saves Excel into PDF with Standard size. However, you can also save it with Minimum size using the PdfSaveOptions.GetOptimizationType() property. It accepts the following values:
- PdfOptimizationType::Standard
- PdfOptimizationType::MinimumSize
Save Excel into PDF with Standard or Minimum Size using Aspose.Cells
The following sample code shows how you can save Excel into PDF with Standard or Minimum size using PdfSaveOptions.GetOptimizationType() property.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::Rendering;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Path of input excel file
U16String inputFilePath = srcDir + u"SampleBook.xlsx";
// Path of output PDF file
U16String outputFilePath = outDir + u"OptimizedOutput_out.pdf";
// Load excel file into workbook object
Workbook workbook(inputFilePath);
// Create PDF save options
PdfSaveOptions opts;
// Set optimization type to minimum size
opts.SetOptimizationType(PdfOptimizationType::MinimumSize);
// Save the workbook to PDF with the specified options
workbook.Save(outputFilePath, opts);
std::cout << "Workbook saved to PDF with minimum size optimization!" << std::endl;
Aspose::Cells::Cleanup();
}