Merge pull request #542 from arturadib/pdfdoc-arg
PDFDoc() now detects argument type
This commit is contained in:
		
						commit
						73e41cba94
					
				
							
								
								
									
										20
									
								
								pdf.js
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								pdf.js
									
									
									
									
									
								
							| @ -201,7 +201,8 @@ var Stream = (function streamStream() { | ||||
|     }, | ||||
|     makeSubStream: function stream_makeSubstream(start, length, dict) { | ||||
|       return new Stream(this.bytes.buffer, start, length, dict); | ||||
|     } | ||||
|     }, | ||||
|     isStream: true | ||||
|   }; | ||||
| 
 | ||||
|   return constructor; | ||||
| @ -3829,8 +3830,21 @@ var Catalog = (function catalogCatalog() { | ||||
| })(); | ||||
| 
 | ||||
| var PDFDoc = (function pdfDoc() { | ||||
|   function constructor(data) { | ||||
|     var stream = new Stream(data); | ||||
|   function constructor(arg, callback) {     | ||||
|     // Stream argument
 | ||||
|     if (typeof arg.isStream !== 'undefined') { | ||||
|       init.call(this, arg); | ||||
|     } | ||||
|     // ArrayBuffer argument
 | ||||
|     else if (typeof arg.byteLength !== 'undefined') { | ||||
|       init.call(this, new Stream(arg)); | ||||
|     } | ||||
|     else { | ||||
|       error('Unknown argument type'); | ||||
|     }     | ||||
|   } | ||||
| 
 | ||||
|   function init(stream){ | ||||
|     assertWellFormed(stream.length > 0, 'stream must have data'); | ||||
|     this.stream = stream; | ||||
|     this.setup(); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user