コード例 #1
0
        /*
         * Signs a pdf file
         */
        public void Sign(String input_file, String output_file)
        {
            //To sign a document you must initialize an instance of PTEID_PDFSignature
            //It may take the path for the input file as argument
            PTEID_PDFSignature signature = new PTEID_PDFSignature(input_file);

            //You can set the location and reason fields of the signature
            String location = "Lisboa, Portugal";
            String reason   = "Concordo com o conteudo do documento";

            //The page number where the signature will be printed
            int page = 1;

            //The location in the page where the visible signature will be printed in percentage of page height/width
            double pos_x = 0.1;
            double pos_y = 0.1;

            //You can set custom dimensions for your visible seal by using this method.
            //The first argument is the width and the second is the height of the seal.
            signature.setCustomSealSize(200, 200);

            //To actually sign the document you invoke this method, and the signature PIN will be requested in an SDK dialog
            eidCard.SignPDF(signature, page, pos_x, pos_y, location, reason, output_file);

            Console.WriteLine("File signed with success.");
        }
コード例 #2
0
        /*
         * Signs multiple pdf files
         */
        public void Sign(String[] args)
        {
            //Get the output directory
            String output_directory = args [0];

            //To sign a document you must initialize an instance of PTEID_PDFSignature
            PTEID_PDFSignature signature = new PTEID_PDFSignature();

            //Iterate through the various files to sign and add them to the batch to be signed
            for (int i = 1; i < args.Length; i++)
            {
                signature.addToBatchSigning(args[i]);
            }

            //You can set the location and reason fields of the signature
            String location = "Lisboa, Portugal";
            String reason   = "Concordo com o conteudo do documento";

            //The page and coordinates where the signature will be printed
            int    page  = 1;
            double pos_x = 0.1;
            double pos_y = 0.1;

            //To actually sign the document you invoke this method, your authentication PIN will be requested
            //After this you can check the signed document in the path provided
            eidCard.SignPDF(signature, page, pos_x, pos_y, location, reason, output_directory);

            Console.WriteLine("Files signed with success.");
        }
コード例 #3
0
        /*
         * Signs a pdf file
         */
        public void Sign(String input_file, String output_file)
        {
            //To sign a document you must initialize an instance of PTEID_PDFSignature
            //It may take the path for the input file as argument
            PTEID_PDFSignature signature = new PTEID_PDFSignature(input_file);

            //You can set the location and reason fields of the signature
            String location = "Lisboa, Portugal";
            String reason   = "Concordo com o conteudo do documento";

            //The page and coordinates where the signature will be printed
            int    page  = 1;
            double pos_x = 0.1;
            double pos_y = 0.1;

            //Instead of calling the getEIDCard() method, you can now also initialize an instance of the CMDSignatureClient to sign files with CMD
            PTEID_CMDSignatureClient client = new PTEID_CMDSignatureClient();

            //And you sign the file normally as you would in the previous versions of the SDK
            client.SignPDF(signature, page, pos_x, pos_y, location, reason, output_file);

            Console.WriteLine("File signed with success.");
        }
コード例 #4
0
        /*
         * Signs a pdf file
         */
        public void Sign(String flag, String input_file, String output_file)
        {
            //To sign a document you must initialize an instance of PTEID_PDFSignature
            //It may take the path for the input file as argument
            PTEID_PDFSignature signature = new PTEID_PDFSignature(input_file);

            //You can set the location and reason fields of the signature
            String location = "Lisboa, Portugal";
            String reason   = "Concordo com o conteudo do documento";

            //The page and coordinates where the signature will be printed
            int    page  = 1;
            double pos_x = 0.1;
            double pos_y = 0.1;

            //Instead of calling the getEIDCard() method, you can now call getSigningDevice() after initializing a SigningDeviceFactory
            //This way you can choose to use CMD or your card to sign the files
            if (flag.Equals("-CMD"))
            {
                //You only want CMD, so you disallow normal signature by setting the first argument to false
                PTEID_SigningDeviceFactory factory = new PTEID_SigningDeviceFactory(false, true);

                //You then get a SigningDevice by calling getSigningDevice()
                PTEID_SigningDevice device = factory.getSigningDevice();

                //And you sign the file normally as you would in the previous versions of the SDK
                device.SignPDF(signature, page, pos_x, pos_y, location, reason, output_file);

                Console.WriteLine("File signed successfully");
            }
            else if (flag.Equals("-CARD"))
            {
                //You only want the card signature, so you disallow CMD by setting the second argument to false
                PTEID_SigningDeviceFactory factory = new PTEID_SigningDeviceFactory(true, false);

                //You then get a SigningDevice by calling getSigningDevice()
                PTEID_SigningDevice device = factory.getSigningDevice();

                //And you sign the file normally as you would in the previous versions of the SDK
                device.SignPDF(signature, page, pos_x, pos_y, location, reason, output_file);

                Console.WriteLine("File signed successfully");
            }
            else if (flag.Equals("-BOTH"))
            {
                //If you want both methods to be available (CMD and CARD signature) you either initialize "factory(true, true)" or use the default constructor:
                PTEID_SigningDeviceFactory factory = new PTEID_SigningDeviceFactory();

                //You then get a SigningDevice by calling getSigningDevice()
                PTEID_SigningDevice device = factory.getSigningDevice();

                //And you sign the file normally as you would in the previous versions of the SDK
                device.SignPDF(signature, page, pos_x, pos_y, location, reason, output_file);

                Console.WriteLine("File signed successfully");
            }
            else
            {
                Console.WriteLine("Flag not supported, please provided a valid flag: [-CMD|-CARD|-BOTH]");
            }
        }