Пример #1
0
        private string SavePdf(string base64data)
        {
            string destinationFileName = "";

            try
            {
                List <string> pdfFiles = new List <string>();
                byte[]        pdfbytes = Convert.FromBase64String(base64data);

                // string installedPath = @"C:\";
                string installedPath = @"C:\Users\Public\";
                string fileName      = "Certificatebk" + ".pdf";

                destinationFileName = System.IO.Path.Combine(installedPath, System.IO.Path.GetFileName(fileName));
                // byte[] readFile = File.ReadAllBytes("http://geneinsureclaim.kindlebit.com//Documents/29062/GMCC200002648-1/20200403155646,Invoice.pdf");

                File.WriteAllBytes(destinationFileName, pdfbytes);
            }
            catch (Exception ex)
            {
                MyMessageBox.ShowBox(ex.Message, "Modal error message");
            }
            return(destinationFileName);
        }
Пример #2
0
        private void btnPdf_Click(object sender, EventArgs e)
        {
            if (txtLicPdfCode.Text == "" || txtLicPdfCode.Text == "Enter Pdf Verfication Code")
            {
                txtLicPdfCode.Focus();
                errorProvider1.SetError(txtLicPdfCode, "Enter Pdf Verfication Code");
                return;
            }
            else
            {
                errorProvider1.Clear();
            }


            var vehicelDetails = GetVehicelDetialsByLicPdfCode(txtLicPdfCode.Text);

            if (vehicelDetails != null && vehicelDetails.VehicelId != 0)
            {
                RequestToke token = Service_db.GetLatestToken();
                if (ObjToken != null)
                {
                    parternToken = token.Token;
                }

                pictureBox2.Visible    = true;
                pictureBox2.WaitOnLoad = true;

                String WebUrlPath       = WebConfigurationManager.AppSettings["WebUrlPath"];
                string filePath         = WebUrlPath + "/" + "Documents/License/" + vehicelDetails.VehicelId + ".pdf";
                string optionalFilePath = WebUrlPath + "/" + "Documents/License/" + vehicelDetails.RegistrationNo + ".pdf";
                //urlPath
                //var pdfPath = SavePdfFromUrl(filePath, optionalFilePath);
                //// var pdfPath = @"F:\sample.pdf";
                //PdfDocument doc = new PdfDocument();
                //doc.LoadFromFile(pdfPath);
                //doc.Pages.Insert(0);
                //doc.Pages.Add();
                //doc.Pages.RemoveAt(0);//Since First page have always Red Text if use Free Version.
                //doc.SaveToFile(pdfPath);


                string installedPath = @"C:\Users\Public\";
                string fileName      = "Certificate" + ".pdf";

                var destinationFileName = System.IO.Path.Combine(installedPath, System.IO.Path.GetFileName(fileName));


                PdfReader  reader  = new PdfReader(filePath);
                PdfStamper stamper = new PdfStamper(reader, new FileStream(destinationFileName, FileMode.Create));
                int        total   = reader.NumberOfPages;
                for (int pageNumber = total; pageNumber > 0; pageNumber--)
                {
                    stamper.InsertPage(pageNumber, PageSize.A4);
                }
                stamper.Close();
                reader.Close();


                MyMessageBox.ShowBox("Please Print Licence Disk. ", "Print License Disk");

                printPDFWithAcrobat(destinationFileName);
                pictureBox2.Visible = false;

                riskDetail = new RiskDetailModel {
                    CombinedID = vehicelDetails.CombinedID, LicenseId = vehicelDetails.LicenseId, RegistrationNo = vehicelDetails.RegistrationNo
                };


                this.Close();
                WebCertificateSerial obj = new WebCertificateSerial(riskDetail, parternToken);
                obj.Show();
            }
            else
            {
                pictureBox2.Visible = false;
                MyMessageBox.ShowBox("Certificate is not found for this code", "Message");
            }

            pictureBox2.Visible = false;
        }
Пример #3
0
        private void btnScan_Click(object sender, EventArgs e)
        {
            try
            {
                pictureBox2.Visible    = true;
                pictureBox2.WaitOnLoad = true;
                var pdfPath = SavePdf(_base64Data);

                //PdfDocument doc = new PdfDocument();
                //doc.LoadFromFile(pdfPath);
                //doc.Pages.Insert(0);
                //doc.Pages.Add();
                //doc.Pages.RemoveAt(0);//Since First page have always Red Text if use Free Version.
                //doc.SaveToFile(pdfPath);

                //string installedPath = @"C:\Users\Public\";
                //string fileName = "Certificate" + ".pdf";
                string installedPath = @"C:\Users\Public\";
                string fileName      = "Certificate" + ".pdf";

                var destinationFileName = System.IO.Path.Combine(installedPath, System.IO.Path.GetFileName(fileName));

                PdfReader  reader  = new PdfReader(pdfPath);
                PdfStamper stamper = new PdfStamper(reader, new FileStream(destinationFileName, FileMode.Create));
                int        total   = reader.NumberOfPages;
                for (int pageNumber = total; pageNumber > 0; pageNumber--)
                {
                    stamper.InsertPage(pageNumber, PageSize.A4);
                }
                stamper.Close();
                reader.Close();


                //MessageBox.Show("Please Print Licence Disk.                                                                       ", "Print License Disk");

                MyMessageBox.ShowBox("Please Print Licence Disk. ", "Print License Disk");

                printPDFWithAcrobat(destinationFileName);

                CreateLicenseFile(_base64Data);

                CertSerialNoDetailModel model = new CertSerialNoDetailModel();
                model.VehicleId    = RiskDetailModel.Id;
                model.CertSerialNo = txtCertificateSerialNumber.Text;

                SaveCertSerialNum(model);

                //  pictureBox2.WaitOnLoad = false;
                pictureBox2.Visible = false;
                txtCertificateSerialNumber.ForeColor = Color.Gray;

                txtCertificateSerialNumber.Focus();
            }
            catch (Exception ex)
            {
                pictureBox2.WaitOnLoad = false;
                pictureBox2.Visible    = false;
                // MessageBox.Show(ex.Message);
                MyMessageBox.ShowBox(ex.Message, "Modal error message");
            }
        }