VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Pdf Namespace / PdfTextEncodingObfuscator Class
Members Object Syntax Remarks Example Hierarchy Requirements SeeAlso
In This Topic
    PdfTextEncodingObfuscator Class
    In This Topic
    Obfuscates text encodings in fonts of PDF document.
    Object Model
    PdfTextEncodingObfuscator
    Syntax
    'Declaration
    
    Public Class PdfTextEncodingObfuscator
    
    
    public class PdfTextEncodingObfuscator
    
    
    public __gc class PdfTextEncodingObfuscator
    
    
    public ref class PdfTextEncodingObfuscator
    
    
    Remarks

    Obfuscation of text encoding consists from 2 steps:

    • Unicode codes of symbols are removed from font
    • Font program is changed randomly (glyphs are rearranged; not used glyphs are removed; duplicate glyphs are added; etc).

    Text search and text extraction will be not possible after the text encoding obfuscation - extracted text will contain "garbage". PDF page view will not be changed after obfuscation, i.e. PDF page view before and after obfuscation are the same.

    Current version supports obfuscation of TrueType, Type1 and Type3 fonts.
    A System.NotSupportedException will be thrown whenever an unsupported font is encountered during obfuscation.
    A System.InvalidOperationException will be thrown whenever an external font is encountered during obfuscation.

    Important! - PDF document must be packed (Pack) after text encoding obfuscation otherwise the original encodings can be restored.

    Example

    Here is an example that shows how to obfuscate the encoding of embedded fonts in PDF document:

    
    ''' <summary>
    ''' Obfuscates encoding of all fonts of PDF document.
    ''' </summary>
    ''' <param name="pdfFilename">The filename of PDF document.</param>
    ''' <param name="resultFilename">The filename of resulting PDF document.</param>
    Public Shared Sub ObfuscateEncodingOfAllFonts(pdfFilename As String, resultFilename As String)
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename)
            ' create obfuscator
            Dim textEncodingObfuscator As New Vintasoft.Imaging.Pdf.PdfTextEncodingObfuscator()
            Try
                ' obfuscate all fonts
                textEncodingObfuscator.Obfuscate(document)
                ' pack and save document to new location
                document.Pack(resultFilename)
            Catch ex As System.Exception
                System.Console.WriteLine(ex.Message)
            End Try
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Obfuscates encoding of all fonts of PDF document.
    /// </summary>
    /// <param name="pdfFilename">The filename of PDF document.</param>
    /// <param name="resultFilename">The filename of resulting PDF document.</param>
    public static void ObfuscateEncodingOfAllFonts(string pdfFilename, string resultFilename)
    {
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument(pdfFilename))
        {
            // create obfuscator
            Vintasoft.Imaging.Pdf.PdfTextEncodingObfuscator textEncodingObfuscator = 
                new Vintasoft.Imaging.Pdf.PdfTextEncodingObfuscator();
            try
            {
                // obfuscate all fonts
                textEncodingObfuscator.Obfuscate(document);
                // pack and save document to new location
                document.Pack(resultFilename);
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Pdf.PdfTextEncodingObfuscator

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also