Added getOperatorList to api.js
This commit is contained in:
		
							parent
							
								
									834c69aa0a
								
							
						
					
					
						commit
						1d00e9d13c
					
				@ -395,6 +395,15 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
 | 
				
			|||||||
 *                      to the callback.
 | 
					 *                      to the callback.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * PDF page operator list.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @typedef {Object} PDFOperatorList
 | 
				
			||||||
 | 
					 * @property {Array} fnArray - Array containing the operator functions.
 | 
				
			||||||
 | 
					 * @property {Array} argsArray - Array containing the arguments of the
 | 
				
			||||||
 | 
					 *                               functions.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Proxy to a PDFPage in the worker thread.
 | 
					 * Proxy to a PDFPage in the worker thread.
 | 
				
			||||||
 * @class
 | 
					 * @class
 | 
				
			||||||
@ -554,6 +563,45 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      return renderTask;
 | 
					      return renderTask;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @return {Promise} A promise resolved with an {@link PDFOperatorList}
 | 
				
			||||||
 | 
					     * object that represents page's operator list.
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    getOperatorList: function PDFPageProxy_getOperatorList() {
 | 
				
			||||||
 | 
					      function operatorListChanged() {
 | 
				
			||||||
 | 
					        if (intentState.operatorList.lastChunk) {
 | 
				
			||||||
 | 
					          intentState.opListReadCapability.resolve(intentState.operatorList);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      var renderingIntent = 'oplist';
 | 
				
			||||||
 | 
					      if (!this.intentStates[renderingIntent]) {
 | 
				
			||||||
 | 
					        this.intentStates[renderingIntent] = {};
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      var intentState = this.intentStates[renderingIntent];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (!intentState.opListReadCapability) {
 | 
				
			||||||
 | 
					        var opListTask = {};
 | 
				
			||||||
 | 
					        opListTask.operatorListChanged = operatorListChanged;
 | 
				
			||||||
 | 
					        intentState.receivingOperatorList = true;
 | 
				
			||||||
 | 
					        intentState.opListReadCapability = createPromiseCapability();
 | 
				
			||||||
 | 
					        intentState.renderTasks = [];
 | 
				
			||||||
 | 
					        intentState.renderTasks.push(opListTask);
 | 
				
			||||||
 | 
					        intentState.operatorList = {
 | 
				
			||||||
 | 
					          fnArray: [],
 | 
				
			||||||
 | 
					          argsArray: [],
 | 
				
			||||||
 | 
					          lastChunk: false
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        this.transport.messageHandler.send('RenderPageRequest', {
 | 
				
			||||||
 | 
					          pageIndex: this.pageIndex,
 | 
				
			||||||
 | 
					          intent: renderingIntent
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      return intentState.opListReadCapability.promise;
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @return {Promise} That is resolved a {@link TextContent}
 | 
					     * @return {Promise} That is resolved a {@link TextContent}
 | 
				
			||||||
     * object that represent the page text content.
 | 
					     * object that represent the page text content.
 | 
				
			||||||
@ -599,7 +647,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
 | 
				
			|||||||
    _startRenderPage: function PDFPageProxy_startRenderPage(transparency,
 | 
					    _startRenderPage: function PDFPageProxy_startRenderPage(transparency,
 | 
				
			||||||
                                                            intent) {
 | 
					                                                            intent) {
 | 
				
			||||||
      var intentState = this.intentStates[intent];
 | 
					      var intentState = this.intentStates[intent];
 | 
				
			||||||
      intentState.displayReadyCapability.resolve(transparency);
 | 
					      // TODO Refactor RenderPageRequest to separate rendering
 | 
				
			||||||
 | 
					      // and operator list logic
 | 
				
			||||||
 | 
					      if (intentState.displayReadyCapability) {
 | 
				
			||||||
 | 
					        intentState.displayReadyCapability.resolve(transparency);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * For internal use only.
 | 
					     * For internal use only.
 | 
				
			||||||
 | 
				
			|||||||
@ -130,10 +130,18 @@ describe('api', function() {
 | 
				
			|||||||
    it('gets ref', function() {
 | 
					    it('gets ref', function() {
 | 
				
			||||||
      expect(page.ref).toEqual({num: 15, gen: 0});
 | 
					      expect(page.ref).toEqual({num: 15, gen: 0});
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('gets operator list', function() {
 | 
				
			||||||
 | 
					      var promise = page.getOperatorList();
 | 
				
			||||||
 | 
					      waitsForPromise(promise, function (oplist) {
 | 
				
			||||||
 | 
					        expect(!!oplist.fnArray).toEqual(true);
 | 
				
			||||||
 | 
					        expect(!!oplist.argsArray).toEqual(true);
 | 
				
			||||||
 | 
					        expect(oplist.lastChunk).toEqual(true);
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
    // TODO rotate
 | 
					    // TODO rotate
 | 
				
			||||||
    // TODO viewport
 | 
					    // TODO viewport
 | 
				
			||||||
    // TODO annotaions
 | 
					    // TODO annotaions
 | 
				
			||||||
    // TOOD text content
 | 
					    // TOOD text content
 | 
				
			||||||
    // TODO operation list
 | 
					 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user