View previous topic :: View next topic |
Author |
Message |
matthewb
Joined: 30 Dec 2008 Posts: 7
|
Posted: Tue Dec 30, 2008 2:18 pm Post subject: Big table only shown on page 1 other pages aren't shown? |
|
|
I have is I have created a big table which is rendered via a datatable. When I load the pdf it is created but only the first page is shown. In theory there should be around 30 pages. I thought the table would automatically create and go onto a seperate page or am i misinformed? Could someone look at my code and please tell me what to change so that all the table is shown. Many thanks Matt.
Code: | PdfDocument outputPdf = new PdfDocument();
PdfPage page0 = outputPdf.AddPage();
Document doc = new Document();
Section tableSection = doc.AddSection();
Table myTable2 = tableSection.AddTable();
myTable2.Borders.Visible = false;
myTable2.Format.Borders.Visible = false;
Column column1 = myTable2.AddColumn(Unit.FromCentimeter(2));
Column column2 = myTable2.AddColumn(Unit.FromCentimeter(2));
Column column3 = myTable2.AddColumn(Unit.FromCentimeter(8));
Column column4 = myTable2.AddColumn(Unit.FromCentimeter(2));
Column column5 = myTable2.AddColumn(Unit.FromCentimeter(2));
Column column6 = myTable2.AddColumn(Unit.FromCentimeter(2));
Row row1 = myTable2.AddRow();
row1.Cells[0].AddParagraph("Forename");
row1.Cells[1].AddParagraph("Surname");
row1.Cells[2].AddParagraph("Email");
row1.Cells[3].AddParagraph("Tel Num");
row1.Cells[4].AddParagraph("Username");
row1.Cells[5].AddParagraph("Password");
for(int i =0; i<dt.Rows.Count; i++)
{
Row row2 = myTable2.AddRow();
string item1 = dt.Rows[i][0].ToString();
string item2 = dt.Rows[i][1].ToString();
string item3 = dt.Rows[i][2].ToString();
string item4 = dt.Rows[i][3].ToString();
string item5 = dt.Rows[i][4].ToString();
string item6 = dt.Rows[i][5].ToString();
row2.Cells[0].AddParagraph(item1);
row2.Cells[1].AddParagraph(item2);
row2.Cells[2].AddParagraph(item3);
row2.Cells[3].AddParagraph(item4);
row2.Cells[4].AddParagraph(item5);
row2.Cells[5].AddParagraph(item6);
}
DocumentRenderer docRenderer = new MigraDoc.Rendering.DocumentRenderer(doc);
docRenderer.PrepareDocument();
XGraphics gfx = XGraphics.FromPdfPage(page0);
docRenderer.RenderPage(gfx, 1, PageRenderOptions.All);
outputPdf.Save("C:/Documents and Settings/Matthew Bryant/My Documents/Visual Studio 2008/WebSites/Matt Drop Down/mattsfile.pdf");
|
|
|
Back to top |
|
|
stu72
Joined: 12 Nov 2008 Posts: 2
|
Posted: Mon Jan 05, 2009 2:09 pm Post subject: |
|
|
Well, looking at your code it seems to be doing exactly what you tell it to: rendering only one page.
I'm a bit confused as to why you're using the XGraphics package here. I'm using PDFSharp to render a multi-page table with headers and footers. My rendering code looks something like this:
Code: |
Document document = gvPDF.CreateDocument(GridView1);
MiagraDoc.Rendering.PdfDocumentRenderer pdfRenderer = new MiagraDoc.Rendering.PdfDocumentRenderer(true);
pdfRenderer.Document = document;
pdfRenderer.RenderDocument();
pdfRenderer.Save("test.pdf");
|
There's nothing special about my document, it's just a section with a table and some rows and columns. |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Thu Jan 08, 2009 10:41 am Post subject: |
|
|
stu72 wrote: | I'm a bit confused as to why you're using the XGraphics package here. |
Yep, that's right.
After calling PrepareDocument you can determine how many pages there are in the document. Then you have to loop thru all pages.
If you don't want to modify the pages with PDFsharp calls, then simply follow stu72's approach. _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
|