PDF security

185 views
Skip to first unread message

sagar priyadarshi

unread,
Mar 11, 2011, 7:37:31 AM3/11/11
to JODConverter
Hi

Can JODconverter be used to create secured pdf? ex: password protected pdf

Since direct conversion of any format to pdf using openoffice gives option  of creating password protected pdf.
How to implement other  security parameter to generated pdf ( for ex: disable "save " /"save a copy" option,etc..)

Any suggestions is highly appreciated.

thanks
Sagar Priyadarshi


pratap komaravolu

unread,
Mar 11, 2011, 8:49:20 AM3/11/11
to jodcon...@googlegroups.com
Yes you can do it.

Pratap Rudra



--
You received this message because you are subscribed to the Google Groups "JODConverter" group.
To post to this group, send email to jodcon...@googlegroups.com.
To unsubscribe from this group, send email to jodconverter...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jodconverter?hl=en.

sagar priyadarshi

unread,
Mar 11, 2011, 9:06:35 AM3/11/11
to jodcon...@googlegroups.com
Thanks Pratap

I tried and I am able to  generate password protected pdf.
My purpose was to convert any format to jpeg format. So i was doing it in two steps
1. any format to pdf using JOD
2. Pdf to jpeg using imagemagick or ghostscript.

but second step is still not 100 % successful. I am sometime getting jpeg and many a times not.

So finally i thought to let my work till pdf only and making it password protected and disabling other options as "save pdf" etc. My ultimate aim is that pdf is viewable to user and user is unable to save it.
--
Sagar Priyadarshi


pratap komaravolu

unread,
Mar 11, 2011, 9:19:46 AM3/11/11
to jodcon...@googlegroups.com
Did you try swftools.

Pratap Rudra

sagar priyadarshi

unread,
Mar 11, 2011, 11:16:15 AM3/11/11
to jodcon...@googlegroups.com
Surprising error:

i tried running following code

        OpenOfficeConnection OpenOfficeConnection = new SocketOpenOfficeConnection(8100);
        OpenOfficeConnection.connect();
        File inputFile = new File("/user/spp/Desktop/PLM_Customization.ppt");
        File outputFile = new File("/user/spp/Desktop/plmreport.pdf");
        DocumentConverter DocToPDFConverter = new OpenOfficeDocumentConverter(OpenOfficeConnection);
        DocumentFormat customPdfFormat =
                new DocumentFormat("Portable Document Format", "application/pdf", "pdf");
        customPdfFormat.setExportFilter(DocumentFamily.TEXT, "writer_pdf_Export");


        Map pdfOptions = new HashMap();
        pdfOptions.put("EncryptFile", Boolean.TRUE);
        pdfOptions.put("DocumentOpenPassword", "mdslv");
        pdfOptions.put("EnableCopyingOfContent", Boolean.FALSE);
        pdfOptions.put("ResizeWindowToInitialPage",Boolean.TRUE);
       pdfOptions.put("HideViewerMenubar",Boolean.TRUE);
       pdfOptions.put("PermissionPassword","sagar");
        pdfOptions.put("HideViewerToolbar",Boolean.TRUE);
        pdfOptions.put("HideViewerWindowControls",Boolean.TRUE);
        customPdfFormat.setExportOption(DocumentFamily.TEXT, "FilterData", pdfOptions);
       
        DocToPDFConverter.convert(inputFile, outputFile,customPdfFormat);

        OpenOfficeConnection.disconnect();




and below is the error I am getting:

Exception in thread "main" java.lang.IllegalArgumentException: unsupported conversion: from Microsoft PowerPoint to Portable Document Format
        at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:102)
        at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:74)


Any idea?

Rudolf Schmidt

unread,
Mar 13, 2011, 3:19:05 PM3/13/11
to jodcon...@googlegroups.com
Hi Sagar,

why don't you use Apache's PDFBox? I use JODConverter to convert my documents and PDFBox to encrypt them - follow this link to read more.

After reading the PDF Reference, though, the applied permissions (such as disallowing to save the document) is up to the PDF Reader only. So, in the end it does not provide certain security to the document.

At the moment, I am looking for a way to forgery protect my documents, which is going rather not so very successful ;-( If anyone has any experience with it I'd appreciate the help :-)

Best,
Rudi

Richard Gathogo

unread,
Mar 13, 2011, 3:23:29 PM3/13/11
to jodcon...@googlegroups.com
Hi Rud,
Have you tried the pdf Overlay offered by pdf box. I think it is a great feature. You can have like a watermark or something to identify you documents in one document. Then apply that to all the pages in you document.
Regards Richard Gathogo.

--
You received this message because you are subscribed to the Google Groups "JODConverter" group.
To post to this group, send email to jodcon...@googlegroups.com.
To unsubscribe from this group, send email to jodconverter...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jodconverter?hl=en.



--
+4521843194
Java Developer,
Skype: muraguri2005


Rudolf Schmidt

unread,
Mar 13, 2011, 4:16:42 PM3/13/11
to JODConverter
Hi Richard,

thanks for the hint! Is it possible to revalidate the document
afterwards again? I mean, when applying the overlay... are the two
documents merged into one or can the overlays be "read out" again
separately?

I have the requirement to check the document for it's authenticity.
Basically, when sending out PDF's we need to make sure nobody has
modified them. However, in the case of modification we need to be able
to tell the difference. I am just starting with this so every help is
much appreciated.

Best,
Rudi

On Mar 13, 8:23 pm, Richard Gathogo <muraguri2...@gmail.com> wrote:
> Hi Rud,
> Have you tried the pdf Overlay offered by pdf box. I think it is a great
> feature. You can have like a watermark or something to identify you
> documents in one document. Then apply that to all the pages in you document.
>
> Regards Richard Gathogo.
>
> On Sun, Mar 13, 2011 at 8:19 PM, Rudolf Schmidt
> <rud.schm...@googlemail.com>wrote:
>
>
>
> > Hi Sagar,
>
> > why don't you use Apache's PDFBox <http://pdfbox.apache.org/index.html>? I
> > use JODConverter to convert my documents and PDFBox to encrypt them - follow
> > this link <http://pdfbox.apache.org/commandlineutilities/Encrypt.html> to
> > read more.
>
> > After reading the PDF Reference, though, the applied permissions (such as
> > disallowing to save the document) is up to the PDF Reader only. So, in the
> > end it does not provide certain security to the document.
>
> > At the moment, I am looking for a way to forgery protect my documents,
> > which is going rather not so very successful ;-( If anyone has any
> > experience with it I'd appreciate the help :-)
>
> > Best,
> > Rudi
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "JODConverter" group.
> > To post to this group, send email to jodcon...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > jodconverter...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/jodconverter?hl=en.
>
> --
>
> *+254752847158*
> ***+4521843194
> ** Java Developer*,* *
> * Skype: muraguri2005*

Richard Gathogo

unread,
Mar 13, 2011, 4:43:08 PM3/13/11
to jodcon...@googlegroups.com
Hi Rudi,
That is interesting. Pdfbox is can be used in two ways to create the overlay. One is a command line utility like "java org.apache.pdfbox.Overlay overlay.pdf document.pdf result.pdf". In this you create a new file. Else you can use in Java program, where you use the method Overlay.overlay(PDDocument overlay, PDDocument destination); Where the PDDocuments are just the in memory representation of both the overlay pdf and destination pdf. It returns an in memory representation of the destination pdf. I am not sure about reading them out again. It might not be directly be implemented by pdfbox but there should be away out.
I have also not used all the classes and methods within pdfbox, but I will tell you more once I get an idea.
Regards Richard Gathogo.

Alex Vb

unread,
Mar 14, 2011, 3:42:34 AM3/14/11
to jodcon...@googlegroups.com
Just random thought: you could add an encrypted hash to the pdf. Maybe as a footer or something. Or for pure awesomeness: convert the encrypted hash into an image and use that as a watermark.

Rudolf Schmidt

unread,
Mar 14, 2011, 6:22:56 AM3/14/11
to JODConverter
@Richard:
I've been experimenting with the Overlay stuff in PDFBox and it seems
to be working fairly well. I'm using the command line to do so,
because the project I am working on is not in Java. I think it is even
possible to Stamp the PDF which is more like watermarking, but that
requires being able to program in java :-S

@Alex:
You've got a point there, but this approach means that someone can
alter the beginning of the document and the encrypted hash at the end
of the document will revalidate anyway. For this, something more into
the direction of steganography is what I'm looking for, e.g. hiding a
message across the document. Like so, if someone changes the contents,
the hidden message will be broken and we're able to proof someone
tempered with the PDF. I don't know if there are any libraries for
that. I keep looking and will let you know.

Regards,
Rudi
On Mar 14, 8:42 am, Alex Vb <i8c.a...@gmail.com> wrote:
> Just random thought: you could add an encrypted hash to the pdf. Maybe as a
> footer or something. Or for pure awesomeness: convert the encrypted hash
> into an image and use that as a watermark.
>
> On 13 March 2011 21:43, Richard Gathogo <muraguri2...@gmail.com> wrote:
>
>
>
> > Hi Rudi,
> > That is interesting. Pdfbox is can be used in two ways to create the
> > overlay. One is a command line utility like "*java
> > org.apache.pdfbox.Overlay overlay.pdf document.pdf result.pdf*". In this

Alex Vb

unread,
Mar 14, 2011, 9:13:30 AM3/14/11
to jodcon...@googlegroups.com
You have two options really:
- hash the pdf and store the hash in a table so you can look it up later. Altering the pdf will generate a different hash which will not be valid when compared to the database. The problem is that you have to keep track of which pdf is linked to which hash.
- hash the pdf and encrypt the hash with your private key, then put the encrypted hash in the pdf. If the pdf is altered they can rehash it, but they can not properly encrypt the hash, as such the pdf can not be altered without you knowing about it. As a bonus everyone who has your public key can check that the pdf hasn't altered since you created it.

Disclaimer: I know practically nothing about the PDF format, there may be PDF-specific ways of doing this stuff.
Reply all
Reply to author
Forward
0 new messages