Files
dwroller/scripts/dump-pdf-pages.js
Alex caf8a03553 feat: Add scripts for upserting and validating bestiary data
- Implemented `upsert-allewis-from-5001.js` to fetch and update Allewis data from API.
- Created `upsert-missing-movement-from-5001.js` to fill missing movement and wounds data from API.
- Developed `upsert-missing-movement-from-pdfs.js` to extract movement and wounds from PDF text.
- Added `upsert-missing-profiles-from-pdfs.js` to fill missing profiles from PDF data.
- Introduced `upsert-missing-wounds-from-pdfs.js` to update wounds data from PDF sources.
- Created `validate-bestiary.js` to validate the structure of the bestiary JSON.
- Updated `BestiaryTab.jsx` component to display bestiary data with improved structure and search functionality.
- Added tests for `BestiaryTab` to ensure proper rendering and functionality.
2025-08-17 16:21:00 +02:00

25 lines
924 B
JavaScript

const fs = require('fs');
const path = require('path');
const pdfjs = require('pdfjs-dist/legacy/build/pdf.js');
(async ()=>{
const pdfPath = path.resolve(__dirname, '../data/Deathwatch - The Emperor Protects.pdf');
if (!fs.existsSync(pdfPath)) { console.error('PDF not found at', pdfPath); process.exit(2); }
const data = new Uint8Array(fs.readFileSync(pdfPath));
const loadingTask = pdfjs.getDocument({data});
const doc = await loadingTask.promise;
const pages = [88,89];
for (const pnum of pages){
try{
const page = await doc.getPage(pnum);
const content = await page.getTextContent();
const text = content.items.map(i=>i.str).join(' ');
console.log('----- PAGE', pnum, 'START -----');
console.log(text);
console.log('----- PAGE', pnum, 'END -----\n');
}catch(err){
console.error('error reading page', pnum, err.message);
}
}
process.exit(0);
})();