Solved

How to know the number of lines of text in iFrame

Posted on 2012-04-13
9
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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
 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint and CAML query help 4 21
Calculating percentage 2 45
HTML editor custom button 3 83
Change javascript filter code from OR logic to AND 5 38
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

738 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