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

Free Support Forum - aspose.com

Converting xlsx to pdf- set OnePagePerSheet=true not working

Hi Team


I am using Aspose.Cell to convert a xlsx file to a pdf file, and I set the OnePagePerSheet property to true, turns out some columns on the sheet1 are still converted to the next page in the pdf file. Could you take a look at this ?
Here is the code:
private void ConvertFromExcel(Stream inputStream, Stream outputStream)
{
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(inputStream);
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.OnePagePerSheet = true;
imgOptions.SaveFormat = Aspose.Cells.SaveFormat.Pdf;
workbook.Save(outputStream, Aspose.Cells.SaveFormat.Pdf);
}
And I have updated the files as attachments.
Thanks

Hi,

Thanks for your posting and using Aspose.Cells.

Please use PdfSaveOptions.OnePagePerSheet instead of ImageOrPrintOptions.OnePagePerSheet.

Please see the following sample code and its output pdf which I have attached for your reference.

C#

string filePath = @“D:\AsposeTestFiles\F405500104_20150331v1.xlsx”;

Workbook workbook = new Workbook(filePath);

PdfSaveOptions opts = new PdfSaveOptions();
opts.OnePagePerSheet = true;

workbook.Save(“output.pdf”, opts);

Thanks Shakeel


Thanks for your quick reply,now I get it.The reason I used the imageOrPrintOptions was that I used the one in the aspose.task which dose not have this property “OnePagePersheet”, there are two pdfSaveOptions classes in two namespace. After changing it to the one under the aspose.pdf, now it works fine.

Thanks

Hi,

Thanks for your feedback and using Aspose.Cells.

It is good to know that your issue is resolved. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

Please make sure you are using Aspose.Cells.PdfSaveOptions and not any other PdfSaveOptions so please change the above line of codes into

Aspose.Cells.PdfSaveOptions opts = new Aspose.Cells.PdfSaveOptions();
opts.OnePagePerSheet = true;