PDF text split issue for Merged cells

While converting the PDF from excel, the text in the last merged row is getting split between two pages.
Upper half of the text is coming in one page and lower half in next. Please refer to the attached PDF document TextSplitIssue.pdf.
TextSplitIssue.pdf (91.7 KB)

Please find the below sample code which is used to generate the PDF from excel.

internal void GeneratePDF()
{
try
{
Workbook wb = new(Path.Join(Directory.GetCurrentDirectory(), @“ExcelSample\SAMPLE_EXCEL.xlsx”));
Worksheet worksheet = wb.Worksheets[0];

            PageSetup pageSetup = worksheet.PageSetup;
            pageSetup.PrintTitleRows = "$1:$5";

            SetMarginForPdf(wb, 1, 1, 1, 1, 0);

            PdfSaveOptions pdfSaveOptions = new()
            {
                AllColumnsInOnePagePerSheet = true,
                OutputBlankPageWhenNothingToPrint = false
            };

            if (!Directory.Exists(Path.Join(Directory.GetCurrentDirectory(), $"PDFOutput")))
            {
                Directory.CreateDirectory(Path.Join(Directory.GetCurrentDirectory(), $"PDFOutput"));
            }
            wb.Save(Path.Join(Directory.GetCurrentDirectory(), $"PDFOutput\\{Guid.NewGuid()}.pdf"), pdfSaveOptions);
        }
        catch (Exception)
		{

			throw;
		}
    }

    private void SetMarginForPdf(Workbook excelworkbook, int topMargin, int leftMargin, int rightMargin, int bottomMargin, int sheetNumber)
    {
        excelworkbook.Worksheets[sheetNumber].PageSetup.PaperSize = PaperSizeType.PaperA4;
        excelworkbook.Worksheets[sheetNumber].PageSetup.Zoom = 100;
        excelworkbook.Worksheets[sheetNumber].PageSetup.TopMargin = topMargin;
        excelworkbook.Worksheets[sheetNumber].PageSetup.LeftMargin = leftMargin;
        excelworkbook.Worksheets[sheetNumber].PageSetup.RightMargin = rightMargin;
        excelworkbook.Worksheets[sheetNumber].PageSetup.BottomMargin = bottomMargin;
    }

@PolarisAP

Please share your sample Excel file with us as well in .zip format so that we can test the scenario in our environment and address it accordingly. Furthermore, this thread is being moved to the Aspose.Cells category because you are using this API.

@PolarisAP
Would you like to provide sample file? You can compress the file into zip format and upload it to the forum. We will check it soon.

Attaching the sample excel file
SampleFile.zip (99.5 KB)

@PolarisAP
By using sample files and code for testing, we are able to reproduce the issue. Found that the text is getting split between two pages when converting file to PDF.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-55245

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@PolarisAP ,

When page break is in the merged cell(between start row and end row of the merged cell), a single line text in the merged cell may be cut into two parts, one part is in one page and the other part is in next part.

You can save the file to Excel xlsx file before saving to pdf, then open the generated xlsx file in Excel, printview it, you will find a similar behavior at merged cell A69, page break is between row 69 and row 70. Text in the merged cell A69 is cut into two parts. see screenshot:
Screenshot_page_break.png (3.7 KB)

After setting print quality to 600(The origin value in the source file is 200, however Excel alway takes it as 600 now), you will get the same page break as Excel.

excelworkbook.Worksheets[sheetNumber].PageSetup.PrintQuality = 600;