We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Can''t draw table, because there is not enough space for it.

I'm creating a PdfLightTable populating it manually. I'm using the "BeginCellLayout" event to format the header row. In that event I have the following code:

If (args.RowIndex = -1) Then
... ...
... ...
end if

I have 3 columns - each defined with equal width. If I format the second and third columns, the PDF generates w/o error (but the first column isn't formatted properly). If I format all 3 columns, I get the error: "Can't draw table, because there is not enough space for it."

The first part of the error is as follows:
================================================
[PdfLightTableException: Can't draw table, because there is not enough space for it.]
Syncfusion.Pdf.Tables.LightTableLayouter.LayoutOnPage(Int32 startRowIndex, PdfLayoutParams param, Boolean isPageFirst) +2745
Syncfusion.Pdf.Tables.LightTableLayouter.LayoutInternal(PdfLayoutParams param) +1601
Syncfusion.Pdf.Graphics.ElementLayouter.Layout(PdfLayoutParams param) +88
...
...
================================================

I've tried changing the table width and column sizes, but I can't seem to format the FIRST column.

During the event execution, I can see that the "args.Bounds" shows the width of each column to be exactly 1/3 of the total table width.

Why am I getting this error?

bert

3 Replies

PJ Pravin Joshua D Syncfusion Team March 11, 2010 10:39 AM UTC

Hi Bert,

Thank you for your interest in Syncfusion products.


This is not an bug with our library. If we try to draw more number of columns on a particular page which does not have enough room available to accomodate all the columns, then this exception will be thrown. We need to workaround this by taking advantage of our PdfLightTableLayouter class and handle the horizontal overflow of columns to subsequent pages.Also, we recommend that you use the EndCellLayout() method, if you were to modify the entire row. This method will produce the exact result as you expected. We have also created a sample to change the format of the entire header. Please refer to the modified sample below.

Sample:

http://files.syncfusion.com/samples/PDF.Web/TableManipulation.zip

Generated PDF:

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GeneratedPDF-676146022.zip

Please try this and let us know if you have any questions.


Regards,
Pravin Joshua D


AD Administrator Syncfusion Team August 23, 2012 10:57 AM UTC

Hi

I am also getting the same issue. I am trying to create a PDF file having around 800 pages. I am getting this error at around 5500 page. I am having 3 columns always.

void table_EndCellLayout(object sender, EndCellLayoutEventArgs args)
{
if (args.RowIndex != 0 && args.CellIndex == 0 && !isSkipped) //Name column
{
args.Graphics.DrawRectangle(PdfPens.Black, PdfBrushes.LightPink, args.Bounds);
}
}
bool isSkipped = false;

void table_BeginCellLayout(object sender, BeginCellLayoutEventArgs args)
{
try
{
if (args.RowIndex == _TotalRowsCount || (args.RowIndex != 0 && _IsDrawingHeaderRowInMiddle && _JustPrintedHeaderRow))
{
args.Skip = true;
isSkipped = true;
}
}
catch (Exception e)
{
GuiController.ShowException("Error when populating the data in the PDF", e);
}
}
Can you suggest any solution for this? if i am skipping this error at 5500th page, from there it will go fine and generate the PDF properly. but it will not write one row value. this row value is a string and relatively large but more bigger string has been drawn in early pages.
Please help...

Regards
Biju Koshy


GM Geetha M Syncfusion Team August 24, 2012 09:02 AM UTC

Hi Biju,

Thank you for your interest in Syncfusion products.

This exception might occur when the width of the row is more than the page size. You can solve this by changing the size of the PdfPage or reducing the width in each columns. Here is the code snippet:

PdfDocument document = new PdfDocument();

document.PageSettings.Size = new SizeF(1000, 800);

//or

table.Columns[0].Width = 5;

Please try this and let me know if you have any questions.

Regards

Geetha


Loader.
Live Chat Icon For mobile
Up arrow icon