static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); string rtfPath = @"..\..\example.rtf"; string pdfPath = @"..\..\test.pdf"; // Let's create a PDF file from RTF file p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape; //Specify page numbers: {1 of N}, font: Verdana, 18 p.PageSettings.Numbering.Text = "{page} of {numpages}"; p.PageSettings.Numbering.FontFace = "Verdana"; p.PageSettings.Numbering.FontSize = 18; p.RtfToPdfConvertFile(rtfPath, pdfPath); #region split PDF file //Split PDF by pages: 1st, 2nd, 3rd ... p.SplitPDFFileToPDFFolder(pdfPath, Path.GetDirectoryName(pdfPath)); #endregion #region merge PDF files //Merge only 1st and 3rd pages string[] pdfFiles = { @"..\..\test-00001.pdf", @"..\..\test-00003.pdf" }; p.MergePDFFileArrayToPDFFile(pdfFiles, @"..\..\test_Split_and_Merge_1and3page.pdf"); #endregion //Show merged PDF (it doesn't have 2nd page) System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(@"..\..\test_Split_and_Merge_1and3page.pdf") { UseShellExecute = true }); }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); //After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; //specify some options p.PageSettings.Size.A4(); p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape; p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; if (p != null) { string inputFile = @"..\..\example.htm"; string outputFile = @"..\..\test.pdf"; int result = p.HtmlToPdfConvertFile(inputFile, outputFile); if (result == 0) { System.Console.WriteLine("Converted successfully!"); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true }); } else { System.Console.WriteLine("Converting Error!"); } } }
private static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component. //p.Serial = "XXXXXXXXXXX"; //Prepare variables with path. string docxFile = Path.GetFullPath(@"..\..\example.docx"); string pdfFileFromDocx = Path.GetFullPath(@"..\..\exampleResultDocx.pdf"); string rtfFile = Path.GetFullPath(@"..\..\example.rtf"); string pdfFileFromRtf = Path.GetFullPath(@"..\..\exampleResultRtf.pdf"); string htmlFile = Path.GetFullPath(@"..\..\example.htm"); string pdfFileFromHtml = Path.GetFullPath(@"..\..\exampleResultHtml.pdf"); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(Path.GetFullPath(@"..\..\")) { UseShellExecute = true }); // Convert DOCX file to PDF file p.DocxToPdfConvertFile(docxFile, pdfFileFromDocx); // Convert RTF file to PDF file p.RtfToPdfConvertFile(rtfFile, pdfFileFromRtf); // Convert HTML file to PDF file p.HtmlToPdfConvertFile(htmlFile, pdfFileFromHtml); }
protected void Button1_Click(object sender, EventArgs e) { //Get HTML from temporary file which we've created in the overridden method Render() string html = File.ReadAllText(Path.Combine(Server.MapPath("Temp"), "temp.htm"), Encoding.UTF8); string url = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; if (html.Length > 0) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); //After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; p.HtmlSettings.BaseUrl = url; byte[] pdf = p.HtmlToPdfConvertStringToByte(html); //show PDF if (pdf != null) { Response.Buffer = true; Response.Clear(); Response.ContentType = "application/PDF"; Response.AddHeader("content-disposition", "attachment; filename=Result.pdf"); Response.BinaryWrite(pdf); Response.Flush(); Response.End(); } } }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component. //p.Serial = "XXXXXXXXXXX"; // Let's set: A4, Landscape orientation, left and right margins: 1.5 Inch, top and bottom: 1 Inch p.PageSettings.Size.A4(); p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape; p.PageSettings.MarginLeft.Inch(1.5f); p.PageSettings.MarginRight.Inch(1.5f); p.PageSettings.MarginTop.Inch(1.0f); p.PageSettings.MarginBottom.Inch(1.0f); if (p != null) { string textPath = @"..\..\example.txt"; string pdfPath = Path.ChangeExtension(textPath, ".pdf"); if (p.TextToPdfConvertFile(textPath, pdfPath) == 0) { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { System.Console.WriteLine("An error occurred during converting Text to PDF!"); Console.ReadLine(); } } }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component. //p.Serial = "XXXXXXXXXXX"; if (p != null) { string textPath = @"..\..\example.txt"; string pdfPath = Path.ChangeExtension(textPath, ".pdf"); string textString = File.ReadAllText(textPath); // 2. Convert Text to PDF in memory byte[] pdfBytes = p.TextToPdfConvertStringToByte(textString); if (pdfBytes != null) { //3. Save the PDF document to a file for a viewing purpose. File.WriteAllBytes(pdfPath, pdfBytes); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { System.Console.WriteLine("An error occurred during converting Text to PDF!"); } } }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component. //p.Serial = "XXXXXXXXXXX"; if (p != null) { string docxPath = @"..\..\example.docx"; string pdfPath = Path.ChangeExtension(docxPath, ".pdf"); byte[] docx = File.ReadAllBytes(docxPath); // 2. Convert DOCX to PDF in memory byte[] pdf = p.DocxToPdfConvertByte(docx); if (pdf != null) { // 3. Save the PDF document to a file for a viewing purpose. File.WriteAllBytes(pdfPath, pdf); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { System.Console.WriteLine("Conversion failed!"); Console.ReadLine(); } } }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component. //p.Serial = "XXXXXXXXXXX"; if (p != null) { string docxPath = @"..\..\example.docx"; string pdfPath = Path.ChangeExtension(docxPath, ".pdf"); // 2. Convert DOCX file to PDF file if (p.DocxToPdfConvertFile(docxPath, pdfPath) == 0) { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { System.Console.WriteLine("Conversion failed!"); Console.ReadLine(); } } }
private void button1_Click(object sender, System.EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); if (p != null) { string pdfPath = @"..\..\test.pdf"; //1. Get RTF content string rtfString = this.richTextBox1.Rtf; //2. Converting RTF to PDF byte[] pdf = p.RtfToPdfConvertStringToByte(rtfString); if (pdf != null) { //3. Save to PDF file File.WriteAllBytes(pdfPath, pdf); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } } }
static void Main(string[] args) { // How to set a version for the PDF document. SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; // PDF Metamorphosis .Net generates PDF 1.4 document by default. // Let's change the PDF version to PDF_A. p.PdfSettings.PdfVersion = SautinSoft.PdfMetamorphosis.PdfSetting.PdfVersions.PDF_A; if (p != null) { string rtfPath = @"..\..\example.rtf"; string pdfPath = Path.ChangeExtension(rtfPath, ".pdf"); int i = p.RtfToPdfConvertFile(rtfPath, pdfPath); if (i != 0) { System.Console.WriteLine("An error occurred during converting RTF to PDF!"); } else { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } } }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component. //p.Serial = "XXXXXXXXXXX"; if (p != null) { string rtfPath = @"..\..\example.rtf"; string pdfPath = Path.ChangeExtension(rtfPath, ".pdf"); // 1. Get RTF content from file string rtfString = File.ReadAllText(rtfPath); // 2. Convert RTF string to a PDF file if (p.RtfToPdfConvertStringToFile(rtfString, pdfPath) == 0) { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { System.Console.WriteLine("An error occurred during converting RTF to PDF!"); } } }
private void buttonConvert_Click(object sender, EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; //specify some options p.PageSettings.Size.A4(); p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Auto; p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; if (p != null) { string inputFile = @"..\..\example.htm"; string outputFile = @"..\..\test.pdf"; int result = p.HtmlToPdfConvertFile(inputFile, outputFile); if (result == 0) { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true }); } else { MessageBox.Show("Converting Error!"); } } }
static void Main(string[] args) { // This sample shows how to specify page numbers SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; //Page 1 of N, position: 30 mm from the left of the page p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; p.PageSettings.Numbering.PosX.Mm = 30; p.PageSettings.Numbering.PosY.Mm = 10; p.PageSettings.Numbering.FontFace = "Courier"; p.PageSettings.Numbering.FontSize = 22; if (p != null) { string rtfPath = @"..\..\example.rtf"; string pdfPath = @"..\..\example.pdf"; int i = p.RtfToPdfConvertFile(rtfPath, pdfPath); if (i != 0) { System.Console.WriteLine("An error occurred during converting RTF to PDF!"); } else { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } } }
protected void Button1_Click(object sender, EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); //After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; ArrayList pdfs = new ArrayList(); int files = 0; if (FileUpload1.FileBytes.Length > 0) { pdfs.Add(FileUpload1.FileBytes); files++; } if (FileUpload2.FileBytes.Length > 0) { pdfs.Add(FileUpload2.FileBytes); files++; } if (FileUpload3.FileBytes.Length > 0) { pdfs.Add(FileUpload3.FileBytes); files++; } if (files < 2) { Result.Text = "Error! Before merging please select at least two PDF documents!"; return; } byte[] pdfBytes = null; //merge pdfBytes = p.MergePDFStreamArrayToPDFStream(pdfs); //show PDF if (pdfBytes != null) { Response.Buffer = true; Response.Clear(); Response.ContentType = "application/PDF"; Response.AppendHeader("content-disposition", "attachment; filename=single.pdf"); Response.BinaryWrite(pdfBytes); Response.Flush(); Response.End(); } else { Result.Text = "Error in merging these PDF files, email to [email protected]!"; } }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; // Specify some PDF options. p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Portrait; p.PageSettings.Size.Letter(); // Specify header in HTML format. p.PageSettings.Header.FromString("<b>Sample header in HTML format</b>", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html); // Specify footer in RTF format. p.PageSettings.Footer.FromString(@"{\rtf1 \b Bold Footer}", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Rtf); // Specify page numbers p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; p.PageSettings.Numbering.PosX.Mm = p.PageSettings.Size.Width.Mm / 2; p.PageSettings.Numbering.PosY.Mm = 10; if (p != null) { string htmlPath = @"..\..\example.htm"; string pdfPath = Path.ChangeExtension(htmlPath, ".pdf"); string htmlString = ""; // The easiest way is using the method 'HtmlToPdfConvertFile': // int ret = p.HtmlToPdfConvertFile(htmlPath,pdfPath); // or : // 1. Get HTML content from file htmlString = ReadFromFile(htmlPath); // 2. Converting HTML to PDF // Specify BaseUrl to help converter find a full path to relative images and external CSS. p.HtmlSettings.BaseUrl = Path.GetDirectoryName(htmlPath); if (p.HtmlToPdfConvertStringToFile(htmlString, pdfPath) == 0) { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { System.Console.WriteLine("An error occurred during converting HTML to PDF!"); } } }
protected string GeneratePDF(string strHtml, string P_Company_Id, string P_Case_Id, string P_User_Name, string P_Case_No, string P_Invoice_ID) { GeneratePatientInfoPDF objPDF = new GeneratePatientInfoPDF(); Bill_Sys_NF3_Template objNF3Template = new Bill_Sys_NF3_Template(); string pdffilename = ""; try { SautinSoft.PdfMetamorphosis objHTMToPDF = new SautinSoft.PdfMetamorphosis(); _InvoiceDAO = new InvoiceDAO(); objHTMToPDF.Serial = "10007706603"; string htmfilename = getFileName("I") + ".htm"; string FullPath = ""; pdffilename = getFileName("P") + ".pdf"; StreamWriter sw = new StreamWriter(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename); sw.Write(strHtml); sw.Close(); Int32 iTemp; iTemp = objHTMToPDF.HtmlToPdfConvertFile(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename, ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename); String szDestinationDir = Company_Name + "/" + Case_Id + "/No Fault File/Invoice/"; FullPath = objNF3Template.getPhysicalPath().ToString() + szDestinationDir.ToString() + pdffilename.ToString(); string FilePath = szDestinationDir.ToString(); string Path = szDestinationDir.ToString() + pdffilename.ToString(); if (File.Exists(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename)) { if (!Directory.Exists(objNF3Template.getPhysicalPath() + szDestinationDir)) { Directory.CreateDirectory(objNF3Template.getPhysicalPath() + szDestinationDir); } File.Copy(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename, objNF3Template.getPhysicalPath() + szDestinationDir + pdffilename); } ArrayList objAL1 = new ArrayList(); objAL1.Add(P_Company_Id); objAL1.Add(P_Case_Id); objAL1.Add(pdffilename); // SZ_BILL_NAME objAL1.Add(FilePath); // SZ_BILL_FILE_PATH objAL1.Add(P_User_Name); objAL1.Add("NF"); objAL1.Add(P_Case_No); objAL1.Add(Path); objAL1.Add(P_Invoice_ID); _InvoiceDAO.saveGeneratedInvoicePath(objAL1); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } return(pdffilename); }
protected string GeneratePDF() { string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url); using (Utils utility = new Utils()) { utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod()); } GeneratePatientInfoPDF objPDF = new GeneratePatientInfoPDF(); string pdffilename = ""; try { string szFileData = File.ReadAllText(ConfigurationManager.AppSettings["NF2_SENT_MAIL_HTML"]); szFileData = objPDF.getNF2MailDetails(szFileData, oC_Account.SZ_COMPANY_ID); string strHtml = GenerateHTML(); szFileData = szFileData.Replace("VL_SZ_TABLE_DATA", strHtml); szFileData = szFileData.Replace("VL_SZ_CASE_COUNT", Session["VL_COUNT"].ToString()); SautinSoft.PdfMetamorphosis objHTMToPDF = new SautinSoft.PdfMetamorphosis(); objHTMToPDF.Serial = "10007706603"; string htmfilename = getFileName("P") + ".htm"; pdffilename = getFileName("P") + ".pdf"; StreamWriter sw = new StreamWriter(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename); sw.Write(szFileData); sw.Close(); Int32 iTemp; iTemp = objHTMToPDF.HtmlToPdfConvertFile(ApplicationSettings.GetParameterValue("EXCEL_SHEET") + htmfilename, ApplicationSettings.GetParameterValue("EXCEL_SHEET") + pdffilename); } catch (Exception ex) { //string strError = ex.Message.ToString(); //strError = strError.Replace("\n", " "); Elmah.ErrorSignal.FromCurrentContext().Raise(ex); using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } string str2 = "Error Request=" + id + ".Please share with Technical support."; base.Response.Redirect("Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2); } return(pdffilename); //Method End using (Utils utility = new Utils()) { utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod()); } }
public ActionResult DescargarPdf(int?id) { var archivo = db.planillascontratos.Where(dp => dp.PC_Id == id).FirstOrDefault(); SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); if (p != null) { byte[] pdfbyte = p.DocxToPdfConvertByte(archivo.PC_Binario); return(File(pdfbyte, "document/pdf", archivo.PC_Nom + ".pdf")); } return(View()); }
public void ConvertirRTF_PDF(string Archivo) { SautinSoft.PdfMetamorphosis ConvertirPDF = new SautinSoft.PdfMetamorphosis(); //Le ponemos el serial ConvertirPDF.Serial = "10011534841"; //Lo Transformamos System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); byte[] Palabras = FileToByteArray(Archivo); byte[] binaryPDF = ConvertirPDF.RtfToPdfConvertByte(Palabras); _ArchivoPDF = Archivo.Replace(".rtf", ".pdf"); FileStream pdfFile = File.OpenWrite(_ArchivoPDF); pdfFile.Write(binaryPDF, 0, binaryPDF.Length); pdfFile.Close(); }
private void buttonConvert_Click(object sender, EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; // Specify some page options p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape; // Set page header in HTML format p.PageSettings.Header.FromString("<b>Sample header in HTML format</b>", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html); // Set page footer in RTF format p.PageSettings.Footer.FromString(@"{\rtf1\b Bold footer}", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Rtf); // Set page numbers p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; if (p != null) { string rtfPath = @"..\..\example.rtf"; string pdfPath = @"..\..\test.pdf"; //1. Get RTF content from file string rtfString = File.ReadAllText(rtfPath); //2. Convert RTF to PDF bytes byte[] pdfBytes = p.RtfToPdfConvertStringToByte(rtfString); if (pdfBytes != null) { //3. Save pdfBytes to PDF file File.WriteAllBytes(pdfPath, pdfBytes); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { System.Console.WriteLine("An error occurred during converting RTF to PDF!"); Console.ReadLine(); } } }
public byte[] CreateFilePDF(int courseId, int userId) { var certificate = Database.Certificates.Get(courseId, userId); if (certificate == null) { throw new ValidationException("Сертификата не существует", ""); } SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); string htmlString = $"This certificate confirms that {certificate.FullName} has completed the {certificate.NameCourse} course."; byte[] pdfBytes = p.TextToPdfConvertStringToByte(htmlString); return(pdfBytes); }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); SautinSoft.PdfMetamorphosis.WaterMark w1 = new SautinSoft.PdfMetamorphosis.WaterMark(@"..\..\WaterMark.png"); w1.PosX.Mm = 0; w1.PosX.Mm = 0; w1.PosDX.Mm = 50; w1.PosDY.Mm = 50; p.WaterMarks.Add(w1); SautinSoft.PdfMetamorphosis.WaterMark w2 = p.WaterMarks.Add(); w2.Img = System.Drawing.Image.FromFile(@"..\..\WaterMark.png"); w2.Transparency = 20; w2.PosX.Mm = 60; w2.PosY.Mm = 0; w2.PosDX.Mm = 100; w2.PosDY.Mm = 100; w2.SelectedPages = new int[] { 1 }; if (p != null) { string rtfPath = @"..\..\example.rtf"; string pdfPath = Path.ChangeExtension(rtfPath, ".pdf"); int i = p.RtfToPdfConvertFile(rtfPath, pdfPath); if (i != 0) { System.Console.WriteLine("An error occurred during converting RTF to PDF!"); } else { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } } }
static void Main(string[] args) { // How to set a single font for the whole PDF document. SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; // Let's make that the all text in PDF became in 'Courier New' font p.TextSettings.FontFace.Custom("Courier New"); // Set also a single font size 10 p.TextSettings.FontSize = 10; // Set also single text color p.TextSettings.FontColor = System.Drawing.Color.FromArgb(33, 150, 150); // Embed all fonts inside PDF. p.PdfSettings.EmbedAllFonts = true; if (p != null) { string rtfPath = @"..\..\example.rtf"; string pdfPath = @"..\..\example.pdf"; int i = p.RtfToPdfConvertFile(rtfPath, pdfPath); if (i != 0) { System.Console.WriteLine("An error occurred during converting RTF to PDF!"); } else { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } } }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; // Specify some page options. p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape; // Set page header in HTML format. p.PageSettings.Header.FromString("<b style=\"color: green;\">Sample header in HTML format</b>", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html); // Set page footer in RTF format. p.PageSettings.Footer.FromString("{\\rtf1 \\b Bold Footer in RTF format}", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Rtf); // Set page numbers. p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; if (p != null) { string rtfPath = @"..\..\example.rtf"; string pdfPath = Path.ChangeExtension(rtfPath, ".pdf"); int i = p.RtfToPdfConvertFile(rtfPath, pdfPath); if (i != 0) { System.Console.WriteLine("An error occurred during converting RTF to PDF!"); } else { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } } }
private void buttonConvert_Click(object sender, EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; // Specify some options p.PageSettings.Orientation = SautinSoft.PdfMetamorphosis.PageSetting.Orientations.Landscape; // Specify header in HTML format p.PageSettings.Header.FromString("<b>Sample header in HTML format</b>", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html); // Specify footer in RTF format p.PageSettings.Footer.FromString(@"{\rtf1\b Bold footer}", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Rtf); // Specify page numbers p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; if (p != null) { string rtfPath = @"..\..\example.rtf"; string pdfPath = @"..\..\test.pdf"; int i = p.RtfToPdfConvertFile(rtfPath, pdfPath); if (i != 0) { MessageBox.Show("An error occurred during converting RTF to PDF!"); } else { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } } }
static void Main(string[] args) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component // p.Serial = "XXXXXXXXXXX"; if (p != null) { string htmlPath = @"..\..\example.htm"; string pdfPath = Path.ChangeExtension(htmlPath, ".pdf"); string htmlString = ""; // The easiest way is using the method 'HtmlToPdfConvertFile': // int ret = p.HtmlToPdfConvertFile(htmlPath,pdfPath); // or : // 1. Get HTML content. htmlString = ReadFromFile(htmlPath); // 2. Converting HTML to PDF // Specify BaseUrl to help converter find a full path for relative images, CSS. p.HtmlSettings.BaseUrl = Path.GetDirectoryName(Path.GetFullPath(htmlPath)); byte[] pdfBytes = p.HtmlToPdfConvertStringToByte(htmlString); if (pdfBytes != null) { // 3. Save the PDF document to a file for a viewing purpose. File.WriteAllBytes(pdfPath, pdfBytes); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { System.Console.WriteLine("An error occurred during converting HTML to PDF!"); } } }
private void buttonConvert_Click(object sender, EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); //After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; if (p != null) { string htmlPath = @"..\..\example.htm"; string pdfPath = @"..\..\test.pdf"; string htmlString = ""; // The easiest way is using the method 'HtmlToPdfConvertFile': // int ret = p.HtmlToPdfConvertFile(htmlPath,pdfPath); // or : //1. Get HTML content htmlString = ReadFromFile(htmlPath); //2. Converting HTML to PDF //specify BaseUrl to help converter find a full path for relative images, CSS p.HtmlSettings.BaseUrl = Path.GetDirectoryName(Path.GetFullPath(htmlPath)); byte[] pdfBytes = p.HtmlToPdfConvertStringToByte(htmlString); if (pdfBytes != null) { //3. Save pdfBytes to PDF file File.WriteAllBytes(pdfPath, pdfBytes); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } else { MessageBox.Show("An error occurred during converting HTML to PDF!"); } } }
static void Main(string[] args) { // Activation of PDF Metamorphosis .Net after purchasing SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // Place your serial(s) number. // You will get own serial number(s) after purchasing the license. // If you will have any questions, email us to [email protected] or ask at online chat https://www.sautinsoft.com. p.Serial = "1234567890"; string docxPath = @"..\..\example.docx"; string pdfPath = Path.ChangeExtension(docxPath, ".pdf"); if (p.DocxToPdfConvertFile(docxPath, pdfPath) == 0) { System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pdfPath) { UseShellExecute = true }); } }
protected void Button1_Click(object sender, EventArgs e) { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); // After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; // Let's set page numbers p.PageSettings.Numbering.Text = "Page {page} of {numpages}"; // Set page header within HTML string p.PageSettings.Header.FromString("<table border=\"1\"><tr><td>We added this header using the property \"Header.Html\"</td></tr></table>", SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html); // Add page footer from HTML file p.PageSettings.Footer.FromFile(Path.Combine(Server.MapPath(""), @"footer.htm"), SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html); // Get content of the ASPX page as HTML document string htmlString = GetHtmlFromAspx(Path.Combine(Server.MapPath(""), @"Default.aspx")); p.HtmlSettings.BaseUrl = Server.MapPath(""); byte[] pdfBytes = p.HtmlToPdfConvertStringToByte(htmlString); //show PDF if (pdfBytes != null) { Response.Buffer = true; Response.Clear(); Response.ContentType = "application/PDF"; Response.BinaryWrite(pdfBytes); Response.Flush(); Response.End(); } else { Result.Text = "Converting failed!"; } }
static void Main(string[] args) { //How to add page header and footer SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); //After purchasing the license, please insert your serial number here to activate the component //p.Serial = "XXXXXXXXXXX"; //Let's add page header in HTML format string headerInHtml = "<table width=\"100%\" border=\"1\"><tr><td width=\"50%\" align=\"center\"></td><td>You are welcome!</td></tr></table>"; p.PageSettings.Header.FromString(headerInHtml, SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Html); string footerInRtf = @"{\rtf1\i Italic footer }"; p.PageSettings.Footer.FromString(footerInRtf, SautinSoft.PdfMetamorphosis.HeadersFooters.InputFormat.Rtf); if (p != null) { string inputFile = @"..\..\example.htm"; string outputFile = Path.ChangeExtension(inputFile, ".pdf"); int result = p.HtmlToPdfConvertFile(inputFile, outputFile); if (result == 0) { System.Console.WriteLine("Converted successfully!"); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(outputFile) { UseShellExecute = true }); } else { System.Console.WriteLine("Converting Error!"); } } }
//private string GetSubmitActionUrlText(string AAction, string ATradeId, string ARqmtId, string AConfirmId, // string AFaxTelexInd, string AFaxTelexNumber, string AConfirmLabel, string ARequestId) //{ // string urlText = Properties.Settings.Default.TransmissionGatewayCallbackUrl; // try // { // string addr = ""; // for (int i = 0; i < AFaxTelexNumber.Length; i++) // if (AFaxTelexNumber[i] != ' ') // addr += AFaxTelexNumber[i]; // urlText += "?action=" + AAction; // urlText += "&tradeId=" + ATradeId; // urlText += "&tradeRqmtId=" + ARqmtId; // urlText += "&tradeRqmtConfirmId=" + AConfirmId; // urlText += "&faxTelexInd=" + AFaxTelexInd; // urlText += "&addr=" + addr; // urlText += "&label=" + AConfirmLabel; // //Israel 10/6/2015 // //urlText += "&sender=" + toolbarOrWindowsUserId.ToUpper(); // urlText += "&sender=" + Utils.GetUserNameWithoutDomain(toolbarOrWindowsUserId.ToUpper()); // } // catch (Exception ex) // { // throw new Exception("GetSubmitActionUrlText: " + ex.Message); // } // return urlText; //} //Israel 11/13/2015 -- Removed as part of move to XmitRequest/XmitResult //private void CallInsertToFaxLogSent(long ATradeId, string AFaxTelexInd, string AFaxTelexNumber, // string ADocRefCode) //{ // try // { // FaxLogSentDto faxLogSentDto = new FaxLogSentDto(); // faxLogSentDto.TradeId = Convert.ToInt32(ATradeId); // faxLogSentDto.DocType = DOC_TYPE[(int)DocType.CNF]; // faxLogSentDto.Sender = p_UserId; // FaxCode faxCode; // if (AFaxTelexNumber.IndexOf("@") > -1) // faxCode = FaxCode.EMAIL; // else if (AFaxTelexInd == "F") // faxCode = FaxCode.FAX; // else if (AFaxTelexInd == "T") // faxCode = FaxCode.TELEX; // else // throw new Exception("Internal Exception: Unsupported FaxTelexInd=" + AFaxTelexInd); // faxLogSentDto.FaxTelexCode = FAX_CODE[(int)faxCode]; // faxLogSentDto.FaxTelexNumber = AFaxTelexNumber; // faxLogSentDto.DocRefCode = ADocRefCode; // FaxLogSentDal faxLogSentDal = new FaxLogSentDal(sqlConnectionStr); // faxLogSentDal.Insert(faxLogSentDto); // } // catch (Exception ex) // { // throw new Exception("CallInsertToFaxLogSent: " + ex.Message); // } //} private void SaveRtfAsPdfDoc(string ARtfFileName, string APdfFileName) { try { SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis(); //specify Metamorphosis options p.Serial = PDF_METAMORPHOSIS_SERIAL; p.PageStyle.PageOrientation.Portrait(); //p.TextStyle.Header = @"Sample header"; //p.PageStyle.PageNumFormat = "Page {page} of {numpages}"; if (p != null) { int result = p.RtfToPdfConvertFile(ARtfFileName, APdfFileName); //if (result != 0) //throw new Exception("Pdf conversion error"); } } catch (Exception ex) { XtraMessageBox.Show("An error occurred while saving a confirm RTF document as a PDF using the following values:" + Environment.NewLine + "RTF File Name: " + ARtfFileName + ", PDF File Name: " + APdfFileName + Environment.NewLine + "Error CNF-148 in " + FORM_NAME + ".SaveRtfAsPdfDoc(): " + ex.Message, MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } }