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

Free Support Forum - aspose.com

Aspose.pdf version 3.3 issue :Tables are getting overlapped on header

Hi ,


I am using Aspose.pdf jar with version as 3.3. I have created headers ,table and footers in pdf.

but the problem is Table is getting overlapped on header (ideally table should be created after header is set on page,this is how aspose.pdf behaves).Recently I just upgraded the version to 3.3 from 3.1.0 and I caught this issue.Although from next page tables are coming after header which is correct.

Sample Code snippet-
Pdf pdf = new Pdf();
for(int i=0;i<3;i++){
Section sec1 = pdf.getSections().add();
HeaderFooter Header1 = new HeaderFooter(sec1);
//Set the header of odd pages of the PDF document
sec1.setOddHeader(Header1);
sec1.setEvenHeader(Header1);
//Enable this header for first page only
//Header1.setIsFirstPageOnly(true);

//Instantiate a Text paragraph that will store the content to show as header
Text text = new Text(“Sample header Text \n” +
“Sample header Text\n” +
“Sample header Text\n” +
“Sample header Text\n” +
“Sample header Text\n” +
“Sample header Text\n” +
“Sample header Text\n” +
“PSample header Text\n” +
“Sample header Text\n” +
“Sample header Text\n”);
// specify the font color information for text object
text.getTextInfo().setColor(new aspose.pdf.Color(“Green”));
//specify the font name as Arial
text.getTextInfo().setFontName(“Arial”);
// set the top margin informatin for Header as 20
Header1.getMargin().setTop(20);
//Add the text object to the Paragraphs collection of HeaderFooter object to
//display header on the pages of PDF document
Header1.getParagraphs().add(text);
// ======= In following code we will create a Table =======//
// create a new Table object
Table Table1 = new Table(sec1);
// specify the Column width information for Table object
// Table1.setColumnWidths(“70 70”);
// specify the Border information for Table
Table1.setDefaultCellBorder(new BorderInfo(BorderSide.All.getValue(), 0.9F, new aspose.pdf.Color(“Black”)));
// Set the BackGround color information for Tabel as Yellow
Table1.setBackgroundColor(new aspose.pdf.Color(“White”));
Table1.setIsFirstRowRepeated(true);
Table1.setWidth(sec1.getPageInfo().getPageWidth() - 5);
//Table1.setColumnAdjustment(ColumnAdjustmentType.AutoFitToContent);
int rowCount = 0;
for(int j=1;j<10;j++){
Row row21 = Table1.getRows().add();
row21.setFixedRowHeight(15);
if(j==1){
for(int k = 0;k<10;k++){{
Cell cell= row21.getCells().add(“Ankit”);
cell.setWidth(20);
cell.setHeight(20);
cell.setBackgroundColor(new aspose.pdf.Color(“White”));// specify the BackGround color information for cell of Row
cell.setAlignment(AlignmentType.Center);// specify the Horizontal Alignment information for cell of Row
cell.setVerticalAlignment(VerticalAlignmentType.Center);// specify the Vertical Alignment information for cell of Row
cell.getDefaultCellTextInfo().setColor(new aspose.pdf.Color(“Black”));// specify the Text Color information for cell of Row
cell.getDefaultCellTextInfo().setFontSize(10);
Table innerTable = new Table();
Row row = innerTable.getRows().add();
row.getCells().add(“Child”);
cell.getParagraphs().add(innerTable);
}
}
}
else{
for(int k = 0;k<10;k++){
Cell cell= row21.getCells().add(“Col”+rowCount+k);
cell.setWidth(20);
cell.setHeight(20);
cell.setBackgroundColor(new aspose.pdf.Color(“White”));// specify the BackGround color information for cell of Row
cell.setAlignment(AlignmentType.Center);// specify the Horizontal Alignment information for cell of Row
cell.setVerticalAlignment(VerticalAlignmentType.Center);// specify the Vertical Alignment information for cell of Row
cell.getDefaultCellTextInfo().setColor(new aspose.pdf.Color(“Black”));// specify the Text Color information for cell of Row
cell.getDefaultCellTextInfo().setFontSize(10);
}
}
// add a cell to first row of Table
rowCount++;
}
// add table to paragraphs collection of section object
sec1.getParagraphs().add(Table1);
//set footer
HeaderFooter footer = new HeaderFooter(sec1);
// specify the Alignment information for the contents of HeaderFooter as Center Aligned
footer.getTextInfo().setAlignment(AlignmentType.Center);
// set the font color information for HeaderFooter object as Red
footer.getTextInfo().setColor(new aspose.pdf.Color(“Red”));
// create a sample text object with special replaceabel symbols
Text footText = new Text(footer, “Page: $p / $P”);
// add text object to paragraphs collection of HeaderFooter object
footer.getParagraphs().add(footText);
// set above create HeaderFooter object as Odd Footer for section1
sec1.setOddFooter(footer);
// set above create HeaderFooter object as Even Footer for section1
sec1.setEvenFooter(footer);
}
pdf.save(“D:\pdftest\Resultant.pdf”);

Please look into this.

Thanks and best Regards,
Ankit

Hi Ankit,


Thanks for contacting support.

I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as
PDFJAVA-33181. We
will investigate this issue in details and will keep you updated on the status
of a correction.

We
apologize for your inconvenience.

Hi ,


Any updates on this issue. When can we get fix for this.

Any ETA for this would be helpful.

Regards,
Ankit

Hi Ankit,


Thanks for your inquiry. I’ve verified the status of your reported issue, it’s still pending for analysis in the queue. Please be patient and spare us some time. We will keep you updated via this thread about your issue status.

Best Regards,

Hi Ankit,


Thanks for your patience.

We have further investigated the issue reported earlier and as per our observations, the methods cell.setWidth(20) and cell.setHeight(20); are obsolete and should not be used. Furthermore, the overlapped inner table is not an error as it’s a result of following code line:

row21.setFixedRowHeight(15);

Please try using the latest release of Aspose.Pdf for Java 9.0.0 and in case you still face the same issue, please feel free to contact.

The issues you have found earlier (filed as PDFJAVA-33181) have been fixed in Aspose.Pdf for Java 9.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan