Edit Links |
Tips /
Adding an "invisible" tag to a PDFCategories: Tag me << | Page list | >>Description of how you can add an "invisible" tag to your PDF output that is not visible or printable. This page was created by chr based on an post to the LyX users' list by Steve Litt. Motivation for add an "invisible" tagIf you are publishing an E-book in PDF format, you may want to discourage copying. However, you want to avoid obnoxious DRM that disallows printing, degrades the printing or locks it to a specific computer. Here are two things that can be done instead:
So the end purpose is simply to tag the file on the off chance that it is later desirable to match it against a sold file. How to add an invisible tag to a PDF fileThe tag will be added as a metadata property with a key and
value by using How to read the tag from a PDF fileYou can use DetailsHere's how it's done, assuming you want to tweak org.pdf so it includes metadata MYKEY=MYVALUE in the output PDF, tweaked.pdf: pdftk org.pdf dump_data output mymetadata.txt echo InfoKey: MYKEY >> mymetadata.txt echo InfoValue: MYVALUE >> mymetadata.txt pdftk org.pdf update_info mymetadata.txt output tweaked.pdf You've now put metadata key MYKEY with value MYVALUE into tweaked.pdf. You can quickly pull that data out with my check_pdf.sh script: ./check_pdf.sh tweaked.pdf MYKEY Here's the (bash script) code for #!/bin/bash cat $1 | grep -a "$2" | sed -e "s/.*$2\s*//" | \ format_pdf_metadata_value.exe The program Here is the C source code for #include <stdio.h> int main() { int ord = getchar(); int count = 0; /* GO TO OPENING PAREN */ for(; ord != '(' && count < 20; count++, ord=getchar()); if(count >= 20) /* magic number, much bigger than needed */ { fprintf(stderr, "Value not found\n"); return 1; } /* GO PAST OPENING PAREN */ for(; ord == '('; ord=getchar()); /* BLOW OFF LEADING NONPRINTABLES */ for(;((ord < 0) || (ord > 127)); ord = getchar()); /* PRINT UP TO BUT NOT INCLUDING CLOSING PAREN */ /* DO NOT PRINT ALL THE NULL BYTES */ for(; ord != ')'; ord = getchar()) if(ord != 0) putchar(ord); return 0; } Contributors
|