回答編集履歴
2
誤りの訂正
    
        answer	
    CHANGED
    
    | @@ -1,2 +1,31 @@ | |
| 1 1 | 
             
            PDFのパスワードを設定するということですか?[ Spire.PDF for Android via Java](https://www.e-iceblue.com/Introduce/pdf-for-android-via-java.html#.ZHa8_u9ByUk) を試してみませんか。 これは、Adobe Acrobatやその他のサードパーティ製ライブラリを使用せずに、PDFドキュメントの作成、読み取り、操作、変換をサポートしています。
         | 
| 2 | 
            +
            サンプルコードを次に示します。
         | 
| 3 | 
            +
            ```java
         | 
| 4 | 
            +
            import android.os.Environment;
         | 
| 5 | 
            +
            import com.spire.pdf.*;
         | 
| 6 | 
            +
            import com.spire.pdf.security.*;
         | 
| 7 | 
            +
            import java.util.EnumSet;
         | 
| 2 8 |  | 
| 9 | 
            +
            public class encryption {
         | 
| 10 | 
            +
                public void main() {
         | 
| 11 | 
            +
                    String ExStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Spire/";
         | 
| 12 | 
            +
                    String input = ExStoragePath + "data/encryption.pdf";
         | 
| 13 | 
            +
                    String output =ExStoragePath + "output/encryption.pdf";
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    //load a pdf spire.document.
         | 
| 16 | 
            +
                    PdfDocument doc = new PdfDocument();
         | 
| 17 | 
            +
                    doc.loadFromFile(input);
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    //encrypt
         | 
| 20 | 
            +
                    PdfEncryptionKeySize keySize = PdfEncryptionKeySize.Key_128_Bit;
         | 
| 21 | 
            +
                    String openPassword = "e-iceblue";
         | 
| 22 | 
            +
                    String permissionPassword = "test";
         | 
| 23 | 
            +
                    EnumSet<PdfPermissionsFlags> flags = EnumSet.of(PdfPermissionsFlags.Print, PdfPermissionsFlags.Fill_Fields);
         | 
| 24 | 
            +
                    doc.getSecurity().encrypt(openPassword, permissionPassword, flags, keySize);
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    //save pdf file.
         | 
| 27 | 
            +
                    doc.saveToFile(output, FileFormat.PDF);
         | 
| 28 | 
            +
                    doc.close();
         | 
| 29 | 
            +
                }
         | 
| 30 | 
            +
            }
         | 
| 31 | 
            +
            ```
         | 
1
誤りの訂正
    
        answer	
    CHANGED
    
    | @@ -1,33 +1,2 @@ | |
| 1 1 | 
             
            PDFのパスワードを設定するということですか?[ Spire.PDF for Android via Java](https://www.e-iceblue.com/Introduce/pdf-for-android-via-java.html#.ZHa8_u9ByUk) を試してみませんか。 これは、Adobe Acrobatやその他のサードパーティ製ライブラリを使用せずに、PDFドキュメントの作成、読み取り、操作、変換をサポートしています。
         | 
| 2 | 
            -
             サンプルコードを以下に示します。
         | 
| 3 | 
            -
            ```java
         | 
| 4 2 |  | 
| 5 | 
            -
            import android.os.Environment;
         | 
| 6 | 
            -
            import com.spire.pdf.*;
         | 
| 7 | 
            -
            import com.spire.pdf.security.*;
         | 
| 8 | 
            -
            import java.util.EnumSet;
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            public class encryption {
         | 
| 11 | 
            -
                public void main() {
         | 
| 12 | 
            -
                    String ExStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Spire/";
         | 
| 13 | 
            -
                    String input = ExStoragePath + "data/encryption.pdf";
         | 
| 14 | 
            -
                    String output =ExStoragePath + "output/encryption.pdf";
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                    //load a pdf spire.document.
         | 
| 17 | 
            -
                    PdfDocument doc = new PdfDocument();
         | 
| 18 | 
            -
                    doc.loadFromFile(input);
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                    //encrypt
         | 
| 21 | 
            -
                    PdfEncryptionKeySize keySize = PdfEncryptionKeySize.Key_128_Bit;
         | 
| 22 | 
            -
                    String openPassword = "e-iceblue";
         | 
| 23 | 
            -
                    String permissionPassword = "test";
         | 
| 24 | 
            -
                    EnumSet<PdfPermissionsFlags> flags = EnumSet.of(PdfPermissionsFlags.Print, PdfPermissionsFlags.Fill_Fields);
         | 
| 25 | 
            -
                    doc.getSecurity().encrypt(openPassword, permissionPassword, flags, keySize);
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                    //save pdf file.
         | 
| 28 | 
            -
                    doc.saveToFile(output, FileFormat.PDF);
         | 
| 29 | 
            -
                    doc.close();
         | 
| 30 | 
            -
                }
         | 
| 31 | 
            -
            }
         | 
| 32 | 
            -
             | 
| 33 | 
            -
            ```
         |