PageSetup.PaperSize property of Microsoft.Office.Interop.Excel._Worksheet is not taken during PDF print via ExportAsFixedFormat function
Vinay Jirgale
1
Reputation point
I am trying to print the certain cell range of excel into PDF in A3 file format. But when I open the generated PDF, the document properties show a size different than A3. Can someone help me here?
Following is the code,
oWB = oXL.Workbooks.Open(excelPath, false, false, Type.Missing, "", "", true, XlPlatform.xlWindows, "", false, false, 0, false, true, 0);
oSheet = (_Worksheet)oWB.ActiveSheet;
oSheet.PageSetup.FitToPagesWide = 1;
oSheet.PageSetup.FitToPagesTall = 1;
oSheet.PageSetup.PrintArea = "$A$1:$W$40";
oSheet.PageSetup.Orientation = XlPageOrientation.xlLandscape;
oSheet.PageSetup.PaperSize = XlPaperSize.xlPaperA3;
oSheet.PageSetup.Zoom = false;
oSheet.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, pdfPath, XlFixedFormatQuality.xlQualityMinimum, true,false);
When I check the PDF, it is not in A3 format.
Thank you.