Solved

How to know the number of lines of text in iFrame

Posted on 2012-04-13
9
254 Views
Last Modified: 2012-05-03
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
Comment
Question by:Finsol123
  • 4
  • 3
  • 2
9 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37845820
Serve a PDF - safest way to be able to format the way you want
0
 

Author Comment

by:Finsol123
ID: 37845852
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 37845862
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
 

Author Comment

by:Finsol123
ID: 37845870
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 37845875
Do you have <BR> or \n in the content?

You can split on '<br>' and count length
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37845883
are you saying that printing is done with javascript from within the web page in the browser?
0
 

Author Comment

by:Finsol123
ID: 37850255
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 37850487
>> 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
 

Author Closing Comment

by:Finsol123
ID: 37922981
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now