PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 4:37 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Wed Aug 27, 2008 12:39 pm 
Offline

Joined: Mon Aug 25, 2008 9:14 pm
Posts: 7
Hey guys.

I successfully created my single invoice document by following your sample. I also included page numbers, which is a nice feature itself.

But now I am trying to mass generate invoices, which means I want to generate each single invoice as before, and add it to a "container" document which includes all invoices.

This works fine:

Code:
Document document = new Document();

OrderCollection orders = ShopServiceManager.Orders().GetOrdersByCustomer(34);
foreach (var order in orders)
{
    BL.Documents.Invoice invoice = new BL.Documents.Invoice();
    invoice.DocumentCreator = new InvoiceDocument();
    invoice.Order = order;
    invoice.Print(false);
    document.Add(invoice.Document.LastSection.Clone());
}

PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);
pdfRenderer.Document = document;
pdfRenderer.RenderDocument();


The print method sets the property Document of the invoice object to the internally new generated MigraDoc Document. By adding the LastSection I can add the single document to the container doc and print this container document at the and of the game.

This all works. The problem: the page numbers are counted over all single invoice documents within the container doc. For example, if I am printing 6 invoices which are all containing one single page, I should get a result like 6 times "Page 1/1". Instead of that I get "Page 1/6", "Page 2/6" and so on - because the used AddNumPagesField() seems to be counted over all documents (sections).

I was trying to render each single invoice within the loop and add the final rendered result to the container document, but with no success.

I would be very glad if anyone could assist.

Thanks in advance!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 27, 2008 1:06 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi!

How about using AddSectionPagesField() instead?
Don't forget to set section.PageSetup.StartingNumber ...

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 27, 2008 1:35 pm 
Offline

Joined: Mon Aug 25, 2008 9:14 pm
Posts: 7
Hi Thomas,

thanks for your fast response. With AddSectionPagesField() I get the absolute count of pages in the section, but how do I receive the current page number?

P.s.: Is there a documentation available anywhere? It's really a great library, but also a hard trial and error game :(


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 27, 2008 1:52 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
No change for page number (that's why you have to set the starting number).

Re: documentation:
I press F12 and look what's there.
Press F12 on AddNumPagesField and you'll find AddSectionPagesField.
I knew there was a way to set the starting page of a section; since I didn't find it in Section, I looked in PageSetup.

Apart from Intellisense there are no documents worth mentioning.
The samples are a good source of information.

We had a volunteer for our help project http://wikihost.org/wikis/pdfsharp/ ...
... but he vanished ...

_________________
Regards
Thomas Hoevel
PDFsharp Team


Last edited by Thomas Hoevel on Tue Dec 02, 2008 8:26 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 27, 2008 2:08 pm 
Offline

Joined: Mon Aug 25, 2008 9:14 pm
Posts: 7
Thomas Hoevel wrote:
No change for page number (that's why you have to set the starting number).


Yes. It's a bit inconsistent I think. For all others:

//Resetting starting number
section.PageSetup.StartingNumber = 1;

// Current Page
AddPageField()

// Total Page Count
AddSectionPagesField()

Thomas Hoevel wrote:
Re: documentation:
I press F12 and look what's there.
Press F12 on AddNumPagesField and you'll find AddSectionPagesField.
I knew there was a way to set the starting page of a section; since I didn't find it in Section, I looked in PageSetup.

Apart from Intellisense there are no documents worth mentioning.
The samples are a good source of information.


IntelliSense would be a great help.

Thomas Hoevel wrote:
We had a volunteer for our help project http://pdfsharp.wikihost.org/ ...
... but he vanished ...


I know the situation of open source projects, I am involved in some. But I have not the time to get involved in this too, instead I would pay for a commercial version if offered for a fair price.

Just my 2 cents. Thanks again for your support.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 27, 2008 2:34 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
IntelliSense works.
Did you include the MigraDoc projects in your solution?
Or did you reference the DLLs directly?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 27, 2008 3:11 pm 
Offline

Joined: Mon Aug 25, 2008 9:14 pm
Posts: 7
It's a bit warm here :? Sorry, of course IntelliSense works. But it seems you did not set any XML Comments to provide more meaningful information within the IntelliSense popups.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 26 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