title: Prevent copy and paste of PDF content - iOS devices
body: <p>Is there a way I could prevent the user from copying the content of a PDF file on iOS devices?</p>
  
  <p>To detail a bit the background of this query, I have an app that is downloading a PDF and displaying it in the browser. The file is provided by a <strong>.NET Core</strong> web api and the client that it's serving the file is developed in <strong>Angular</strong>.</p>
  
  <p>At the API level I am using <strong>iTextSharp</strong> to encrypt and set permissions for it (just printing permission). This works without any issues on desktop, but not on iOS devices.</p>
  
  <p>If anyone could help me, I would be grateful.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>.NET Core encryption method</p>
  
  <pre><code>public byte[] EncryptPdf(byte[] bytes, string encryptionKey)
          {
              using (var ms = new MemoryStream())
              {
                  using (var reader = new PdfReader(bytes))
                  using (var stamper = new PdfStamper(reader, ms))
                  {
                      stamper.SetEncryption(null, Encoding.ASCII.GetBytes(encryptionKey),
                          PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128);
                      stamper.Close();
                  }
                  return ms.ToArray();
              }
          }
  
  </code></pre>
  
  <p>Angular snippet for handling the blob</p>
  
  <pre><code>downloadFile(data: any) {
      var windowUrl = window.URL || (window as any).webkitURL;
      if (navigator.msSaveOrOpenBlob) {
        navigator.msSaveOrOpenBlob(data.body, this.getFileName(data));
        return;
      } else if (navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i)) {
        const url = windowUrl.createObjectURL(data.body);
        window.location.href = url;
        return;
      }
      saveAs(data.body, this.getFileName(data));
    }
  
  </code></pre>