Unwanted text in table cell

Hi,


I am using licensed Aspose 11.0.0 PDF java version.

I have a PDF with A4 page size which contains a table with 5 columns each having 200 width.

I am facing a problem of unwanted text at end of the PDF.
I have attached the image showing the problem.

I know my table width is greater than the page size but even so the pointed text should not present at that particular location.

Also notice the incomplete data in the last column.

How do I fix this ?

Hi Saurabh,


Thanks for your inquriy. If your table is larger than page width then you may either increase the page width or set Broken property to break table to next page or same page. However we will appreciate it if you please share your sample code here, we will look into it and guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

Hi,


This is the method that is creating the table.

private static Table getDataTable() {
Table table = new Table();
for( int i = 0; i < 1000; i++ ) {
Row row = table.getRows().add();
for( int j = 0; j < 5; j++ ){
Cell cell = getCell( i, j );
row.getCells().add(cell);
}
}
table.setColumnWidths( "200 200 200 200 200 " );
return table;
}

The 2 solution that you suggested -
1 - Increase page size
The application where I am using Aspose takes the page size as input and I cannot change it later hence I cannot implement this solution.

2 - Set broken table property
This solution will also not be applicable because the problem is width wise and not height wise. And according to my understanding this property starts the table from the start of the page if the table is not able to fit in remaining PDF page ( please correct me if I am wrong). Hence I cannot implement this solution.


Does Aspose have any other solution ?

Hi Saurabh,


Thanks for your feedback. You may try to set column width in percentage. It will adjust column width in respect to page width. Hopefully it will help you to accomplish the task.

com.aspose.pdf.Table table = new
com.aspose.pdf.Table();<o:p></o:p>

table.setColumnWidths("20% 20% 20% 20% 20%");


Please feel free to contact us for any further assistance.


Best Regards,

Hi,


The solution that you provided is not required by my application.
This solution will squeze the table columns so that all columns will fit in page. But as sometimes my application has a lot of columns and the user of my application is OK if the data is cropped.

But due to that invalid text ( the text from the next cell ). The PDF look and feel is completely destroyed, the table style changes and so on.

Hence please I just want to remove that text.
The cropping of data is fine.

Hi Saurabh,


Thanks for your feedback. As requested above, please share your sample code to replicate the unwanted issue at our end, it will help us to address your issue exactly.

Best Regards,

Hi,


I have shared the code that reproduces the issue on my side.

It is just before your % width solution reply.

Thanks.

Hi Saurabh,


Thanks for your feedback. I have tested the scenario again using your code, it wraps text in third column and destroy the table style. As I suggested you above that in such case you should use Broken Property of table, if table does not fit horizontally on a page then it breaks the table vertically on next pages, please find attached a sample output.

However if it does not fulfill your requirement then please share your sample required output here, so we will log a ticket in our issue tracking system for further investigation and rectification.

We are sorry for the inconvenience caused.

Best Regards,

Hi,


I don’t want the table to break or show the remaining data that does not fit in the page.

LET IT GET CROPPED.

I have attached the image, the first row shows how currently it is working and the rest of the rows how I would like it to work.

The black border in the image is shown only if the cell is fit completely. If it does not fit then it is OK if it also gets cropped.

Hi Saurabh,


While using your shared sample code snippet without using Broken property and column width in %, I am unable to reproduce output similar to your shared screen shot.

Please find attached sample documents. As per my understanding, if the table is larger than the page width then you want to crop the table columns(Table_Crop.PNG) with wrapped text. Please confirm whether we are on same page, so I will log an investigation ticket accordingly.

We are sorry for the inconvenience.

Best Regards,

Hi,


Sorry for late reply, but can you please share your code ?

Cause in the attached PDF I found the exact same the thing that I don’t want it to occur.
I have attached image which indicates what I want to ignore .


Hi Saurabh,


SaurabhMayekar:

Sorry for late reply, but can you please share your code ?


Please find sample code used to generate above shared PDF.

Document doc = new Document();

Page page = doc.getPages().add();

// Initializes a new instance of the Table

com.aspose.pdf.Table table = new com.aspose.pdf.Table();

table.setColumnWidths( "200 200 200 200 200");

for( int i = 0; i < 20; i++ ) {

Row row = table.getRows().add();

for( int j = 0; j < 5; j++ ){

Cell cell = getCell( i, j );

row.getCells().add(cell);

}

}

// Add table object to first page of input document

page.getParagraphs().add(table);

doc.save(myDir+"DOMTable.pdf");

-----

private static Cell getCell( int i, int j ) {

TextSegment segment = new TextSegment( "This is some sample text");

TextState state = segment.getTextState();

state.setFont( FontRepository.findFont("Verdana") );

state.setForegroundColor(com.aspose.pdf.Color.getBlack() );

state.setBackgroundColor( com.aspose.pdf.Color.getWheat() );

//state.setFontSize( 15f );

TextFragment textFragment = new TextFragment();

textFragment.getSegments().add( segment );

Cell cell = new Cell();

cell.getParagraphs().add( textFragment );

BorderInfo info = new BorderInfo();

com.aspose.pdf.GraphInfo ginfo = new com.aspose.pdf.GraphInfo();

ginfo.setLineWidth( 2 );

ginfo.setColor( com.aspose.pdf.Color.getBlack() );

info.setTop( ginfo );

info.setLeft( ginfo );

info.setRight( ginfo );

info.setBottom( ginfo );

cell.setBorder( info );

MarginInfo mInfo = new MarginInfo( 5, 5, 5, 5 );

//cell.setMargin( mInfo );

return cell;

}

Best Regards,

Hi Saurabh,

SaurabhMayekar:

Cause in the attached PDF I found the exact same the thing that I don't want it to occur.
I have attached image which indicates what I want to ignore .



Thanks for your feedback. As per your requirements, I have logged an investigation ticket PDFNEWJAVA-35646 in our issue tracking system for further investigation. We will keep you updated about the issue resolution progress.

Best Regards,