This commit is contained in:
0m.ax 2026-08-22 15:33:55 +02:00
commit 74718f7fb5
7 changed files with 1176 additions and 0 deletions

46
flake.nix Normal file
View file

@ -0,0 +1,46 @@
{
description = "Tooling for turning datasheet PDFs into text";
inputs.nixpkgs.url =
"github:NixOS/nixpkgs/a50de1b7d8a586adc18d2395c19de7d6058e6030";
outputs = { self, nixpkgs }:
let
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f:
nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
in
{
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
name = "datasheet-to-text";
packages = with pkgs; [
# Split / merge / inspect PDFs losslessly.
# qpdf --split-pages=1 in.pdf out-%d.pdf
# qpdf in.pdf --pages . 12-34 -- out.pdf
qpdf
# pdfseparate, pdfunite, pdftotext, pdfinfo, pdfimages, pdftoppm
poppler-utils
# mutool: draw/extract/convert, good structured text output
# mutool draw -F text -o out.txt in.pdf 12-34
mupdf
# Crop/trim rendered pages down to individual figures.
# magick in.png -crop WxH+X+Y +repage out.png
imagemagick
# Runs tools/extract-figures.py (stdlib only).
python3
];
shellHook = ''
echo "datasheet-to-text shell"
echo " qpdf $(qpdf --version | head -1 | grep -o '[0-9.]*$') pdftotext mutool magick python3"
'';
};
});
};
}