All files / hummus-toc/src createLink.js

100% Statements 21/21
100% Branches 0/0
100% Functions 1/1
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 361x 1x 1x   1x                 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x   1x   1x    
module.exports = (objCtx, pageRef, [x1, y1, x2, y2]) => {
  const annotationObj = objCtx.startNewIndirectObject()
  const dictionaryContext = objCtx.startDictionary()
 
  dictionaryContext
    .writeKey('Type')
    .writeNameValue('Annot')
    .writeKey('Subtype')
    .writeNameValue('Link')
    .writeKey('Rect')
    .writeRectangleValue([x1, y1, x2, y2])
    .writeKey('Dest')
 
  objCtx.startArray()
  objCtx.writeIndirectObjectReference(pageRef)
  objCtx.writeName('XYZ')
  const c = objCtx.startFreeContext()
  c.write([ 32, 110, 117, 108, 108, 32, 110, 117, 108, 108, 32, 48, 32 ]/*" null null 0 "*/)
  objCtx.endFreeContext()
  objCtx.endArray()
  objCtx.endLine()
 
  // remove annoying default border
  dictionaryContext.writeKey('Border')
  objCtx.startArray()
	objCtx.writeNumber(0)
  objCtx.writeNumber(0)
  objCtx.writeNumber(0)
	objCtx.endArray()
  objCtx.endLine()
 
  objCtx.endDictionary(dictionaryContext).endIndirectObject()
 
  return annotationObj
}