static void Main(string[] args)
        {
            //need licence
            PDFDocument  pDFDocument  = new PDFDocument(/*insert licence here*/);
            PDFSignature pDFSignature = new PDFSignature("../../../test.pfx", "123456", "because", "here", "contactInfo", 1);

            pDFDocument.AddSignature(pDFSignature);
            pDFDocument.Save("../../testingC signed.pdf");
        }
Example #2
0
        public DigitalSignaturesDialog(PDFSignature signature)
        {
            InitializeComponent();

            _signature = signature;

            InitializeSummaryTab();
            InitializeDetailsTab();
        }
Example #3
0
        public SignatureValidationStatusDialog(PDFSignature signature)
        {
            InitializeComponent();

            if (signature == null)
            {
                return;
            }

            _signature = signature;

            SetCertificationInformation();
        }
Example #4
0
 private void _signaturesTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (e.Node != null)
     {
         if (e.Node.Tag is PDFSignature)
         {
             PDFSignature signature = e.Node.Tag as PDFSignature;
             using (DigitalSignaturesDialog signaturesDialog = new DigitalSignaturesDialog(signature))
             {
                 signaturesDialog.ShowDialog();
             }
         }
     }
 }
Example #5
0
        private void _signaturesTreeView_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return && _signaturesTreeView.SelectedNode != null)
            {
                TreeNode node = _signaturesTreeView.SelectedNode;

                if (node != null && node.Tag is PDFSignature)
                {
                    PDFSignature signature = node.Tag as PDFSignature;
                    using (DigitalSignaturesDialog signaturesDialog = new DigitalSignaturesDialog(signature))
                    {
                        signaturesDialog.ShowDialog();
                    }
                }
            }
        }
        public void Pdf_ConvertAndSign_Tests()
        {
            try
            {
                pdfService.ConvertToSomeFormat("pdf-sample.pdf", PDFDocumentConvertFormat.Html, Utils.CloudStorage_Input_Folder, Utils.Local_Output_Path + "pdf-html-out.html");
                pdfService.ConvertToSomeFormat("pdf-sample.pdf", PDFDocumentConvertFormat.Html, Utils.CloudStorage_Input_Folder, Utils.CloudStorage_Output_Folder + "/pdf-html-out.html");

                pdfService.ConvertToSomeFormat("pdf-sample.pdf", PDFDocumentConvertFormat.Doc, Utils.CloudStorage_Input_Folder, Utils.Local_Output_Path + "pdf-doc-out.doc");
                pdfService.ConvertToSomeFormat("pdf-sample.pdf", PDFDocumentConvertFormat.Doc, Utils.CloudStorage_Input_Folder, Utils.CloudStorage_Output_Folder + "/pdf-doc-out.doc");

                #region Sign document

                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-signed.pdf");

                PDFSignature signature = new PDFSignature();
                signature.SignaturePath = Utils.CloudStorage_Input_Folder + "/signature.pfx";
                signature.SignatureType = "PKCS7";
                signature.Password      = "******";
                signature.Appearance    = Utils.CloudStorage_Input_Folder + "/signature.jpg";
                signature.Reason        = "Success";

                signature.Contact       = "*****@*****.**";
                signature.Location      = "Australia";
                signature.Visible       = true;
                signature.FormFieldName = "Signature1";
                signature.Authority     = "Aspose Marketplace";
                signature.Rectangle     = new Rectangle(100, 100, 200, 200);
                signature.Date          = DateTime.Now.ToString();

                pdfService.SignDocument("pdf-signed.pdf", Utils.CloudStorage_Output_Folder, signature);

                storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/pdf-signed.pdf", Utils.Local_Output_Path + "/pdf-signed.pdf");


                #endregion Sign document
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public async Task <IActionResult> PostFile([FromForm] IFormFile file, [FromForm] string OTP, [FromForm] string pin)
        {
            //var uploads = Path.Combine(_hostingEnvironment.ContentRootPath, "Documents");
            var filePath = Path.GetTempFileName();

            if (file.Length > 0)
            {
                using (var stream = new FileStream(filePath, FileMode.Create))
                {
                    await file.CopyToAsync(stream);

                    Microsoft.Extensions.Primitives.StringValues value;
                    string access_token = "";
                    if (Request.Headers.TryGetValue("Authorization", out value))
                    {
                        access_token = value.ToString().Replace("Bearer ", "");
                    }
                    else
                    {
                        OutputError error = new OutputError()
                        {
                            error             = "invalid_access_token",
                            error_description = "Invalid access_token"
                        };
                    }

                    PDFSignature pdfSign = new PDFSignature();
                    pdfSign.SignFilePDF(stream, access_token, OTP, pin);
                }
                //System.IO.File.Copy(file.Name, @"E:\Dezvoltare\test.pdf", true);

                //System.IO.FileStream F = new FileStream(@"E:\Dezvoltare\test.pdf", FileMode.Open, FileAccess.ReadWrite);
                //try()
                //var stream = file.OpenReadStream();
                //var name = file.FileName;
                //var type = file.ContentType;

                return(null);
            }
            return(null);
        }
        public void Pdf_Pages_Tests()
        {
            try
            {
                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-pages.pdf");
                PagesResponse pagesResponse = pdfService.Pages.ReadDocumentPagesInfo("pdf-pages.pdf", Utils.CloudStorage_Output_Folder);
                System.Threading.Thread.Sleep(3000); // Just for testing
                PagesResponse pagesResponse2 = pdfService.Pages.AddNewPageToEndOfTheDocument("pdf-pages.pdf", Utils.CloudStorage_Output_Folder);
                PageResponse  pageResponse   = pdfService.Pages.ReadDocumentPageInfo("pdf-pages.pdf", 1, Utils.CloudStorage_Output_Folder);
                System.Threading.Thread.Sleep(3000); // Just for testing

                pdfService.Pages.ConvertToSomeFormat("pdf-pages.pdf", 1, PDFPageConvertFormat.Png, Utils.Local_Output_Path + "\\pdf-page-out.png", Utils.CloudStorage_Output_Folder);
                WordsPerPageResponse wordsPerPageResponse = pdfService.Pages.GetNumberOfWordsPerDocumentPage("pdf-sample.pdf", Utils.CloudStorage_Input_Folder);
                System.Threading.Thread.Sleep(3000); // Just for testing

                pdfService.Pages.DeleteDocumentPageByItsNumber("pdf-pages.pdf", 1, Utils.CloudStorage_Output_Folder);
                pdfService.Pages.MovePageToNewPosition("pdf-pages.pdf", 1, 3, Utils.CloudStorage_Output_Folder);

                System.Threading.Thread.Sleep(3000); // Just for testing

                //---------------------------------------------------------------------

                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-pages.pdf");

                PDFSignature signature = new PDFSignature();
                signature.SignaturePath = Utils.CloudStorage_Input_Folder + "/signature.pfx";
                signature.SignatureType = "PKCS7";
                signature.Password      = "******";
                signature.Appearance    = Utils.CloudStorage_Input_Folder + "/signature.jpg";
                signature.Reason        = "Success";

                signature.Contact       = "*****@*****.**";
                signature.Location      = "Australia";
                signature.Visible       = true;
                signature.FormFieldName = "Signature1";
                signature.Authority     = "Aspose Marketplace";
                signature.Rectangle     = new Rectangle(100, 100, 200, 200);
                signature.Date          = DateTime.Now.ToString();

                pdfService.Pages.SignPage("pdf-pages.pdf", 1, Utils.CloudStorage_Output_Folder, signature);

                //---------------------------------------------------------------------
                System.Threading.Thread.Sleep(3000); // Just for testing
                storageService.File.CopyFile(Utils.CloudStorage_Input_Folder + "/pdf-sample.pdf", Utils.CloudStorage_Output_Folder + "/pdf-pages.pdf");

                PageStamp stamp = new PageStamp();
                stamp.Type                = 0;
                stamp.Background          = true;
                stamp.BottomMargin        = 2.1;
                stamp.HorizontalAlignment = 0;
                stamp.LeftMargin          = 3.1;
                stamp.Opacity             = 4.1;
                stamp.RightMargin         = 5.1;
                stamp.Rotate              = 0;
                stamp.RotateAngle         = 6.1;
                stamp.TopMargin           = 7.1;
                stamp.VerticalAlignment   = 0;
                stamp.XIndent             = 8.1;
                stamp.YIndent             = 9.1;
                stamp.Zoom                = 10.1;
                stamp.TextAlignment       = 0;
                stamp.Value               = "sample string 11";

                Color     backGroundColor = new Color(64, 64, 64, 64);
                TextState textState       = new TextState();
                textState.BackgroundColor = backGroundColor;
                textState.ForegroundColor = backGroundColor;
                textState.FontSize        = 12;
                textState.Font            = "Tahoma";
                textState.FontStyle       = 1;
                stamp.TextState           = textState;

                stamp.FileName       = Utils.CloudStorage_Input_Folder + "/signature.jpg";
                stamp.Width          = 13.1;
                stamp.Height         = 14.1;
                stamp.PageIndex      = 1;
                stamp.StartingNumber = 1;

                System.Threading.Thread.Sleep(3000); // Just for testing

                pdfService.Pages.AddPageStamp("pdf-pages.pdf", 1, Utils.CloudStorage_Output_Folder, stamp);

                System.Threading.Thread.Sleep(3000); // Just for testing

                storageService.File.DownloadFile(Utils.CloudStorage_Output_Folder + "/pdf-pages.pdf", Utils.Local_Output_Path + "/pdf-pages.pdf");
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }