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

Multiple Pages On The Fly
https://forum.pdfsharp.net/viewtopic.php?f=2&t=253
Page 1 of 1

Author:  enginious [ Sun Nov 04, 2007 9:25 pm ]
Post subject:  Multiple Pages On The Fly

Hi,

Sorry if I'm asking a really basic question, but I would like to use this for generating a PDF brochure, where the number of pages is different each time it is produced.

As it's produced from a database, I just want to be able to make it automatically create Page1, Page2 etc all in one document.

However, so far I can only get it to have a static number of pages, which are designated at design time - am I missing anything obvious?

Thanks for any help you can offer.
Sparky.

Author:  ACS [ Sat Dec 01, 2007 8:02 pm ]
Post subject: 

Generating multiple pages dynamically is easy. All you need to do to add a new page is call the .AddPage() method of the PdfDocument object.

For example, let's say I have a program that uses a variable which stores the number of pages I wanna generate, called numPages.

You can then write code as follows (this is in C#):

Code:
PdfDocument doc;
PdfPage page;

doc = new PdfDocument();
for (int i = 0; i < numPages; i++)
{
  page = doc.AddPage();

  // do whatever you need to do here...
}


Now inside the for loop you can put stuff onto the "page" object.

Author:  jpavez [ Mon Dec 17, 2007 6:03 pm ]
Post subject:  It's possible create from single page to multiple pages?

Hi'

For a large process diagram (in a single page) i need tranform the document with single pagen in a document with multiple pages..(sorry my english, i speak spanish...)

Regards, José.

Author:  ACS [ Wed Dec 19, 2007 12:31 am ]
Post subject: 

Hi jpavez,

Are you saying that you have a diagram that can't fit onto one page, so you want to spread it across multiple pages?

Author:  Vyacheslav Popov [ Wed Dec 19, 2007 8:45 am ]
Post subject: 

You have insert a number page using: AddPageField()

example:
Code:
        public static void WriteNumberPagina(Document document, PositionNumber position, Color color)
        {
            Paragraph paragraph;
            FormattedText formattedText;
            TextFrame textFrame;

            textFrame = document.LastSection.AddTextFrame();
            textFrame.RelativeVertical = RelativeVertical.Page;
            textFrame.RelativeHorizontal = RelativeHorizontal.Page;
            textFrame.Width = "20mm";
            textFrame.Top = document.DefaultPageSetup.PageHeight - Unit.FromMillimeter(10);
            if (posicion == PositionNumber.Left)
                textFrame.Left = Unit.FromMillimeter(7);
            else
                textFrame.Left = document.DefaultPageSetup.PageWidth - textFrame.Width - Unit.FromMillimeter(2);
            paragraph = textFrame.AddParagraph();
            formattedText = paragraph.AddFormattedText("Pag. ");
            formattedText.Font.Size = 9;
            formattedText.Font.Bold = true;
            formattedText.Color = color;
            formattedText = paragraph.AddFormattedText();
            formattedText.AddPageField();
            formattedText.Font.Size = 16;
            formattedText.Font.Bold = true;
            formattedText.Color = color;
        }

Author:  jpavez [ Thu Dec 20, 2007 4:02 am ]
Post subject: 

Hi' ACS:

I Have a diagram that "can" fit onto one page, but i want spread it across multiple pages using c# code...

I am generating BPMN Diagram and Database Model in PDF in one page, having that, i need spread it across multiple pages...

BPMN Diagrams y DataBase model can be very large and i need print in A4 or 8.5x11" Letter.

It's possible?

Regards, José
(from Chile)

Author:  jpavez [ Thu Dec 20, 2007 4:03 am ]
Post subject: 

PD: The diagram generate it on the fly, over Web.

Author:  ACS [ Mon Dec 24, 2007 4:47 am ]
Post subject: 

Hi jpavez,

If you want your diagram spread across multiple pages, what you'll need to do is generate the diagram on each separate page, but offset.

For example, let's say for the sake of simplicity you want half the diagram rendered on one page, and the other half rendered on the other.

What you wanna do is render the full diagram on page 1, but with an offset, so part of it will be offpage. The offpage part obviously won't be rendered.
Then insert your second page, and render the same diagram on the page, but offset in the OTHER direction.

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