PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

migradoc tables and adding new pages when out of space
https://forum.pdfsharp.net/viewtopic.php?f=2&t=651
Page 1 of 1

Author:  erik_buchanan@yahoo.com [ Fri Feb 20, 2009 11:26 pm ]
Post subject:  migradoc tables and adding new pages when out of space

I found a couple of posts talking about migradoc auto adding pages when you've run out of space, but it doesn't seem to to do this working with tables.

If this is the case is there a way to determine your current position in the document or the remaining space as you're generating the document?

Any help would be great, thanks.

Author:  erik_buchanan@yahoo.com [ Mon Feb 23, 2009 9:59 pm ]
Post subject:  Here's the code - hope somebody will see what I'm missing.

I get 1 page with 57 rows.
Again thanks for any help...

Code:
using System.Data.Sql;
using System.Data.SqlClient;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.Rendering;
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.IO;
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Drawing.Layout;
using PdfSharp;
using PdfSharp.Pdf.IO;
using PdfSharp.Pdf.Advanced;
using System.Globalization;
using System.Xml;
using System.Xml.XPath;


public partial class make_transcript : System.Web.UI.Page
{
    public string ssn;
    public string sql;
    public string sql1;
    public string sql2;
    public string sql3;
    public string sql4;
    public string aarts_date;
    SqlDataAdapter transcript_da;
    SqlDataAdapter transcript_crs_da;
    SqlDataAdapter transcript_cc_da;
    SqlDataAdapter transcript_crd_da;
    SqlConnection sqlconnection;
    DataSet transcript_ds;
    DataSet transcript_crs_ds;
    DataSet transcript_cc_ds;
    DataSet transcript_crd_ds;
    public string status;


    protected void Page_Load(object sender, EventArgs e)
    {       
        PdfDocument pdfdocument = new PdfDocument();       

        page1(pdfdocument);

        MemoryStream stream = new MemoryStream();
        pdfdocument.Save(stream, false);
        Response.Clear();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-length", stream.Length.ToString());
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        stream.Close();
        Response.End();
    }
    void page1(PdfDocument pdfdocument)
    {
        PdfPage page = pdfdocument.AddPage();       
        Document document1 = new Document();
       
        string pagecount = "1";

        Section section = document1.AddSection();

        MigraDoc.DocumentObjectModel.Tables.Table table1 = section.AddTable();

        Column column1 = table1.AddColumn("1.5in");
        Column column2 = table1.AddColumn("4in");
        Column column3 = table1.AddColumn("1.5in");

        for (int P = 0; P < 200; P++)
        {
            Row row31 = table1.AddRow();
            Paragraph paragraph31a = row31.Cells[0].AddParagraph();
            paragraph31a.Style = "NORMAL";
            paragraph31a.Format.Font.Name = "ARIAL";
            paragraph31a.Format.Font.Size = "8";
            paragraph31a.Format.Alignment = ParagraphAlignment.Left;
            paragraph31a.AddText("ROW " +P.ToString());
        }           
        MigraDoc.Rendering.DocumentRenderer docRenderer = new DocumentRenderer(document1);
        docRenderer.PrepareDocument();
        XGraphics gfx = XGraphics.FromPdfPage(page);
        docRenderer.RenderPage(gfx, 1);
    }
}

Author:  Thomas Hoevel [ Tue Feb 24, 2009 8:02 am ]
Post subject: 

It seems you tell PDFsharp to render the first page - so you get one page.
Nothing wrong!

Look here (if you don't need XGraphics):
viewtopic.php?t=592&highlight=frompdfpage&mforum=pdfsharp

Look here (if you need XGraphics):
viewtopic.php?t=556&highlight=frompdfpage&mforum=pdfsharp

Author:  erik_buchanan@yahoo.com [ Tue Feb 24, 2009 3:09 pm ]
Post subject:  Thanks...

Thanks - I was pretty sure it was something I was doing or not doing.
Everything works great now.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/