Page numbers

4 posts, 0 answers
  1. Jer
    Jer avatar
    10 posts
    Member since:
    Jun 2012

    Posted 02 Jul 2015 Link to this post

    Can you provide an example on how to have page numbers on the exported pdf?
  2. Aneliya Petkova
    Admin
    Aneliya Petkova avatar
    207 posts

    Posted 06 Jul 2015 Link to this post

    Hi Jeremy,

    The only way to add page Numbers in your PDF file is using html elements in your markup(the following code is extracted from our PDF Multi Page Export online demo):
    <telerik:RadPageView runat="server" ID="PageView1" CssClass="recipePage">
        <div class="recipeImage qsf-ib">
            <img src="images/Beef_Stewed.png" alt="image" />
        </div>
        <div class="ingredients qsf-ib">
            <p>Beef Stewed in a Salty Herb Crust</p>
            <ul>
                <li>800 gr beef bonfile</li>
                <li>2 tablespoons olive oil</li>
                <li>1 tabslespoon butter</li>
                <li>salt and pepper</li>
            </ul>
            <p class="subtitle">For the crust:</p>
            <ul>
                <li>120 gr cooking salt </li>
                <li>200 gr sea salt</li>
                <li>500 gr butter</li>
                <li>2 egg whites</li>
                <li>250 ml water</li>
                <li>2 tablespoons of rosmarin and salvia</li>
            </ul>
        </div>
        <a href="#">1</a>
    </telerik:RadPageView>

    You can also use JavaScript to append such elements to every page.

    Regards,
    Aneliya Petkova
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jer
    Jer avatar
    10 posts
    Member since:
    Jun 2012

    Posted 10 Jul 2015 in reply to Aneliya Petkova Link to this post

    Thanks! Please provide the JavaScript example to append to every page.
  5. Aneliya Petkova
    Admin
    Aneliya Petkova avatar
    207 posts

    Posted 13 Jul 2015 Link to this post

    Hi,

    I added the following script to the PDF Multi Page Export demo( I am using jQuery .append method to add the page numbers to a certain div element):
    window.onload = function (e) {
        var page = $("div.recipePage");
     
        for (var i = 1; i <= page.length; i++) {
            var element = page.eq(i-1);
            $(element).append("<a class='page-numbers' href='#'>" + i.toString() + "</a>");
        }
    }

    You can style the page numbers using the class I added to the anchor element(page-numbers).

    Please find attached the modified demo and test it at your side.

    Hope this will be helpful.

    Regards,
    Aneliya Petkova
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top