How to add a custom page size Width and Height on GemBox.Spreadsheet.ExcelWorksheet

26 Views Asked by At

I am trying to print a pdf document based on a ExcelFile. I want to print a doc that's 100x34, so quite small. The default page sizes doesn't support this size, but I checked that they have a Custom option. I'm just not able to make it work.

This is the code:

 var workbook = ExcelFile.Load(stream);
 ExcelWorksheet worksheet = workbook.Worksheets[0];
 worksheet.PrintOptions.PaperType = PaperType.Custom;

 using (MemoryStream memoryStream = new MemoryStream())
 {
     workbook.Save(memoryStream, saveOptions);
     return (memoryStream.ToArray());
 }

I saw some examples on their documentation but it doesn't work. This one would be perfect, but it doesn't work: https://forum.gemboxsoftware.com/t/set-printoptions-papertype-to-a0-or-a1/264/2

Does anyone knows how to set the custom width and height of the document?

0

There are 0 best solutions below