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

Free Support Forum - aspose.com

PDF file created from Excel using Aspose.cell has content with very small font size

Dear Support Team,

We are generating PDF from Excel file using Aspose.cells component. Excel file has multiple sheets and some of the sheet has large number of rows and columns which require to generate multiple PDF pages from single Excel sheet.

As per our requirement we have to adjust excelsheet column in single page but rows should go to next page if it has large number of rows. To achieve it I am using below code.

Code-1

We are using aspose.cells property pdfSaveOptions.AllColumnsInOnePagePerSheet = true; to adjust all excel sheet column in single page.

public void Convert(Stream sourceFileStream, string sourceFilePath)
{
var convertFileCommonFunction=new ConvertFileCommonFunction();
// Load excel file containing custom properties
var workbook = new Workbook(sourceFileStream);
//
//PageSetup pageSetup = workbook.Worksheets[1].PageSetup;
// pageSetup.PrintArea= “A1:D56”;
// Create an instance of PdfSaveOptions and pass SaveFormat to the constructor
var pdfSaveOptions = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);

        pdfSaveOptions.AllColumnsInOnePagePerSheet = true;
        
        //Save the document in pdf format.
        var memoryStream = new MemoryStream();
        // Save the workbook to PDF format while passing the object of PdfSaveOptions
        workbook.Save(memoryStream, pdfSaveOptions);

       
    }   

PDF is generated as per our requirement. Excelsheet columns are adjusted in single PDF page and if there are more number of rows it goes to next PDF page.

Issue - PDF created with very small font and non readable from sheet which has less number of column and column has less content compare to other sheet. It is only readable in 800% zoom in of PDF file.

Code -2

I tried to use below code but it’s create one PDF page from a Excel sheet. It does not matter hw much content a Excel sheet has.

public void Convert(Stream sourceFileStream, string sourceFilePath)
{
var convertFileCommonFunction=new ConvertFileCommonFunction();
// Load excel file containing custom properties
var workbook = new Workbook(sourceFileStream);
//
//PageSetup pageSetup = workbook.Worksheets[1].PageSetup;
// pageSetup.PrintArea= “A1:D56”;
// Create an instance of PdfSaveOptions and pass SaveFormat to the constructor
var pdfSaveOptions = new Aspose.Cells.PdfSaveOptions(Aspose.Cells.SaveFormat.Pdf);

        //********************************
        foreach (var worksheet in workbook.Worksheets)
        {

            //var worksheet = workbook.Worksheets[1];
            // Setting the orientation to Portrait
            worksheet.PageSetup.Orientation = PageOrientationType.Portrait;

            //Setting the scaling factor to 100
            worksheet.PageSetup.Zoom = 100;
            // OR Alternately you can use Fit to Page Options as under

            // Setting the number of pages to which the length of the worksheet will be spanned
            worksheet.PageSetup.FitToPagesTall = 1;

            // Setting the number of pages to which the width of the worksheet will be spanned
            worksheet.PageSetup.FitToPagesWide = 1;

            // Setting the paper size to A4
            worksheet.PageSetup.PaperSize = PaperSizeType.PaperA4;

            // Setting the print quality of the worksheet to 1200 dpi
            worksheet.PageSetup.PrintQuality = 1200;
        }

        //*******************************************


        //Save the document in pdf format.
        var memoryStream = new MemoryStream();
        // Save the workbook to PDF format while passing the object of PdfSaveOptions
        workbook.Save(memoryStream, pdfSaveOptions);

       
    }      

Please suggest solution for this issue.

Regards,
Rupesh

@porbistech,
Could you please share your template excel file and output PDF files for our analysis. If you can create expected output using Excel, having many rows and columns while keeping the contents readable then share it too.