Search code examples
coldfusioncoldfusion-2016

Text based redaction in ColdFusion 2016?


Is there a way for Text based redaction in ColdFusion? I can see the documentation for coordinates based alone. Code used for coordinates based redaction is:

<cfpdf action="redact" source="#sourcefile#" destination="#destinationfile#" overwrite="true">
    <cfpdfparam pages="1-2" coordinates="0,0,0,0">
</cfpdf>

Is there a similar way for text based redaction too?


Solution

  • There is in fact now the option to redact text in ColdFusion. It's not documented as the feature is still work in progress, but it does work for most of the cases. A few new attributes have been added for this support.

    1. The words you want to redact must be given as an array with the attribute name as 'wordstoredact'
    2. There is a new attribute in cfpdfparam namely wordmatchingcriteria with values as:

      • MATCHPARTIALWORD_MARKPARTIALWORD (matches partial words, and also redacts them)
      • MATCHPARTIALWORD_MARKWHOLEWORD (matches partial words, but redacts the whole word)
      • MARKWHOLEWORD (matches and redacts only whole words).

    An example of how to do it is as shown below:

    cfpdf(action="redact", source="#sourcefile#", destination="#destinationfile#", overwrite=true){
        cfpdfparam(wordstoredact=["Windo", "disclaim"], ignorecase=true, pages="1", wordmatchingcriteria="MATCHPARTIALWORD_MARKPARTIALWORD" );
        cfpdfparam(wordstoredact=["http://", "2010"], ignorecase=true, pages="1", wordmatchingcriteria="MATCHPARTIALWORD_MARKWHOLEWORD" );
        cfpdfparam(wordstoredact=["December", "Resources"], ignorecase=true, pages="2", wordmatchingcriteria="MARKWHOLEWORD" );
        cfpdfparam(wordstoredact=["Tutorial", "definitions"], ignorecase=false, pages="3", wordmatchingcriteria="MATCHPARTIALWORD_MARKWHOLEWORD" );
    };
    

    Please reply if you have any confusion or any more queries regarding text based redaction in ColdFusion