1. Tag Results
convert (19)
1 - 19 of 19
Convert Excel to PDF with Azure function in .NET standard application.
Syncfusion&reg; Excel (XlsIO) library is a .NET Excel Library used to create, read, and edit Excel documents. Using this library, you can convert Excel documents into PDF in Azure functions. Steps to convert Excel to PDF with Azure functions in a .NET Standard application programmatically: Step 1: Create a new Azure function project. Create a new Azure function project Step 2: Select framework Azure Functions v2 (.NET Standard) and select HTTP trigger as follows. Select framework and HTTP trigger Step 3: Install the Syncfusion.XlsIORenderer.Net.Core NuGet package as a reference to your .NET Standard applications from NuGet.org. Install NuGet package Step 4: Include the following namespaces in the Function1.cs file. C# using System.IO; using Syncfusion.XlsIO; using Syncfusion.XlsIORenderer; using Syncfusion.Pdf; using System.Net.Http.Headers;   Step 5: Add the following code snippet to open and modify Excel document in Azure functions and return the output document to client end. C# [FunctionName("Function1")]public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log){    Stream stream = req.Content.ReadAsStreamAsync().Result;    // Instantiate the spreadsheet creation engine    using (ExcelEngine excelEngine = new ExcelEngine())    {        // Instantiate the Excel application object        IApplication application = excelEngine.Excel;        // Assign default application version        application.DefaultVersion = ExcelVersion.Excel2013;        IWorkbook workbook = application.Workbooks.Open(stream);        // Access a worksheet from the workbook        IWorksheet worksheet = workbook.Worksheets[0];        // Open the Excel document to convert        XlsIORenderer renderer = new XlsIORenderer();        // Initialize PDF document        PdfDocument pdfDocument = new PdfDocument();        // Convert Excel document into PDF document        pdfDocument = renderer.ConvertToPDF(workbook);        MemoryStream memoryStream = new MemoryStream();        // Save the PDF file        pdfDocument.Save(memoryStream);        // Create the response to return        HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);        // Set the PDF document content response        response.Content = new ByteArrayContent(memoryStream.ToArray());        // Set the content disposition as attachment        response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")        {            FileName = "Output.pdf"        };        // Set the content type as PDF format MIME type        response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");        // Return the response with output PDF stream        return response;    }} Step 6: Right-click the project and select Publish. Then, create a new profile in the Publish Window. Publish window Step 7: Create App service using Azure subscription and select a hosting plan. Create App Service Note:Syncfusion&reg; XlsIO library will work from basic hosting plan (B1). So, select the hosing plan as needed. Syncfusion XlsIO library will not work if the hosting plan is Consumption.   Configure Hosting Plan Step 8: After creating the profile, click the Publish button. Publish Step 9: Now, go to the Azure portal and select the App Services. After running the service, click Get function URL by copying it. Then, paste it into the below client sample (which will request the Azure Function to convert Excel to PDF with Azure functions). You will get the PDF document as shown below. Output PDF document A complete Azure function sample can be downloaded from Convert ExcelToPDF from Azure Function.zip. Steps to post the request to Azure function with template Excel document: Create a simple console application to request the Azure function API. Add the following code snippet into the Main method to request the Azure function with a template Excel document and get the converted PDF document. C# // Open the required template Excel fileStream fileStream = File.Open("../../Data/Input.xlsx", FileMode.Open);// Create a memory stream to save the templateMemoryStream inputStream = new MemoryStream();// Copy the file stream into memory streamfileStream.CopyTo(inputStream);// Dispose of the file streamfileStream.Dispose();try{    // Create HttpWebRequest with hosted Azure function URL    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("Your Azure function URL");    // Set request method as POST    req.Method = "POST";    // Get the request stream to store the Excel document stream    Stream stream = req.GetRequestStream();    // Write the Excel document stream into the request stream    stream.Write(inputStream.ToArray(), 0, inputStream.ToArray().Length);    // Get the response from the Azure Function request    HttpWebResponse res = (HttpWebResponse)req.GetResponse();    // Create file stream to save the output PDF file    FileStream outStream = File.Create("Sample.pdf");    // Copy the response stream into the file stream    res.GetResponseStream().CopyTo(outStream);    // Dispose of the input stream    inputStream.Dispose();    // Dispose of the file stream    outStream.Dispose();}catch (Exception ex){    throw;}// Launch the output documentSystem.Diagnostics.Process.Start("Sample.pdf"); The console application can be downloaded from DownloadConvertedPDF.zip.Know more about the Essential&reg; (XlsIO) library through the documentation, where you can find features like charts , drawing objects, chart to image conversion and worksheet to image conversion etc. with respective code examples.Refer here to explore the rich set of Syncfusion&reg; Excel (XlsIO) library features. Note:Starting with v16.2.0.x, if you reference Syncfusion&reg; assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion&reg; license key in your application to use the components without a trial message.ConclusionI hope you enjoyed learning about how to convert Excel document to PDF with Azure function in .NET Standard.You can refer to our ASP.NET Core XIsIO feature tour page to know about its other groundbreaking feature representations documentationand how to quickly get started for configuration specifications.  You can also explore our ASP.NET Core XIsIO example to understand how to create and manipulate data. For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!  
How to save signature as a byte array in Xamarin.Forms Signature Pad
Step 1: Create a SfSignaturePad sample that includes all required assemblies.   Please refer to the following link to create a simple SignaturePad sample along with the ways to configure it. https://help.syncfusion.com/xamarin/signaturepad/overview   Step 2: Create a simple SignaturePad sample using the following code snippet.   XAML:   <?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"              xmlns:d="http://xamarin.com/schemas/2014/forms/design"              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"             mc:Ignorable="d"              xmlns:signature="clr-namespace:Syncfusion.XForms.SignaturePad;assembly=Syncfusion.SfSignaturePad.XForms"              x:Class="SignaturePadSample.MainPage">       <StackLayout>         <Label Text="Input Your Signature"/>         <Frame>             <signature:SfSignaturePad  x:Name="signature"                                       HeightRequest="250"/>         </Frame>         <Button Text="ConvertSourceToBytes" Clicked="Button_Clicked"/>     </StackLayout> </ContentPage>   Step 3: You can convert the saved SignaturePad bitmap format to byte arrays as shown in the following code sample.   XAML.cs: using SkiaSharp; using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms;   namespace SignaturePadSample {     [DesignTimeVisible(false)]     public partial class MainPage : ContentPage     {         public MainPage()         {             InitializeComponent();         }           private void Button_Clicked(object sender, EventArgs e)         {             signature.Save();             StreamImageSource streamImageSource = (StreamImageSource)signature.ImageSource;             System.Threading.CancellationToken cancellationToken =             System.Threading.CancellationToken.None;             Task<Stream> task = streamImageSource.Stream(cancellationToken);             Stream stream = task.Result;             byte[] bytes = new byte[stream.Length];             stream.Read(bytes, 0, bytes.Length);         }     } }   View Sample in GitHub
How to bind online JSON data to Xamarin.Forms ListView (SfListView)
You can fetch data from a web server and store it on a local server for Xamarin.Forms SfListView. You can refer to the document regarding offline JSON with ListView from here. XAML Create Xamarin.Forms application with SfListView. <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             xmlns:local="clr-namespace:ListViewXamarin"             xmlns:syncfusion="clr-namespace:Syncfusion.ListView.XForms;assembly=Syncfusion.SfListView.XForms"             xmlns:data="clr-namespace:Syncfusion.DataSource;assembly=Syncfusion.DataSource.Portable"             x:Class="ListViewXamarin.MainPage" Padding="{OnPlatform iOS='0,40,0,0'}">     <ContentPage.BindingContext>         <local:ListViewModel/>     </ContentPage.BindingContext>       <ContentPage.Content>         <StackLayout>             <Grid BackgroundColor="#2196F3" HeightRequest="40">                 <Label Text="To Do Items" x:Name="headerLabel" TextColor="White" FontAttributes="Bold" VerticalOptions="Center" HorizontalOptions="Center" />             </Grid>             <syncfusion:SfListView x:Name="listView" ItemSize="60" GroupHeaderSize="50" BackgroundColor="#FFE8E8EC" ItemsSource="{Binding Items}">                 <syncfusion:SfListView.ItemTemplate >                     <DataTemplate>                         ...                     </DataTemplate>                 </syncfusion:SfListView.ItemTemplate>                 <syncfusion:SfListView.DataSource>                     <data:DataSource>                         <data:DataSource.GroupDescriptors>                             <data:GroupDescriptor PropertyName="userId"/>                         </data:DataSource.GroupDescriptors>                     </data:DataSource>                 </syncfusion:SfListView.DataSource>                 <syncfusion:SfListView.GroupHeaderTemplate>                     <DataTemplate>                        ...                     </DataTemplate>                 </syncfusion:SfListView.GroupHeaderTemplate>             </syncfusion:SfListView>         </StackLayout>     </ContentPage.Content> </ContentPage> C# Fetch data and download from the web server. 1. Using the HTTPClient.GetAsync method, retrieve data from the web server for the specified URL. 2. The HTTPContent.ReadAsStreamAsync returns the data in stream format. 3. Use Environment.GetFolderPath method to create a local path to store the retrieved data and combine 4. the path with the file name using Path.Combine method. 5. The FileInfo.OpenWrite creates a write only stream and write to the local file stream using CopyToAsync method. namespace ListViewXamarin {     public class DataServices     {         private static HttpClient httpClient;           public DataServices()         {             httpClient = new HttpClient();         }           /// <summary>         /// Fetches data from web server and write it to the local file.         /// </summary>         /// <returns>Returns true, if data fetched from webserver and downloaded to the local location.</returns>         public async Task<bool> DownloadJsonAsync()         {             try             {                 var url = "https://jsonplaceholder.typicode.com/todos"; //Set your REST API url here                   //Sends request to retrieve data from the web service for the specified Uri                 var response = await httpClient.GetAsync(url);                 using (var stream = await response.Content.ReadAsStreamAsync()) //Reads data as stream                 {                     //Gets the path to the specified folder                     var localFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);                       var newpath = Path.Combine(localFolder, "data.json"); // Combine path with the file name                       var fileInfo = new FileInfo(newpath);                       //Creates a write-only file stream                     using (var fileStream = fileInfo.OpenWrite())                     {                         await stream.CopyToAsync(fileStream); //Reads data from the current stream and write to destination stream (fileStream)                     }                 }             }             catch (OperationCanceledException e)             {                 System.Diagnostics.Debug.WriteLine(@"ERROR {0}", e.Message);                 return false;             }             catch (Exception e)             {                 System.Diagnostics.Debug.WriteLine(@"ERROR {0}", e.Message);                 return false;             }             return true;         }     } } C# Read data from local file and set it to collection. namespace ListViewXamarin {     public class ListViewModel : INotifyPropertyChanged     {         private dynamic items;         private bool isDownloaded;           public dynamic Items         {             get { return items; }             set             {                 items = value;                 OnPropertyChanged("Items");             }         }         public DataServices DataService { get; set; }           public ListViewModel()         {             DataService = new DataServices();             GetDataAsync();         }           private async void GetDataAsync()         {             isDownloaded = await DataService.DownloadJsonAsync();             if (isDownloaded)             {                 var localFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);                 var fileText = File.ReadAllText(Path.Combine(localFolder, "data.json"));                 //Read data from the local file path and set it to the collection bound to the ListView.                 Items = JsonConvert.DeserializeObject<dynamic>(fileText);             }         }     } } View sample in GitHub  
Convert Excel to PDF with Azure functions
Syncfusion&reg; Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. Using this library, you can convert Excel documents into PDF in Azure Functions. Steps to convert Excel to PDF with Azure Functions programmatically: Step 1: Create a new Azure Function project. Create a new Azure function project Step 2: Select the framework Azure Functions v1 (.NET Framework) and select HTTP trigger as follows. Select framework and HTTP trigger Step 3: Install the Syncfusion.ExcelToPdfConverter.WinForms NuGet package as a reference to your .NET Framework applications from NuGet.org. Install NuGet package Step 4: Include the following namespaces in Function1.cs file. C# using System.IO; using Syncfusion.XlsIO; using Syncfusion.ExcelToPdfConverter; using Syncfusion.Pdf; using System.Net.Http.Headers;   Step 5: Add the following code snippet in the Run method of the Function1 class to open and modify the Excel document in Azure Functions and return the output document to the client end. C# Stream stream = req.Content.ReadAsStreamAsync().Result; // Instantiate the spreadsheet creation engine using (ExcelEngine excelEngine = new ExcelEngine()) {     // Instantiate the Excel application object     IApplication application = excelEngine.Excel;       // Assigns default application version     application.DefaultVersion = ExcelVersion.Excel2013;       IWorkbook workbook = application.Workbooks.Open(stream);       // Access a worksheet from workbook     IWorksheet worksheet = workbook.Worksheets[0];       // Open the Excel document to Convert     ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);       // Initialize PDF document     PdfDocument pdfDocument = new PdfDocument();       // Convert Excel document into PDF document     pdfDocument = converter.Convert();                  MemoryStream memoryStream = new MemoryStream();       // Save the PDF file     pdfDocument.Save(memoryStream);       // Create the response to return     HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);                     // Set the PDF document content response     response.Content = new ByteArrayContent(memoryStream.ToArray());                     // Set the contentDisposition as attachment     response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")     {         FileName = "Output.pdf"     };     // Set the content type as PDF format mime type     response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");                    // Return the response with output PDF stream     return response; }   Step 6: Right-click the project and select Publish. Then, create a new profile in the Publish Window. Publish window Step 7: Create App service using Azure subscription and select a hosting plan. Create App Service Note:Syncfusion&reg; Excel (XlsIO) library will work from basic hosting plan (B1). So, select the hosing plan as needed. Syncfusion Excel (XlsIO) library will not work if the hosting plan is Consumption.   Configure Hosting Plan Step 8: After creating the profile, click the Publish button. Publish Step 9: Now, go to the Azure portal and select App Services. After running the service, click Get Function URL by copying it. Then, paste it into the below client sample (which will request the Azure Function to convert Excel to PDF with Azure Functions). You will get the PDF document as shown below. Output PDF document A complete Azure function sample can be downloaded from Convert ExcelToPDF from Azure Function.zip. Steps to post the request to Azure function with template Excel document: Create simple console application to request the Azure function API. Add the following code snippet into Main method to request the Azure function with template Excel document and get the converted PDF document. C# // Open the required template Excel file Stream fileStream = File.Open(@"../../Data/Input.xlsx", FileMode.Open);   // Create memory stream to save the template MemoryStream inputStream = new MemoryStream();   // Copy the file stream into memory stream fileStream.CopyTo(inputStream);   // Dispose the file stream fileStream.Dispose(); try {     // Create HttpWebRequest with hosted azure function URL     HttpWebRequest req = (HttpWebRequest)WebRequest.Create("Your Azure function url");       // Set request method as POST     req.Method = "POST";       // Get the request stream to strore the Excel document stream     Stream stream = req.GetRequestStream();       // Write the Excel document stream into request stream     stream.Write(inputStream.ToArray(), 0, inputStream.ToArray().Length);       // Gets the responce from the Azure Function request     HttpWebResponse res = (HttpWebResponse)req.GetResponse();       // Create file stream to save the output PDF file     FileStream outStream = File.Create("Sample.pdf");       // Copy the responce stream into file stream     res.GetResponseStream().CopyTo(outStream);       // Dispose the input stream     inputStream.Dispose();       // Dispose the file stream     outStream.Dispose(); } catch (Exception ex) {     throw; }   // Launch the output document System.Diagnostics.Process.Start("Sample.pdf");   Console application can be downloaded from DownloadConvertedPDF.zip. Know more about Syncfusion&reg; Excel (XlsIO) library through the documentation, where you can find features like charts , drawing objects , chart to image conversion and worksheet to image conversion etc. with respective code examples. Refer here to explore the rich set of Syncfusion&reg; Excel (XlsIO) library features. Note:Starting with v16.2.0.x, if you reference Syncfusion&reg; assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion&reg; license key in your application to use the components without a trial message.ConclusionI hope you enjoyed learning about Convert Excel to PDF with Azure functions.You can refer to our XIsIO’s feature tour page to learn about its other groundbreaking features. Explore our UG documentation and online demos to understand how to manipulate data in Excel documents.If you are an existing user, you can access our latest components from the License and Downloads page. For new users, you can try our 30-day free trial to check out XlsIO and other Syncfusion&reg; components.If you have any queries or require clarification, please let us know in the comments below or contact us through our support forums, Support Tickets, or feedback portal. We are always happy to assist you!
Convert Excel to PDF with Azure function in ASP.NET Core.
Syncfusion&reg; Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. Using this library, you can convert Excel documents into PDF in Azure Functions. Steps to convert Excel to PDF with Azure Functions in a .NET Standard application programmatically: Step 1: Create a new Azure Function project. Create a new Azure function project Step 2: Select framework Azure Functions v2 (.NET Standard) and select HTTP trigger as follows. Select framework and HTTP trigger Step 3: Install the Syncfusion.XlsIORenderer.Net.Core NuGet package as a reference to your .NET Standard applications from NuGet.org. Install NuGet package Step 4: Include the following namespaces in Function1.cs file. C# using System.IO; using Syncfusion.XlsIO; using Syncfusion.XlsIORenderer; using Syncfusion.Pdf; using System.Net.Http.Headers;   Step 5: Add the following code snippet to open and modify Excel document in Azure functions and return the output document to client end. C# [FunctionName("Function1")] public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log) {     Stream stream = req.Content.ReadAsStreamAsync().Result;     // Instantiate the spreadsheet creation engine     using (ExcelEngine excelEngine = new ExcelEngine())     {         // Instantiate the Excel application object         IApplication application = excelEngine.Excel;           // Assign default application version         application.DefaultVersion = ExcelVersion.Excel2013;           IWorkbook workbook = application.Workbooks.Open(stream);           // Access a worksheet from the workbook         IWorksheet worksheet = workbook.Worksheets[0];           // Open the Excel document to convert         XlsIORenderer renderer = new XlsIORenderer();           // Initialize PDF document         PdfDocument pdfDocument = new PdfDocument();           // Convert Excel document into PDF document         pdfDocument = renderer.ConvertToPDF(workbook);           MemoryStream memoryStream = new MemoryStream();           // Save the PDF file         pdfDocument.Save(memoryStream);           // Create the response to return         HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);           // Set the PDF document content response         response.Content = new ByteArrayContent(memoryStream.ToArray());           // Set the contentDisposition as attachment         response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")         {             FileName = "Output.pdf"         };         // Set the content type as PDF format mime type         response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");           // Return the response with output PDF stream         return response;     } } Step 6: Right-click the project and select Publish. Then, create a new profile in the Publish Window. Publish window Step 7: Create App service using Azure subscription and select a hosting plan. Create App Service Note:Syncfusion&reg; XlsIO library will work from basic hosting plan (B1). So, select the hosing plan as needed. Syncfusion&reg; XlsIO library will not work if the hosting plan is Consumption.   Configure Hosting Plan Step 8: After creating the profile, click the Publish button. Publish Step 9: Now, go to Azure portal and select the App Services. After running the service, click Get function URL by copying it. Then, paste it to the below client sample (Which will request the Azure Function, to convert Excel to PDF with Azure functions). You will get the PDF document as shown below. Output PDF document A complete Azure function sample can be downloaded from Convert ExcelToPDF from Azure Function.zip. Steps to post the request to Azure function with template Excel document: Create simple console application to request the Azure function API. Add the following code snippet into Main method to request the Azure function with template Excel document and get the converted PDF document. C# // Open the required template Excel file Stream fileStream = File.Open(@"../../Data/Input.xlsx", FileMode.Open);   // Create memory stream to save the template MemoryStream inputStream = new MemoryStream();   // Copy the file stream into memory stream fileStream.CopyTo(inputStream);   // Dispose the file stream fileStream.Dispose(); try {     // Create HttpWebRequest with hosted azure function URL     HttpWebRequest req = (HttpWebRequest)WebRequest.Create("Your Azure function url");       // Set request method as POST     req.Method = "POST";       // Get the request stream to strore the Excel document stream     Stream stream = req.GetRequestStream();       // Write the Excel document stream into request stream     stream.Write(inputStream.ToArray(), 0, inputStream.ToArray().Length);       // Gets the responce from the Azure Function request     HttpWebResponse res = (HttpWebResponse)req.GetResponse();       // Create file stream to save the output PDF file     FileStream outStream = File.Create("Sample.pdf");       // Copy the responce stream into file stream     res.GetResponseStream().CopyTo(outStream);       // Dispose the input stream     inputStream.Dispose();       // Dispose the file stream     outStream.Dispose(); } catch (Exception ex) {     throw; }   // Launch the output document System.Diagnostics.Process.Start("Sample.pdf");   Console application can be downloaded from DownloadConvertedPDF.zip. Know more about Essential (XlsIO) library through the documentation, where you can find features like charts , drawing objects, chart to image conversion and worksheet to image conversion etc. with respective code examples. Refer here to explore the rich set of Syncfusion&reg; Excel (XlsIO) library features. Note:Starting with v16.2.0.x, if you reference Syncfusion&reg; assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion&reg; license key in your application to use the components without a trial message.ConclusionI hope you enjoyed learning about how to convert Excel to PDF with Azure function in .NET Standard application.You can refer to our ASP.NET Core XIsIO feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our ASP.NET Core XIsIO example to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
How to convert XAML to PDF using C# and VB.NET?
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can convert XAML to PDF in C# and VB.NET by using following steps: Convert XAML to XPS Convert XPS to PDF Steps to convert XAML to PDF programmatically: Create a new Windows Forms application project. Install the Syncfusion.Pdf.WinForms NuGet package as reference to your .NET Framework application from NuGet.org. Add the following system assemblies as reference to your application. PresentationCore.dll PresentationFramework.dll ReachFramework.dll System.Printing.dll Include the following namespace in the Form1.Designer.cs file. C# using Syncfusion.Pdf; using System.Windows; using System.Windows.Xps; using System.Windows.Documents; using System.Windows.Xps.Packaging;   VB.NET Imports Syncfusion.Pdf Imports System.Windows Imports System.Windows.Xps Imports System.Windows.Documents Imports System.Windows.Xps.Packaging   Add the following code snippet to convert XAML document to PDF. C# private void button_Click(object sender, System.EventArgs e) {     //Input XAML file location     string fileName = "input.xaml";     //Convert XAML file to XPS file     Stream xpsFile = GetXPSDocument(fileName);     if (xpsFile != null)     {         xpsFile.Position = 0;         //Initialize XPSToPdfConverter         Syncfusion.XPS.XPSToPdfConverter converter = new Syncfusion.XPS.XPSToPdfConverter();         //Convert XPS document into PDF document         PdfDocument document = converter.Convert(xpsFile);         //Save the Pdf document         document.Save("XAMLToPDF.pdf");         //Close the Pdf document         document.Close(true);         //This will open the PDF file so, the result will be seen in default PDF viewer         System.Diagnostics.Process.Start("XAMLToPDF.pdf");     } } /// <summary> /// Convert XAML flow document into XPS file /// </summary> private MemoryStream GetXPSDocument(string fileName) {     //Create visual UIElement     UIElement visual = System.Windows.Markup.XamlReader.Load(System.Xml.XmlReader.Create(fileName)) as System.Windows.UIElement;     FixedDocument doc = new FixedDocument();     PageContent pageContent = new PageContent();     FixedPage fixedPage = new FixedPage();       //Create first page of document     fixedPage.Children.Add(visual);     ((System.Windows.Markup.IAddChild)pageContent).AddChild(fixedPage);       //Adding page content to pages     doc.Pages.Add(pageContent);       //Create the stream     MemoryStream xpsStream = new MemoryStream();     XpsDocument xpsDocument = new XpsDocument(System.IO.Packaging.Package.Open(xpsStream, FileMode.Create));     XpsDocumentWriter xpsDocumentWriter = XpsDocument.CreateXpsDocumentWriter(xpsDocument);       //Write the XPS document     xpsDocumentWriter.Write(doc);       //Close the XPS document     xpsDocument.Close();     return xpsStream; }   VB.NET Private Sub button_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button.Click     'Input XAML file location     Dim fileName As String = "input.xaml"     'Convert XAML file to XPS file     Dim xpsFile As Stream = GetXPSDocument(fileName)     If xpsFile IsNot Nothing Then         xpsFile.Position = 0         'Initialize XPSToPdfConverter         Dim converter As New Syncfusion.XPS.XPSToPdfConverter()         'Convert XPS document into PDF document         Dim document As PdfDocument = converter.Convert(xpsFile)         'Save the Pdf document         document.Save("XAMLToPDF.pdf")         'Close the Pdf document         document.Close(True)         'This will open the PDF file so, the result will be seen in default PDF viewer         System.Diagnostics.Process.Start("XAMLToPDF.pdf")     End If End Sub ''' <summary> ''' Convert XAML flow document into XPS file ''' </summary> Private Function GetXPSDocument(fileName As String) As MemoryStream     'Create visual UIElement     Dim visual As UIElement = TryCast(System.Windows.Markup.XamlReader.Load(System.Xml.XmlReader.Create(fileName)), UIElement)     Dim doc As New FixedDocument()     Dim pageContent As New PageContent()     Dim fixedPage As New FixedPage()       'Create first page of document     fixedPage.Children.Add(visual)     DirectCast(pageContent, System.Windows.Markup.IAddChild).AddChild(fixedPage)       'Adding page content to pages     doc.Pages.Add(pageContent)       'Create the stream     Dim xpsStream As New MemoryStream()     Dim xpsDocument As New XpsDocument(System.IO.Packaging.Package.Open(xpsStream, FileMode.Create))     Dim xpsDocumentWriter As XpsDocumentWriter = XpsDocument.CreateXpsDocumentWriter(xpsDocument)       'Write the XPS document     xpsDocumentWriter.Write(doc)     'Close the XPS document     xpsDocument.Close()     Return xpsStream End Function   A complete working sample can be downloaded from XAMLToPDFSample.zip. By executing the program, you will get the PDF document as follows. Refer here to explore the rich set of Syncfusion Essential PDF features. See Also: Convert XAML to PDF in UWP Convert XAML to PDF in WPF Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message. Conclusion:I hope you enjoyed learning about how to convert XAML to PDF using C# and VB.NET. You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!
How to Convert CSV to PDF Table Using C# and VB.NET in WinForms?
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can convert a CSV (Comma-Separated Values) file to a PDF table in C# and VB.NET. Steps to convert CSV to PDF table programmatically: Create a new C# console application project. Install the Syncfusion.ExcelToPdfConverter.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org. Include the following namespaces in the Program.cs file. C# using Syncfusion.Pdf; using Syncfusion.Pdf.Grid; using Syncfusion.XlsIO; using System.Drawing;   VB.NET Imports Syncfusion.Pdf Imports Syncfusion.Pdf.Grid Imports Syncfusion.XlsIO Imports System.Drawing   Use the following code snippet to convert CSV to a PDF table. C# // Instantiate the spreadsheet creation engine ExcelEngine excelEngine = new ExcelEngine(); // Instantiate the Excel application object IApplication application = excelEngine.Excel; // Load or open an existing workbook through the Open method of IWorkbooks IWorkbook workbook = application.Workbooks.Open("Input.csv"); // Access via index IWorksheet worksheet = workbook.Worksheets[0]; // Create a new PDF document PdfDocument document = new PdfDocument(); // Add a page to the document PdfPage page = document.Pages.Add(); // Create a new PdfGrid PdfGrid pdfGrid = new PdfGrid(); // Add columns pdfGrid.Columns.Add(worksheet.UsedRange.LastColumn); pdfGrid.Headers.Add(1); PdfGridRow pdfGridHeader = pdfGrid.Headers[0]; for (int i = 0; i < worksheet.UsedRange.LastColumn; i++) { pdfGridHeader.Cells[i].Value = worksheet.UsedRange.Columns[i].DisplayText; } // Add rows for (int row = 2; row <= worksheet.UsedRange.LastRow; row++) { PdfGridRow pdfGridRow = pdfGrid.Rows.Add(); for (int col = 1; col <= worksheet.UsedRange.LastColumn; col++) { string text = worksheet[row, col].Text; pdfGridRow.Cells[col - 1].Value = text; } } // Apply built-in style pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable5DarkAccent6); // Draw the PdfGrid pdfGrid.Draw(page, PointF.Empty); // Save the document document.Save("Table.pdf"); // Close the document document.Close(true); // This will open the PDF file so the result will be seen in the default PDF viewer System.Diagnostics.Process.Start("Table.pdf"); VB.NET ' Instantiate the spreadsheet creation engine Dim excelEngine As New ExcelEngine() ' Instantiate the Excel application object Dim application As IApplication = excelEngine.Excel ' Load or open an existing workbook through the Open method of IWorkbooks Dim workbook As IWorkbook = application.Workbooks.Open("Input.csv") ' Access via index Dim worksheet As IWorksheet = workbook.Worksheets(0) ' Create a new PDF document Dim document As New PdfDocument() ' Add a page to the document Dim page As PdfPage = document.Pages.Add() ' Create a new PdfGrid Dim pdfGrid As New PdfGrid() ' Add columns pdfGrid.Columns.Add(worksheet.UsedRange.LastColumn) pdfGrid.Headers.Add(1) Dim pdfGridHeader As PdfGridRow = pdfGrid.Headers(0) For i As Integer = 0 To worksheet.UsedRange.LastColumn - 1 pdfGridHeader.Cells(i).Value = worksheet.UsedRange.Columns(i).DisplayText Next ' Add rows For row As Integer = 2 To worksheet.UsedRange.LastRow Dim pdfGridRow As PdfGridRow = pdfGrid.Rows.Add() For col As Integer = 1 To worksheet.UsedRange.LastColumn Dim text As String = worksheet(row, col).Text pdfGridRow.Cells(col - 1).Value = text Next Next ' Apply built-in style pdfGrid.ApplyBuiltinStyle(PdfGridBuiltinStyle.GridTable5DarkAccent6) ' Draw the PdfGrid pdfGrid.Draw(page, PointF.Empty) ' Save the document document.Save("Table.pdf") ' Close the document document.Close(True) ' This will open the PDF file so the result will be seen in the default PDF viewer System.Diagnostics.Process.Start("Table.pdf")A complete working sample can be downloaded from CSVToPDFSample.zip. By executing the program, you will get the PDF document as follows. Take a moment to peruse the documentation, where you can find features like Excel to PDF, Word to PDF, and adding a simple table in a PDF document with code examples. Refer here to explore the rich set of Syncfusion Essential PDF features. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.  ConclusionI hope you enjoyed learning how to convert a CSV to a PDF table using C# and VB.NET in WinForms.You can refer to our WinForms PDF feature tour page to learn about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms PDF examples to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!
How to convert WinForms Excel file to CSV in C#, VB.NET?
Syncfusion&reg; Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. It also, converts Excel documents to PDF files. Using this library, you can convert an Excel file with simple text into a CSV file. Steps to convert an Excel file to CSV file programmatically: Step 1: Create a new C# console application project. Create a new C# console application Step 2: Install the Syncfusion.XlsIO.WinForms NuGet package as a reference to your .NET Framework applications from NuGet.org. Install the NuGet package Step 3: Include the following namespace in the Program.cs file. C# using Syncfusion.XlsIO;   VB.NET Imports Syncfusion.XlsIO   Step 4: Use the following code snippet to convert an Excel file with simple text into CSV file. C# // Initialize ExcelEngine. using (ExcelEngine excelEngine = new ExcelEngine()) {     // Initialize Application.     IApplication application = excelEngine.Excel;       // Set default version for application.     application.DefaultVersion = ExcelVersion.Excel2013;       // Create a new workbook.     IWorkbook workbook = application.Workbooks.Create(1);       // Access the first worksheet in the workbook.     IWorksheet worksheet = workbook.Worksheets[0];       // Adding text to a cell     worksheet.Range["A1:N30"].Text = "Hello World";       // Save the workbook to csv format.     worksheet.SaveAs("Sample.csv", ","); }   VB.NET 'Initialize ExcelEngine. Using excelEngine As ExcelEngine = New ExcelEngine       'Initialize Application.     Dim application As IApplication = excelEngine.Excel       'Set default version for application.     application.DefaultVersion = ExcelVersion.Excel2013       'Create a new workbook.     Dim workbook As IWorkbook = application.Workbooks.Create(1)       'Access the first worksheet in the workbook.     Dim worksheet As IWorksheet = workbook.Worksheets(0)       'Adding text to a cell     worksheet.Range("A1:N30").Text = "Hello World"       'Save the workbook to csv format.     worksheet.SaveAs("Sample.csv", ",")   End Using   A complete working example to convert an Excel file to CSV can be downloaded from Convert Excel File To CSV File.zip. SaveAs() method saves a workbook with the specified file name. SaveAs() method has three overloads to convert Excel file to CSV whose API references are as follows: SaveAs(String,String) SaveAs(String,String,Encoding) SaveAs(Stream,String) SaveAs(Stream,String,Encoding) By executing the program, you will get the output Excel file as shown below. Output Excel document Take a moment to peruse the documentation, where you can find basic worksheet data manipulation options along with features like Conditional Formatting, worksheet calculations through Formulas, adding Charts in worksheet or workbook, organizing and analyzing data through Tables and Pivot Tables, appending multiple records to worksheet using Template Markers, and most importantly PDF and Image conversions etc., with code examples. Refer here to explore the rich set of Syncfusion&reg; Excel (XlsIO) library features. An online sample link to convert Excel file to CSV file. Note:Starting with v16.2.0.x, if you reference Syncfusion&reg; assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion&reg; license key in your application to use the components without a trial message.  ConclusionI hope you enjoyed learning about how to convert WinForms Excel file to CSV in C#, VB.NET.You can refer to our XIsIO’s feature tour page to learn about its other groundbreaking features. Explore our UG documentation and online demos to understand how to manipulate data in Excel documents.If you are an existing user, you can access our latest components from the License and Downloads page. For new users, you can try our 30-day free trial to check out XlsIO and other Syncfusion&reg; components.If you have any queries or require clarification, please let us know in the comments below or contact us through our support forums, Support Tickets, or feedback portal. We are always happy to assist you!
How to convert Excel file to CSV in C#, VB.NET?
Syncfusion&reg; Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. Using this library, you can convert an Excel file with simple text into a CSV file. Steps to convert an Excel file to CSV file programmatically: Step 1: Create a new C# console application project. Create a new C# console application Step 2: Install the Syncfusion.XlsIO.WinForms NuGet package as a reference to your .NET Framework applications from NuGet.org. Install NuGet package Step 3: Include the following namespace in the Program.cs file. C# using Syncfusion.XlsIO; VB.NET Imports Syncfusion.XlsIO   Step 4: Use the following code snippet to convert an Excel file with simple text into CSV file. C# // Initialize ExcelEngine. using (ExcelEngine excelEngine = new ExcelEngine()) {     // Initialize Application.     IApplication application = excelEngine.Excel;       // Set default version for application.     application.DefaultVersion = ExcelVersion.Excel2013;       // Create a new workbook.     IWorkbook workbook = application.Workbooks.Create(1);       // Access the first worksheet in the workbook.     IWorksheet worksheet = workbook.Worksheets[0];       // Adding text to a cell     worksheet.Range["A1:N30"].Text = "Hello World";       // Save the workbook to csv format.     worksheet.SaveAs("Sample.csv", ","); }   VB.NET 'Initialize ExcelEngine. Using excelEngine As ExcelEngine = New ExcelEngine       'Initialize Application.     Dim application As IApplication = excelEngine.Excel       'Set default version for application.     application.DefaultVersion = ExcelVersion.Excel2013       'Create a new workbook.     Dim workbook As IWorkbook = application.Workbooks.Create(1)       'Accessing the first worksheet in the workbook.     Dim worksheet As IWorksheet = workbook.Worksheets(0)       'Adding text to a cell     worksheet.Range("A1:N30").Text = "Hello World"       'Save the workbook to csv format.     worksheet.SaveAs("Sample.csv", ",")   End Using A complete working example can be downloaded from Convert Excel File To CSV File.zip. By executing the program, you will get the output Excel file as shown below. Output Excel document Take a moment to peruse the documentation, where you can find basic worksheet data manipulation options along with features like Conditional Formatting, worksheet calculations through Formulas, adding Charts in worksheet or workbook, organizing and analyzing data through Tables and Pivot Tables, appending multiple records to worksheet using Template Markers, and most importantly PDF and Image conversions etc., with code examples. Refer here to explore the rich set of Syncfusion&reg; Excel (XlsIO) library features. An online sample link to convert Excel file to CSV file. Note:Starting with v16.2.0.x, if you reference Syncfusion&reg; assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion&reg; license key in your application to use the components without a trial message.ConclusionI hope you enjoyed learning about how to convert Excel file to CSV in C#, VB.NET.You can refer to our  WinForms XlsIO feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms XlsIO documentation to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
How to convert WinForms Excel to PDF in C#, VB.NET?
Syncfusion® WinForms Excel library is the .NET Excel library used to create, read, and edit Excel documents. Excel helps in daily life to manage records, analyze data, perform calculations, serve as an analytical tool for business, and provide visualization. PDF (Portable Document Format) is one of the file formats like Excel, and it can capture all the elements of a printed document as an electronic image that you can view, navigate, and print. Syncfusion® Excel (XlsIO) library helps you to convert Excel file to PDF in C# and VB.NET.XlsIO helps to convert Excel to PDF by loading the workbook or worksheet into ExcelToPDFConverter and converting the loaded document using the Convert method. This conversion is supported on platforms like Windows Forms, WPF, ASP.NET, ASP.NET MVC, ASP.NET Core, Xamarin, and Azure. This article shows you how to convert Excel to PDF in C#, VB.NET. Steps to convert an Excel file to PDF programmatically: Step 1: Create a new C# console application project. Create a new C# console application Step 2: Install Syncfusion.ExcelToPdfConverter.WinForms NuGet package as a reference to your .NET Framework applications from the NuGet.org. Install NuGet package Step 3: Include the following namespaces in the Program.cs file: C# using Syncfusion.ExcelToPdfConverter; using Syncfusion.Pdf; using Syncfusion.XlsIO; using System.IO; using System.Reflection;   VB.NET Imports System.IO Imports System.Reflection Imports Syncfusion.ExcelToPdfConverter Imports Syncfusion.Pdf Imports Syncfusion.XlsIO   Step 4: Open an existing Excel document or create a new document and load it into IWorkbook instance. C# // Initialize Application IApplication application = excelEngine.Excel;   // Set the default application version as Xlsx application.DefaultVersion = ExcelVersion.Xlsx;   // Open existing workbook with data entered Assembly assembly = typeof(Program).GetTypeInfo().Assembly; Stream fileStream = assembly.GetManifestResourceStream("ExcelToPDFConversion.Sample.xlsx"); IWorkbook workbook = application.Workbooks.Open(fileStream);   VB.NET 'Initialize Application Dim application As IApplication = excelEngine.Excel   'Set the default application version as Xlsx application.DefaultVersion = ExcelVersion.Xlsx   'Open existing workbook with data entered Dim assembly As Assembly = GetType(Program).GetTypeInfo.Assembly Dim fileStream As Stream = assembly.GetManifestResourceStream("ExcelToPDFConversion.Sample.xlsx") Dim workbook As IWorkbook = application.Workbooks.Open(fileStream)   Step 5: Convert the Excel file to PDF. C# // Initialize ExcelToPDF Converter ExcelToPdfConverter converter = new ExcelToPdfConverter(workbook);   // Initialize PDF document PdfDocument pdfDocument = new PdfDocument();   // Convert Excel document into PDF document pdfDocument = converter.Convert();   // Save the PDF file pdfDocument.Save("Output.pdf");   VB.NET 'Initialize ExcelToPDF Converter Dim converter As ExcelToPdfConverter = New ExcelToPdfConverter(workbook)   'Initialize PDF document Dim pdfDocument As PdfDocument = New PdfDocument   'Convert Excel document into PDF document pdfDocument = converter.Convert   'Save the PDF file pdfDocument.Save("Output.pdf")   A complete working example to convert Excel file to PDF along with the input file used for conversion can be downloaded from Convert-Excel-to-PDF-Sample.zip. By executing the program, you will get the PDF file as below. Output PDF document Know more about Syncfusion® Excel (XlsIO) library through the documentation, where you can find the supported features like Excel file with worksheets, charts and chart sheets to PDF conversion and different printer settings along with Worksheet to Image conversion, Chart to Image conversion and Excel to ODS conversion.An online sample link for Excel to PDF conversion.To learn more about the Syncfusion® Excel (XlsIO) library, refer to the documentation where you will find basic worksheet data manipulation options along with features like Conditional Formatting, worksheet calculations through Formulas, adding Charts in worksheets or workbooks, organizing and analyzing data through Tables and Pivot Tables, appending multiple records to worksheets using Template Markers with code examples.See Also:How to convert the PDF document into ExcelConvert Excel to PDF with Azure function in .NET Standard applicationConvert Excel to PDF in Azure platformHow to convert an Excel file to CSVHow to convert Excel worksheet to imageTake a moment to peruse the documentation where you can find basic Excel document processing options along with the features like import and export data, chart, formulas, conditional formatting, data validation, tables, pivot tables and, protect the Excel documents, and most importantly, the PDF, CSV and Image conversions with code examples.Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer the link to learn about generating and registering Syncfusion® license key in your application to use the components without trail message.ConclusionI hope you enjoyed learning about how to convert WinForms Excel to PDF in C#, VB.NET.You can refer to our XIsIO’s feature tour page to learn about its other groundbreaking features. Explore our UG documentation and online demos to understand how to manipulate data in Excel documents.If you are an existing user, you can access our latest components from the License and Downloads page. For new users, you can try our 30-day free trial to check out XlsIO and other Syncfusion components.If you have any queries or require clarification, please let us know in the comments below or contact us through our support forums, Support Tickets, or feedback portal. We are always happy to assist you!
How to convert PDF to JPG using C# and VB.NET?
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using Pdf Viewer library, you can convert PDF to JPG in C# and VB.NET. Steps to convert a page of the PDF file into a JPG image programmatically: Create a new C# console application project. Install the Syncfusion.PdfViewer.Windows NuGet package as a reference to your .NET Framework application from NuGet.org. Include the following namespace in the Program.cs file. C# using Syncfusion.Pdf.Parsing; using Syncfusion.Windows.Forms.PdfViewer; using System.Drawing; using System.Drawing.Imaging;   VB.NET Imports Syncfusion.Pdf.Parsing Imports Syncfusion.Windows.Forms.PdfViewer Imports System.Drawing Imports System.Drawing.Imaging   Use the following code snippet to convert a page of the PDF file to a JPG image. C# //Initialize the PdfViewer Control PdfViewerControl pdfViewer = new PdfViewerControl();   //Load the input PDF file PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/Barcode.pdf");   pdfViewer.Load(loadedDocument);   //Export the particular PDF page as image at the page index of 0 Bitmap image = pdfViewer.ExportAsImage(0);   // Save the image. image.Save("Sample.jpg", ImageFormat.Jpeg);   VB.NET 'Initialize the PdfViewer Control Dim pdfViewer As PdfViewerControl = New PdfViewerControl()   'Load the input PDF file Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("../../Data/Barcode.pdf")   pdfViewer.Load(loadedDocument)   'Export the particular PDF page as image at the page index of 0 Dim image As Bitmap = pdfViewer.ExportAsImage(0)   'Save the image. image.Save("Sample.jpg", ImageFormat.Jpeg)   Steps to convert a specific range of pages of the PDF file into JPG images programmatically: Include the following namespace in the Program.cs file. C# using Syncfusion.Pdf.Parsing; using Syncfusion.Windows.Forms.PdfViewer; using System.Drawing; using System.Drawing.Imaging;   VB.NET Imports Syncfusion.Pdf.Parsing Imports Syncfusion.Windows.Forms.PdfViewer Imports System.Drawing Imports System.Drawing.Imaging   Use the following code snippet to convert the specific range of pages of a PDF file that can be exported as JPEG images. C# //Initialize the PdfViewer Control PdfViewerControl pdfViewer = new PdfViewerControl();   //Load the input PDF file PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/Barcode.pdf");   pdfViewer.Load(loadedDocument);   //Export all the pages as images at the specific page range Bitmap[] image = pdfViewer.ExportAsImage(0, loadedDocument.Pages.Count - 1);   for (int i = 0; i < image.Length; i++) {      // Save the image.     image[i].Save("Sample" + i.ToString()+".jpg", ImageFormat.Jpeg);   }   VB.NET 'Initialize the PdfViewer Control Dim pdfViewer As PdfViewerControl = New PdfViewerControl() 'Load the input PDF file Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("../../Data/Barcode.pdf")   pdfViewer.Load(loadedDocument) 'Export all the pages as images at the specific page range Dim image As Bitmap() = pdfViewer.ExportAsImage(0, loadedDocument.Pages.Count - 1)         For i As Integer = 0 To image.Length - 1             'Save the image.             image(i).Save("Sample" + i.ToString() + ".jpg", ImageFormat.Jpeg)         Next     You can download the working sample from PDFToJPEGSample.Zip By executing the program, you will get the image as follows. Take a moment to peruse the documentation, where you can find other features like converting Word to PDF, Excel to PDF, XPS to PDF, and HTML to PDF with code examples. Refer here to explore the rich set of Syncfusion Essential PDF features. Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message.     See Also: https://support.syncfusion.com/kb/article/9455/how-to-convert-pdf-to-jpg-in-wpf-pdfviewer https://support.syncfusion.com/kb/article/9462/how-to-convert-pdf-to-image-in-wpf-pdfviewerhttps://www.syncfusion.com/blogs/post/pdf-to-image-conversion-is-made-easy-with-wpf-pdf-viewer.aspxConclusionA new version of Essential Studio® for ASP.NET is available. Versions prior to the release of Essential Studio® 2014, Volume 2 will now be referred to as classic versions. The new ASP.NET suite is powered by Essential Studio for JavaScript, providing client-side rendering of HTML5-JavaScript controls, offering better performance, and better support for touch interactivity. The new version includes all the features of the old version, so migration is easy.The Classic controls can be used in existing projects; however, if you are starting a new project, we recommend using the latest version of Essential Studio® for ASP.NET. Although Syncfusion® will continue to support all Classic Versions, we are happy to assist you in migrating to the newest edition.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls. If you have any queries or require clarifications, please let us know in the comments section below.You can also contact us through our support forums or feedback portal. We are always happy to assist you!
How to convert PDF to PNG using C# and VB.NET?
Syncfusion Essential PDF is a .NET PDF Libraries used to create, read, and edit PDF documents. Using Pdf Viewer library, you can convert PDF to PNG in C# and VB.NET.  Steps to convert a page of the PDF file into a PNG image programmatically: Create a new C# console application project. Install the Syncfusion.PdfViewer.Windows NuGet package as a reference to your .NET Framework application from NuGet.org. Include the following namespace in the Program.cs file. C# using Syncfusion.Pdf.Parsing; using Syncfusion.Windows.Forms.PdfViewer; using System.Drawing; using System.Drawing.Imaging;   VB.NET Imports Syncfusion.Pdf.Parsing Imports Syncfusion.Windows.Forms.PdfViewer Imports System.Drawing Imports System.Drawing.Imaging   Use the following code snippet to convert a page of the PDF file to a PNG image. C# //Initialize the PdfViewer Control PdfViewerControl pdfViewer = new PdfViewerControl();   //Load the input PDF file PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/Barcode.pdf");   pdfViewer.Load(loadedDocument);   //Export the particular PDF page as image at the page index of 0 Bitmap image = pdfViewer.ExportAsImage(0);   // Save the image. image.Save("Sample.png", ImageFormat. Png);   VB.NET 'Initialize the PdfViewer Control Dim pdfViewer As PdfViewerControl = New PdfViewerControl()   'Load the input PDF file Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("../../Data/Barcode.pdf")   pdfViewer.Load(loadedDocument)   'Export the particular PDF page as image at the page index of 0 Dim image As Bitmap = pdfViewer.ExportAsImage(0)   'Save the image. image.Save("Sample. png ", ImageFormat. Png)   Steps to convert a specific range of pages of the PDF file into PNG images programmatically: Include the following namespace in the Program.cs file. C# using Syncfusion.Pdf.Parsing; using Syncfusion.Windows.Forms.PdfViewer; using System.Drawing; using System.Drawing.Imaging;   VB.NET Imports Syncfusion.Pdf.Parsing Imports Syncfusion.Windows.Forms.PdfViewer Imports System.Drawing Imports System.Drawing.Imaging   Use the following code snippet to convert the specific range of pages of a PDF file that can be exported as PNG images. C# //Initialize the PdfViewer Control PdfViewerControl pdfViewer = new PdfViewerControl();   //Load the input PDF file PdfLoadedDocument loadedDocument = new PdfLoadedDocument("../../Data/Barcode.pdf");   pdfViewer.Load(loadedDocument);   //Export all the pages as images at the specific page range Bitmap[] image = pdfViewer.ExportAsImage(0, loadedDocument.Pages.Count - 1);   for (int i = 0; i < image.Length; i++) {      // Save the image.     image[i].Save("Sample" + i.ToString()+".png", ImageFormat. Png);   }   VB.NET 'Initialize the PdfViewer Control Dim pdfViewer As PdfViewerControl = New PdfViewerControl() 'Load the input PDF file Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument("../../Data/Barcode.pdf")   pdfViewer.Load(loadedDocument) 'Export all the pages as images at the specific page range Dim image As Bitmap() = pdfViewer.ExportAsImage(0, loadedDocument.Pages.Count - 1)         For i As Integer = 0 To image.Length - 1             'Save the image.             image(i).Save("Sample" + i.ToString() + ".png", ImageFormat.Png)         Next     You can download the working sample from PDFToPNGSample.ZipBy executing the program, you will get the image as follows. Take a moment to peruse the documentation, where you can find other features like converting Word to PDF, Excel to PDF, XPS to PDF, and HTML to PDF with code examples.Refer here to explore the rich set of Syncfusion Essential PDF features.Note:Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion license key in your application to use the components without a trail message.     See Also:https://support.syncfusion.com/kb/article/8092/how-to-convert-pdf-to-jpg-using-c-and-vb-nethttps://support.syncfusion.com/kb/article/9462/how-to-convert-pdf-to-image-in-wpf-pdfviewerhttps://support.syncfusion.com/kb/article/9455/how-to-convert-pdf-to-jpg-in-wpf-pdfviewerhttps://www.syncfusion.com/blogs/post/pdf-to-image-conversion-is-made-easy-with-wpf-pdf-viewer.aspx Note:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message. Conclusion:I hope you enjoyed learning about how to convert PDF to PNG using C# and VB.NET. You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!
How to export a PowerPoint presentation file as PDF file in C#, VB.NET?
Syncfusion Essential Presentation is a .NET PowerPoint library used to create, open, read, edit, and export PowerPoint presentations. Using this library, you can export a PowerPoint presentation file as a PDF file in C# and VB.NET. Steps to convert a PowerPoint presentation file as PDF document programmatically: Create a new C# console application. Install Syncfusion.Presentation.Base NuGet package to the console application project from nuget.org. For more information about adding a NuGet feed in Visual Studio and installing NuGet packages, refer to documentation. Install Syncfusion.OfficeChartToImageConverter.WPF NuGet package to the console application project from nuget.org. Install Syncfusion.PresentationToPdfConverter.Base NuGet package to the console application project from nuget.org. Include the following namespace in the Program.cs file. using Syncfusion.Presentation; using Syncfusion.OfficeChartToImageConverter; using Syncfusion.Pdf; using Syncfusion.PresentationToPdfConverter;   Imports Syncfusion.Presentation Imports Syncfusion.OfficeChartToImageConverter Imports Syncfusion.Pdf Imports Syncfusion.PresentationToPdfConverter   Use the following code snippet to convert a PowerPoint presentation file as PDF document. //Open the PowerPoint Presentation. IPresentation powerpointDoc = Presentation.Open("Sample.pptx");   //Create an instance of ChartToImageConverter and assign it to ChartToImageConverter property of presentation. powerpointDoc.ChartToImageConverter = new ChartToImageConverter();   //Convert the PowerPoint Presentation into PDF document. PdfDocument pdfDocument = PresentationToPdfConverter.Convert(powerpointDoc);   //Save the PDF document. pdfDocument.Save("Sample.pdf");   //Close the PDF document. pdfDocument.Close(true);   //Close the Presentation. powerpointDoc.Close();   'Open the PowerPoint Presentation. Dim powerpointDoc As IPresentation = Presentation.Open("Sample.pptx")   'Create an instance of ChartToImageConverter and assign it to ChartToImageConverter property of Presentation. powerpointDoc.ChartToImageConverter = New ChartToImageConverter   'Convert the PowerPoint Presentation into PDF document. Dim pdfDocument As PdfDocument = PresentationToPdfConverter.Convert(powerpointDoc)   'Save the PDF document. pdfDocument.Save("Sample.pdf")   'Close the PDF document. pdfDocument.Close(True)   'Close the Presentation. powerpointDoc.Close()   You can download the working sample from Convert-PowerPoint-To-PDF.Zip. By executing the program, you will get the PowerPoint document as follows.   An online sample link to convert a PowerPoint-presentation-to-PDF-document. Take a moment to peruse the documentation, where you can find other options to format the text with code examples.  Refer here to explore the rich set of Syncfusion Essential Presentation features. Refer here to explore more PowerPoint presentation to PDF conversion options. Note: Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.ConclusionI hope you enjoyed learning about how to export a PowerPoint presentation file as PDF file in C#, VB.NET.You can refer to our WinForms Presentation feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms Presentation example to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
How to export a PowerPoint presentation file as images in C#, VB.NET
Syncfusion Essential Presentation is a .NET PowerPoint library used to create, open, read, edit, and export PowerPoint presentations. Using this library, you can export a PowerPoint presentation slides as images in C# and VB.NET. Steps to export a PowerPoint file as images programmatically: Create a new C# console application.   Install Syncfusion.Presentation.Base NuGet package to the console application project from nuget.org. For more information about adding a NuGet feed in Visual Studio and installing NuGet packages, refer to documentation.   Install Syncfusion.OfficeChartToImageConverter.Wpf NuGet package to the console application project from nuget.org.   Include the following namespace in the Program.cs file.     Use the following code snippet to convert the slides in the PowerPoint presentation as images.     You can download the working sample from Convert-PowerPoint-To-Images.Zip. An online sample link to convert a PowerPoint presentation slides as images. Take a moment to peruse the documentation, where you can find mode details with code examples. Refer here to explore the rich set of Syncfusion Essential Presentation features. Note: Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.
How to convert a PowerPoint presentation file to images [JPEG, PNG, BMP]
Syncfusion Essential PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can convert PowerPoint document to PDF in C# and VB.NET. Steps to convert PowerPoint document to PDF programmatically: Create a new C# console application project. Install the Syncfusion.PresentationToPDFConverter.WinForms NuGet packages as reference to your .NET Framework application from NuGet.org. Include the following namespaces in the Program.cs file. C# using Syncfusion.Pdf; using Syncfusion.Presentation; using Syncfusion.PresentationToPdfConverter;   VB.NET Imports Syncfusion.Pdf Imports Syncfusion.Presentation Imports Syncfusion.PresentationToPdfConverter   Use the following code snippet to convert PowerPoint document to PDF. C# //Opens a PowerPoint Presentation IPresentation presentation = Presentation.Open("Syncfusion Presentation.pptx"); //Converts the PowerPoint Presentation into PDF document PdfDocument pdfDocument = PresentationToPdfConverter.Convert(presentation); //Saves the PDF document pdfDocument.Save("PPTToPDF.pdf"); //Closes the PDF document pdfDocument.Close(true); //Closes the Presentation presentation.Close(); //This will open the PDF file so, the result will be seen in default PDF viewer System.Diagnostics.Process.Start("PPTToPDF.pdf");   VB.NET 'Opens a PowerPoint Presentation Dim presentationDocument As IPresentation = Presentation.Open("Syncfusion Presentation.pptx") 'Converts the PowerPoint Presentation into PDF document Dim pdfDocument As PdfDocument = PresentationToPdfConverter.Convert(presentationDocument) 'Saves the PDF document pdfDocument.Save("PPTToPDF.pdf") 'Closes the PDF document pdfDocument.Close(True) 'Closes the Presentation presentationDocument.Close() 'This will open the PDF file so, the result will be seen in default PDF viewer System.Diagnostics.Process.Start("PPTToPDF.pdf")   A complete working sample can be downloaded from PPTToPDFSample.zip By executing the program, you will get the PDF document as follows. Take a moment to peruse the documentation for working with document conversion , where you will find various document conversion options like Word, Excel, RTF, TIFF, and XPS to PDF. Refer here to explore the rich set of Syncfusion Essential PDF features. Note:Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.   Conclusion I hope you enjoyed learning about how to convert PowerPoint to PDF using C# and VB.NET You can refer to our .NET PowerPoint library’s feature tour page to know about its other groundbreaking feature representations. For current customers, you can check out our File Formats from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our .NET PowerPoint and other File Formats framework. If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!    
How to convert a PowerPoint presentation file to metafile image [EMF] in WinForms?
​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​Syncfusion Essential Presentation is a .NET PowerPoint Library used to create, open, read, edit, and export PowerPoint presentations. Using this library, you can export a PowerPoint presentation slides as EMF images in C# and VB.NET. Exporting the PowerPoint slides as EMF images will result good quality images. Steps to convert a PowerPoint presentation file to metafile images programmatically: Create a new C# console application. Install Syncfusion.Presentation.Base NuGet package to the console application project from nuget.org. For more information about adding a NuGet feed in Visual Studio and installing NuGet packages, refer to documentation. Install Syncfusion.OfficeChartToImageConverter.Wpf NuGet package to the console application project from nuget.org. For more information about adding a NuGet feed in Visual Studio and installing NuGet packages, refer to documentation. Include the following namespace in the Program.cs file.using Syncfusion.Presentation; using Syncfusion.OfficeChartToImageConverter;   Imports Syncfusion.Presentation Imports Syncfusion.OfficeChartToImageConverter   Use the following code snippet to convert the slides in the PowerPoint presentation as .emf images.//Open the PowerPoint Presentation. IPresentation powerpointDoc = Presentation.Open("Sample.pptx");   //Create an instance of ChartToImageConverter and assign it to ChartToImageConverter property of presentation. powerpointDoc.ChartToImageConverter = new ChartToImageConverter();   //Iterate the slides in the PowerPoint file and convert to image foreach (ISlide slide in powerpointDoc.Slides) {     //Convert the slide as EMF image stream.     System.IO.Stream emfImgStream = slide.ConvertToImage(Syncfusion.Drawing.ImageFormat.Emf);       //Create a FileStream object to write the EMF image stream to a file     using (System.IO.FileStream fileStream = System.IO.File.Create("Slide_" + slide.SlideNumber + ".emf", (int)emfImgStream.Length))     {         //Fill the bytes array with the EMF stream data         byte[] bytesInStream = new byte[emfImgStream.Length];           //Copy the EMF image stream to FileStream         emfImgStream.Read(bytesInStream, 0, (int)bytesInStream.Length);           //Write the EMF image to the specified file         fileStream.Write(bytesInStream, 0, bytesInStream.Length);     } }   //Close the Presentation. powerpointDoc.Close();   'Open the PowerPoint Presentation. Dim powerpointDoc As IPresentation = Presentation.Open("Sample.pptx")   'Create an instance of ChartToImageConverter and assign it to ChartToImageConverter property of presentation. powerpointDoc.ChartToImageConverter = New ChartToImageConverter()   'Iterate the slides in the PowerPoint file and convert to image For Each slide As ISlide In powerpointDoc.Slides     'Convert the slide as EMF image stream.     Dim emfImgStream As System.IO.Stream = slide.ConvertToImage(Syncfusion.Drawing.ImageFormat.Emf)       'Create a FileStream object to write the EMF image stream to a file     Using fileStream As System.IO.FileStream = System.IO.File.Create("Slide_" + slide.SlideNumber + ".emf", CInt(emfImgStream.Length))         'Fill the bytes array with the EMF stream data         Dim bytesInStream As Byte() = New Byte(emfImgStream.Length - 1) {}           'Copy the EMF image stream to FileStream         emfImgStream.Read(bytesInStream, 0, CInt(bytesInStream.Length))           'Write the EMF image to the specified file         fileStream.Write(bytesInStream, 0, bytesInStream.Length)     End Using Next   'Close the Presentation. powerpointDoc.Close()   You can download the working sample from Convert-PowerPoint-To-EMF-Images.Zip. An online sample link to convert a PowerPoint presentation slides as images. Take a moment to peruse the documentation, where you can find mode details about exporting the PowerPoint slides as images with code examples. Refer here to explore the complete set of Syncfusion Essential Presentation features. Note:Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.ConclusionI hope you enjoyed learning about how to convert a PowerPoint presentation file to metafile image [EMF] in WinForms.You can refer to our WinForms Presentation feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our  WinForms Presentation​ example to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!
How to convert OXPS to PDF?
Syncfusion Essential&reg; PDF is a .NET PDF library used to create, read, and edit PDF documents. Using this library, you can convert OXPS to a PDF document using C# and VB.NET. Steps to convert OXPS to PDF programmatically: Create a new C# Windows Forms application project. Install the Syncfusion.Pdf.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org. Include the following namespaces in the Form1.cs file. C# using Syncfusion.Pdf; using Syncfusion.XPS;   VB.NET Imports Syncfusion.Pdf Imports Syncfusion.XPS   Use the following code snippet in the click event of button to convert OXPS to PDF document. C# //Create converter class XPSToPdfConverter converter = new XPSToPdfConverter(); //Convert the OXPS to PDF PdfDocument document = converter.Convert("input.oxps"); //Save and close the document document.Save("OXPSToPDF.pdf"); document.Close(true);   VB.NET 'Create converter class Dim converter = New XPSToPdfConverter() 'Convert the OXPS to PDF Dim document = converter.Convert("input.oxps") 'Save And close the document document.Save("OXPSToPDF.pdf") document.Close(True)   A complete working sample can be downloaded from OXPS_To_PDF.zip. By executing the program, you will get the PDF document as follows. Take a moment to peruse the documentation for working with document conversions, where you will find other options like the conversion of Word to PDF, Excel to PDF, RTF to PDF, TIFF to PDF, and HTML to PDF with code examples. Refer here to explore the rich set of Syncfusion Essential&reg; PDF features. An online sample link to convert XPS to PDF. Note:Starting with v16.2.0.x, if you reference Syncfusion&reg; assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion&reg; license key in your application to use the components without a trial message. ConclusionI hope you enjoyed learning about how to convert OXPS to PDF.You can refer to our WinForms PDF’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms PDF documentation to understand how to present and manipulate data.For current customers, you can check out our WinForms components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our WinForms PDF and other WinForms components.If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you! 
Convert Excel page to PDF in C#, VB.NET
Syncfusion&reg; Excel (XlsIO) library is a .NET Excel library used to create, read, and edit Excel documents. It also, converts Excel documents to PDF files. Using this library, you can also convert each page in an Excel file to an individual PDF document. This can be achieved by identifying the page breaks in the Excel worksheet and copying the range within that page breaks to a temporary worksheet. The temporary worksheet will be used as input for ExcelToPdfConverter which generates the PDF documents. Steps to convert each page in an Excel file to an individual PDF document, programmatically: Step 1: Create a new C# console application project. Create a new C# console application project Step 2: Install the Syncfusion.ExcelToPdfConverter.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org. Install NuGet package to the project Step 3: Add the Excel file from which you want to convert each page to an individual PDF document and make the file an Embedded Resource, by following the below steps. In Visual Studio, click the Project menu and select Add Existing Item. Find and select the Excel file you want to add to your project. In the Solution Explorer window, right-click on the Excel file you just added to your project and select Properties from the popup menu. The Properties tool window appears. In the Properties window, change the Build Action property to Embedded Resource. Build the project. Excel file will be compiled into your project’s assembly. Step 4: Include the following namespaces in Program.cs file. C# using Syncfusion.ExcelToPdfConverter; using Syncfusion.Pdf; using Syncfusion.XlsIO; using System.IO; using System.Reflection;   VB.NET Imports Syncfusion.ExcelToPdfConverter Imports Syncfusion.Pdf Imports Syncfusion.XlsIO Imports System.IO Imports System.Reflection   Step 5: Include the following code snippet in main method of the Program.cs file, to convert each page in Excel file to an individual PDF document. C# using (ExcelEngine excelEngine = new ExcelEngine()) {     // Instantiate the Excel application object     IApplication application = excelEngine.Excel;       // Load an existing Excel file into IWorkbook     Assembly assembly = typeof(Program).GetTypeInfo().Assembly;     Stream fileStream = assembly.GetManifestResourceStream("GeneratePDF.Sample.xlsx");     IWorkbook workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic);       // Initialize IWorksheet object     IWorksheet worksheet = null;       // Convert each page in every worksheet to a PDF document     for (int i = 0; i < workbook.Worksheets.Count; i++)     {         worksheet = workbook.Worksheets[i];         bool hasVertical = worksheet.VPageBreaks.Count > 0 ? true : false;         bool hasHorizontal = worksheet.HPageBreaks.Count > 0 ? true : false;         bool isHCompleted = false;         for (int k = 0, VCount = worksheet.VPageBreaks.Count, r = 0; (k <= VCount && VCount != 0) || (!hasVertical && hasHorizontal); k++)         {             if (isHCompleted)                 break;               bool isVCompleted = false;             for (int j = 0, HCount = worksheet.HPageBreaks.Count; (j <= HCount && HCount != 0) || (hasVertical && !hasHorizontal); j++)             {                 if (isVCompleted)                     break;                   // Create a new worksheet in the workbook                 IWorksheet tempWorksheet = workbook.Worksheets.Create();                   if (j == 0 && !hasVertical)                     worksheet.Range[1, 1, worksheet.HPageBreaks[j].Location.Row - 1, worksheet.UsedRange.LastColumn].CopyTo(tempWorksheet.Range[1, 1]);                   else if (k == 0 && !hasHorizontal)                     worksheet.Range[1, 1, worksheet.UsedRange.LastRow, worksheet.VPageBreaks[k].Location.Column - 1].CopyTo(tempWorksheet.Range[1, 1]);                   else if (j == 0 && k == 0 && hasVertical && hasHorizontal)                     worksheet.Range[1, 1, worksheet.HPageBreaks[j].Location.Row - 1, worksheet.VPageBreaks[k].Location.Column - 1].CopyTo(tempWorksheet.Range[1, 1]);                   else if (j == HCount - 1 && !hasVertical)                     worksheet.Range[worksheet.HPageBreaks[j - 1].Location.Row, worksheet.HPageBreaks[j - 1].Location.Column, worksheet.UsedRange.LastRow, worksheet.UsedRange.LastColumn].CopyTo(tempWorksheet.Range[1, 1]);                   else if (k < VCount && !hasHorizontal)                     worksheet.Range[1, worksheet.VPageBreaks[k - 1].Location.Column, worksheet.UsedRange.LastRow, worksheet.VPageBreaks[k].Location.Column - 1].CopyTo(tempWorksheet.Range[1, 1]);                   else if (k == VCount && !hasHorizontal)                     worksheet.Range[1, worksheet.VPageBreaks[k - 1].Location.Column, worksheet.UsedRange.LastRow, worksheet.UsedRange.LastColumn].CopyTo(tempWorksheet.Range[1, 1]);                   else                 {                     if (!hasVertical)                         worksheet.Range[worksheet.HPageBreaks[j - 1].Location.Row, worksheet.HPageBreaks[j - 1].Location.Column, worksheet.HPageBreaks[j].Location.Row - 1, worksheet.UsedRange.LastColumn].CopyTo(tempWorksheet.Range[1, 1]);                       else if (!hasHorizontal)                         worksheet.Range[1, worksheet.VPageBreaks[k].Location.Column, worksheet.UsedRange.LastRow, worksheet.VPageBreaks[k + 1].Location.Column - 1].CopyTo(tempWorksheet.Range[1, 1]);                       else if (k == 0 && j == HCount)                         worksheet.Range[worksheet.HPageBreaks[j - 1].Location.Row + 1, 1, worksheet.UsedRange.LastRow, worksheet.VPageBreaks[k].Location.Column].CopyTo(tempWorksheet.Range[1, 1]);                       else if (k == 0)                         worksheet.Range[worksheet.HPageBreaks[j - 1].Location.Row, 1, worksheet.HPageBreaks[j].Location.Row - 1, worksheet.VPageBreaks[k].Location.Column - 1].CopyTo(tempWorksheet.Range[1, 1]);                       else if (j == 0 && k == VCount)                         worksheet.Range[1, worksheet.VPageBreaks[k - 1].Location.Column, worksheet.HPageBreaks[j].Location.Row - 1, worksheet.UsedRange.LastColumn].CopyTo(tempWorksheet.Range[1, 1]);                       else if (j == 0 && k > 0)                         worksheet.Range[1, worksheet.VPageBreaks[k - 1].Location.Column, worksheet.HPageBreaks[j].Location.Row - 1, worksheet.VPageBreaks[k].Location.Column - 1].CopyTo(tempWorksheet.Range[1, 1]);                       else if (k == VCount && j == HCount)                         worksheet.Range[worksheet.HPageBreaks[j - 1].Location.Row, worksheet.VPageBreaks[k - 1].Location.Column, worksheet.UsedRange.LastRow, worksheet.UsedRange.LastColumn].CopyTo(tempWorksheet.Range[1, 1]);                       else if (k > 0 && j == HCount)                         worksheet.Range[worksheet.HPageBreaks[j - 1].Location.Row, worksheet.VPageBreaks[k - 1].Location.Column, worksheet.UsedRange.LastRow, worksheet.VPageBreaks[k].Location.Column - 1].CopyTo(tempWorksheet.Range[1, 1]);                       else if (j > 0 && k == VCount)                         worksheet.Range[worksheet.HPageBreaks[j - 1].Location.Row, worksheet.VPageBreaks[k - 1].Location.Column, worksheet.HPageBreaks[j].Location.Row - 1, worksheet.UsedRange.LastColumn].CopyTo(tempWorksheet.Range[1, 1]);                       else                         worksheet.Range[worksheet.HPageBreaks[j - 1].Location.Row, worksheet.VPageBreaks[k - 1].Location.Column, worksheet.HPageBreaks[j].Location.Row - 1, worksheet.VPageBreaks[k].Location.Column - 1].CopyTo(tempWorksheet.Range[1, 1]);                 }                   // Initialize the Excel to PDF converter                 ExcelToPdfConverter converter = new ExcelToPdfConverter(tempWorksheet);                   // Initialize the Excel to PDF converter settings                 ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();                   //Set the layout options of converter settings                 if (!hasHorizontal && hasVertical)                     settings.LayoutOptions = LayoutOptions.FitAllRowsOnOnePage;                 else                     settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;                   // Initialize the PdfDocument object                 PdfDocument document = converter.Convert(settings);                 r++;                   // Save the PDF document                 document.Save("../../Output/Page" + r + ".pdf");                   // Remove the worksheet from the workbook                 workbook.Worksheets.Remove(tempWorksheet);                   if (j == HCount - 1 && !hasVertical)                 {                     isHCompleted = true;                     break;                 }                 if (j == 0 && hasVertical && !hasHorizontal)                 {                     isVCompleted = true;                     break;                 }                   // Close the instance of PdfDocument                 document.Close();             }         }     } }   VB.NET Using excelEngine As ExcelEngine = New ExcelEngine()     'Instantiate the Excel application object     Dim application As IApplication = excelEngine.Excel       'Load an existing Excel file into IWorkbook     Dim assembly As Assembly = GetType(Module1).GetTypeInfo.Assembly     Dim fileStream As Stream = assembly.GetManifestResourceStream("GeneratePDF.Sample.xlsx")     Dim workbook As IWorkbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic)       'Initialize IWorksheet object     Dim worksheet As IWorksheet = Nothing       'Convert each page in every worksheet to a PDF document     For i As Integer = 0 To workbook.Worksheets.Count - 1 Step 1         worksheet = workbook.Worksheets(i)         Dim hasVertical As Boolean = If(worksheet.VPageBreaks.Count > 0, True, False)         Dim hasHorizontal As Boolean = If(worksheet.HPageBreaks.Count > 0, True, False)         Dim isHCompleted As Boolean = False           Dim k As Integer = 0, VCount As Integer = worksheet.VPageBreaks.Count, r As Integer = 0         While (k <= VCount AndAlso VCount <> 0) OrElse (Not hasVertical AndAlso hasHorizontal)               If isHCompleted Then                 Exit While             End If               Dim isVCompleted As Boolean = False             Dim j As Integer = 0, HCount As Integer = worksheet.HPageBreaks.Count             While (j <= HCount AndAlso HCount <> 0) OrElse (hasVertical AndAlso Not hasHorizontal)                   If isVCompleted Then                     Exit While                 End If                   'Create a new worksheet in the workbook                 Dim tempWorksheet As IWorksheet = workbook.Worksheets.Create()                   If j = 0 AndAlso Not hasVertical Then                 worksheet.Range(1, 1, worksheet.HPageBreaks(j).Location.Row - 1, worksheet.UsedRange.LastColumn).CopyTo(tempWorksheet.Range(1, 1))                   ElseIf k = 0 AndAlso Not hasHorizontal Then                 worksheet.Range(1, 1, worksheet.UsedRange.LastRow, worksheet.VPageBreaks(k).Location.Column - 1).CopyTo(tempWorksheet.Range(1, 1))                   ElseIf j = 0 AndAlso k = 0 AndAlso hasVertical AndAlso hasHorizontal Then                 worksheet.Range(1, 1, worksheet.HPageBreaks(j).Location.Row - 1, worksheet.VPageBreaks(k).Location.Column - 1).CopyTo(tempWorksheet.Range(1, 1))                   ElseIf j = HCount - 1 AndAlso Not hasVertical Then                 worksheet.Range(worksheet.HPageBreaks(j - 1).Location.Row, worksheet.HPageBreaks(j - 1).Location.Column, worksheet.UsedRange.LastRow, worksheet.UsedRange.LastColumn).CopyTo(tempWorksheet.Range(1, 1))                   ElseIf k < VCount AndAlso Not hasHorizontal Then                 worksheet.Range(1, worksheet.VPageBreaks(k - 1).Location.Column, worksheet.UsedRange.LastRow, worksheet.VPageBreaks(k).Location.Column - 1).CopyTo(tempWorksheet.Range(1, 1))                   ElseIf k = VCount AndAlso Not hasHorizontal Then                 worksheet.Range(1, worksheet.VPageBreaks(k - 1).Location.Column, worksheet.UsedRange.LastRow, worksheet.UsedRange.LastColumn).CopyTo(tempWorksheet.Range(1, 1))                   Else                     If Not hasVertical Then                         worksheet.Range(worksheet.HPageBreaks(j - 1).Location.Row, worksheet.HPageBreaks(j - 1).Location.Column, worksheet.HPageBreaks(j).Location.Row - 1, worksheet.UsedRange.LastColumn).CopyTo(tempWorksheet.Range(1, 1))                       ElseIf Not hasHorizontal Then                         worksheet.Range(1, worksheet.VPageBreaks(k).Location.Column, worksheet.UsedRange.LastRow, worksheet.VPageBreaks(k + 1).Location.Column - 1).CopyTo(tempWorksheet.Range(1, 1))                       ElseIf k = 0 AndAlso j = HCount Then                         worksheet.Range(worksheet.HPageBreaks(j - 1).Location.Row + 1, 1, worksheet.UsedRange.LastRow, worksheet.VPageBreaks(k).Location.Column).CopyTo(tempWorksheet.Range(1, 1))                       ElseIf k = 0 Then                         worksheet.Range(worksheet.HPageBreaks(j - 1).Location.Row, 1, worksheet.HPageBreaks(j).Location.Row - 1, worksheet.VPageBreaks(k).Location.Column - 1).CopyTo(tempWorksheet.Range(1, 1))                       ElseIf j = 0 AndAlso k = VCount Then                         worksheet.Range(1, worksheet.VPageBreaks(k - 1).Location.Column, worksheet.HPageBreaks(j).Location.Row - 1, worksheet.UsedRange.LastColumn).CopyTo(tempWorksheet.Range(1, 1))                       ElseIf j = 0 AndAlso k > 0 Then                     worksheet.Range(1, worksheet.VPageBreaks(k - 1).Location.Column, worksheet.HPageBreaks(j).Location.Row - 1, worksheet.VPageBreaks(k).Location.Column - 1).CopyTo(tempWorksheet.Range(1, 1))                       ElseIf k = VCount AndAlso j = HCount Then                     worksheet.Range(worksheet.HPageBreaks(j - 1).Location.Row, worksheet.VPageBreaks(k - 1).Location.Column, worksheet.UsedRange.LastRow, worksheet.UsedRange.LastColumn).CopyTo(tempWorksheet.Range(1, 1))                       ElseIf k > 0 AndAlso j = HCount Then                     worksheet.Range(worksheet.HPageBreaks(j - 1).Location.Row, worksheet.VPageBreaks(k - 1).Location.Column, worksheet.UsedRange.LastRow, worksheet.VPageBreaks(k).Location.Column - 1).CopyTo(tempWorksheet.Range(1, 1))                       ElseIf j > 0 AndAlso k = VCount Then                     worksheet.Range(worksheet.HPageBreaks(j - 1).Location.Row, worksheet.VPageBreaks(k - 1).Location.Column, worksheet.HPageBreaks(j).Location.Row - 1, worksheet.UsedRange.LastColumn).CopyTo(tempWorksheet.Range(1, 1))                       Else                         worksheet.Range(worksheet.HPageBreaks(j - 1).Location.Row, worksheet.VPageBreaks(k - 1).Location.Column, worksheet.HPageBreaks(j).Location.Row - 1, worksheet.VPageBreaks(k).Location.Column - 1).CopyTo(tempWorksheet.Range(1, 1))                     End If                 End If                   'Initialize the Excel to PDF converter                 Dim converter As New ExcelToPdfConverter(tempWorksheet)                   'Initialize the Excel to PDF converter settings                 Dim settings As New ExcelToPdfConverterSettings()                   'Set the layout options of converter settings                 If Not hasHorizontal AndAlso hasVertical Then                     settings.LayoutOptions = LayoutOptions.FitAllRowsOnOnePage                 Else                     settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage                 End If                   'Initialize the PdfDocument object                 Dim document As PdfDocument = converter.Convert(settings)                 r += 1                   'Save the PDF document                 document.Save("../../Output/Page" & r & ".pdf")                   'Remove the worksheet from the workbook                 workbook.Worksheets.Remove(tempWorksheet)                   If j = HCount - 1 AndAlso Not hasVertical Then                     isHCompleted = True                     Exit While                 End If                   If j = 0 AndAlso hasVertical AndAlso Not hasHorizontal Then                     isVCompleted = True                     Exit While                 End If                   'Close the instance of PdfDocument                 document.Close()                   j += 1             End While             k += 1         End While     Next End Using   A complete working sample to convert each page in Excel file to an individual PDF document can be downloaded from GeneratePDF.zip. The Excel file used in this sample has 16 pages and its print preview looks as follows. Input Excel document By executing the program, you will get 16 PDF files. Individual PDF documents created for each page in Excel file PDF document created for the first page in Excel file Take a moment to peruse the documentation, where you will find other options like move or copy a worksheet, freeze, unfreeze and split panes, show or hide worksheet and worksheet tabs, page setup settings and more with code examples. Click here to explore the rich set of Syncfusion&reg; Excel (XlsIO) library features. An online sample link for Excel to PDF conversion See Also: Different layout options in Excel to PDF conversion Convert an Excel file to PDF document in C#, VB.NET Adjust the zoom ratio in Excel to PDF conversion Convert an Excel file to PDF document in Azure platform Change the display mode of an Excel to PDF converted document Note:Starting with v16.2.0.x, if you reference Syncfusion&reg; assemblies from a trial setup or from the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion&reg; license key in your application to use the components without a trial message.   ConclusionI hope you enjoyed learning about Convert Excel page to PDF in C#, VB.NET.You can refer to our XIsIO’s feature tour page to learn about its other groundbreaking features. Explore our UG documentation and online demos to understand how to manipulate data in Excel documents.If you are an existing user, you can access our latest components from the License and Downloads page. For new users, you can try our 30-day free trial to check out XlsIO and other Syncfusion&reg; components.If you have any queries or require clarification, please let us know in the comments below or contact us through our support forums, Support Tickets, or feedback portal. We are always happy to assist you!
How to convert the PDF stored in a PdfDocument object to byte array?
In .NET PDF, you can convert the PDF stored in a PdfDocument object to byte array by creating a new Memory stream class and saving the PdfDocument as stream. This stream contains information about the PdfDocument object and can be converted to byte array. C# // Creates a new instance of PdfDocument class. PdfDocument document = new PdfDocument(); // Adds a page to the document. PdfPage page = document.Pages.Add(); // Creates Pdf graphics for the page. PdfGraphics g = page.Graphics; // Creates a solid brush PdfBrush brush = new PdfSolidBrush(Color.Black); // Sets the font. PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 20f); // Draws the text. g.DrawString("Hello world!", font, brush, new PointF(20, 20)); //Creates a new Memory stream MemoryStream stream = new MemoryStream(); // Saves the document as stream document.Save(stream); document.Close(true); // Converts the PdfDocument object to byte form. byte[] docBytes = stream.ToArray(); //Loads the byte array in PdfLoadedDocument PdfLoadedDocument ldoc = new PdfLoadedDocument(docBytes); //Saves the document and dispose it. ldoc.Save("sample.pdf"); ldoc.Close(); Sample Link https://www.syncfusion.com/downloads/support/directtrac/general/ByteArray-1695560889.zipNote:Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without a trial message. Conclusion:I hope you enjoyed learning about how to convert the PDF stored in a PdfDocument object to byte array. You can refer to our Flutter PDF feature tour page to learn about its other groundbreaking features and documentation, and how to quickly get started with configuration specifications. You can also explore our Flutter PDF Flutter PDF examples to understand how to create and manipulate data.For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to explore our other controls.If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums or feedback portal. We are always happy to assist you!
No articles found
No articles found
1 of 1 pages (19 items)