Free Support Forum - aspose.com

Can't get page breaks to work- spreadsheet to pdf

HI,

Long time Aspose user. Works great, but I'm stuck on something. I open an Excel workbook, set page breaks, response back to user as a pdf, but the page breaks are then missing. It should be a 3 page pdf, instead it's a one page pdf which scrolls down to view all 3 pages. Interestingly, the page breaks are OK in the spreadsheet itself, but the PDF doesn't show them. File attached.

Here's what I'm doing:

Dim MyWorkbook as workbook = new workbook(filepath&filename)

Dim myoptions as New PdfSaveOptions

myoptions.OnePagePerSheet = TRUE

MyWorkbook.Worksheets(0).HorizontalPageBreaks.Add("A53")

MyWorkbook.Worksheets(0).HorizontalPageBreaks.Add("A108")

MyWorkbook.Save(Me.Reponse,"Report.pdf",ContentDisposition.Attachment, myoptions)

myWorkbook = Nothing

Any ideas? Thanks in advance.

da

Hi,


Well, you are getting one PDF page (and ignoring the page breaks) due to the culprit line i.e.:
myoptions.OnePagePerSheet = TRUE
For your information OnePagePerSheet option will always ignore your existing or new pages breaks that you set, it will render one PDF page per the whole worksheet. So, you should not use this option.

Thank you.

Problem solved! Thanks for the instantaneous support!

da

Hi,


It’s good to know that your problem is resolved.

Feel free to contact us any time if you need further help or have any query, we will be happy to assist you.