PageSetup.PaperSize property of Microsoft.Office.Interop.Excel._Worksheet is not taken during PDF print via ExportAsFixedFormat function

Vinay Jirgale 1 Reputation point
2021-12-16T14:43:27.12+00:00

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.

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,294 questions
{count} votes