//public void SaveCertificatePdf() //{ // try // { //string textFile = @"../../Pdf/base_64_pdf.txt"; //byte[] pdfbytes = null; // if (File.Exists(textFile)) // { // var client = new RestClient(ApiURL + "SaveCertificatePdf?base64String=" + File.ReadAllText(textFile)); // var request = new RestRequest(Method.POST); // request.AddHeader("password", Pwd); // request.AddHeader("username", username); // request.AddParameter("application/json", "{\n\t\"Name\":\"ghj\"\n}", ParameterType.RequestBody); // IRestResponse response = client.Execute(request); // var test = response.Content; // } // } // catch (Exception ex) // { // } //} public string SaveCertificatePdf(string base64data = "") { var pdfPath = ""; try { PdfModel objPlanModel = new PdfModel(); objPlanModel.Base64String = base64data; string textFile = @"../../Pdf/base_64_pdf.txt"; if (File.Exists(textFile)) { objPlanModel.Base64String = File.ReadAllText(textFile); } var client = new RestClient(ApiURL + "SaveCertificate"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/json"); request.AddHeader("password", "Geninsure@123"); request.AddHeader("username", "*****@*****.**"); request.RequestFormat = DataFormat.Json; request.AddJsonBody(objPlanModel); IRestResponse response = client.Execute(request); pdfPath = JsonConvert.DeserializeObject <string>(response.Content); } catch (Exception ex) { } return(pdfPath); }
public void CreateLicenseFile(string base64data) { try { byte[] bytes = Encoding.ASCII.GetBytes(base64data); PdfModel objPlanModel = new PdfModel(); objPlanModel.Base64String = base64data; var client = new RestClient(ApiURL + "SaveCertificate"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/json"); request.AddHeader("password", "Geninsure@123"); request.AddHeader("username", "*****@*****.**"); request.RequestFormat = DataFormat.Json; request.AddJsonBody(objPlanModel); IRestResponse response = client.Execute(request); var pdfPath = JsonConvert.DeserializeObject <string>(response.Content); //using (WebClient webClient = new WebClient()) //{ // byte[] data = webClient.DownloadData(pdfPath); // // using (MemoryStream stream = new MemoryStream(data)) // using (MemoryStream stream = new MemoryStream(bytes)) // { // PdfDocument doc = new PdfDocument(stream); // doc.Pages.Insert(0); // doc.Pages.Add(); // doc.Pages.RemoveAt(0);//Since First page have always Red Text if use Free Version. // doc.PrintDocument.Print(); // } //} } catch (Exception ex) { } }