@@ -133,16 +133,16 @@ export function useViewer (container: Ref<HTMLDivElement>, viewer: Ref<HTMLDivEl
133
133
const annotations = await page . getAnnotations ( ) as PDFJSAnnotation [ ]
134
134
135
135
for ( const data of annotations ) {
136
- if ( data . noHTML && ! source . annotationLayer . annotationStorage . has ( data . id ) ) {
136
+ if ( data . annotationType === 20 /* Widget */ && data . fieldType === 'Sig' && ! source . annotationLayer . annotationStorage . has ( data . id ) ) {
137
137
const {
138
138
pageWidth,
139
139
pageHeight,
140
140
pageX,
141
141
pageY,
142
142
} = source . viewport . rawDims as PDFJSRawDimension
143
143
144
- const width = ( data . rotation % 180 === 0 ) ? data . rect [ 2 ] - data . rect [ 0 ] : data . rect [ 3 ] - data . rect [ 1 ]
145
- const height = ( data . rotation % 180 === 0 ) ? data . rect [ 3 ] - data . rect [ 1 ] : data . rect [ 2 ] - data . rect [ 0 ]
144
+ const width = data . rect [ 2 ] - data . rect [ 0 ]
145
+ const height = data . rect [ 3 ] - data . rect [ 1 ]
146
146
147
147
const rect = normalizeRect ( [
148
148
data . rect [ 0 ] ,
@@ -151,14 +151,26 @@ export function useViewer (container: Ref<HTMLDivElement>, viewer: Ref<HTMLDivEl
151
151
page . view [ 3 ] - data . rect [ 3 ] + page . view [ 1 ] ,
152
152
] )
153
153
154
- const div = document . createElement ( 'div' )
155
-
156
- div . classList . add ( 'annotationWidget' , data . subtype , data . fieldType )
157
-
158
- div . style . left = `${ ( 100 * ( rect [ 0 ] - pageX ) ) / pageWidth } %`
159
- div . style . top = `${ ( 100 * ( rect [ 1 ] - pageY ) ) / pageHeight } %`
160
- div . style . width = `${ ( 100 * width ) / pageWidth } %`
161
- div . style . height = `${ ( 100 * height ) / pageHeight } %`
154
+ const div = document . createElement ( 'section' )
155
+
156
+ div . dataset . annotationId = data . id
157
+ div . tabIndex = 1000
158
+ div . className = 'signatureWidgetAnnotation'
159
+ div . role = 'img'
160
+ div . id = `pdfjs_internal_id_${ data . id } `
161
+ div . style . zIndex = '0'
162
+ div . style . left = `${ ( 100 * ( rect [ 0 ] - pageX ) ) / pageWidth } %`
163
+ div . style . top = `${ ( 100 * ( rect [ 1 ] - pageY ) ) / pageHeight } %`
164
+
165
+ if ( data . rotation === 0 ) {
166
+ div . style . width = `${ ( 100 * width ) / pageWidth } %`
167
+ div . style . height = `${ ( 100 * height ) / pageHeight } %`
168
+ } else {
169
+ div . style . width = `${ ( 100 * height ) / pageWidth } %`
170
+ div . style . height = `${ ( 100 * width ) / pageHeight } %`
171
+
172
+ div . dataset . mainRotation = `${ ( 360 - data . rotation ) % 360 } `
173
+ }
162
174
163
175
source . annotationLayer . div . append ( div )
164
176
source . annotationLayer . annotationStorage . setValue ( data . id , { div } )
0 commit comments