PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 3:05 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Nov 24, 2009 5:18 pm 
Offline

Joined: Tue Nov 24, 2009 5:05 pm
Posts: 1
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");
    }


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 25, 2009 8:55 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
If you tell the program to render page 1 only it'll render page 1 only:
Code:
docrender.RenderPage(xgraph, 1);


viewtopic.php?f=2&t=726&p=1735&hilit=RenderPage#p1735

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 415 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group