@@ -7501,6 +7501,32 @@ small scripts as well as for`);
75017501 return fontIndex < 0 ? null : operatorList . argsArray [ fontIndex ] [ 0 ] ;
75027502 } ;
75037503
7504+ it ( "rebuilds a missing AcroForm Fields array" , async function ( ) {
7505+ const data = assemblePdf ( [
7506+ "1 0 obj\n<< /Type /Catalog /Pages 2 0 R /AcroForm 6 0 R >>\nendobj\n" ,
7507+ "2 0 obj\n<< /Type /Pages /Kids [3 0 R] /Count 1 >>\nendobj\n" ,
7508+ "3 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 100 100] " +
7509+ "/Annots [4 0 R] >>\nendobj\n" ,
7510+ "4 0 obj\n<< /Type /Annot /Subtype /Widget /Rect [0 0 20 10] " +
7511+ "/Parent 5 0 R >>\nendobj\n" ,
7512+ "5 0 obj\n<< /FT /Tx /T (group) /Kids [4 0 R] >>\nendobj\n" ,
7513+ "6 0 obj\n<< /DA (/Helv 10 Tf) >>\nendobj\n" ,
7514+ ] ) ;
7515+
7516+ let loadingTask = getDocument ( { data } ) ;
7517+ let pdfDoc = await loadingTask . promise ;
7518+ const extracted = await pdfDoc . extractPages ( [ { document : null } ] ) ;
7519+ expect ( extracted ) . not . toBeNull ( ) ;
7520+ await loadingTask . destroy ( ) ;
7521+
7522+ loadingTask = getDocument ( { data : extracted } ) ;
7523+ pdfDoc = await loadingTask . promise ;
7524+ expect ( Object . keys ( await pdfDoc . getFieldObjects ( ) ) ) . toEqual ( [ "group" ] ) ;
7525+ const annotations = await ( await pdfDoc . getPage ( 1 ) ) . getAnnotations ( ) ;
7526+ expect ( annotations [ 0 ] . fieldName ) . toEqual ( "group" ) ;
7527+ await loadingTask . destroy ( ) ;
7528+ } ) ;
7529+
75047530 it ( "extract page 2 and check AcroForm Fields T entries" , async function ( ) {
75057531 let loadingTask = getDocument (
75067532 buildGetDocumentParams ( "form_two_pages.pdf" )
0 commit comments