public static string DocConvertionUrl = "https://xxx.com/doc2pdf"; public static string ConvertWord(string docFilePath) { string pdfFilePath; try { // Load the DOC document using Aspose.Words using (WebClient client = new WebClient()) { var bytes = File.ReadAllBytes(docFilePath); byte[] responsebytes = client.UploadData(DocConvertionUrl, bytes); pdfFilePath = docFilePath.Replace(".doc", ".pdf"); using (var fs = new FileStream(pdfFilePath, FileMode.Create, FileAccess.Write)) { fs.Write(responsebytes, 0, responsebytes.Length); } } CloseWord(); DeleteWord(docFilePath); return pdfFilePath; } catch (System.Exception ex) { // Handle any exceptions here //Helper.ErrorMessage = ex.Message + ex.StackTrace; Console.WriteLine("Error converting DOC to PDF: " + ex.Message); return null; } }
public static string DocConvertionUrl = "https://xxx.com/doc2pdf";
<%@ Page Language="C#"%><% var ins = Request.InputStream; var loadOptions = new Aspose.Words.Loading.LoadOptions { LoadFormat = Aspose.Words.LoadFormat.Auto }; var pdfDocument = new Aspose.Words.Document(ins, loadOptions); pdfDocument.Save(Response,"file.pdf", Aspose.Words.ContentDisposition.Attachment, new Aspose.Words.Saving.PdfSaveOptions() ); %>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)