Last active
May 11, 2021 01:28
-
-
Save dwarring/1e4e056d84d6fe125262bba1da1f58fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env raku | |
use PDF::IO::Reader; | |
#| strip non-deterministic data from ps2pdf output. | |
#| Ensure multiple runs produce exactly the same binary output | |
#| see https://www.mail-archive.com/[email protected]/msg763682.html | |
sub MAIN( | |
Str $file-in, #= input PDF | |
Str $file-out = $file-in, #= output PDF (optional) | |
Str :$id = "wôBÚ¦Øå³§\x[9D]¡tõpÍ\x[16]", | |
) { | |
CATCH { | |
when X::PDF { note .message; exit 1; } | |
} | |
my PDF::IO::Reader $reader .= new.open($file-in); | |
given $reader.trailer { | |
.<ID> = [$id, $id]; | |
with .<Info> { | |
.<CreationDate>:delete; | |
.<ModDate>:delete; | |
} | |
with .<Root> { | |
.<Metadata>:delete; | |
} | |
} | |
$reader.save-as($file-out, :rebuild); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment