Counting Lines of Rendered HTML?

T

travismcmahan

Hello,

I am working on a project that requires me to paginate a dynamic length
html document so I can then in turn send each page to a PDF conversion
component. I have been researching for an hour now and have yet to
come across a solution.

The data I am dealing with is a string with embedded html. I need to
determine how many lines the rendered output will use in a browser so I
can issue a page break appropriately.

Any suggestions? Thanks in advance!
 
A

Adrienne Boswell

travismcmahan wote:
Hello,

I am working on a project that requires me to paginate a dynamic length
html document so I can then in turn send each page to a PDF conversion
component. I have been researching for an hour now and have yet to
come across a solution.

The data I am dealing with is a string with embedded html. I need to
determine how many lines the rendered output will use in a browser so I
can issue a page break appropriately.

Any suggestions? Thanks in advance!

You could perhaps do something with characters. When 70 characters are
reached, you might have a line break, so you could calculate from that.
 
T

travismcmahan

I appreciate your response, however block elements like <table>, <div>,
<p> cause problems with that sort of approach.
 
T

Toby Inkster

travismcmahan said:
The data I am dealing with is a string with embedded html. I need to
determine how many lines the rendered output will use in a browser so I
can issue a page break appropriately.

How big is your font? How wide is your browser window?
 
B

Blinky the Shark

Toby said:
How big is your font? How wide is your browser window?

That sounds like dirty talk to me. The next thing you'll be asking is
"what are you wearing?"
 
J

Jim Moe

travismcmahan said:
I am working on a project that requires me to paginate a dynamic length
html document so I can then in turn send each page to a PDF conversion
component. I have been researching for an hour now and have yet to
come across a solution.

The data I am dealing with is a string with embedded html. I need to
determine how many lines the rendered output will use in a browser so I
can issue a page break appropriately.
I guess you are limiting yourself to GUI browsers? There are also text
browsers, speech browsers, search engines, etc.
Browsers render HTML within the constraints set by both the user and the
author, and the browser's own limitations. How would you resolve all of
the visual variables to decide what the actual rendering is?
 
A

Adrienne Boswell

I appreciate your response, however block elements like <table>, <div>,
<p> cause problems with that sort of approach.

Then you make allowances for that in your script. If you get a tag, find
out which element it is, account for it, get the text, then look for the
ending tag.

If the element is a block level element, allow 1 line for it. Then you have
a count of the characters in the text between the element tags.
 
A

Andy Dingley

travismcmahan said:
I am working on a project that requires me to paginate a dynamic length
html document so I can then in turn send each page to a PDF conversion
component.

Don't paginate HTML, it sucks at doing it. HTML has no concept of
pages, and the CSS that does isn't well or widely supported.

You'd be better looking at taking your HTML into XML and XSL:FO, then
controlling the pagination in XSL:FO (which is good at it). XSL:FO to
PDF is trivial (lots of tools already around for it - look at Apache
Fop)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top