PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Get Current Page Number
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2411
Page 1 of 1

Author:  dinesh_sp [ Wed Apr 17, 2013 8:10 am ]
Post subject:  Get Current Page Number

Hi,

I am making a PDF product list, which has got an index of all the products and their quick find page numbers at the end. My Problem is I cannt use Paragraph.AddPageField(), and I can't find a way to store this value in an array or a list. All the Products in the Index will be sorted by the Product Code and I have show their page numbers, hence I need the page number where I lay it out.

Also I am not able to use the GetValue method of the PageField, as I can't find the documentation on this API.

Any Help in this issue will be much appreciated.

Cheers.

Author:  Thomas Hoevel [ Wed Apr 17, 2013 8:32 am ]
Post subject:  Re: Get Current Page Number

Hi!

With MigraDoc you define the contents of a document. No page numbers exist at this stage.

When you render a document (e.g. as PDF), it gets rendered to pages. Therefore you have to use fields to show page numbers - either on the page or in references.

dinesh_sp wrote:
My Problem is I cannt use Paragraph.AddPageField()
My problem is you have to be more specific or I cannot help you. Why can't you use it? What have you tried?

Author:  dinesh_sp [ Wed Apr 17, 2013 9:37 am ]
Post subject:  Re: Get Current Page Number

Hi Thomas,

Thanks for your prompt reply. This is what I am trying to achieve.

I have a list of products, that are grouped by category, and I am able to display that on PDF successfully. At the end, when all products have been displayed, I show an index of products, which has Product Code and the Page on which it is found.
Ex.
Product Page Number
AAA 10
BBB 2
CCC 1.

This list is sorted by Products, but the table which shows the product details is sorted by category.
Now when I am writing the Prouduct AAA, I want to store the Page number 10 in an array to be displayed in this index, however, I am not having much luck using the AddPageField. I cant use a paragraph becuase the Index will be sorted by Product Code and I am looping products which are not sorted by product code.

hence while laying out products in a loop, I want some way to find which page this product will be displayed

Please suggest a way.

kind Regards,

Author:  Thomas Hoevel [ Wed Apr 17, 2013 11:22 am ]
Post subject:  Re: Get Current Page Number

See this sample:
http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashx

Search for "Paragraphs" (including quotes) and see how it is used with AddBookmark(), AddPageRefField(), and AddHyperlink().
You need a unique string for each product (will not be displayed). Your PDF will have entries that are linked to the product page (do not use AddHyperlink if you do not want that).

Author:  dinesh_sp [ Thu Apr 18, 2013 7:31 am ]
Post subject:  Re: Get Current Page Number

Hi Thomas,

I have made fair bit of progress in doing the Indexing. What I have found is bookmarks are not working correctly if placed inside of a table cell ?? It there some kind of limitation that bookmarks wouldnt work in a table cell ??

Basically I have a table with 3 columns, if I want to put a bookmark, I merge 3 columns, and put a bookmark and display the headig in a paragraph. For some reason, all my bookmarks go to page 1 for some strange reason.

I also want to bookmark all products in the list, and display them in a table, would migradoc support bookmarking a product in a table cell and showing in the Table of Contents as an index ??

Thanks in Advance.

Author:  dinesh_sp [ Wed May 01, 2013 12:08 am ]
Post subject:  Re: Get Current Page Number

I got around to my problem of bookmarking by create separate table for each row and the indexing worked.

Thanks for you help.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/