@@ -5968,5 +5968,43 @@ small scripts as well as for`);
59685968 await loadingTask . destroy ( ) ;
59695969 } ) ;
59705970 } ) ;
5971+
5972+ describe ( "Extract pages and reorganize them" , function ( ) {
5973+ it ( "extract page and check destinations" , async function ( ) {
5974+ let loadingTask = getDocument (
5975+ buildGetDocumentParams ( "tracemonkey.pdf" )
5976+ ) ;
5977+ let pdfDoc = await loadingTask . promise ;
5978+ const data = await pdfDoc . extractPages ( [
5979+ { document : null , includePages : [ 1 , 3 , 5 ] , pageIndices : [ 1 , 2 , 0 ] } ,
5980+ ] ) ;
5981+ await loadingTask . destroy ( ) ;
5982+ loadingTask = getDocument ( data ) ;
5983+ pdfDoc = await loadingTask . promise ;
5984+
5985+ expect ( pdfDoc . numPages ) . toEqual ( 3 ) ;
5986+
5987+ // Page 6 in the original document.
5988+ const firstPage = await pdfDoc . getPage ( 1 ) ;
5989+ let { items : textItems } = await firstPage . getTextContent ( ) ;
5990+ expect (
5991+ mergeText ( textItems ) . includes ( "4. Nested Trace Tree Formation" )
5992+ ) . toBeTrue ( ) ;
5993+
5994+ // Page 2 in the original document.
5995+ const secondPage = await pdfDoc . getPage ( 2 ) ;
5996+ ( { items : textItems } = await secondPage . getTextContent ( ) ) ;
5997+ expect (
5998+ mergeText ( textItems ) . includes ( "2. Overview: Example Tracing Run" )
5999+ ) . toBeTrue ( ) ;
6000+
6001+ // Page 4 in the original document.
6002+ const thirdPage = await pdfDoc . getPage ( 3 ) ;
6003+ ( { items : textItems } = await thirdPage . getTextContent ( ) ) ;
6004+ expect ( mergeText ( textItems ) . includes ( "3. Trace Trees" ) ) . toBeTrue ( ) ;
6005+
6006+ await loadingTask . destroy ( ) ;
6007+ } ) ;
6008+ } ) ;
59716009 } ) ;
59726010} ) ;
0 commit comments