Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Sep 26, 2017 9:17 am

Gary.zhang wrote:Hello,

It seems that there is something wrong on your codes, so could you please show the codes that demonstrate the process of drawing the three tables?

Thanks,
Gary
E-iceblue support team


for (int i = 0; i < option.Length; i++)
{
try
{

PdfDocument temp_ = new PdfDocument();
PdfPageBase tempPage = temp_.Pages.Add(page.Canvas.ClientSize, new PdfMargins(0));
PdfLayoutResult result2 = table.Draw(tempPage, new PointF(15, 10));
float height = result2.Bounds.Bottom;
if (page.Canvas.ClientSize.Height - yy >= height)
{
resultx = table.Draw(page, new PointF(15, yy));
yy = resultx.Bounds.Bottom + 30;

}
else
{
page = doc.Pages.Add(PdfPageSize.A4, margin);
resultx = table.Draw(page, new PointF(15, 10));
yy = resultx.Bounds.Bottom + 15;
}
//resultx = table.Draw(page, new PointF(15, yy));
//yy = resultx.Bounds.Bottom + yy + 15;
}
catch (PdfTableException ex)
{

}
}

mels
 
Posts: 3
Joined: Tue Aug 22, 2017 3:52 am

Tue Sep 26, 2017 9:21 am

This is the generated file

mels
 
Posts: 3
Joined: Tue Aug 22, 2017 3:52 am

Wed Sep 27, 2017 10:12 am

Hi mels,

I will look into it and reply you ASAP.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Thu Sep 28, 2017 6:22 am

Hi mels,

Sorry for the late reply.
Please refer to the below code.
Code: Select all
       for (int i = 0; i < tables.Count; i++)
            {
               //there's no need to make an judgement on when to add a new page,
               // you just need to get the last page and draw the table on it.
                page = doc.Pages[doc.Pages.Count - 1];
                PdfTableLayoutFormat tableLayout = new PdfTableLayoutFormat();
                tableLayout.Break = PdfLayoutBreakType.FitElement;
                tableLayout.Layout = PdfLayoutType.Paginate;
                PdfLayoutResult result = tables[i].Draw(page, new PointF(0, y), tableLayout);
                y = result.Bounds.Bottom + 30;
            }

Attached is the whole testing code and the generated pdf.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Sat Sep 30, 2017 8:04 am

Hi mels,

How is your issue now?
Does the code I provided make sense?
Your feedback will be greatly appreciated.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.PDF