On Saturday 08 April 2006 09:07 pm, [EMAIL PROTECTED] wrote:
On Sat, 8 Apr 2006, Steve Litt wrote:

Hi Steve

I think I understand what you're doing, but would you mind explaining why?

best regards
/Christian

PS. Then I could add what you wrote to some wiki page if you'd like, but
only if I can understand the purpose :-)

Hi Steve

For some reason I had a copy of your post left in my folder... I've added some comments to this page

        http://wiki.lyx.org/Tips/AddingInvisibleTagToPDF

So I'm not sure why, maybe I was waiting for some kind of comment from you?

Anyway, the page is there now :-)

/Christian




On Sun, 9 Apr 2006, Steve Litt wrote:
Sure Christian,

I'm publishing an Ebook in PDF format. I want to discourage copying, but don't
want to do obnoxious DRM like not allowing printing, degrading printing, or
locking it to a specific computer.

So I do 2 things:

1) Print the customer's name in a footer at the bottom of the page (which is
why I asked before how to get a footer to print from paper edge to paper
edge). This discourages the customer from giving the PDF to his friends,
because it's his name on the book, and if it "escapes" into the wild, it's
obvious who did it. Now you and I probably know at least 3 ways to get rid of
that name, but your average joe doesn't.

2) In case it escapes into the wild and maybe someone altered the name in the
footer, I want a code inside the pdf that doesn't print. The easiest way I
know to do this is to make the code a metadata property with a key and a
value. The key will be a nonobvious string, and the value will look like
gibberish, but I can scan the PDF for the key, get the value, and relate it
back to my book sales.

So to add a key->value pair, you use the pdftk dump_data to write all metadata
to a text file, then append the new key and value to the text file, then
pdftk update_info to put back all the metadata, including the new key value
pair.

You can then use grep to get the line containing the key and value, and sed to
partially remove garbage, and my the listed C program to strip it down to
nothing but the value so it can be assigned to a variable in a script using
backticks or $(mycommand) syntax.

I hope this helps you understand what I was doing, but if you or anyone else
has any questions, please feel free to ask.

Thanks

SteveT


On Saturday 08 April 2006 03:34 pm, Steve Litt wrote:
Hi all,

Is there a way I can have something in my LyX file (maybe a comment
environment or something), and have it occur in the PDF output without
having it print or be viewable?

If that's not possible, is there a way I can "brand" a PDF with a
number somehow? I have pdftk.

Thanks

SteveT

Here's how it's done, assuming you want to tweak org.pdf so it includes
metadata MYKEY=MYVALUE in the output PDF, tweaked.pdf:

[EMAIL PROTECTED] ~]$ pdftk org.pdf dump_data output mymetadata.txt
[EMAIL PROTECTED] ~]$ echo InfoKey: MYKEY >> mymetadata.txt
[EMAIL PROTECTED] ~]$ echo InfoValue: MYVALUE >> mymetadata.txt
[EMAIL PROTECTED] ~]$ 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:

[EMAIL PROTECTED] ~]$ ./check_pdf.sh tweaked.pdf MYKEY
[EMAIL PROTECTED] ~]$

Here's the (bash script) code for check_pdf.sh, which I put in the public
domain and disclaim all warranty and liability:

#!/bin/bash
cat $1 | grep -a "$2" | sed -e "s/.*$2\s*//" |
format_pdf_metadata_value.exe

format_pdf_metadata_value.exe simply grabs the value from the line
containing the key. It should work under Linux or Windows (or BSD, which
I assume would make it Mac compatible). Here is the C source code for
format_pdf_metadata_value.exe, which I put in the public domain and
disclaim all warranty and liability:

#include <stdio.h>
int main(int argc, char *argv[])
        {
        int ord = getc(stdin);
        int count = 0;

        /* GO TO OPENING PAREN */
        for(; ord != '(' && count < 20; count++, ord=getc(stdin));
        if(count >= 20) /* magic number, much bigger than needed */
                {
                fprintf(stderr, "Value not found\n");
                return(1);
                }

        /* GO PAST OPENING PAREN */
        for(; ord == '('; ord=getc(stdin));

        /* BLOW OFF LEADING NONPRINTABLES */
        for(;((ord < 0) || (ord > 127)); ord = getc(stdin));

        /* PRINT UP TO BUT NOT INCLUDING CLOSING PAREN */
        /* DO NOT PRINT ALL THE NULL BYTES */
        for(; ord != ')'; ord = getc(stdin))
                if(ord != 0)
                        putc(ord, stdout);
        return 0;
        }



--
Christian Ridderström, +46-8-768 39 44               http://www.md.kth.se/~chr

Reply via email to