8 Replies Latest reply on Sep 30, 2015 2:37 AM by evan71922978

    Security for PDF

    evan71922978

      Hi !

       

      I want to ad a security for the PDF I creat with my Export script.

       

      You can open the PDF, print it, put no edit it with InDesign or Illustrator etc...

       

      Can you help me please ?

       

      Thank you

        • 1. Re: Security for PDF
          Trevorׅ Adobe Community Professional

          See here and search for the word security

          Adobe InDesign CS5 (7.0) Object Model JS: PDFExportPreference

          • 2. Re: Security for PDF
            evan71922978 Level 1

            I've try to use it... but whitout succed :/

             

            Can you tell me how to use it correctly ?

             

            Thank you

            • 3. Re: Security for PDF
              Ronald63 Level 4

              Try this ...

              var myPDF = new File('~/desktop/foo3.pdf');
              
              with (app.pdfExportPreferences)
              {
                  pageRange = PageRange.ALL_PAGES;
                  useSecurity = true;
                  disallowChanging = true;
                  disallowCopying = true
                  disallowDocumentAssembly = true;
                  disallowExtractionForAccessibility = true;
                  disallowFormFillIn = true;
                  disallowHiResPrinting = true;
                  disallowNotes = true;
                  disallowPlaintextMetadata = true;
                  disallowPrinting = false;
              }
              app.activeDocument.exportFile(ExportFormat.pdfType, myPDF, false);
              
              
              
              • 4. Re: Security for PDF
                evan71922978 Level 1

                Where i place it ?

                • 5. Re: Security for PDF
                  Ronald63 Level 4

                  Look the snippet ...

                   

                  1°) change PDF Export preferences

                  2°) export PDF

                  • 6. Re: Security for PDF
                    evan71922978 Level 1

                    Hi, now it's different, I want to put this same option but, only when the computeur is not connected to my serveur.

                     

                    So, when you are in the serveur, you can do what you want with the PDF, ans when you're not, you can juste open, copy and print it.

                     

                    It's urgent, help me please

                     

                    Thank you

                     

                    That's my actual code :


                     

                    app.activeDocument.dataMergeProperties.mergeRecords();    

                    var myDocument = app.activeDocument;   

                     

                    main();   

                    function main(){   

                    exportPDF();   

                     

                    function exportPDF(){ 

                     

                    var myPageName, myFilePath, myFile;  

                     

                    var myPDFExportPreset = app.pdfExportPresets.item("[Qualité supérieure]"); 

                     

                    for(var myCounter = 0; myCounter < myDocument.pages.length; myCounter++){    

                     

                    myPageName = myDocument.pages.item(myCounter).name;  

                    app.pdfExportPreferences.pageRange = myPageName;  

                     

                    var myRegExp = /:/gi; 

                     

                    myPageName = myPageName.replace(myRegExp, "_");   

                    myFilePath = "//TE-srv/hrx/02_JUY_CDSC" + "/" + extractPAFname(myCounter) + ".pdf";   

                    myFile = new File(myFilePath);   

                    if(!myFile.exists){ 

                    myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFExportPreset); 

                     

                    }else{ 

                    var mConfirm= confirm ('Le document ' + extractPAFname(myCounter) + ' existe déjà, voulez-vous le remplacer ?', 'Document existant'); 

                    if (mConfirm){ 

                    myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFExportPreset); 

                         } 

                              }  

                                   } 

                     

                    function extractPAFname(AllPages){ 

                    var myStyle = myDocument.paragraphStyles.itemByName('nom_fichier');    

                     

                    if (myStyle.isValid){ 

                    app.findGrepPreferences = app.changeGrepPreferences = null;  

                    app.findGrepPreferences.appliedParagraphStyle = myStyle;

                     

                    var mySearch = myDocument.findGrep(); 

                     

                    if (mySearch.length >0){  

                    return mySearch[AllPages].contents  

                     

                    }else { 

                    alert('Erreur - Pas de texte'); 

                    exit();    

                    }    

                     

                    }else { 

                    alert('Erreur - Pas de style'); 

                    exit(); 

                    }  

                         } 

                    • 7. Re: Security for PDF
                      [Jongware] Most Valuable Participant

                      So, when you are in the serveur, you can do what you want with the PDF, ans when you're not, you can juste open, copy and print it.

                       

                      That's not how the PDF security options work. They are stored inside the file, and it does not matter where the file is stored.

                      • 8. Re: Security for PDF
                        evan71922978 Level 1

                        I think I don't used the correct word sorry

                         

                        It's not possible to protect the file when an user outside the network use it, if this user is not in the network, I can just open, copy and print it.

                         

                        That's possible ?

                         

                        Thank you