Forum Samples, Tips and Tricks

how to know that two divs on same page of pdf in succession

gaurvisrivastava
Below is my code to display start line and end line of contents.

Query: How to know that, whether end line of first content and start Line of second content are on same page of pdf in succession

<div class="outerdiv">
<div class="wrapper">
<table>
<tbody>
<tr>
<td class="startLine">....</td> //start line of first content
</tr>
</tbody>
</table>
</div>
<div class="wrapper">.....</div>
<div class="endLine"></div> //endline of first content
</div>

<div class="outerdiv">
<div class="wrapper">
<table>
<tbody>
<tr>
<td class="startLine">....</td> //start line of second content
</tr>
</tbody>
</table>
</div>
<div class="wrapper">.........</div>
<div class="endLine"></div> //end line of second content
</div>


//css
<style>

.endLine .startLine{
border-top:1px solid #000;
}
</style>
mikeday
You can use JavaScript to detect if the two boxes ended up on the same page after conversion.
gaurvisrivastava
how can i detect that two boxes ended up on same page. how can make condition of same page?

Edited by gaurvisrivastava

gaurvisrivastava
do you have any JavaScript code snippet that can detect two divs/classes on the same page of pdf

Edited by gaurvisrivastava

mikeday
You can use the box-tracking API.

Here is an example of using it to detect overflow:

https://www.princexml.com/forum/topic/3603/detecting-overflow
gaurvisrivastava
hey mike,

Is there any example of box tracking API for php prince xml.
mikeday
The use of this API all happens within JavaScript, but it could log some output messages for the PHP to check if necessary. What is it you want to do if the boxes are on the same page / different pages?
gaurvisrivastava
yes, i want to detect if boxes are on same / different pages before conversion

Edited by gaurvisrivastava

gaurvisrivastava
how to use JavaScript in php princexml. I have added my JS file by below code

$prince = new Prince('usr/bin/prince');
$prince->addScript(__DIR__ . '/../../public/js/main.js');

Any code written in my JS file is not reflecting in pdf.

Please suggest asap

Edited by gaurvisrivastava

mikeday
Are you seeing any errors in the Prince output log? Does the script work when you run Prince from the command-line?