Hi,
I am using pdfsharp & MigraDoc. I am having 70 rows records need to be displayed.But only 27 records getting displayed in first page.Remaining r not displaying in second page.Atleast second is not getting created.Please help.my project needs this urgently.thnks in advance.
Please give me reply.....
Below is the code i am using ....
Code:
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=SANTOSHREDDYT;uid=sa;pwd=sa;Database=pubs");
SqlDataAdapter da = new SqlDataAdapter("select * FROM discounts,AUTHORS order by au_fname", conn);
DataSet ds = new DataSet();
da.Fill(ds);
int count = ds.Tables[0].Rows.Count;
PdfDocument pdfdoc = new PdfDocument();
pdfdoc.PageLayout = PdfPageLayout.SinglePage;
PdfPage pdfpage = pdfdoc.AddPage();
pdfpage.Size = PageSize.A4;
XGraphics xgraph = XGraphics.FromPdfPage(pdfpage);
Document document = new Document();
Section section = new Section();
Section sec = document.AddSection();
MigraDoc.DocumentObjectModel.Shapes.Image img = sec.Headers.Primary.AddImage("C:\\a.jpg");
img.Height = "2cm";
img.Width = "2cm";
img.LockAspectRatio = true;
img.RelativeVertical = RelativeVertical.Line;
Paragraph ppp = sec.Footers.Primary.AddParagraph("this is a footer");
img.Top = ShapePosition.Top;
img.Left = ShapePosition.Right;
img.Left = ShapePosition.Right;
document.Add(sec.Clone());
MigraDoc.DocumentObjectModel.Tables.Table table = sec.AddTable();
table.Style = "Table";
table.Borders.Color = Colors.Black;
table.Rows.LeftIndent = 0;
Column column = new Column();
column = table.AddColumn();
table.AddColumn();
table.AddColumn();
table.AddColumn();
table.AddColumn();
Row rowout = table.AddRow();
rowout.HeadingFormat = true;
rowout.Shading.Color = Colors.PaleGoldenrod;
Cell celll = rowout.Cells[0];
celll.AddParagraph("heading1");
celll = rowout.Cells[1];
celll.AddParagraph("heading2");
celll = rowout.Cells[2];
celll.AddParagraph("heading3");
celll = rowout.Cells[3];
celll.AddParagraph("heading4");
celll = rowout.Cells[4];
celll.AddParagraph("SNo: ");
column.Borders.Color = Colors.Red;
for (int i = 0; i < count; i++)
{
Row row = table.AddRow();
row.Format.Alignment = ParagraphAlignment.Left;
row.HeadingFormat = false;
Cell cell0 = row.Cells[0];
cell0.AddParagraph(ds.Tables[0].Rows[i][0].ToString());
Cell cell1 = row.Cells[1];
cell1.AddParagraph(ds.Tables[0].Rows[i][1].ToString());
Cell cell2 = row.Cells[2];
cell2.AddParagraph(ds.Tables[0].Rows[i][2].ToString());
Cell cell3 = row.Cells[3];
cell3.AddParagraph(ds.Tables[0].Rows[i][3].ToString());
Cell cell4 = row.Cells[4];
cell4.AddParagraph(i.ToString());
}
table.SetEdge(0, 0, 2, count, Edge.Cross, MigraDoc.DocumentObjectModel.BorderStyle.DashDotDot, MigraDoc.DocumentObjectModel.Unit.FromCentimeter(0));
document.Add(section);
DocumentRenderer docrender = new DocumentRenderer(document);
docrender.PrepareDocument();
docrender.RenderPage(xgraph, 1);
pdfdoc.Save("finalpdfgeneration.pdf");
System.Diagnostics.Process.Start("finalpdfgeneration.pdf");
}