void OnButtonClicked(object sender, EventArgs e) { Stream docStream = typeof(Stamping).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.Product Catalog.pdf"); PdfLoadedDocument ldoc = new PdfLoadedDocument(docStream); PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 100f, PdfFontStyle.Regular); foreach (PdfPageBase lPage in ldoc.Pages) { PdfGraphics g = lPage.Graphics; PdfGraphicsState state = g.Save(); g.TranslateTransform(ldoc.Pages[0].Size.Width / 2, ldoc.Pages[0].Size.Height / 2); g.SetTransparency(0.25f); SizeF waterMarkSize = font.MeasureString("Sample"); g.RotateTransform(-40); g.DrawString("Sample", font, PdfPens.Red, PdfBrushes.Red, new PointF(-waterMarkSize.Width / 2, -waterMarkSize.Height / 2)); g.Restore(state); } MemoryStream stream = new MemoryStream(); ldoc.Save(stream); ldoc.Close(true); if (stream != null) { SaveiOS iosSave = new SaveiOS(); iosSave.Save("Stamping.pdf", "application/pdf", stream); } }
void OnConvertClicked2(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); WordDocument document = new WordDocument(); // Open an existing template document. Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.TrackChangesTemplate.docx"); document.Open(inputStream, FormatType.Docx); inputStream.Dispose(); if (rejectAll != null && (bool)rejectAll.IsChecked) { document.Revisions.RejectAll(); } else { document.Revisions.AcceptAll(); } string fileName = null; string ContentType = null; MemoryStream ms = new MemoryStream(); fileName = "Track Changes.docx"; ContentType = "application/msword"; document.Save(ms, FormatType.Docx); //Reset the stream position ms.Position = 0; //Close the document instance. document.Close(); if (ms != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save(fileName, ContentType, ms as MemoryStream); } }
void OnButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.Images.pptx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); IPresentation presentation = Presentation.Open(fileStream); // Method call to create slides CommentsHelper.SlideWithComments1(presentation); CommentsHelper.SlideWithComments2(presentation); CommentsHelper.SlideWithComments3(presentation); MemoryStream stream = new MemoryStream(); presentation.Save(stream); presentation.Close(); stream.Position = 0; if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("CommentsPresentation.pptx", "application/mspowerpoint", stream); } }
void OnButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.EmbeddedOleObject.pptx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); IPresentation presentation = Presentation.Open(fileStream); //Gets the first slide of the Presentation ISlide slide = presentation.Slides[0]; //Gets the Ole Object of the slide IOleObject oleObject = slide.Shapes[2] as IOleObject; //Gets the file data of embedded Ole Object. byte[] array = oleObject.ObjectData; //Gets the file Name of OLE Object string outputFile = oleObject.FileName; MemoryStream stream = new MemoryStream(array); presentation.Close(); stream.Position = 0; if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save(outputFile, "application/msword", stream); } }
void OnInsertOleButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); //New Instance of PowerPoint is Created.[Equivalent to launching MS PowerPoint with no slides]. IPresentation presentation = Syncfusion.Presentation.Presentation.Create(); ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly); IShape titleShape = slide.Shapes[0] as IShape; titleShape.Left = 0.65 * 72; titleShape.Top = 0.24 * 72; titleShape.Width = 11.5 * 72; titleShape.Height = 1.45 * 72; titleShape.TextBody.AddParagraph("Ole Object"); titleShape.TextBody.Paragraphs[0].Font.Bold = true; titleShape.TextBody.Paragraphs[0].HorizontalAlignment = HorizontalAlignmentType.Left; IShape heading = slide.Shapes.AddTextBox(100, 100, 100, 100); heading.Left = 0.84 * 72; heading.Top = 1.65 * 72; heading.Width = 2.23 * 72; heading.Height = 0.51 * 72; heading.TextBody.AddParagraph("MS Word Object"); heading.TextBody.Paragraphs[0].Font.Italic = true; heading.TextBody.Paragraphs[0].Font.Bold = true; heading.TextBody.Paragraphs[0].Font.FontSize = 18; string mswordPath = "SampleBrowser.Samples.Presentation.Templates.OleTemplate.docx"; //Get the word file as stream Stream wordStream = assembly.GetManifestResourceStream(mswordPath); string imagePath = "SampleBrowser.Samples.Presentation.Templates.OlePicture.png"; //Image to be displayed, This can be any image Stream imageStream = assembly.GetManifestResourceStream(imagePath); IOleObject oleObject = slide.Shapes.AddOleObject(imageStream, "Word.Document.12", wordStream); //Set size and position of the ole object oleObject.Left = 4.53 * 72; oleObject.Top = 0.79 * 72; oleObject.Width = 4.26 * 72; oleObject.Height = 5.92 * 72; //Set DisplayAsIcon as true, to open the embedded document in separate (default) application. oleObject.DisplayAsIcon = true; MemoryStream stream = new MemoryStream(); presentation.Save(stream); presentation.Close(); stream.Position = 0; if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("InsertOLEObject.pptx", "application/mspowerpoint", stream); } }
void OnButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.Template.pptx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); //Open the existing PowerPoint Presentation. IPresentation presentation = Presentation.Open(fileStream); //Convert the PowerPoint document to PDF document. PdfDocument pdfDocument = PresentationToPdfConverter.Convert(presentation); MemoryStream stream = new MemoryStream(); //Save the converted PDF document to MemoryStream. pdfDocument.Save(stream); stream.Position = 0; //Close the PDF document. pdfDocument.Close(true); //Close the PowerPoint Presentation. presentation.Close(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("PPTXToPDF.pdf", "application/pdf", stream); } }
void OnButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); // Creating a new document. WordDocument document = new WordDocument(); Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Letter Formatting.docx"); //Open Template document document.Open(inputStream, FormatType.Word2013); inputStream.Dispose(); List <Customer> source = new List <Customer>(); source.Add(new Customer("ALFKI", "Alfreds Futterkiste", "Maria Anders", "Sales Representative", "Obere Str. 57", "Berlin", "12209", "Germany", "030-0074321", "030-0076545")); //source.Add(new Customer("ANATR", "Ana Trujillo Emparedados y helados", "Ana Trujillo", "Owner", "Avda. de la Constitución 2222", "México D.F.", "05021", "Mexico", "(5) 555-4729", "(5) 555-3745")); document.MailMerge.Execute(source); MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Word2013); document.Close(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("MailMerge.docx", "application/msword", stream); } }
void OnButtonInputClicked(object sender, EventArgs e) { ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; #region Initializing Workbook string resourcePath = "SampleBrowser.Samples.XlsIO.Template.ExportSales.xlsx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); IWorkbook workbook = application.Workbooks.Open(fileStream); IWorksheet sheet = workbook.Worksheets[0]; #endregion workbook.Version = ExcelVersion.Excel2013; MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); excelEngine.Dispose(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("InputTemplate.xlsx", "application/msexcel", stream); } }
void OnButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); // Creating a new document. WordDocument document = new WordDocument(); Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.EmployeesReportDemo.doc"); //Open Template document document.Open(inputStream, FormatType.Word2013); inputStream.Dispose(); System.Data.DataTable table = GetDataTable(); //Uses the mail merge events handler for image fields document.MailMerge.MergeImageField += new MergeImageFieldEventHandler(MergeField_ProductImage); document.MailMerge.ExecuteGroup(table); MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Word2013); document.Close(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("MailMerge.docx", "application/msword", stream); } }
void OnButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Employees.xml"); // Create a new document. WordDocument document = new WordDocument(); //Add a section & a paragraph in the empty document. document.EnsureMinimal(); //Loads XML file into the customXML part of the Word document. CustomXMLPart docIOxmlPart = new CustomXMLPart(document); docIOxmlPart.Load(inputStream); //Insert content controls and maps Employees details to it. InsertAndMapEmployees(document, "EmployeesList", docIOxmlPart); MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Word2013); document.Close(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("XMLMapping.docx", "application/msword", stream); } }
void SaveAndView(MemoryStream stream, string contentType) { if (stream != null) { stream.Position = 0; SaveiOS iOSSave = new SaveiOS(); if (contentType == "application/pdf") { iOSSave.Save("ExcelToPDF.pdf", contentType, stream); } else { iOSSave.Save("Input Template.xlsx", contentType, stream); } } }
void OnButtonClicked(object sender, EventArgs e) { ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; //A new workbook is created.[Equivalent to creating a new workbook in MS Excel] //The new workbook will have 1 worksheets IWorkbook workbook = application.Workbooks.Create(1); //The first worksheet object in the worksheets collection is accessed. IWorksheet worksheet = workbook.Worksheets[0]; worksheet.ImportData((List <Brand>)sfGrid.ItemsSource, 4, 1, true); #region Define Styles IStyle pageHeader = workbook.Styles.Add("PageHeaderStyle"); IStyle tableHeader = workbook.Styles.Add("TableHeaderStyle"); pageHeader.Font.FontName = "Calibri"; pageHeader.Font.Size = 16; pageHeader.Font.Bold = true; pageHeader.Color = Color.FromArgb(0, 146, 208, 80); pageHeader.HorizontalAlignment = ExcelHAlign.HAlignCenter; pageHeader.VerticalAlignment = ExcelVAlign.VAlignCenter; tableHeader.Font.Bold = true; tableHeader.Font.FontName = "Calibri"; tableHeader.Color = Color.FromArgb(0, 146, 208, 80); #endregion #region Apply Styles // Apply style for header worksheet["A1:C2"].Merge(); worksheet["A1"].Text = "Automobile Brands in the US"; worksheet["A1"].CellStyle = pageHeader; worksheet["A4:C4"].CellStyle = tableHeader; worksheet["A1:C1"].CellStyle.Font.Bold = true; worksheet.UsedRange.AutofitColumns(); #endregion workbook.Version = ExcelVersion.Excel2013; MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); excelEngine.Dispose(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("ImportCollectionObjects.xlsx", "application/msexcel", stream); } }
void OnButtonClicked(object sender, EventArgs e) { PdfDocument doc = new PdfDocument(); //Add a page PdfPage page = doc.Pages.Add(); PdfSolidBrush brush = new PdfSolidBrush(Syncfusion.Drawing.Color.Black); PdfPen pen = new PdfPen(Syncfusion.Drawing.Color.Black, 1f); //Create font PdfStandardFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 11.5f); PdfFont heading = new PdfStandardFont(PdfFontFamily.TimesRoman, 12, PdfFontStyle.Bold); font = new PdfStandardFont(PdfFontFamily.Helvetica, 10f); page.Graphics.DrawString("Create, Read, and Edit PDF Files from C#, VB.NET", heading, PdfBrushes.Black, new RectangleF(0, 0, page.GetClientSize().Width, 20), new PdfStringFormat(PdfTextAlignment.Center)); string longText = "The <b> Syncfusion Essential PDF </b> is a feature-rich and high-performance .NET PDF library that allows you to add robust PDF functionalities to any .NET application." + "It allows you to create, read, and edit PDF documents programmatically without Adobe dependencies. This library also offers functionality to <font color='#0000F8'> merge, split, stamp, form-fill, compress, and secure PDF files.</font>" + "<br/><br/><font color='#FF3440'><b>1. Secure your PDF with advanced encryption, digital signatures, and redaction.</b></font>" + "<br/><br/><font color='#FF9E4D'><b>2. Extract text and images from your PDF files.</b></font>" + "<br/><br/><font color='#4F6200'><b>3. Top features: forms, tables, barcodes; stamp, split, and merge PDFs.</b></font>"; //Rendering HtmlText PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(longText, font, brush); // Formatting Layout PdfLayoutFormat format = new PdfLayoutFormat(); format.Layout = PdfLayoutType.OnePage; //Drawing htmlString richTextElement.Draw(page, new RectangleF(0, 20, page.GetClientSize().Width, page.GetClientSize().Height), format); MemoryStream stream = new MemoryStream(); //Save the PDF dcoument. doc.Save(stream); //Close the PDF document. doc.Close(); stream.Position = 0; if (stream != null) { SaveiOS iosSave = new SaveiOS(); iosSave.Save("HtmlTextElement.pdf", "application/pdf", stream); } }
void OnButtonClicked(object sender, EventArgs e) { ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; #region Initializing Workbook //A new workbook is created.[Equivalent to creating a new workbook in MS Excel] //The new workbook will have 1 worksheets IWorkbook workbook = application.Workbooks.Create(1); //The first worksheet object in the worksheets collection is accessed. IWorksheet sheet = workbook.Worksheets[0]; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.XlsIO.Template.customers.xml"); // Import the XML contents to worksheet XlsIOExtensions exten = new XlsIOExtensions(); exten.ImportXML(fileStream, sheet, 1, 1, true); // Apply style for header IStyle headerStyle = sheet[1, 1, 1, sheet.UsedRange.LastColumn].CellStyle; headerStyle.Font.Bold = true; headerStyle.Font.Color = ExcelKnownColors.Brown; headerStyle.Font.Size = 10; // Resize columns sheet.Columns[0].ColumnWidth = 11; sheet.Columns[1].ColumnWidth = 30.5; sheet.Columns[2].ColumnWidth = 20; sheet.Columns[3].ColumnWidth = 25.6; sheet.Columns[6].ColumnWidth = 10.5; sheet.Columns[4].ColumnWidth = 40; sheet.Columns[5].ColumnWidth = 25.5; sheet.Columns[7].ColumnWidth = 9.6; sheet.Columns[8].ColumnWidth = 15; sheet.Columns[9].ColumnWidth = 15; #endregion workbook.Version = ExcelVersion.Excel2013; MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); excelEngine.Dispose(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("ImportXML.xlsx", "application/msexcel", stream); } }
void OnConvertClicked(object sender, EventArgs e) { //Instantiate excel engine ExcelEngine excelEngine = new ExcelEngine(); //Excel application IApplication application = excelEngine.Excel; #region Initializing Workbook //Load the input template from assembly. string resourcePath = "SampleBrowser.Samples.XlsIO.Template.ExpenseReport.xlsx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); //Open workbook IWorkbook workbook = application.Workbooks.Open(fileStream); //The first worksheet object in the worksheets collection is accessed. IWorksheet sheet = workbook.Worksheets[0]; #endregion //Create a new memory stream to store the generated image. MemoryStream stream = new MemoryStream(); //Initialize XlsIORenderer. application.XlsIORenderer = new XlsIORenderer(); ExportImageOptions imageOptions = new ExportImageOptions(); string fileName = null; string ContentType = null; if (jpegButton != null && (bool)jpegButton.IsChecked) { imageOptions.ImageFormat = ExportImageFormat.Jpeg; fileName = "Image.jpeg"; ContentType = "image/jpeg"; } else { imageOptions.ImageFormat = ExportImageFormat.Png; fileName = "Image.png"; ContentType = "image/png"; } //Convert to image sheet.ConvertToImage(sheet.UsedRange, imageOptions, stream); stream.Position = 0; if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save(fileName, ContentType, stream); } }
void OnButtonClicked(object sender, EventArgs e) { MemoryStream stream = new MemoryStream(); //Opens the existing presentation stream. using (IPresentation presentation = Syncfusion.Presentation.Presentation.Create()) { ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly); IParagraph paragraph = ((IShape)slide.Shapes[0]).TextBody.Paragraphs.Add(); //Apply center alignment to the paragraph paragraph.HorizontalAlignment = HorizontalAlignmentType.Center; //Add slide title ITextPart textPart = paragraph.AddTextPart("Northwind Management Report"); textPart.Font.Color = ColorObject.FromArgb(46, 116, 181); //Get chart data from xml file List <ProductDetails> Products = LoadXMLData(); //Add a new chart to the presentation slide IPresentationChart chart = slide.Charts.AddChart(44.64, 133.2, 870.48, 380.16); //Set chart type chart.ChartType = OfficeChartType.Pie; //Set chart title chart.ChartTitle = "Best Selling Products"; //Set chart properties font name and size chart.ChartTitleArea.FontName = "Calibri (Body)"; chart.ChartTitleArea.Size = 14; for (int i = 0; i < Products.Count; i++) { ProductDetails product = Products[i]; chart.ChartData.SetValue(i + 2, 1, product.ProductName); chart.ChartData.SetValue(i + 2, 2, product.Sum); } //Create a new chart series with the name “Sales” AddSeriesForChart(chart); //Setting the font size of the legend. chart.Legend.TextArea.Size = 14; //Setting background color chart.ChartArea.Fill.ForeColor = Syncfusion.Drawing.Color.FromArgb(242, 242, 242); chart.PlotArea.Fill.ForeColor = Syncfusion.Drawing.Color.FromArgb(242, 242, 242); chart.ChartArea.Border.LinePattern = OfficeChartLinePattern.None; chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 11, 1]; //Saves the presentation instance to the stream. presentation.Save(stream); } stream.Position = 0; if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("ChartsPresentation.pptx", "application/mspowerpoint", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Create a new PDF document PdfDocument document = new PdfDocument(); //Add a page PdfPage page = document.Pages.Add(); //Create font Stream arialFontStream = typeof(RTLSupport).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.arial.ttf"); PdfFont font = new PdfTrueTypeFont(arialFontStream, 14); //Read the text from text file Stream rtlText = typeof(RTLSupport).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.arabic.txt"); StreamReader reader = new StreamReader(rtlText, System.Text.Encoding.Unicode); string text = reader.ReadToEnd(); reader.Dispose(); //Create a brush PdfBrush brush = new PdfSolidBrush(new PdfColor(0, 0, 0)); PdfPen pen = new PdfPen(new PdfColor(0, 0, 0)); SizeF clipBounds = page.Graphics.ClientSize; RectangleF rect = new RectangleF(0, 0, clipBounds.Width, clipBounds.Height); //Set the property for RTL text PdfStringFormat format = new PdfStringFormat(); format.TextDirection = PdfTextDirection.RightToLeft; format.Alignment = PdfTextAlignment.Right; format.ParagraphIndent = 35f; //Draw text. page.Graphics.DrawString(text, font, brush, rect, format); MemoryStream stream = new MemoryStream(); //Save the PDF dcoument. document.Save(stream); //Close the PDF document. document.Close(); stream.Position = 0; if (stream != null) { SaveiOS iosSave = new SaveiOS(); iosSave.Save("RTLText.pdf", "application/pdf", stream); } }
void OnButtonClicked(object sender, EventArgs e) { // Create a new instance of PdfDocument class. PdfDocument document = new PdfDocument(); // Add a new page to the newly created document. PdfPage page = document.Pages.Add(); PdfStandardFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 12, PdfFontStyle.Bold); PdfGraphics g = page.Graphics; g.DrawString("JPEG Image", font, PdfBrushes.Blue, new Syncfusion.Drawing.PointF(0, 40)); //Load JPEG image to stream. Stream jpgImageStream = typeof(ImageInsertion).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.Xamarin_JPEG.jpg"); //Load the JPEG image PdfImage jpgImage = new PdfBitmap(jpgImageStream); //Draw the JPEG image g.DrawImage(jpgImage, new Syncfusion.Drawing.RectangleF(0, 70, 515, 215)); g.DrawString("PNG Image", font, PdfBrushes.Blue, new Syncfusion.Drawing.PointF(0, 355)); //Load PNG image to stream. Stream pngImageStream = typeof(ImageInsertion).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.Xamarin_PNG.png"); //Load the PNG image PdfImage pngImage = new PdfBitmap(pngImageStream); //Draw the PNG image g.DrawImage(pngImage, new Syncfusion.Drawing.RectangleF(0, 365, 199, 300)); MemoryStream stream = new MemoryStream(); //Save the PDF document document.Save(stream); stream.Position = 0; //Close the PDF document document.Close(true); if (stream != null) { SaveiOS iosSave = new SaveiOS(); iosSave.Save("ImageInsertion.pdf", "application/pdf", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Create a new PDF document PdfDocument document = new PdfDocument(PdfConformanceLevel.Pdf_A1B); //Add a page PdfPage page = document.Pages.Add(); //Create font Stream arialFontStream = typeof(Conformance).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.arial.ttf"); PdfFont font = new PdfTrueTypeFont(arialFontStream, 14); //Text to draw string text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; //Create a brush PdfBrush brush = new PdfSolidBrush(new PdfColor(0, 0, 0)); PdfPen pen = new PdfPen(new PdfColor(0, 0, 0)); SizeF clipBounds = page.Graphics.ClientSize; RectangleF rect = new RectangleF(0, 0, clipBounds.Width, clipBounds.Height); //Set the property for text PdfStringFormat format = new PdfStringFormat(); format.Alignment = PdfTextAlignment.Justify; format.ParagraphIndent = 35f; //Draw text. page.Graphics.DrawString(text, font, brush, rect, format); MemoryStream stream = new MemoryStream(); //Save the PDF dcoument. document.Save(stream); //Close the PDF document. document.Close(); stream.Position = 0; if (stream != null) { SaveiOS iosSave = new SaveiOS(); iosSave.Save("PDF_A1b.pdf", "application/pdf", stream); } }
void OnButtonInputClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.XlsIO.Template.ExportSales.xlsx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); MemoryStream stream = new MemoryStream(); fileStream.CopyTo(stream); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("InputTemplate.xlsx", "application/msexcel", stream); } }
void OnButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); // Creating a new document. WordDocument document = new WordDocument(); Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Template_Letter.doc"); //Open Template document document.Open(inputStream, FormatType.Word2013); inputStream.Dispose(); inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.Employees.xml"); DataSet ds = new DataSet(); ds.ReadXml(inputStream); ArrayList commands = new ArrayList(); //DictionaryEntry contain "Source table" (KEY) and "Command" (VALUE) DictionaryEntry entry = new DictionaryEntry("Employees", string.Empty); commands.Add(entry); // To retrive customer details System.Data.DataTable table = ds.Tables["Customers"]; string relation = table.ParentRelations[0].ChildColumns[0].ColumnName + " = %Employees." + table.ParentRelations[0].ParentColumns[0].ColumnName + "%"; entry = new DictionaryEntry("Customers", relation); commands.Add(entry); // To retrieve order details table = ds.Tables["Orders"]; relation = table.ParentRelations[0].ChildColumns[0].ColumnName + " = %Customers." + table.ParentRelations[0].ParentColumns[0].ColumnName + "%"; entry = new DictionaryEntry("Orders", relation); commands.Add(entry); //Executes nested Mail merge using explicit relational data. document.MailMerge.ExecuteNestedGroup(ds, commands); MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Word2013); document.Close(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("MailMerge.docx", "application/msword", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Stream to save the created PowerPoint presnetation MemoryStream stream = new MemoryStream(); //Creates a new instance of the presentation. using (IPresentation presentation = Syncfusion.Presentation.Presentation.Create()) { #region Slide1 //To add a slide to PowerPoint presentation ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly); //To set the table title in a slide SetTableTitle(slide); //To get the table data from an XML file Dictionary <string, Dictionary <string, string> > products = LoadXMLData(); int columnCount = products.Keys.Count + 1; int rowCount = products[products.Keys.ToArray()[0]].Count + 1; //To add a new table in slide. ITable table = slide.Shapes.AddTable(rowCount, columnCount, 61.92, 95.76, 856.8, 378.72); //To set the style for the table. table.BuiltInStyle = BuiltInTableStyle.MediumStyle2Accent6; //To set category title SetCategoryTitle(table); //Iterates and sets the values to the table cells. for (int rowIndex = 0; rowIndex < table.Rows.Count; rowIndex++) { IRow row = table.Rows[rowIndex]; Dictionary <string, string> months = products[products.Keys.ToArray()[0]]; string[] monthName = months.Keys.ToArray(); for (int cellIndex = 0; cellIndex < row.Cells.Count - 1; cellIndex++) { months = products[products.Keys.ToArray()[cellIndex]]; AddHeaderRowAndColumn(row, cellIndex, products.Keys.ToArray(), rowIndex, monthName); AddCellContent(row, rowIndex, monthName, months, cellIndex); } } #endregion //Save the presentation instance to the memory stream. presentation.Save(stream); } stream.Position = 0; if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("TablesPresentation.pptx", "application/mspowerpoint", stream); } }
void OnInpTemplateButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.DocIO.Templates.WordtoPDF.docx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); MemoryStream stream = new MemoryStream(); fileStream.CopyTo(stream); stream.Position = 0; fileStream.Dispose(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("WordtoPDF.docx", "application/msword", stream); } }
void OnInpTemplateButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.ShapeWithAnimation.pptx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); MemoryStream stream = new MemoryStream(); fileStream.CopyTo(stream); stream.Position = 0; fileStream.Dispose(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("InputTemplate.pptx", "application/mspowerpoint", stream); } }
void OnConvertClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.Template.pptx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); //Open the existing PowerPoint Presentation. IPresentation presentation = Presentation.Open(fileStream); //Initialize PresentationRenderer to perform image conversion. presentation.PresentationRenderer = new PresentationRenderer(); string fileName = null; string ContentType = null; Syncfusion.Presentation.ExportImageFormat imageFormat; if (jpegButton != null && (bool)jpegButton.IsChecked) { imageFormat = ExportImageFormat.Jpeg; fileName = "Image.jpeg"; ContentType = "image/jpeg"; } else { imageFormat = ExportImageFormat.Png; fileName = "Image.png"; ContentType = "image/png"; } //Convert PowerPoint slide to image. Stream stream = presentation.Slides[0].ConvertToImage(imageFormat); //Reset the stream position stream.Position = 0; //Close the PowerPoint Presentation. presentation.Close(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save(fileName, ContentType, stream as MemoryStream); } }
void OnButtonClicked(object sender, EventArgs e) { Stream docStream = typeof(Booklet).GetTypeInfo().Assembly.GetManifestResourceStream("SampleBrowser.Samples.PDF.Assets.JavaScript Succinctly.pdf"); PdfLoadedDocument ldoc = new PdfLoadedDocument(docStream); float width = 1224; float height = 792; PdfDocument document = PdfBookletCreator.CreateBooklet(ldoc, new Syncfusion.Drawing.SizeF(width, height), true); MemoryStream stream = new MemoryStream(); document.Save(stream); document.Close(true); if (stream != null) { SaveiOS iosSave = new SaveiOS(); iosSave.Save("Booklet.pdf", "application/pdf", stream); } }
void OnButtonClicked(object sender, EventArgs e) { ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; #region Initializing Workbook string resourcePath = "SampleBrowser.Samples.XlsIO.Template.ChartData.xlsx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); IWorkbook workbook = application.Workbooks.Open(fileStream); //The first worksheet object in the worksheets collection is accessed. IWorksheet sheet = workbook.Worksheets[0]; #endregion #region Generate Chart IChartShape chart = sheet.Charts.Add(); chart.DataRange = sheet["A16:E26"]; chart.ChartTitle = sheet["A15"].Text; chart.HasLegend = false; chart.TopRow = 3; chart.LeftColumn = 1; chart.RightColumn = 6; chart.BottomRow = 15; #endregion workbook.Version = ExcelVersion.Excel2013; MemoryStream stream = new MemoryStream(); workbook.SaveAs(stream); workbook.Close(); excelEngine.Dispose(); if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("Charts.xlsx", "application/msexcel", stream); } }
void OnButtonClicked(object sender, EventArgs e) { string resourcePath = "SampleBrowser.Samples.Presentation.Templates.HeaderFooter.pptx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); //Create an instance for PowerPoint IPresentation presentation = Presentation.Open(fileStream); //Add footers into all the PowerPoint slides. foreach (ISlide slide in presentation.Slides) { //Enable a date and time footer in slide. slide.HeadersFooters.DateAndTime.Visible = true; //Enable a footer in slide. slide.HeadersFooters.Footer.Visible = true; //Sets the footer text. slide.HeadersFooters.Footer.Text = "Footer"; //Enable a slide number footer in slide. slide.HeadersFooters.SlideNumber.Visible = true; } //Add header into first slide notes page. //Add a notes slide to the slide. INotesSlide notesSlide = presentation.Slides[0].AddNotesSlide(); //Enable a header in notes slide. notesSlide.HeadersFooters.Header.Visible = true; //Sets the header text. notesSlide.HeadersFooters.Header.Text = "Header"; MemoryStream stream = new MemoryStream(); presentation.Save(stream); presentation.Close(); stream.Position = 0; if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("HeaderFooterPresentation.pptx", "application/mspowerpoint", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Load the input template from assembly. string resourcePath = "SampleBrowser.Samples.Presentation.Templates.Template.pptx"; Assembly assembly = Assembly.GetExecutingAssembly(); Stream fileStream = assembly.GetManifestResourceStream(resourcePath); //Create a new memory stream. MemoryStream stream = new MemoryStream(); //Copy input template to newly created memory stream. fileStream.CopyTo(stream); stream.Position = 0; if (stream != null) { SaveiOS iOSSave = new SaveiOS(); iOSSave.Save("Template.pptx", "application/mspowerpoint", stream); } }
void OnButtonClicked(object sender, EventArgs e) { //Create ZugFerd invoice PDF PdfDocument document = new PdfDocument(PdfConformanceLevel.Pdf_A3B); document.ZugferdVersion = ZugferdVersion.ZugferdVersion2_0; document.ZugferdConformanceLevel = ZugferdConformanceLevel.Extended; CreateZugFerdInvoicePDF(document); //Create ZugFerd Xml attachment file Stream zugferdXmlStream = CreateZugFerdXML(); //Creates an attachment. PdfAttachment attachment = new PdfAttachment("ZUGFeRD-invoice.xml", zugferdXmlStream); attachment.Relationship = PdfAttachmentRelationship.Alternative; attachment.ModificationDate = DateTime.Now; attachment.Description = "Adventure Invoice"; attachment.MimeType = "application/xml"; document.Attachments.Add(attachment); MemoryStream stream = new MemoryStream(); //Save the PDF document. document.Save(stream); //Close the PDF document. document.Close(); stream.Position = 0; if (stream != null) { SaveiOS iosSave = new SaveiOS(); iosSave.Save("ZugFerd.pdf", "application/pdf", stream); } }