Page Numbering

Technical support for Spire.PDF

Moderator: iceblue support

Page Numbering

Postby KenIKing » Mon Jul 16, 2012 9:01 pm

I need to append together multiple Microsoft Reporting Service reports into one PDF and/or Word and/or Excel. The reports that get appended change based on the customer selection.

If the first report has 2 pages and the second appended report has 5 pages can I number the pages 1,2,3,4,5,6,7 or will is show pages 1,2 then restart and show 1,2,3,4,5? My Reporting Services reports already have a page footer that shows the bank name, software version and date/time and possible other information. Can I add a incremental page number and still keep my other footer information?

Thanks.
KenIKing
 
Posts: 1
Joined: Mon Jul 16, 2012 7:41 pm

Re: Page Numbering

Postby amy.zhao » Tue Jul 17, 2012 6:31 am

Hi KenIKing,

Thanks for evaluating Spire.*.

As the issue you reported, we have created a research on it, but we need some more time to fix it. I can not provide you any reliable estimate regarding it's complexity. However, you will be surely informed once we fix it.

Thanks for your understanding and cooperation.

Have a nice day!

Amy
e-iceblue support
User avatar
amy.zhao
 
Posts: 2277
Joined: Wed Jun 27, 2012 8:50 am

Re: Page Numbering

Postby amy.zhao » Tue Jul 17, 2012 9:13 am

Hi KenIKing,

We have done a simple demo which together multiple reports into one PDF.
Please check it, hope it will help you.

Have a great day!

Amy
e-iceblue support
You do not have the required permissions to view the files attached to this post.
User avatar
amy.zhao
 
Posts: 2277
Joined: Wed Jun 27, 2012 8:50 am

Re: Page Numbering

Postby amy.zhao » Tue Jul 17, 2012 9:50 am

Hi KenIKing,

We also have done a simple demo which together multiple reports into one Word.
Please check the following code:

Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

namespace SALESSUPPORT_592_doc
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create word document
            Document document = new Document();

            for(int i = 0; i < 2; i++)
            {
                Section section = document.AddSection();

                //page setup
                SetPage(section);

                if (i == 0)
                {
                    //insert header and footer
                    InsertFooter(section);
                }

                for (int p = 0; p < 4; p++)
                {
                    Paragraph para = section.AddParagraph();
                    if (p > 0)
                    {
                        para.AppendBreak(BreakType.PageBreak);
                    }
                    para.AppendText(String.Format("Paragraph {0}", 4 * i + p + 1));
                }
            }

            document.SaveToFile("sample.doc");
            System.Diagnostics.Process.Start("sample.doc");
        }

        private static void InsertFooter(Section section)
        {
            HeaderFooter footer = section.HeadersFooters.Footer;

            //insert picture to footer
            Paragraph footerParagraph = footer.AddParagraph();

            //insert page number
            footerParagraph.AppendText("page ");
            footerParagraph.AppendField("page number", FieldType.FieldPage);
            footerParagraph.Format.HorizontalAlignment
                = Spire.Doc.Documents.HorizontalAlignment.Right;

            //border
            footerParagraph.Format.Borders.Top.BorderType
                = Spire.Doc.Documents.BorderStyle.Single;
            footerParagraph.Format.Borders.Top.Space = 0.05F;
        }

        private static void SetPage(Section section)
        {
            //the unit of all measures below is point, 1point = 0.3528 mm
            section.PageSetup.PageSize = PageSize.A4;
            section.PageSetup.Margins.Top = 72f;
            section.PageSetup.Margins.Bottom = 72f;
            section.PageSetup.Margins.Left = 89.85f;
            section.PageSetup.Margins.Right = 89.85f;
            section.PageSetup.RestartPageNumbering = true;
            section.PageSetup.PageStartingNumber = 1;
        }
    }
}


Amy
e-iceblue support
User avatar
amy.zhao
 
Posts: 2277
Joined: Wed Jun 27, 2012 8:50 am

Re: Page Numbering

Postby amy.zhao » Wed Jul 18, 2012 10:17 am

Hi KenIKing,

We have fixed that together multiple reports into one Excel.You only need put reports into every worksheet and add the following code in every worksheet.
Please check the following code:
Code: Select all
foreach (Worksheet sheet in workbook.Worksheets)
            {
                sheet.PageSetup.AutoFirstPageNumber = false;
                sheet.PageSetup.FirstPageNumber = 1;
                sheet.PageSetup.CenterFooter = "Page &P";
            }

Hope it will help you.
Have a nice day!

Amy
e-iceblue support
User avatar
amy.zhao
 
Posts: 2277
Joined: Wed Jun 27, 2012 8:50 am


Return to Spire.PDF

Who is online

Users browsing this forum: No registered users and 1 guest

cron