//private void PDF_PreviewMouseLeftButtonDown_1(object sender, MouseButtonEventArgs e) //{ // Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); // saveFileDialog.Filter = "PDF File|*.pdf"; // saveFileDialog.Title = "Save to a PDF file"; // saveFileDialog.ShowDialog(); // if (!string.IsNullOrEmpty(saveFileDialog.FileName)) // { // float docWidth = (float)diagramView.Page.ActualWidth; // float docHeight = (float)diagramView.Page.ActualHeight; // string jpgFileName = "tempjpg.jpg"; // string xpsFileName = "tempXpS.xps"; // Syncfusion.XPS.XPSToPdfConverter xpsTopdfConverter = new Syncfusion.XPS.XPSToPdfConverter(); // Syncfusion.Pdf.Graphics.PdfUnitConvertor converter = new Syncfusion.Pdf.Graphics.PdfUnitConvertor(); // float pdfHeight = converter.ConvertUnits(docHeight, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Inch, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Point); // float pdfWidth = converter.ConvertUnits(docWidth, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Inch, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Point); // System.Drawing.SizeF pageSize = new System.Drawing.SizeF(pdfWidth, pdfHeight); // diagramView.Save(jpgFileName, new Size(docWidth * 1.5, docHeight * 1.5), ImageStretch.Expand); // Syncfusion.Pdf.PdfDocument pdfDocument = new Syncfusion.Pdf.PdfDocument(); // pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape; // pdfDocument.PageSettings.Margins.All = 0; // PdfImage image = new PdfBitmap(jpgFileName); // pdfDocument.PageSettings.Size = image.PhysicalDimension; // Syncfusion.Pdf.PdfPage page = pdfDocument.Pages.Add(); // page.Graphics.DrawImage(image, 0, 0); // pdfDocument.Save(saveFileDialog.FileName); // pdfDocument.Close(true); // UpadteImageformat(); // } //} private void ExportToPDF_Click_1(object sender, RoutedEventArgs e) { Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); saveFileDialog.Filter = "PDF File|*.pdf"; saveFileDialog.Title = "Save to a PDF file"; saveFileDialog.FileName = "Diagram"; saveFileDialog.ShowDialog(); if (!string.IsNullOrEmpty(saveFileDialog.FileName)) { float docWidth = (float)diagramView.Page.ActualWidth; float docHeight = (float)diagramView.Page.ActualHeight; string jpgFileName = "tempjpg.jpg"; string xpsFileName = "tempXpS.xps"; Syncfusion.XPS.XPSToPdfConverter xpsTopdfConverter = new Syncfusion.XPS.XPSToPdfConverter(); Syncfusion.Pdf.Graphics.PdfUnitConvertor converter = new Syncfusion.Pdf.Graphics.PdfUnitConvertor(); float pdfHeight = converter.ConvertUnits(docHeight, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Inch, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Point); float pdfWidth = converter.ConvertUnits(docWidth, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Inch, Syncfusion.Pdf.Graphics.PdfGraphicsUnit.Point); System.Drawing.SizeF pageSize = new System.Drawing.SizeF(pdfWidth, pdfHeight); diagramView.Save(jpgFileName, new Size(docWidth * 1.5, docHeight * 1.5), ImageStretch.Expand); Syncfusion.Pdf.PdfDocument pdfDocument = new Syncfusion.Pdf.PdfDocument(); pdfDocument.PageSettings.Orientation = PdfPageOrientation.Landscape; pdfDocument.PageSettings.Margins.All = 0; PdfImage image = new PdfBitmap(jpgFileName); pdfDocument.PageSettings.Size = image.PhysicalDimension; Syncfusion.Pdf.PdfPage page = pdfDocument.Pages.Add(); page.Graphics.DrawImage(image, 0, 0); pdfDocument.Save(saveFileDialog.FileName); pdfDocument.Close(true); //UpadteImageformat(); } }
private void BtnPK_Click(object sender, EventArgs e) { List <Sport> sport = new List <Sport>(); sport = InfoWhole(); //Create a new PDF document PdfDocument doc = new PdfDocument(); //Add a page PdfPage page = doc.Pages.Add(); // Create a PdfLightTable PdfLightTable pdfLightTable = new PdfLightTable(); // Initialize DataTable to assign as DateSource to the light table System.Data.DataTable table = new System.Data.DataTable(); //Include columns to the DataTable table.Columns.Add("Kalorije"); table.Columns.Add("Vzpon distance"); table.Columns.Add("Kadenca"); table.Columns.Add("Avg kadenca"); //Include rows to the DataTable int count = sport.Count; int stevec = 1; foreach (var item in sport) { table.Rows.Add(new string[] { item.Porabljene_kalorije, item.Skupen_vzpon, item.Max_kadenca, item.Povp_kadenca }); stevec++; } //Applying cell padding to table pdfLightTable.Style.CellPadding = 3; pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable3Accent3); //Assign data source pdfLightTable.DataSource = table; //Setting this property to true to show the header of table pdfLightTable.Style.ShowHeader = true; //Draw PdfLightTable pdfLightTable.Draw(page, new PointF(0, 0)); //Save the document doc.Save("PdfTable.pdf"); //Close the document doc.Close(true); //This will open the PDF file so, the result will be seen in default PDF viewer Process.Start("PdfTable.pdf"); }
private void BtnPDF_Click(object sender, EventArgs e) { List <Sport> sport = new List <Sport>(); sport = Info(); //Create a new PDF document Syncfusion.Pdf.PdfDocument doc = new PdfDocument(); //Add a page PdfPage page = doc.Pages.Add(); // Create a PdfLightTable PdfLightTable pdfLightTable = new PdfLightTable(); // Initialize DataTable to assign as DateSource to the light table System.Data.DataTable table = new System.Data.DataTable(); //Include columns to the DataTable table.Columns.Add("Kolesar"); table.Columns.Add("Total distance"); table.Columns.Add("Total calories"); table.Columns.Add("Total time"); //Include rows to the DataTable int count = sport.Count; int stevec = 1; foreach (var item in sport) { table.Rows.Add(new string[] { stevec.ToString(), item.Stevilo_prevozenih_km, item.Porabljene_kalorije, item.Trajanje_aktivnosti }); stevec++; } //Applying cell padding to table pdfLightTable.Style.CellPadding = 3; pdfLightTable.ApplyBuiltinStyle(PdfLightTableBuiltinStyle.GridTable3Accent3); //Assign data source pdfLightTable.DataSource = table; //Setting this property to true to show the header of table pdfLightTable.Style.ShowHeader = true; //Draw PdfLightTable pdfLightTable.Draw(page, new PointF(0, 0)); //Save the document doc.Save("PdfTable.pdf"); //Close the document doc.Close(true); //This will open the PDF file so, the result will be seen in default PDF viewer Process.Start("PdfTable.pdf"); }
public IActionResult Index() { HtmlToPdfConverter converter = new HtmlToPdfConverter(); WebKitConverterSettings settings = new WebKitConverterSettings(); settings.WebKitPath = Path.Combine(Environment.CurrentDirectory, "QtBinariesWindows"); converter.ConverterSettings = settings; string path = "https://localhost:44347/Invoice/ShowInvoice?OrderId=2015"; PdfDocument document = converter.Convert("https://www.google.com"); MemoryStream ms = new MemoryStream(); document.Save(ms); document.Close(true); ms.Position = 0; FileStreamResult fileStreamResult = new FileStreamResult(ms, "application/pdf"); fileStreamResult.FileDownloadName = "CHUJ.pdf"; return(fileStreamResult); }
protected void btnGenerateReport_Click(object sender, EventArgs e) { //Syncfusion PDF Syncfusion.Pdf.PdfDocument[] documents = new Syncfusion.Pdf.PdfDocument[10]; string[] allPDFDocument = new string[10]; List <string> listPDF = new List <string>(); DocToPDFConverter converter = new DocToPDFConverter(); dsShowAllDocData = dbFamilyDetailsData.getSOOfficeDocument(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString()); if (dsShowAllDocData.Tables[0].Rows.Count > 0) { int i = 0; foreach (DataRow rows in dsShowAllDocData.Tables[0].Rows) { string DocFileName = rows["docfile"].ToString(); if (DocFileName != "" && !string.IsNullOrEmpty(DocFileName)) { string FileExist = Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName); if (File.Exists(FileExist)) { string fileextension = Path.GetExtension(FileExist.ToString()); switch (fileextension) { case ".docx": WordDocument wordDocumentdocx = new WordDocument(FileExist, FormatType.Docx); string FolderNameDocx = Server.MapPath(@"~/TempFile/" + cmbVillage.SelectedValue.ToString() + "/"); if (!Directory.Exists(FolderNameDocx)) { Directory.CreateDirectory(FolderNameDocx); } documents[i] = converter.ConvertToPDF(wordDocumentdocx); string genfilenameDocx = wordDocumentdocx + "_" + i; //Response.WriteFile(Server.MapPath(@"~/Documents/" + lblVillageCodeHidden.Text + "/" + lbllinkRegisrationSearch.Text)); documents[i].Save(FolderNameDocx + genfilenameDocx + ".pdf"); allPDFDocument[i] = FolderNameDocx + genfilenameDocx + ".pdf"; //documents[i].Save(@"F:\\DocToPDF1.pdf"); listPDF.Add(FolderNameDocx + genfilenameDocx + ".pdf"); break; //RSD case ".doc": WordDocument wordDocumentDoc = new WordDocument(FileExist, FormatType.Doc); string FolderNameDoc = Server.MapPath(@"~/TempFile/" + cmbVillage.SelectedValue.ToString() + "/"); if (!Directory.Exists(FolderNameDoc)) { Directory.CreateDirectory(FolderNameDoc); } documents[i] = converter.ConvertToPDF(wordDocumentDoc); string genfilenameDoc = wordDocumentDoc + "_" + i; //Response.WriteFile(Server.MapPath(@"~/Documents/" + lblVillageCodeHidden.Text + "/" + lbllinkRegisrationSearch.Text)); documents[i].Save(FolderNameDoc + genfilenameDoc + ".pdf"); allPDFDocument[i] = FolderNameDoc + genfilenameDoc + ".pdf"; //documents[i].Save(@"F:\\DocToPDF1.pdf"); listPDF.Add(FolderNameDoc + genfilenameDoc + ".pdf"); break; case ".pdf": string FolderNamePDF = Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName); if (!File.Exists(FolderNamePDF)) { //Directory.CreateDirectory(FolderNameDoc); } else { //listPDF.Add(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + FileExist + ".pdg"); listPDF.Add(Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName)); } break; } } } i = i + 1; }//FOr End //Get All 7/12 File DataSet dsGet712Files = new DataSet(); List <string> listPDF712File = new List <string>(); dsGet712Files = dbFamilyDetailsData.Get712files(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString()); if (dsGet712Files.Tables[0].Rows.Count > 0) { foreach (DataRow rows in dsGet712Files.Tables[0].Rows) { string PDFFileName712 = rows["pdffilename"].ToString(); if (PDFFileName712 != "" && !string.IsNullOrEmpty(PDFFileName712)) { string FileExist = Server.MapPath(@"~/7-12PDF/" + PDFFileName712 + ".pdf"); if (File.Exists(FileExist)) { listPDF712File.Add(FileExist); } } } //Create 712 PDF FIle One Syncfusion.Pdf.PdfDocument PDFFile712 = new Syncfusion.Pdf.PdfDocument(); //Syncfusion.Pdf.PdfDocumentBase.Merge(PDFFile712, listPDFArray712); //listPDF.Add(Server.MapPath(@"~/Documents/" + cmbVillage.SelectedValue.ToString() + "/" + DocFileName)); } //End 712file Syncfusion.Pdf.PdfDocument newPdf1 = new Syncfusion.Pdf.PdfDocument(); //DocToPDFConverter converter2 = new DocToPDFConverter(); string[] listPDFArray = listPDF.ToArray(); string[] listPDFArray712 = listPDF712File.ToArray(); Syncfusion.Pdf.PdfDocumentBase.Merge(newPdf1, listPDFArray); Syncfusion.Pdf.PdfDocumentBase.Merge(newPdf1, listPDFArray712); //newPdf1.Save(@"F:\\newPDFRSD.pdf"); //newPdf1.Close(true); try { string registerFileNo = dbFileNoData.getFileNo("PTS"); //string filename = Path.GetFileName(FControlName.FileName); string fileExtension = ".pdf"; string VillageCode = cmbVillage.SelectedValue.ToString(); string DocumentNo = cmbDocumentNo.SelectedValue.ToString(); string NewFileName = "PTS" + "_" + VillageCode + "_" + DocumentNo + "_" + registerFileNo + fileExtension; string folderName = Server.MapPath("~/Documents/" + VillageCode + "/"); if (!Directory.Exists(folderName)) { Directory.CreateDirectory(folderName); } newPdf1.Save(folderName + NewFileName); newPdf1.Close(true); // FControlName.SaveAs(folderName + NewFileName); dbFileNoData.registername = "PTS"; dbFileNoData.currentno = Convert.ToInt32(registerFileNo) + 1; dbFileNoData.UpdateFileNo(); lbllnkTS.Text = NewFileName; string FinalPath = folderName + NewFileName; ViewState["filepath"] = FinalPath; //Insert in to Document Status string DocumentID = dbDocumentStatusData.getDocumentSeqNo(); dbDocumentStatusData.documentid = Convert.ToInt32(DocumentID); dbDocumentStatusData.villagecode = cmbVillage.SelectedValue.ToString(); dbDocumentStatusData.documentcode = "PTS"; dbDocumentStatusData.documentname = NewFileName; dbDocumentStatusData.documentpath = ViewState["filepath"].ToString(); dbDocumentStatusData.createdby = Session["UserName"].ToString(); dbDocumentStatusData.createddate = DateTime.Today; dbDocumentStatusData.docno = cmbDocumentNo.SelectedValue.ToString(); //Check For Record Exist dsDocumenteExists = dbDocumentStatusData.DocumentExistRO(cmbVillage.SelectedValue.ToString(), cmbDocumentNo.SelectedValue.ToString(), "PTS"); if (dsDocumenteExists.Tables[0].Rows.Count == 0) { //string ModifiedSurveyNo = dbDocumentStatusData.surveyno; //dbDocumentStatusData.surveyno = ModifiedSurveyNo.Replace("'", ""); dbDocumentStatusData.surveyno = ""; dbDocumentStatusData.familyno = ""; dbDocumentStatusData.titlesearchno = ""; dbDocumentStatusData.officename = "SO1"; bool DocInsert = dbDocumentStatusData.AddDocumentStatus(); if (DocInsert) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report File Not Uploaded');", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report File Uploaded');", true); SendSMS("5"); } } else { bool DocumentFileUpdate = dbDocumentStatusData.UpdateDocumentStatusFile(); if (DocumentFileUpdate) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report Not Uploaded');", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Primary Title Search Report File Update');", true); SendSMS("5"); } } } catch (Exception ex) { } } }