What is the text of pageheights
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 10
- Joined: Mon Aug 26, 2013 6:49 pm
What is the text of pageheights
Is there a function to identify the text appearing in a field after a scroll using the pageHeights ?
Hello,
Here is my problem:
I use a field with fixedLineHeight=false. In this field the text is very long and the user can change the textSize of the words, in different locations. Now to print this text (in fact to create a pdf file) I use a repeat with the lines of the pageheights of this field. It works well for the firsts lines appearing in the top of each page, but not for the last line appearing in the page. Because of the height of each line, the last one appears truncked and some time a line appears at the bottom of a page (not very truncked) and at the top of the next page.
To solve this problem I need a function (but I don't know if existing) wich indicates what is the text appearing in a page. If I know this text I can use the formattedHeight of this text and determine if I must ajust the height of the field so the truncked line does not appear at the bottom of the field.
Without such a function, it is possible, but not very fun, to use a loop that looks like
repeat with ANumberWord =1 to the number of words of my field
if the formattedHeight of word 1 to ANumberWord of my field >the pageHeights of this page
then set the height of my field smaller
end repeat
(I can send an script if necessary)
Have you another solution ?
Thanks for all help
Jean-Marc from Nice (France)
Hello,
Here is my problem:
I use a field with fixedLineHeight=false. In this field the text is very long and the user can change the textSize of the words, in different locations. Now to print this text (in fact to create a pdf file) I use a repeat with the lines of the pageheights of this field. It works well for the firsts lines appearing in the top of each page, but not for the last line appearing in the page. Because of the height of each line, the last one appears truncked and some time a line appears at the bottom of a page (not very truncked) and at the top of the next page.
To solve this problem I need a function (but I don't know if existing) wich indicates what is the text appearing in a page. If I know this text I can use the formattedHeight of this text and determine if I must ajust the height of the field so the truncked line does not appear at the bottom of the field.
Without such a function, it is possible, but not very fun, to use a loop that looks like
repeat with ANumberWord =1 to the number of words of my field
if the formattedHeight of word 1 to ANumberWord of my field >the pageHeights of this page
then set the height of my field smaller
end repeat
(I can send an script if necessary)
Have you another solution ?
Thanks for all help
Jean-Marc from Nice (France)
-
- Posts: 10
- Joined: Mon Aug 26, 2013 6:49 pm
Re: What is the text of pageheights
Since my post, I have found a way to go to a page and shorting the height of the field so it's suit to the text:
My fundamental problem remains, how to know what is the text appearing in the field ?
Also I have write a function to do it, but this function use a loop repeat on each char from the beginning ; so it is not very speedy for a very big text. This is the function:
If some body knows a better way to do this
Perhaps I try to do something existing in LC
jean-marc
Code: Select all
on GoToPage MyField,MyMask,PageToGo
set the rect of fld MyField to the defaultRect of fld MyField
repeat with ll=1 to -1+PageToGo
add line ll of the pageheights of fld MyField to TheScroll
end repeat
set the rect of fld MyField to item 1 to 3 of the defaultRect of fld MyField,5+the top of fld MyField+line PageToGo of the pageheights of fld MyField --3/5
set the scroll of fld MyField to TheScroll
end GoToPage
Also I have write a function to do it, but this function use a loop repeat on each char from the beginning ; so it is not very speedy for a very big text. This is the function:
Code: Select all
function CharDisplayFieldChunk MyField
put 1 into FirstChar
repeat while the formattedHeight of char 1 to FirstChar of fld MyField<=the scroll of fld MyField
if FirstChar>=length(fld MyField) then exit repeat
else add 1 to FirstChar
end repeat
put FirstChar into LastChar
repeat while the formattedHeight of char 1 to LastChar of fld MyField<=the scroll of fld MyField+the height of fld MyField
if LastChar>=length(fld MyField) then exit repeat
else add 1 to LastChar
end repeat
if LastChar<length(fld MyField) then subtract 1 from LastChar
return "char"&&FirstChar&&"to"&&LastChar&&"of field"&&MyField
end CharDisplayFieldChunk
Perhaps I try to do something existing in LC
jean-marc
-
- Posts: 10
- Joined: Mon Aug 26, 2013 6:49 pm
Re: What is the text of pageheights
Sorry, in the function GoToPage, there is no parameter MyMask :
Code: Select all
on GoToPage MyField,PageToGo
Re: What is the text of pageheights
If I understand correctly you want to print the field (say fld "Print") to pdf, nothing else?
If so, did you already try (kind of) the following?
If so, did you already try (kind of) the following?
Code: Select all
on mouseUp
ask file "Output to file:" with "test.pdf"
if it is empty then exit mouseUp
open printing to pdf it
revprintField the name of fld "Print"
close printing
end mouseUp
shiftLock happens
-
- Posts: 10
- Joined: Mon Aug 26, 2013 6:49 pm
Re: What is the text of pageheights
hello hh,
Before printing I must assume that the text is correctly well done. So before printing I nead to have a field with it's rect is the printing rect. This field must present exactly the printing pages. So I can go from page to page in this field, I can change text in it so that the new pages will exactly represente the futur printing pages and so on. For this, the pageHeights function is perfect but the difficulty is to know what are the strings (from char to char) appearing visualy in the text. For more explanations, see above. I am not realy satisfy with the function CharDisplayFieldChunk I have created.
Thanks for your interest
Jean-Marc
Before printing I must assume that the text is correctly well done. So before printing I nead to have a field with it's rect is the printing rect. This field must present exactly the printing pages. So I can go from page to page in this field, I can change text in it so that the new pages will exactly represente the futur printing pages and so on. For this, the pageHeights function is perfect but the difficulty is to know what are the strings (from char to char) appearing visualy in the text. For more explanations, see above. I am not realy satisfy with the function CharDisplayFieldChunk I have created.
Thanks for your interest
Jean-Marc
Re: What is the text of pageheights
I can think of a horrible hack which is unprofessional but might work. Simulate a user selection (pseudocode):
Get the topleft of the group
Add 1 to both items
Get the bottomright of the group
Subtract 1 from both items
Click at the first loc
Click at the second loc with shiftkey
Put the selected text into a variable
It's ugly but might work, I didn't try it. If you see a flash, lock the screen.
Get the topleft of the group
Add 1 to both items
Get the bottomright of the group
Subtract 1 from both items
Click at the first loc
Click at the second loc with shiftkey
Put the selected text into a variable
It's ugly but might work, I didn't try it. If you see a flash, lock the screen.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 10
- Joined: Mon Aug 26, 2013 6:49 pm
Re: What is the text of pageheights
Hello Jaque,
Thanks for your proposal, it's a non-spontaneous idea and interesting, but I cannot use click at that will change the selection. I yet prefere my bad function CharDisplayFieldChunk.
Thanks
jean-marc
Thanks for your proposal, it's a non-spontaneous idea and interesting, but I cannot use click at that will change the selection. I yet prefere my bad function CharDisplayFieldChunk.
Thanks
jean-marc
Re: What is the text of pageheights
You could save the selectedChunk, do the trick, then reset the selectedChunk. It's an ugly hack but I'm sure it would be faster than counting characters.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com