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

Free Support Forum - aspose.com

Title Repetition To Be Avoided In Blank Page Of PDF

Hi Team,

I have an excel in which 2 pages of data is present and for this data a common title is present.
I’m converting excel to pdf and I want to repeat the same title for each and every page of pdf.
I have set the setPrintTitleRows but currently its not working.

Even if its working also I have a scenario where after setting the title in the last page of pdf (which is empty) the title is set.
I want to set the title only to the pages which have data but not empty blank pages.

Could you please kindly help me on this.

I’m attaching sample excel, pdf generated, java code to convert excel to pdf and also screenshot of the empty pdf page but with title.

Regards,
Sanjeev

Hi,

Thanks for the sample code, template files, screenshot.

sanjeevkumarambti:

I have an excel in which 2 pages of data is present and for this data a common title is present.
I'm converting excel to pdf and I want to repeat the same title for each and every page of pdf.
I have set the setPrintTitleRows but currently its not working.

I have evaluated your scenario/ case a bit using your sample code and template file. Well, there is an issue with the following line of code:
i.e.,
Worksheet worksheet = workbook.getWorksheets().get(0);
For your information, your underlying file has a hidden (first) sheet at its zero-indexed position, so kindly do change the line of code to:
i.e.,
Worksheet worksheet = workbook.getWorksheets().get("Chart");

I tried the following sample code with your template file and it works fine and as expected:
e.g
Sample code:

Workbook workbook = new Workbook("MultiplePagesInPDF.xlsx");
Worksheet worksheet = workbook.getWorksheets().get("Chart");
PageSetup pageSetup = worksheet.getPageSetup();
pageSetup.setPrintTitleRows("$6:$6");
pageSetup.setLeftMargin(0.5);
pageSetup.setRightMargin(0.5);
pageSetup.setTopMargin(0.5);
pageSetup.setBottomMargin(0.5);
PdfSaveOptions saveOptions = new PdfSaveOptions(com.aspose.cells.SaveFormat.PDF);
saveOptions.setAllColumnsInOnePagePerSheet(true);
saveOptions.setOnePagePerSheet(false);
saveOptions.setCreatedTime(DateTime.getNow());
saveOptions.setImageResample(220, 100);
workbook.save("out1MultiplePagesInPDF1.pdf", saveOptions);
workbook.save("outMutliplePagesInPDF1.xlsx", SaveFormat.XLSX);

sanjeevkumarambti:

Even if its working also I have a scenario where after setting the title in the last page of pdf (which is empty) the title is set.
I want to set the title only to the pages which have data but not empty blank pages.

Well, Aspose.Cells works the same way as per MS Excel, so if MS Excel does paste title row in the blank page, Aspose.Cells would also do the same in the converted PDF file. Also, in MS Excel you cannot paste the title rows (to be repeated) on your desired pages only. Either you got to insert title rows on all the pages (of a worksheet) or not even on a single page.

Thank you.