php - How to get the X and Y axis of a string or a paragraph from a PDF file? -
i making module system called vtiger crm, system have module installed called pdfmaker allows me make pdf files using html, pdfmaker allows me create custom function insert in template.
i have custom function, puts string called signature in html template.
what need find x , y axis of string after has been converted pdf file due dimension changing when gets converted html template pdf file.
what tried using .position function jquery, problem is, works html file, doesn't work pdf file, makes sense.
now wondering how can find x , y axis paragraph or string in pdf file.
the pdf files created example invoices, quotes , things that, a4 paper format, may vary.
this custom function @ moment:
<?php if(!function_exists('signature')){ function signature($string = 'signature'){ $xaxis = '<script> $(function(){ var p = $("#signature"); var position = p.position(); document.write(position.left); }); </script>'; $yaxis = '<script> $(function(){ var p = $("#signature"); var position = p.position(); document.write(position.top); }); </script>'; return $xaxis . ' ' . $yaxis; } } ?> it not return pdf file.
you have calculate it. first have find out how many pixels there used in pdf. (depending on dpi of pdf).
let's call pdf_width (x) , pdf_height (y)
second need find maximum used width of template. saw template get's it's width reduced fit on page. can find out, getting position.right of element far right possible. let's call max_template_x.
now wee need length of signature text:
var length = p.position().right - p.position().left; then real position on template:
if (p.position().right > max_template_x) { posx = max_template_x - length} then multiply template pdf quota:
posx = posx * (pdf_width / template_max_x) now have x.
for y have same, pagebrake , depending of amount of text put above signature.
Comments
Post a Comment