PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Important Notice: We regret to inform you that our free phpBB forum hosting service will be discontinued by the end of June 30, 2024. If you wish to migrate to our paid hosting service, please contact billing@hostonnet.com.
MigraDoc: Printing multiple Documents and Page Numbers

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
Thomas



Joined: 25 Aug 2008
Posts: 7

PostPosted: Wed Aug 27, 2008 12:39 pm    Post subject: MigraDoc: Printing multiple Documents and Page Numbers Reply with quote

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!
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Wed Aug 27, 2008 1:06 pm    Post subject: Reply with quote

Hi!

How about using AddSectionPagesField() instead?
Don't forget to set section.PageSetup.StartingNumber ...
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
Thomas



Joined: 25 Aug 2008
Posts: 7

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

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 Sad
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Wed Aug 27, 2008 1:52 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Thomas



Joined: 25 Aug 2008
Posts: 7

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

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.
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Wed Aug 27, 2008 2:34 pm    Post subject: Reply with quote

IntelliSense works.
Did you include the MigraDoc projects in your solution?
Or did you reference the DLLs directly?
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
Thomas



Joined: 25 Aug 2008
Posts: 7

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

It's a bit warm here Confused Sorry, of course IntelliSense works. But it seems you did not set any XML Comments to provide more meaningful information within the IntelliSense popups.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com