We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pdf - page settings

Hello
I have the attached report,employeestatusreport_27_07_2022_07_41_17.pdf (60.0 KB)

please kindly explain to me what I need to set in PageSetup to split the page “normally” to fit A4 size.

        var workbook = new Workbook(template);
        var designer = new WorkbookDesigner(workbook)
        {
            LineByLine = false
        };

        foreach (var translation in translations)
        {
            designer.SetDataSource(translation.Key, translation.Value);
        }

        designer.SetDataSource("data", data);
        designer.SetDataSource("logo", logo);
        designer.Workbook.Settings.Author = "JET";

        designer.Process();
        var activeWorksheet = designer.Workbook.Worksheets[designer.Workbook.Worksheets.ActiveSheetIndex];

        PageSetup pageSetup = activeWorksheet.PageSetup;
        pageSetup.PaperSize = PaperSizeType.PaperA4;

and in pdf settings:

new PdfSaveOptions
{
OptimizationType = Aspose.Cells.Rendering.PdfOptimizationType.MinimumSize,
AllColumnsInOnePagePerSheet = true,
};

this is important to keep all columns in one page per sheet.

@zivdaniel,

Thanks for the sample PDF document and details.

Seeing your code segment, you are doing ok. What is the issue you face? If you still could not evaluate your issue, kindly provide us a standalone VS.NET application (source code without compilation errors) with resource files (input Excel file and output files) to show the issue, we will check it soon.

PS. please zip the project and files prior attaching.

@zivdaniel

Please note, setting PdfSaveOptions.AllColumnsInOnePagePerSheet to true will break the width of paper size of pagesetup.

Please try to use PageSetup.SetFitToPages(1,0); to fit content into A4 size. But it has the following limitations:

  1. When content is bigger than paper width, it will scale down the content to fit paper width. However, the minimum scale is 10%, if there are too many columns/content, it is possible that columns will be split into multiple pages.
  2. When content is smaller than paper width, it will not scale up the content to fit paper width.