PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Feb 20, 2009 11:26 pm 
Offline

Joined: Fri Feb 20, 2009 11:19 pm
Posts: 10
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 23, 2009 9:59 pm 
Offline

Joined: Fri Feb 20, 2009 11:19 pm
Posts: 10
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);
    }
}


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Feb 24, 2009 8:02 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Thanks...
PostPosted: Tue Feb 24, 2009 3:09 pm 
Offline

Joined: Fri Feb 20, 2009 11:19 pm
Posts: 10
Thanks - I was pretty sure it was something I was doing or not doing.
Everything works great now.


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 376 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group