Attached is a patch that allows the execute method in
RemoveLaunchApplication to properly handle PRIndirectReference
objects.  I was getting ClassCastExceptions.

On 10/5/05, Bruno Lowagie <[EMAIL PROTECTED]> wrote:
> Mark wrote:
> > Is there a way to combat embedded commands is PDF files with iText?
> > Here is a CERT advisory to describe what I would like to fix.
>
> I wrote a new plug-in that looks for Launch Actions and replaces them
> with a JavaScript action. It is called RemoveLaunchApplication. You can
> get it from CVS in package com.lowagie.tools.plugins. Please download
> it, test it and let me know if it solves your problem.
> br,
> Bruno
>
Index: RemoveLaunchApplication.java
===================================================================
RCS file: 
/cvsroot/itext/src/com/lowagie/tools/plugins/RemoveLaunchApplication.java,v
retrieving revision 1.1
diff -r1.1 RemoveLaunchApplication.java
56a57
> import com.lowagie.text.pdf.PRIndirectReference;
126,140c127,153
<                       l = (PdfDictionary)d.get(PdfName.A);
<                       if (l == null) continue;
<                       n = (PdfName)l.get(PdfName.S);
<                       if (PdfName.LAUNCH.equals(n)) {
<                               if (l.get(PdfName.F) != null) {
<                                       System.out.println("Removed: " + 
l.get(PdfName.F));
<                                       l.remove(PdfName.F);
<                               }
<                               if (l.get(PdfName.WIN) != null) {
<                                       System.out.println("Removed: " + 
l.get(PdfName.WIN));
<                                       l.remove(PdfName.WIN);
<                               }
<                               l.put(PdfName.S, PdfName.JAVASCRIPT);
<                               l.put(PdfName.JS, new 
PdfString("app.alert('Launch Application Action removed by iText');\r"));
<                       }
---
>             
>             PdfObject obj = d.get(PdfName.A);
>             if( obj instanceof PdfDictionary )
>             {
>                       l = (PdfDictionary)d.get(PdfName.A);
>                       if (l == null) continue;
>                       n = (PdfName)l.get(PdfName.S);
>                       if (PdfName.LAUNCH.equals(n)) {
>                               if (l.get(PdfName.F) != null) {
>                                       System.out.println("Removed: " + 
> l.get(PdfName.F));
>                                       l.remove(PdfName.F);
>                               }
>                               if (l.get(PdfName.WIN) != null) {
>                                       System.out.println("Removed: " + 
> l.get(PdfName.WIN));
>                                       l.remove(PdfName.WIN);
>                               }
>                               l.put(PdfName.S, PdfName.JAVASCRIPT);
>                               l.put(PdfName.JS, new 
> PdfString("app.alert('Launch Application Action removed by iText');\r"));
>                       }
>             }
>             else if( obj instanceof PRIndirectReference )
>             {
>               PRIndirectReference iRef = (PRIndirectReference)obj;
>               if( iRef == null ) continue;
>               
>               System.out.println("Found an indirect object");
>             }

Reply via email to