private void Button_Click(object sender, RoutedEventArgs e) { // Configure API key authorization: Apikey Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY"); var apiInstance = new ConvertDocumentApi(); var inputFile = new System.IO.FileStream(txtSource.Text, System.IO.FileMode.Open); // System.IO.Stream | Input file to perform the operation on. byte[] result = apiInstance.ConvertDocumentHtmlToPdf(inputFile); File.WriteAllBytes(txtOutput.Text, result); inputFile.Close(); }
static void Main(string[] args) { // Resizing an image Cloudmersive.APIClient.NETCore.ImageRecognition.Client.Configuration.Default.AddApiKey("Apikey", "YOUR-API-KEY"); var apiInstance1 = new ResizeApi(); var maxWidth = 56; // int? | Maximum width of the output image - final image will be as large as possible while less than or equial to this width var maxHeight = 56; // int? | Maximum height of the output image - final image will be as large as possible while less than or equial to this height var imageFile = new System.IO.FileStream("C:\\temp\\input.jpg", System.IO.FileMode.Open); // System.IO.Stream | Image file to perform the operation on. Common file formats such as PNG, JPEG are supported. try { // Resize an image with parameters byte[] result = apiInstance1.ResizePost(maxWidth, maxHeight, imageFile); Debug.WriteLine("Completed 1"); File.WriteAllBytes("C:\\temp\\output.png", result); } catch (Exception e) { Debug.Print("Exception when calling ResizeApi.ResizePost: " + e.Message); } // Converting a Word Document (DOCX) to PDF Cloudmersive.APIClient.NETCore.DocumentAndDataConvert.Client.Configuration.Default.AddApiKey("Apikey", "YOUR-API-KEY"); var apiInstance2 = new ConvertDocumentApi(); var inputFile = new System.IO.FileStream("C:\\temp\\input.docx", System.IO.FileMode.Open); // System.IO.Stream | Input file to perform the operation on. try { // Word DOCX to PDF byte[] result = apiInstance2.ConvertDocumentDocxToPdf(inputFile); Debug.WriteLine("Completed 2"); File.WriteAllBytes("C:\\temp\\output.pdf", result); } catch (Exception e) { Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentDocxToPdf: " + e.Message); } }
public FileResult ViewPdf(int?id) { var archivo = db.planillascontratos.Where(dp => dp.PC_Id == id).FirstOrDefault(); // Configure API key authorization: Apikey Configuration.Default.AddApiKey("Apikey", "768fa287-07a9-41f9-962d-d1b9356a6b04"); ConvertDocumentApi apiInstance = new ConvertDocumentApi(); //convertir un binario a system.io.stream MemoryStream stream = new MemoryStream(archivo.PC_Binario); // convertir byte[] result = apiInstance.ConvertDocumentDocxToPdf(stream); //return File(result, "document/pdf", archivo.PC_Nom + ".pdf"); ViewBag.nombre = archivo.PC_Nom + "" + archivo.PC_Ext; return(File(result, "application/pdf")); }
static void Main(string[] args) { Console.WriteLine("Starting..."); // Configure API key authorization: Apikey Configuration.Default.AddApiKey("Apikey", "YOUR_API_KEY_HERE"); var apiInstance = new ConvertDocumentApi(); var inputFile = new System.IO.FileStream("C:\\temp\\output.pdf", System.IO.FileMode.Open); // System.IO.Stream | Input file to perform the operation on. byte[] result = apiInstance.ConvertDocumentPdfToPngSingle(inputFile); File.WriteAllBytes("C:\\temp\\output.png", result); Console.WriteLine("Done."); }
public ActionResult DescargarPdf(int?id) { var archivo = db.planillascontratos.Where(dp => dp.PC_Id == id).FirstOrDefault(); // Configure API key authorization: Apikey Configuration.Default.AddApiKey("Apikey", "768fa287-07a9-41f9-962d-d1b9356a6b04"); ConvertDocumentApi apiInstance = new ConvertDocumentApi(); //convertir un binario a system.io.stream MemoryStream stream = new MemoryStream(archivo.PC_Binario); try { // convertir byte[] result = apiInstance.ConvertDocumentDocxToPdf(stream); return(File(result, "document/pdf", archivo.PC_Nom + ".pdf")); } catch (Exception e) { Debug.Print("Error al convertir : " + e.Message); } return(View()); }
public void Init() { instance = new ConvertDocumentApi(); }
protected void btnUpload_Click(object sender, EventArgs e) { // Configure API key authorization: Apikey Configuration.Default.AddApiKey("Apikey", "71b067cf-1d07-474d-9403-1d0e53ca3da4"); var apiInstance = new EditDocumentApi(); var inputFile = new MemoryStream(fileDocumentEditing.FileBytes); // System.IO.Stream | Input file to perform the operation on. // Begin editing a document string result = apiInstance.EditDocumentBeginEditing(inputFile); // Add a header var reqConfig = new DocxSetFooterRequest(); // DocxSetHeaderRequest | reqConfig.InputFileUrl = result.Replace("\"", ""); DocxParagraph p = new DocxParagraph(); DocxRun run = new DocxRun(); DocxText text = new DocxText(); text.TextContent = "Hello, World!"; run.TextItems = new List <DocxText> { text }; DocxRun run2 = new DocxRun(); DocxText text2 = new DocxText(); text2.TextContent = "- From Cloudmersive"; run2.Bold = true; run2.TextItems = new List <DocxText> { text2 }; p.ContentRuns = new List <DocxRun> { run, run2 }; DocxFooter footer = new DocxFooter(); footer.Paragraphs = new List <DocxParagraph> { p }; reqConfig.FooterToApply = footer; DocxSetFooterResponse footerResult = apiInstance.EditDocumentDocxSetFooter(reqConfig); // Add a table var addTable = new InsertDocxTablesRequest(); // InsertDocxTablesRequest | addTable.InputFileUrl = footerResult.EditedDocumentURL; DocxTable table = new DocxTable(); table.TopBorderType = "Single"; table.TopBorderSize = 4; table.TopBorderSpace = 0; table.TopBorderColor = "000000"; table.LeftBorderType = "Single"; table.LeftBorderSize = 4; table.LeftBorderColor = "000000"; table.RightBorderType = "Single"; table.RightBorderSize = 4; table.RightBorderColor = "000000"; table.CellHorizontalBorderType = "Single"; table.CellHorizontalBorderSize = 4; table.CellHorizontalBorderColor = "000000"; table.CellHorizontalBorderSpace = 0; table.CellVerticalBorderType = "Single"; table.CellVerticalBorderSize = 4; table.CellVerticalBorderColor = "000000"; table.CellVerticalBorderSpace = 0; DocxTableRow headerRow = new DocxTableRow(); DocxTableCell col1 = new DocxTableCell(); col1.CellShadingFill = "FFFFFF"; p = new DocxParagraph(); run = new DocxRun(); text = new DocxText(); text.TextContent = "First Header"; run.TextItems = new List <DocxText>() { text }; run.Bold = true; p.ContentRuns = new List <DocxRun>() { run }; col1.Paragraphs = new List <DocxParagraph>() { p }; headerRow.RowCells = new List <DocxTableCell>() { col1 }; table.TableRows = new List <DocxTableRow> { headerRow }; col1 = new DocxTableCell(); col1.CellShadingFill = "FFFFFF"; p = new DocxParagraph(); run = new DocxRun(); text = new DocxText(); text.TextContent = "Second Header"; run.TextItems = new List <DocxText>() { text }; run.Bold = true; p.ContentRuns = new List <DocxRun>() { run }; col1.Paragraphs = new List <DocxParagraph>() { p }; headerRow.RowCells = new List <DocxTableCell>() { col1 }; headerRow.RowCells.Add(col1); table.TableRows = new List <DocxTableRow> { headerRow }; for (int i = 1; i <= 10; i++) { // Column 1 DocxTableRow dataRow = new DocxTableRow(); DocxTableCell dataCol1 = new DocxTableCell(); dataCol1.CellShadingFill = "FFFFFF"; p = new DocxParagraph(); run = new DocxRun(); text = new DocxText(); text.TextContent = "Data Row " + i.ToString(); run.TextItems = new List <DocxText>() { text }; run.Bold = false; p.ContentRuns = new List <DocxRun>() { run }; dataCol1.Paragraphs = new List <DocxParagraph>() { p }; dataRow.RowCells = new List <DocxTableCell>() { dataCol1 }; table.TableRows.Add(dataRow); // Column 2 dataCol1 = new DocxTableCell(); dataCol1.CellShadingFill = "FFFFFF"; p = new DocxParagraph(); run = new DocxRun(); text = new DocxText(); text.TextContent = "Data Row " + i.ToString(); run.TextItems = new List <DocxText>() { text }; run.Bold = false; p.ContentRuns = new List <DocxRun>() { run }; dataCol1.Paragraphs = new List <DocxParagraph>() { p }; dataRow.RowCells = new List <DocxTableCell>() { dataCol1 }; dataRow.RowCells.Add(dataCol1); table.TableRows.Add(dataRow); } addTable.TableToInsert = table; InsertDocxTablesResponse tableAdded = apiInstance.EditDocumentDocxInsertTable(addTable); // Finish editing var finEditing = new FinishEditingRequest(); // FinishEditingRequest | finEditing.InputFileUrl = tableAdded.EditedDocumentURL; byte[] finishedDocument = apiInstance.EditDocumentFinishEditing(finEditing); // Convert to PDF var convertApi = new ConvertDocumentApi(); var finishedDoc = new MemoryStream(finishedDocument); // System.IO.Stream | Input file to perform the operation on. byte[] pdf = convertApi.ConvertDocumentDocxToPdf(finishedDoc); // Display the result var viewerApi = new ViewerToolsApi(); var finalResult = new MemoryStream(pdf); ViewerResponse viewerSnippet = viewerApi.ViewerToolsCreateSimple(finalResult); resultDiv.InnerHtml = viewerSnippet.HtmlEmbed.Replace("iframe", "iframe width='800' height='1000'"); }
public PowerPointProcessor() { _convertDocumentApi = new ConvertDocumentApi(); }
private static async Task Convert() { Cloudmersive.APIClient.NETCore.DocumentAndDataConvert.Client.Configuration.Default.AddApiKey("Apikey", "07af4ce1-40eb-4e97-84e0-c02b4974b190"); Cloudmersive.APIClient.NETCore.DocumentAndDataConvert.Client.Configuration.Default.Timeout = 300000; //base on support var _convertDocumentApi = new ConvertDocumentApi(); var id = 104135; var storage = Container.Resolve <ICloudStorageProvider>(); var client = storage.GetBlobClient(); var container = client.GetContainerReference("spitball-files"); var dir1 = container.GetDirectoryReference("files"); var dir2 = dir1.GetDirectoryReference($"{id}"); var blobs = await dir2.ListBlobsSegmentedAsync(null); var blob = (CloudBlockBlob)blobs.Results.FirstOrDefault(f => ((CloudBlockBlob)f).Name.Contains("file-")); var sr = await blob.OpenReadAsync(); // var sr = new FileStream("C:\\Users\\Ram\\Downloads\\xxx\\file-52936bce-e08a-4138-9639-4971c22640ba-142339.pptx", System.IO.FileMode.Open); // System.IO.Stream | Input file to perform the operation on. var text2 = await _convertDocumentApi.ConvertDocumentPptxToTxtAsync(sr); sr.Seek(0, SeekOrigin.Begin); var result = await _convertDocumentApi.ConvertDocumentAutodetectToPngArrayAsync(sr); Console.WriteLine("here"); //var image = new Image<Rgba32>(500, 500); //image.Mutate(c=>c.BackgroundColor(Color.Aqua)); //var ms = new MemoryStream(); //image.SaveAsJpeg(ms); //try //{ // //var request = new DrawTextRequest(); // //byte[] result2 = apiInstance3.EditDrawText(request); // var sw = new Stopwatch(); // sw.Start(); // var bytes = ms.ToArray(); // //apiInstance3.EditDrawText(new DrawTextRequest()) // var result = apiInstance3.EditDrawText( // new DrawTextRequest( // BaseImageBytes: bytes, // TextToDraw: new List<DrawTextInstance>() // { // new DrawTextInstance( // "בקרוב תראו תוצאות וציונים שיעלו לכם חיוך על הפנים :) (אפילו אם כרגע זה נראה בלתי אפשרי). בעל ניסיון של 6 שנים!", // FontFamilyName: "Georgia", // FontSize:32, // Color:"black",0,0,500,500 // ) // })); // File.WriteAllBytes(@"c:\Users\Ram\Downloads\ram1.jpg",result); // //var v = apiInstance.ConvertDocumentDocxToTxt(inputFile); // //inputFile.Seek(0, SeekOrigin.Begin); // //var f = apiInstance.ConvertDocumentAutodetectGetInfo(inputFile); // // var result = apiInstance.ConvertDocumentAutodetectToPngArray(inputFile); // //apiInstance.ConvertDocumentAutodetectGetInfo() // //var result = apiInstance.ConvertDocumentAutodetectToPngArray(inputFile); // // Word DOCX to PDF // //Object result = apiInstance.ConvertDocumentDocxToPdf(inputFile); // sw.Stop(); // Debug.WriteLine(result); //} //catch (Exception e) //{ // Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentDocxToPdf: " + e.Message); //} }