Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Jan 09, 2015 10:21 pm

Hello all,

From within VS 2012, I've just created a new C# winform application. From the Nuget package, I've just finished installing the Free Spire.PDF for NET.

I'm grasping at straws to understand a few things so I figured I'd post them here in hopes of finding an answer.

My task is the following:
I'm creating a C# winform application that will need to create a single PDF document holding one or more pages.
Once created, that document will be automagically sent to a particular printer (not the default one but another printer...) without prompting the PrintDialog().

In short, my application sells tickets. Once a ticket (or more) is sold, I need to create a PDF document in which the first page will hold the receipt and all subsequent page(s) will be the ticket(s).

I can't seem to find any examples of How to create a single PDF document having multiple pages.

Consider the following:
I have an Order object which has a string Receipt property.
I also have a collection of string which represents the ticket(s).

Both the receipt and ticket(s) are strings which will hold HTML.

I've already found the example that shows how to LoadFromHTML() but I'm still not getting how do I loop my tickets collection and add pages to my initial: PdfDocument pdf = new PdfDocument();

If anyone could help me shed some light on this, that would be great!
Thanks

vlince
 
Posts: 1
Joined: Fri Jan 09, 2015 9:58 pm

Mon Jan 12, 2015 6:56 am

Hello vlince,

Thanks for your inquiry.

Since both your receipt and ticket are string, you can add some "page break" between receipt and ticket like this:
receipt/pb/ticket/pb/ticket

When your application read this tag, create a new page to hold the ticket information:
Code: Select all
PdfPageBase page = pdf.Pages.Add();
page.Canvas.DrawString(...);
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.PDF