const AdmZip = require('adm-zip'); const zip = new AdmZip('C:\\Users\\15850\\Downloads\\DOP生产管理用户操作手册.docx'); // Read styles.xml to understand style definitions const stylesXml = zip.readAsText('word/styles.xml'); const styleIds = []; const styleIdRegex = /]*w:styleId="([^"]+)"[^>]*>/g; let sm; while ((sm = styleIdRegex.exec(stylesXml)) !== null) { styleIds.push(sm[1]); } console.log('=== Style IDs ==='); console.log(styleIds.join(', ')); // Read document.xml const xml = zip.readAsText('word/document.xml'); // Extract all text const allText = []; const textRegex = /]*>([^<]*)<\/w:t>/g; let tm; while ((tm = textRegex.exec(xml)) !== null) { if (tm[1].trim()) allText.push(tm[1]); } console.log('\n=== All text (first 150) ==='); console.log(allText.slice(0, 150).join(' | ')); console.log('\n=== All text (total ' + allText.length + ' segments) ==='); console.log(allText.join('\n')); // Find paragraph styles used const paraStyles = []; const pStyleRegex = //g) || []).length; console.log('\n=== Table count: ' + tableCount + ' ==='); // Count images const imageCount = (xml.match(//g) || []).length; console.log('=== Image count: ' + imageCount + ' ===');