title: OS X / iOS: How do I create a PDF that can't get printed?
body: <p>I want to create a PDF document, that can't get printed. I am using the Quartz framework for that. This is what I do (shorted):</p>
  
  <pre><code>    PDFDocument *pdfDocument = ...
  
      NSMutableDictionary *options = [[NSMutableDictionary alloc] init];
      [options setValue:@"test-password" forKey:(NSString *)kCGPDFContextUserPassword];
      [options setValue:@0 forKey:(NSString *)kCGPDFContextAllowsPrinting];
  
      [pdfDocument writeToFile:savePath withOptions:options];
  </code></pre>
  
  <p>But I can still print the resulting file with Preview.app without having to type in a password.</p>
  
  <p>If I set a <em>kCGPDFContextOwnerPassword</em>, the document is locked with the password (but not the print function)</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks!</p>
  
  <p><a href="https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGPDFContext/Reference/reference.html" rel="nofollow">CGPDFContext Reference</a></p>