Skip to content

Instantly share code, notes, and snippets.

@yurydelendik
Created October 22, 2012 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yurydelendik/3934952 to your computer and use it in GitHub Desktop.
Save yurydelendik/3934952 to your computer and use it in GitHub Desktop.
fix annotations
diff --git a/web/viewer.js b/web/viewer.js
index d1ed8d3..217ff85 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -1801,16 +1801,17 @@ var PageView = function pageView(container, pdfPage, id, scale,
element.style.height = Math.ceil(rect[3] - rect[1]) + 'px';
return element;
}
- function createCommentAnnotation(type, item) {
+ function createTextAnnotation(item) {
var container = document.createElement('section');
container.className = 'annotComment';
var image = createElementWithStyle('img', item);
- var type = item.type;
+ var iconName = item.name;
var rect = viewport.convertToViewportRectangle(item.rect);
rect = PDFJS.Util.normalizeRect(rect);
- image.src = kImageDirectory + 'annotation-' + type.toLowerCase() + '.svg';
- image.alt = mozL10n.get('text_annotation_type', {type: type},
+ image.src = kImageDirectory + 'annotation-' + iconName.toLowerCase() +
+ '.svg';
+ image.alt = mozL10n.get('text_annotation_type', {type: iconName},
'[{{type}} Annotation]');
var content = document.createElement('div');
content.setAttribute('hidden', true);
@@ -1861,9 +1862,9 @@ var PageView = function pageView(container, pdfPage, id, scale,
div.appendChild(link);
break;
case 'Text':
- var comment = createCommentAnnotation(item.name, item);
- if (comment)
- div.appendChild(comment);
+ var textAnnotation = createTextAnnotation(item);
+ if (textAnnotation)
+ div.appendChild(textAnnotation);
break;
case 'Widget':
// TODO: support forms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment