PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sun Nov 04, 2007 9:25 pm 
Offline

Joined: Sun Nov 04, 2007 9:21 pm
Posts: 1
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 01, 2007 8:02 pm 
Offline

Joined: Sat Dec 01, 2007 7:22 pm
Posts: 15
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.


Top
 Profile  
Reply with quote  
PostPosted: Mon Dec 17, 2007 6:03 pm 
Offline

Joined: Mon Dec 17, 2007 5:56 pm
Posts: 4
Location: Chile
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é.

_________________
Salu2, JPavez


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 19, 2007 12:31 am 
Offline

Joined: Sat Dec 01, 2007 7:22 pm
Posts: 15
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?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Dec 19, 2007 8:45 am 
Offline

Joined: Fri Nov 23, 2007 12:10 pm
Posts: 18
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;
        }


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 20, 2007 4:02 am 
Offline

Joined: Mon Dec 17, 2007 5:56 pm
Posts: 4
Location: Chile
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)

_________________
Salu2, JPavez


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Dec 20, 2007 4:03 am 
Offline

Joined: Mon Dec 17, 2007 5:56 pm
Posts: 4
Location: Chile
PD: The diagram generate it on the fly, over Web.

_________________
Salu2, JPavez


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 24, 2007 4:47 am 
Offline

Joined: Sat Dec 01, 2007 7:22 pm
Posts: 15
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.


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 410 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