GemBox Support Forum

Set PrintOptions.PaperType to A0 or A1


I am exporting XLSX file to the PDF. I set the:

ws.PrintOptions.PaperType = PaperType.A2;

Is it possible to use A1, A0 format? Or define some custom format?

If yes, can you please write me an example?

I am using GemBox.Spreadsheet version


Hi Michal,

The reason why there is no PaperType.A0 and PaperType.A1 is because these types are provided by printer drivers, not by file format’s specification.

Or to put this differently, if you have machines with different printer drivers you can end up creating an Excel file with “A0” paper type on one machine, but that same Excel file on another machine may have an unrecognised targeted paper type.
So in short, they are not universal, for Excel files they are driver dependent.

Anyway, you could iterate through your installed printers, check their supported paper types, create a PrintTicket that specifies using it, and then assign that ticket to your file with ExcelWorksheet.PrintOptions.SetPrinterSettings.

But I think that setting the custome type is easier, see the following:

var workbook = new ExcelFile();

var worksheet = workbook.Worksheets.Add("Sheet1");
worksheet.Cells["A1"].SetValue("Custom paper");

var printTicket = new System.Printing.PrintTicket();
printTicket.PageMediaSize = new System.Printing.PageMediaSize(3500 , 2500);

worksheet.PrintOptions.SetPrinterSettings(null, printTicket.GetXmlStream());

// In that older version you need to use this:
worksheet.PrintOptions.PaperType = (PaperType)(-1);
// But in the newer versions you can use this instead:
//worksheet.PrintOptions.PaperType = PaperType.Custom;


I hope this helps.