Browse Source

Text alignment inside input controls

notmasteryet 14 years ago
parent
commit
3d36a05d7f
  1. 1
      src/core.js
  2. 13
      web/viewer.js

1
src/core.js

@ -340,6 +340,7 @@ var Page = (function pagePage() {
var m = /([\d\.]+)\sTf/.exec(da); var m = /([\d\.]+)\sTf/.exec(da);
if (m) if (m)
item.fontSize = parseFloat(m[1]); item.fontSize = parseFloat(m[1]);
item.textAlignment = annotation.get('Q');
item.flags = annotation.get('Ff') || 0; item.flags = annotation.get('Ff') || 0;
break; break;
} }

13
web/viewer.js

@ -398,7 +398,18 @@ var PageView = function pageView(container, content, id, pageWidth, pageHeight,
function assignFontStyle(element, item) { function assignFontStyle(element, item) {
var fontStyles = ''; var fontStyles = '';
if ('fontSize' in item) if ('fontSize' in item)
fontStyles += 'font-size: ' + Math.round(item.fontSize * scale) + 'px'; fontStyles += 'font-size: ' + Math.round(item.fontSize * scale) + 'px;';
switch (item.textAlignment) {
case 0:
fontStyles += 'text-align: left;';
break;
case 1:
fontStyles += 'text-align: center;';
break;
case 2:
fontStyles += 'text-align: right;';
break;
}
element.setAttribute('style', element.getAttribute('style') + fontStyles); element.setAttribute('style', element.getAttribute('style') + fontStyles);
} }

Loading…
Cancel
Save