dealing with page numbers

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

dealing with page numbers

khrypt
Hi guys,
I'm a new user of FM and I need some help from you.
I'm working with some documents and encountered an issue I could not manage yet..
So, int this documents there are some informations that may or may not appear. If they do appear I have to know the number of that page. Here is the issue.
By declaring a variable called pageNumber like:
[#assign pageNumber = "<s p a n   id="pagenumber"/>" /] I can get the number of the page.
But next, I need to remember this number. So I declare another variable controlPage like:
[#assign controlPage = pageNumber /]... And here is the issue... This controlPage will always evaluate as <s p a n   id="pagenumber"/> but I need to be just the value at that point/position where I've done the assignment. Because if I'm printing the controlPage in all pages it will have the value of current page (ex. 2, 3, 4, 5...) even if my declaration was made somewhere on first page and I expect (1, 1, 1, 1, ...).

Thank you for your time.
Reply | Threaded
Open this post in threaded view
|

Re: dealing with page numbers

bredelet
Hi,

> Hi guys,
> I'm a new user of FM and I need some help from you.
> I'm working with some documents and encountered an issue I could not manage
> yet..
> So, int this documents there are some informations that may or may not
> appear. If they do appear I have to know the number of that page. Here is
> the issue.
> By declaring a variable called pageNumber like:
> [#assign pageNumber = "<s p a n   id="pagenumber"/>" /] I can get the number

Are you sure you are using double-quotes this way? I am not even sure what this is supposed to do.

> of the page.
> But next, I need to remember this number. So I declare another variable
> controlPage like:
> [#assign controlPage = pageNumber /]... And here is the issue... This
> *controlPage* will always evaluate as *<s p a n   id="pagenumber"/>* but I
> need to be just the value at that point/position where I've done the
> assignment. Because if I'm printing the *controlPage* in all pages it will
> have the value of current page (ex. 2, 3, 4, 5...) even if my declaration
> was made somewhere on first page and I expect (1, 1, 1, 1, ...).
>
> Thank you for your time.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: dealing with page numbers

Daniel Dekany
In reply to this post by khrypt
Thursday, December 13, 2012, 1:56:44 PM, khrypt wrote:

> Hi guys,
> I'm a new user of FM and I need some help from you.
> I'm working with some documents and encountered an issue I could not manage
> yet..
> So, int this documents there are some informations that may or may not
> appear. If they do appear I have to know the number of that page. Here is
> the issue.
> By declaring a variable called pageNumber like:
> [#assign pageNumber = "<s p a n   id="pagenumber"/>" /] I can get the number
> of the page.

What do mean by you can get it? How? You have just assigned a constant
string to `pageNumber`. (Barring the syntactical error; I assume it
was `[#assign pageNumber = '<span id="pagenumber" />' /]`.) It means
nothing for FreeMarker, it's just an arbitrary sequence of characters
for it.

> But next, I need to remember this number. So I declare another variable
> controlPage like:
> [#assign controlPage = pageNumber /]

So now `controlPage` holds the same string constant. I guess you
expect something else to happen, but what exactly and why?

> ... And here is the issue... This *controlPage* will always evaluate
> as *<s p a n id="pagenumber"/>*

Since it's just a constant, yes.

> but I need to be just the value at that point/position where I've
> done the assignment.

The value of what at the point assignment? The current page number?
What keeps track of the current page number? Or if nothing yet, what
separates the pages? Because at those points you could increase a page
counter variable.

> Because if I'm printing the *controlPage* in all pages it will
> have the value of current page (ex. 2, 3, 4, 5...) even if my declaration
> was made somewhere on first page and I expect (1, 1, 1, 1, ...).

Um... the whole thing is rather strange. What are those spans, and why
are they relevant? How do you expect them to count the pages, if you
do at all?

> Thank you for your time.

--
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
FreeMarker-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
Reply | Threaded
Open this post in threaded view
|

Re: dealing with page numbers

khrypt
Hi Daniel, thank you for you attention.
First:
"What do mean by you can get it? How? You have just assigned a constant
string to `pageNumber`. (Barring the syntactical error; I assume it
was `[#assign pageNumber = '<spa n id="pagenumber" />' /]`.) It means
nothing for FreeMarker, it's just an arbitrary sequence of characters
for it."

-- the syntactical error I've made-it intentionally here.. yes, this is the correct declaration.

Second:
"So now `controlPage` holds the same string constant. I guess you
expect something else to happen, but what exactly and why?"

-- well, here I was expecting to get the value of that instruction.. This span is a css instruction defined as:
#pagenumber:before {content: counter(page);} and in the final step of processing the document it will give me the number of current page.

Third:
"The value of what at the point assignment? The current page number?
What keeps track of the current page number? Or if nothing yet, what
separates the pages? Because at those points you could increase a page
counter variable."

-- here you have a point, probably if no for certain at the "freemarker step" my variables are just some strings, and only in the last step "to pdf" this strings will be evaluated as css directives. Didn't thought about it until now. And this mean that I'm screwed....
Fourth:
"Um... the whole thing is rather strange. What are those spans, and why
are they relevant? How do you expect them to count the pages, if you
do at all? "
-- Yes, this are css directives for counting pages. They are perfectly working. Because of my lack of knowledge I've tried to combine css and freemarker... Didn't work out. That's it. Thank you again for your time.