Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

How to know the number of lines of text in iFrame

Hi,

We are using iFrame in our web application to take the text data and provide the facility to format the data as per the user need. Typing, formatting the data and updating the to the data to database is working fine. When we are printing, we are getting the data from database and updating to text innerhtml. So the data is also printing fine. But when the data is too long and we need to start new page, I am expecting we need to know the number of ines in the content. So that as per the measure, I can print the data correctly in one page and move to the next page by leaving the required space for the header portion. This is the way we are taking the data in java script.

When we are taking the data
var testresult = window.frames["textEditor"].document.body.innerHTML;

After we retrive the data, we are upating to the control -
 document.getElementById('OPLABTESTRESULTREPORT:TEMPLATE1').innerHTML = strTextResult;

I am thinking that if I can know the number of lines at the times of the text data to the database and I can save the value and follow that value count for better formatting in page level.

If any other way to find the numbers of lines from iFrame, that would be greatly appreciated.

Thank you,
Murthy

Any response to my query,
0
Finsol123
Asked:
Finsol123
  • 4
  • 3
  • 2
1 Solution
 
Michel PlungjanIT ExpertCommented:
Serve a PDF - safest way to be able to format the way you want
0
 
Finsol123Author Commented:
I am sorry I did not understand the comment completely. As I mentioned, since I need to take input from the user, I need to have an editable field in the page. So we are giving iFrame there. So we are taking the data and updating to database, I would like to get the number of lines that time and update to database. Even after retrieve also, if I get, that is also fine. But I did not understand how pdf can be used here. If you can explain little more in detail, that will be helpful.

Thank you,
Murthy
0
 
Michel PlungjanIT ExpertCommented:
You are saying

But when the data is too long and we need to start new page, I am expecting we need to know the number of lines in the content. So that as per the measure, I can print the data correctly in one page and move to the next page by leaving the required space for the header portion

So I read that  you do not need to know the number of lines when you save but instead when you print.
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
Finsol123Author Commented:
Correct. Even if I get the number of lines before print, that would be helpful to me. Because sometimes we also combine the text with some other content, where I need to know howmuch the text content takes space and how much left on page. Then I can decide, whether I should start the text content on fresh page or I can print in the left over space (if it fits in the available space). For this purpose, I am looking for number of lines in the content.

Thank you,
Murthy
0
 
Michel PlungjanIT ExpertCommented:
Do you have <BR> or \n in the content?

You can split on '<br>' and count length
0
 
ahoffmannCommented:
are you saying that printing is done with javascript from within the web page in the browser?
0
 
Finsol123Author Commented:
Thanks for your comments.

" Do you have <BR> or \n in the content? You can split on '<br>' and count length"

Yes, we have <BR>, <P> tages. But when we use them, we are not getting exact number. Some times it is being correct for 90% and some times it is 50% correct. So there is lot of fluctuation. So we are looking any better way to handle.

"are you saying that printing is done with javascript from within the web page in the browser?"

Yes, we are getting the content and assigning to outputtext as innerhtml and printing along with the other controls like grids and other output texts. So if I have the correct number of lines with me, then I can correctly format the contet in the print.

Any other suggestions, really appreciable.

Thank you,
Murthy
0
 
ahoffmannCommented:
>> Yes, we have <BR>, <P> tages.
if you have P (or any other block tags), the rendering engine decides where to use line breaks unless you forced the egine to behave different (i.e. with CSS' white-space:pre)
hence I guess that you aproach to count the lines is useless

i.g. you should format the content with CSS, then the browser's print functionality will do a good job but not a prefect one for everybody ;-)

quote http://www.thenoodleincident.com/tutorials/design_rant/
  The Web is not Print
        This isn't news to anyone. But the web isn't screen either.
         Or more accurately it is print, and screen, and voice, and
         many other things.
0
 
Finsol123Author Commented:
We implemented as suggested, but the objective is not completely achieved. We looked other options as other experts mentioned. But those things can not be taken for requirement. For now, we are taking this as our solution

Thank you,
Murthy
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now