public static void Run() { // ExStart:SVGToPDF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion(); // Instantiate Pdf object Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Bind the source SVG file pdf.BindSvg( dataDir + "SVGToPDF.svg"); // Save the resultant PDF document pdf.Save(dataDir + @"SVGToPDF_out.pdf"); // ExEnd:SVGToPDF }
public static void Run() { // ExStart:SVGToPDF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion(); // Instantiate Pdf object Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Bind the source SVG file pdf.BindSvg(dataDir + "SVGToPDF.svg"); // Save the resultant PDF document pdf.Save(dataDir + @"SVGToPDF_out_.pdf"); // ExEnd:SVGToPDF }
public static void Run() { // ExStart:HTMLToPDF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion(); // Instantiate an object PDF class Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Add the section to PDF document sections collection Aspose.Pdf.Generator.Section section = pdf.Sections.Add(); // Read the contents of HTML file into StreamReader object StreamReader r = File.OpenText(dataDir + "resultant.html"); // Create text paragraphs containing HTML text Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd()); // Enable the property to display HTML contents within their own formatting text2.IsHtmlTagSupported = true; // ExStart:OverwriteFontNames text2.IfHtmlTagSupportedOverwriteHtmlFontNames = true; text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = true; // ExEnd:OverwriteFontNames // Add the text paragraphs containing HTML text to the section section.Paragraphs.Add(text2); // Specify the URL which serves as images database pdf.HtmlInfo.ImgUrl = dataDir; // ExStart:SpecialCharacters // Following properties are added from Aspose.Pdf for .NET 8.4.0 pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.TreatAsPlainText; pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = true; // ExEnd:SpecialCharacters // Save the Pdf document pdf.Save(dataDir + "HTML2pdf_out.pdf"); // ExEnd:HTMLToPDF }
public static void Run() { // ExStart:HTMLToPDF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion(); // Instantiate an object PDF class Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Add the section to PDF document sections collection Aspose.Pdf.Generator.Section section = pdf.Sections.Add(); // Read the contents of HTML file into StreamReader object StreamReader r = File.OpenText(dataDir + "resultant.html"); // Create text paragraphs containing HTML text Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd()); // Enable the property to display HTML contents within their own formatting text2.IsHtmlTagSupported = true; // ExStart:OverwriteFontNames text2.IfHtmlTagSupportedOverwriteHtmlFontNames = true; text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = true; // ExEnd:OverwriteFontNames // Add the text paragraphs containing HTML text to the section section.Paragraphs.Add(text2); // Specify the URL which serves as images database pdf.HtmlInfo.ImgUrl = dataDir; // ExStart:SpecialCharacters // Following properties are added from Aspose.Pdf for .NET 8.4.0 pdf.HtmlInfo.BadHtmlHandlingStrategy = BadHtmlHandlingStrategy.TreatAsPlainText; pdf.HtmlInfo.ShowUnknownHtmlTagsAsText = true; // ExEnd:SpecialCharacters // Save the Pdf document pdf.Save(dataDir + "HTML2pdf_out_.pdf"); // ExEnd:HTMLToPDF }
public static void Run() { // ExStart:HTMLToPDFUsingStream // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion(); // Instantiate Pdf object Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Specify the Character encoding for HTML file pdf.HtmlInfo.CharSet = "UTF-8"; pdf.HtmlInfo.CharsetApplyingLevelOfForce = HtmlInfo.CharsetApplyingForceLevel.UseWhenImpossibleDetectFromContent; // Load the HTML file to Stream object using (Stream htmlAsStream = System.IO.File.OpenRead(dataDir + "resultant.html")) { // Bind the source HTML pdf.BindHTML(htmlAsStream, ""); } // Save the PDF file pdf.Save(dataDir + "HTMLToPDFUsingStream_out.pdf"); // ExEnd:HTMLToPDFUsingStream }
public static void Run() { // ExStart:HTMLToPDFUsingStream // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_Conversion(); // Instantiate Pdf object Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Specify the Character encoding for HTML file pdf.HtmlInfo.CharSet = "UTF-8"; pdf.HtmlInfo.CharsetApplyingLevelOfForce = HtmlInfo.CharsetApplyingForceLevel.UseWhenImpossibleDetectFromContent; // Load the HTML file to Stream object using (Stream htmlAsStream = System.IO.File.OpenRead(dataDir + "resultant.html")) { // Bind the source HTML pdf.BindHTML(htmlAsStream, ""); } // Save the PDF file pdf.Save(dataDir + "HTMLToPDFUsingStream_out.pdf"); // ExEnd:HTMLToPDFUsingStream }
public static void Run() { // ExStart:AddTableOfContents // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures(); // Create a PDF instance Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Create a list section Aspose.Pdf.Generator.ListSection tocSection = new Aspose.Pdf.Generator.ListSection("Table Of Contents"); // Set its list type as table of contents tocSection.ListType = ListType.TableOfContents; // Add the list section to the sections collection of the Pdf document pdf.Sections.Add(tocSection); // Define the format of the four levels list by setting the left margins and // Text format settings of each level tocSection.ListFormatArray.Length = 4; tocSection.ListFormatArray[0].LeftMargin = 0; tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true; tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true; tocSection.ListFormatArray[1].LeftMargin = 10; tocSection.ListFormatArray[1].TextInfo.IsUnderline = true; tocSection.ListFormatArray[1].TextInfo.FontSize = 10; tocSection.ListFormatArray[2].LeftMargin = 20; tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true; tocSection.ListFormatArray[3].LeftMargin = 30; tocSection.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true; // Create a section in the Pdf document Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add(); // Add four headings in the section for (int Level = 1; Level < 5; Level++) { Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level); Segment segment1 = new Segment(heading1); heading1.Segments.Add(segment1); heading1.IsAutoSequence = true; segment1.Content = "this is heading of level "; segment1.Content += Level.ToString(); // Add the heading into Table Of Contents. heading1.IsInList = true; // Heading2.TOC = tocSection; sec1.Paragraphs.Add(heading1); } // Create a list section ListSection tocSection2 = new ListSection("Second Table Of Contents"); // Set its list type as table of of contents tocSection2.ListType = ListType.TableOfContents; // Add the list section to the sections collection of the Pdf document pdf.Sections.Add(tocSection2); // Define the format of the four levels list by setting the left margins and // Text format settings of each level tocSection2.ListFormatArray.Length = 4; tocSection2.ListFormatArray[0].LeftMargin = 0; tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true; tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true; tocSection2.ListFormatArray[1].LeftMargin = 10; tocSection2.ListFormatArray[1].TextInfo.IsUnderline = true; tocSection2.ListFormatArray[1].TextInfo.FontSize = 10; tocSection2.ListFormatArray[2].LeftMargin = 20; tocSection2.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true; tocSection2.ListFormatArray[3].LeftMargin = 30; tocSection2.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true; // Create a section in the Pdf document Aspose.Pdf.Generator.Section sec2 = pdf.Sections.Add(); // Add four headings in the section for (int Level = 1; Level < 5; Level++) { Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level); Segment segment2 = new Segment(heading2); heading2.Segments.Add(segment2); heading2.IsAutoSequence = true; segment2.Content = "this is heading of level "; segment2.Content += Level.ToString(); // Add the heading into Table Of Contents. heading2.IsInList = true; // Add the heading elements to second ListSection heading2.TOC = tocSection2; // Add the heading obejct to paragraphs colelction of section2 sec2.Paragraphs.Add(heading2); } dataDir = dataDir + "Multiple_TOC_out.pdf"; // Save the resultant PDF document pdf.Save(dataDir); // ExEnd:AddTableOfContents }
protected void btnProcess_Click(object sender, EventArgs e) { Aspose.Pdf.Generator.Pdf pdf = GetCatalog(); pdf.Save("catalog.pdf", SaveType.OpenInAcrobat, Response); Response.End(); }
/// <summary> /// Creates a pdf representation for a convict and saves it to the output stream /// </summary> /// <param name="convict">The input data that is to be rendered</param> /// <param name="output">An output stream to hold the resulting pdf.This stream's disposal should be managed externaly</param> public void CreatePdf(Convict convict, Stream output) { var pdf = new Aspose.Pdf.Generator.Pdf(); RenderConvictToPdf(convict,pdf); pdf.Save(output); }
protected void btnProcess_Click(object sender, EventArgs e) { Aspose.Pdf.Generator.Pdf pdf = GetProductsByCategory(); pdf.Save("productsbycategory.pdf", SaveType.OpenInAcrobat, Response); Response.End(); }
public static void Run() { // ExStart:AddTableOfContents // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfGenerator_UtilityFeatures(); // Create a PDF instance Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf(); // Create a list section Aspose.Pdf.Generator.ListSection tocSection = new Aspose.Pdf.Generator.ListSection("Table Of Contents"); // Set its list type as table of contents tocSection.ListType = ListType.TableOfContents; // Add the list section to the sections collection of the Pdf document pdf.Sections.Add(tocSection); // Define the format of the four levels list by setting the left margins and // Text format settings of each level tocSection.ListFormatArray.Length = 4; tocSection.ListFormatArray[0].LeftMargin = 0; tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true; tocSection.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true; tocSection.ListFormatArray[1].LeftMargin = 10; tocSection.ListFormatArray[1].TextInfo.IsUnderline = true; tocSection.ListFormatArray[1].TextInfo.FontSize = 10; tocSection.ListFormatArray[2].LeftMargin = 20; tocSection.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true; tocSection.ListFormatArray[3].LeftMargin = 30; tocSection.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true; // Create a section in the Pdf document Aspose.Pdf.Generator.Section sec1 = pdf.Sections.Add(); // Add four headings in the section for (int Level = 1; Level < 5; Level++) { Aspose.Pdf.Generator.Heading heading1 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level); Segment segment1 = new Segment(heading1); heading1.Segments.Add(segment1); heading1.IsAutoSequence = true; segment1.Content = "this is heading of level "; segment1.Content += Level.ToString(); // Add the heading into Table Of Contents. heading1.IsInList = true; // Heading2.TOC = tocSection; sec1.Paragraphs.Add(heading1); } // Create a list section ListSection tocSection2 = new ListSection("Second Table Of Contents"); // Set its list type as table of of contents tocSection2.ListType = ListType.TableOfContents; // Add the list section to the sections collection of the Pdf document pdf.Sections.Add(tocSection2); // Define the format of the four levels list by setting the left margins and // Text format settings of each level tocSection2.ListFormatArray.Length = 4; tocSection2.ListFormatArray[0].LeftMargin = 0; tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontBold = true; tocSection2.ListFormatArray[0].TextInfo.IsTrueTypeFontItalic = true; tocSection2.ListFormatArray[1].LeftMargin = 10; tocSection2.ListFormatArray[1].TextInfo.IsUnderline = true; tocSection2.ListFormatArray[1].TextInfo.FontSize = 10; tocSection2.ListFormatArray[2].LeftMargin = 20; tocSection2.ListFormatArray[2].TextInfo.IsTrueTypeFontBold = true; tocSection2.ListFormatArray[3].LeftMargin = 30; tocSection2.ListFormatArray[3].TextInfo.IsTrueTypeFontBold = true; // Create a section in the Pdf document Aspose.Pdf.Generator.Section sec2 = pdf.Sections.Add(); // Add four headings in the section for (int Level = 1; Level < 5; Level++) { Aspose.Pdf.Generator.Heading heading2 = new Aspose.Pdf.Generator.Heading(pdf, sec1, Level); Segment segment2 = new Segment(heading2); heading2.Segments.Add(segment2); heading2.IsAutoSequence = true; segment2.Content = "this is heading of level "; segment2.Content += Level.ToString(); // Add the heading into Table Of Contents. heading2.IsInList = true; // Add the heading elements to second ListSection heading2.TOC = tocSection2; // Add the heading obejct to paragraphs colelction of section2 sec2.Paragraphs.Add(heading2); } dataDir = dataDir + "Multiple_TOC_out.pdf"; // Save the resultant PDF document pdf.Save(dataDir); // ExEnd:AddTableOfContents }
/// <summary> /// // generate pdf with using html text and replace with required fields in mailMerge document /// </summary> /// <param name="bodyText"></param> private void GeneratePdf(string bodyText) { dt = (DataTable)Session["CsvDataTable"]; for (int i = 0; i < dt.Rows.Count; i++) { bodyText = bodyText.Replace("Contact Person Name", dt.Rows[i][0].ToString()); FilePath = Server.MapPath("~/uploads"); Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf(); Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add(); Text title = new Text(bodyText); var info = new TextInfo(); info.FontSize = 12; //info.IsTrueTypeFontBold = true; title.TextInfo = info; title.IsHtmlTagSupported = true; sec1.Paragraphs.Add(title); pdf1.Save(FilePath + "\\pdf\\" + dt.Rows[i][0].ToString() + ".pdf"); bodyText = mailMergeHtml.Text; } }
protected void btnProcess_Click(object sender, EventArgs e) { Aspose.Pdf.Generator.Pdf pdf = GetCustomerLabels(); pdf.Save("customerlabels.pdf", SaveType.OpenInAcrobat, Response); Response.End(); }