gembox-spreadsheet

Gembox spreadsheet. is there a way to make it fit to one page when saving to pdf


Im trying to find a way to convert xls files to pdf, and gembox spreadsheet is great for this. But i need to be able to make it fit to one page as you can when printing to pdf via excel.


Solution

  • Try specifying FitWorksheetWidthToPages and FitWorksheetHeightToPages properties.
    For example like the following:

    ExcelFile workbook = ExcelFile.Load("Sample.xls");
    ExcelWorksheet worksheet = workbook.Worksheets.ActiveWorksheet;
    
    worksheet.PrintOptions.FitWorksheetWidthToPages = 1;
    worksheet.PrintOptions.FitWorksheetHeightToPages = 1;
    
    workbook.Save("Sample.pdf");
    

    I hope this helps.