支持excel,word,ppt,pdf

using Aspose.Cells;
using Aspose.Words.Saving;
using ESBasic;
using OMCS.Engine.WhiteBoard;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using SMES.LocaleManagerWeb.DoucmentManager;
using ImageSaveOptions = Aspose.Words.Saving.ImageSaveOptions;
using SaveFormat = Aspose.Words.SaveFormat; namespace SMES.LocaleManagerWeb
{
public partial class Upload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//new Aspose.Words.License().SetLicense(AsposeLicenseHelper.LStream);
//new Aspose.Cells.License().SetLicense(AsposeLicenseHelper.LStream);
//new Aspose.Slides.License().SetLicense(AsposeLicenseHelper.LStream);
//new Aspose.Pdf.License().SetLicense(AsposeLicenseHelper.LStream);
string documentExts = "pdf|doc|docx|xlsx|xls|ppt|pptx";
string imageExts = "jpeg|png|jpg|bmp";
string otherExts = "pdf|xls|xlsx|ppt|pptx";
HttpFileCollection files = Request.Files;//这里只能用<input type="file" />才能有效果,因为服务器控件是HttpInputFile类型 FileUpModel model = new FileUpModel();
if (files.Count == 0 || files[0].InputStream.Length == 0)
{
model = new FileUpModel() { State = 0, Error = "没有找到文件" };
Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(model));
//Response.End();
return;
} try
{
HttpPostedFile file = files[0];
model.Extension = GetExtension(file.FileName);
if ((documentExts + "|" + imageExts + "|" + otherExts).IndexOf(model.Extension.ToLower()) == -1)
{
model = new FileUpModel() { State = 0, Error = "不允许上传" + model.Extension + "类型文件" };
Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(model));
//Response.End();
return;
} model.Size = file.ContentLength / 1024;
DateTime nowtime = DateTime.Now;
string dic = "/UpLoadFile/" + nowtime.ToString("yy/MM/dd/");
string newFilename = "/UpLoadFile/" + nowtime.ToString("yy/MM/dd/") + Guid.NewGuid().ToString("N") + "." + model.Extension;
string filepath = Server.MapPath("~" + newFilename);
if (!System.IO.Directory.Exists(Server.MapPath(dic)))
{
System.IO.Directory.CreateDirectory(Server.MapPath(dic));
}
file.SaveAs(filepath);
//将文档装换为图图片
if (documentExts.IndexOf(model.Extension.ToLower()) != -1)
{
//图片目录
string imagedic = newFilename.Replace("." + model.Extension, "");
IImageConverterFactory f = new ImageConverterFactory();
IImageConverter imageConverter = f.CreateImageConverter("." + model.Extension);
string opath = Server.MapPath("~" + newFilename);
string imgpath = Server.MapPath("~" + imagedic + "/");
Thread thd = new Thread(new ThreadStart(() => { imageConverter.ConvertToImage(opath, imgpath); }));
thd.Start();
//DocumentToImage(newFilename, imagedic);
model.ImagePath = imagedic;
} model.State = 1;
model.Path = newFilename; Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(model)); }
catch (Exception ee)
{
model = new FileUpModel() { State = 0, Error = ee.Message };
Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(model));
Response.End();
}
} private void DocumentToImage(string filename, string imagedic)
{
Thread thd = new Thread(new ThreadStart(() =>
{
ConvertWordToImage(Server.MapPath("~" + filename), Server.MapPath("~" + imagedic + "/"), "A", 0, 0, ImageFormat.Png, 0);
}));
thd.Start(); } private string GetExtension(string filename)
{
if (string.IsNullOrEmpty(filename))
return ""; string[] strs = filename.Split('.'); if (strs.Length > 0)
{
return strs[strs.Length - 1];
}
else
{
return "";
}
} public void ConvertWordToImage(string wordInputPath, string imageOutputPath,
string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution)
{
try
{
AsposeLicenseHelper.SetWordsLicense();
// open word file
Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath); // validate parameter
if (doc == null) { throw new Exception("Word文件无效或者Word文件被加密!"); }
if (imageOutputPath.Trim().Length == 0) { imageOutputPath = Path.GetDirectoryName(wordInputPath); }
if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
if (imageName.Trim().Length == 0) { imageName = Path.GetFileNameWithoutExtension(wordInputPath); }
if (startPageNum <= 0) { startPageNum = 1; }
if (endPageNum > doc.PageCount || endPageNum <= 0) { endPageNum = doc.PageCount; }
if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
if (imageFormat == null) { imageFormat = ImageFormat.Png; }
if (resolution <= 0) { resolution = 128; } var imageSaveOptions = new ImageSaveOptions(GetSaveFormat(imageFormat))
{
Resolution = resolution
}; // start to convert each page
for (int i = startPageNum; i <= endPageNum; i++)
{
imageSaveOptions.PageIndex = i - 1;
doc.Save(Path.Combine(imageOutputPath, imageName) + "_" + i.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
}
}
catch (Exception ex)
{ }
} private SaveFormat GetSaveFormat(ImageFormat imageFormat)
{
SaveFormat sf = SaveFormat.Unknown;
if (imageFormat.Equals(ImageFormat.Png))
sf = SaveFormat.Png;
else if (imageFormat.Equals(ImageFormat.Jpeg))
sf = SaveFormat.Jpeg;
else if (imageFormat.Equals(ImageFormat.Tiff))
sf = SaveFormat.Tiff;
else if (imageFormat.Equals(ImageFormat.Bmp))
sf = SaveFormat.Bmp;
else
sf = SaveFormat.Unknown;
return sf;
} } public class FileUpModel
{
/// <summary>
/// 状态 1成功 0失败
/// </summary>
public int State
{ get; set; } /// <summary>
/// 错误信息
/// </summary>
public string Error
{ get; set; } /// <summary>
/// 文件大小
/// </summary>
public decimal Size
{
get;
set;
} /// <summary>
/// 服务端路径
/// </summary>
public string Path
{ get; set; } public string ImagePath
{ get; set; } public string Extension
{ get; set; } } #region 图片转换器工厂 -> 将被注入到OMCS的多媒体管理器IMultimediaManager的ImageConverterFactory属性
/// <summary>
/// 图片转换器工厂。
/// </summary>
public class ImageConverterFactory : IImageConverterFactory
{
public IImageConverter CreateImageConverter(string extendName)
{
if (extendName == ".doc" || extendName == ".docx")
{
return new Word2ImageConverter();
} if (extendName == ".pdf")
{
return new Pdf2ImageConverter();
} if (extendName == ".ppt" || extendName == ".pptx")
{
return new Ppt2ImageConverter();
}
if (extendName == ".xls" || extendName == ".xlsx")
{
return new Xls2ImageConverter();
}
return null;
} public bool Support(string extendName)
{
return extendName == ".doc" || extendName == ".docx" || extendName == ".pdf" || extendName == ".ppt" || extendName == ".pptx" || extendName == ".rar";
}
}
#endregion #region 将word文档转换为图片
public class Word2ImageConverter : IImageConverter
{
private bool cancelled = false;
public event CbGeneric<int, int> ProgressChanged;
public event CbGeneric ConvertSucceed;
public event CbGeneric<string> ConvertFailed; public void Cancel()
{
if (this.cancelled)
{
return;
} this.cancelled = true;
} public void ConvertToImage(string originFilePath, string imageOutputDirPath)
{
this.cancelled = false;
ConvertToImage(originFilePath, imageOutputDirPath, 0, 0, null, 200);
} /// <summary>
/// 将Word文档转换为图片的方法
/// </summary>
/// <param name="wordInputPath">Word文件路径</param>
/// <param name="imageOutputDirPath">图片输出路径,如果为空,默认值为Word所在路径</param>
/// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
/// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为Word总页数</param>
/// <param name="imageFormat">设置所需图片格式,如果为null,默认格式为PNG</param>
/// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
private void ConvertToImage(string wordInputPath, string imageOutputDirPath, int startPageNum, int endPageNum, ImageFormat imageFormat, int resolution)
{
try
{ AsposeLicenseHelper.SetWordsLicense();
Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath); if (doc == null)
{
throw new Exception("Word文件无效或者Word文件被加密!");
} if (imageOutputDirPath.Trim().Length == 0)
{
imageOutputDirPath = Path.GetDirectoryName(wordInputPath);
} if (!Directory.Exists(imageOutputDirPath))
{
Directory.CreateDirectory(imageOutputDirPath);
} if (startPageNum <= 0)
{
startPageNum = 1;
} if (endPageNum > doc.PageCount || endPageNum <= 0)
{
endPageNum = doc.PageCount;
} if (startPageNum > endPageNum)
{
int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum;
} if (imageFormat == null)
{
imageFormat = ImageFormat.Png;
} if (resolution <= 0)
{
resolution = 128;
}
string imageName = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(wordInputPath));
//string imageName = Path.GetFileNameWithoutExtension(wordInputPath);
Aspose.Words.Saving.ImageSaveOptions imageSaveOptions = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Png);
imageSaveOptions.Resolution = resolution;
for (int i = startPageNum; i <= endPageNum; i++)
{
if (this.cancelled)
{
break;
} MemoryStream stream = new MemoryStream();
imageSaveOptions.PageIndex = i - 1;
//string imgPath = Path.Combine(imageOutputDirPath, imageName) + "_" + i.ToString("000") + "." + imageFormat.ToString();
string imgPath = Path.Combine(imageOutputDirPath, "A") + "_" + i + ".Png";
doc.Save(stream, imageSaveOptions);
System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
Bitmap bm = ESBasic.Helpers.ImageHelper.Zoom(img, 0.6f);
bm.Save(imgPath, imageFormat);
img.Dispose();
stream.Dispose();
bm.Dispose(); System.Threading.Thread.Sleep(200);
if (this.ProgressChanged != null)
{
this.ProgressChanged(i - 1, endPageNum);
}
} if (this.cancelled)
{
return;
} if (this.ConvertSucceed != null)
{
this.ConvertSucceed();
}
}
catch (Exception ex)
{
if (this.ConvertFailed != null)
{
this.ConvertFailed(ex.Message);
}
}
}
}
#endregion #region 将pdf文档转换为图片
public class Pdf2ImageConverter : IImageConverter
{
private bool cancelled = false;
public event CbGeneric<int, int> ProgressChanged;
public event CbGeneric ConvertSucceed;
public event CbGeneric<string> ConvertFailed; public void Cancel()
{
if (this.cancelled)
{
return;
} this.cancelled = true;
} public void ConvertToImage(string originFilePath, string imageOutputDirPath)
{
this.cancelled = false;
ConvertToImage(originFilePath, imageOutputDirPath, 0, 0, 200);
} /// <summary>
/// 将pdf文档转换为图片的方法
/// </summary>
/// <param name="originFilePath">pdf文件路径</param>
/// <param name="imageOutputDirPath">图片输出路径,如果为空,默认值为pdf所在路径</param>
/// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
/// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为pdf总页数</param>
/// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
private void ConvertToImage(string originFilePath, string imageOutputDirPath, int startPageNum, int endPageNum, int resolution)
{
try
{
AsposeLicenseHelper.SetPdfLicense();
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(originFilePath); if (doc == null)
{
throw new Exception("pdf文件无效或者pdf文件被加密!");
} if (imageOutputDirPath.Trim().Length == 0)
{
imageOutputDirPath = Path.GetDirectoryName(originFilePath);
} if (!Directory.Exists(imageOutputDirPath))
{
Directory.CreateDirectory(imageOutputDirPath);
} if (startPageNum <= 0)
{
startPageNum = 1;
} if (endPageNum > doc.Pages.Count || endPageNum <= 0)
{
endPageNum = doc.Pages.Count;
} if (startPageNum > endPageNum)
{
int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum;
} if (resolution <= 0)
{
resolution = 128;
} string imageNamePrefix = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(originFilePath));
for (int i = startPageNum; i <= endPageNum; i++)
{
if (this.cancelled)
{
break;
} MemoryStream stream = new MemoryStream();
//string imgPath = Path.Combine(imageOutputDirPath, imageNamePrefix) + "_" + i.ToString("000") + ".Png";
string imgPath = Path.Combine(imageOutputDirPath, "A") + "_" + i + ".Png";
Aspose.Pdf.Devices.Resolution reso = new Aspose.Pdf.Devices.Resolution(resolution);
Aspose.Pdf.Devices.JpegDevice jpegDevice = new Aspose.Pdf.Devices.JpegDevice(reso, 100);
jpegDevice.Process(doc.Pages[i], stream); Image img = Image.FromStream(stream);
Bitmap bm = ESBasic.Helpers.ImageHelper.Zoom(img, 0.6f);
bm.Save(imgPath, ImageFormat.Jpeg);
img.Dispose();
stream.Dispose();
bm.Dispose(); System.Threading.Thread.Sleep(200);
if (this.ProgressChanged != null)
{
this.ProgressChanged(i - 1, endPageNum);
}
} if (this.cancelled)
{
return;
} if (this.ConvertSucceed != null)
{
this.ConvertSucceed();
}
}
catch (Exception ex)
{
if (this.ConvertFailed != null)
{
this.ConvertFailed(ex.Message);
}
}
}
}
#endregion #region 将ppt文档转换为图片
public class Ppt2ImageConverter : IImageConverter
{
private Pdf2ImageConverter pdf2ImageConverter;
public event CbGeneric<int, int> ProgressChanged;
public event CbGeneric ConvertSucceed;
public event CbGeneric<string> ConvertFailed; public void Cancel()
{
if (this.pdf2ImageConverter != null)
{
this.pdf2ImageConverter.Cancel();
}
} public void ConvertToImage(string originFilePath, string imageOutputDirPath)
{
ConvertToImage(originFilePath, imageOutputDirPath, 0, 0, 200);
} /// <summary>
/// 将pdf文档转换为图片的方法
/// </summary>
/// <param name="originFilePath">ppt文件路径</param>
/// <param name="imageOutputDirPath">图片输出路径,如果为空,默认值为pdf所在路径</param>
/// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
/// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为pdf总页数</param>
/// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
private void ConvertToImage(string originFilePath, string imageOutputDirPath, int startPageNum, int endPageNum, int resolution)
{
try
{
AsposeLicenseHelper.SetSlidesLicense();
Aspose.Slides.Presentation doc = new Aspose.Slides.Presentation(originFilePath); if (doc == null)
{
throw new Exception("ppt文件无效或者ppt文件被加密!");
} if (imageOutputDirPath.Trim().Length == 0)
{
imageOutputDirPath = Path.GetDirectoryName(originFilePath);
} if (!Directory.Exists(imageOutputDirPath))
{
Directory.CreateDirectory(imageOutputDirPath);
} if (startPageNum <= 0)
{
startPageNum = 1;
} if (endPageNum > doc.Slides.Count || endPageNum <= 0)
{
endPageNum = doc.Slides.Count;
} if (startPageNum > endPageNum)
{
int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum;
} if (resolution <= 0)
{
resolution = 128;
} //先将ppt转换为pdf临时文件
string tmpPdfPath = originFilePath + ".pdf";
doc.Save(tmpPdfPath, Aspose.Slides.Export.SaveFormat.Pdf); //再将pdf转换为图片
Pdf2ImageConverter converter = new Pdf2ImageConverter();
converter.ConvertFailed += new CbGeneric<string>(converter_ConvertFailed);
converter.ConvertSucceed += new CbGeneric(converter_ConvertSucceed);
converter.ProgressChanged += new CbGeneric<int, int>(converter_ProgressChanged);
converter.ConvertToImage(tmpPdfPath, imageOutputDirPath); //删除pdf临时文件
File.Delete(tmpPdfPath); if (this.ConvertSucceed != null)
{
this.ConvertSucceed();
}
}
catch (Exception ex)
{
if (this.ConvertFailed != null)
{
this.ConvertFailed(ex.Message);
}
} this.pdf2ImageConverter = null;
} void converter_ProgressChanged(int done, int total)
{
if (this.ProgressChanged != null)
{
this.ProgressChanged(done, total);
}
} void converter_ConvertSucceed()
{
if (this.ConvertSucceed != null)
{
this.ConvertSucceed();
}
} void converter_ConvertFailed(string msg)
{
if (this.ConvertFailed != null)
{
this.ConvertFailed(msg);
}
}
}
#endregion #region Excel
public class Xls2ImageConverter : IImageConverter
{
private Xls2ImageConverter xls2ImageConverter;
public event CbGeneric<int, int> ProgressChanged;
public event CbGeneric ConvertSucceed;
public event CbGeneric<string> ConvertFailed; public void Cancel()
{
if (this.xls2ImageConverter != null)
{
this.xls2ImageConverter.Cancel();
}
} public void ConvertToImage(string originFilePath, string imageOutputDirPath)
{
ConvertToImage(originFilePath, imageOutputDirPath, 0, 0, 200);
} private void ConvertToImage(string originFilePath, string imageOutputDirPath, int startPageNum, int endPageNum, int resolution)
{
try
{
AsposeLicenseHelper.SetCellsLicense();
Aspose.Cells.Workbook excel = new Workbook(originFilePath); if (excel == null)
{
throw new Exception("excel文件无效或者excel文件被加密!");
} if (imageOutputDirPath.Trim().Length == 0)
{
imageOutputDirPath = Path.GetDirectoryName(originFilePath);
} if (!Directory.Exists(imageOutputDirPath))
{
Directory.CreateDirectory(imageOutputDirPath);
} if (startPageNum <= 0)
{
startPageNum = 1;
} if (endPageNum > excel.Worksheets.Count || endPageNum <= 0)
{
endPageNum = excel.Worksheets.Count;
} if (startPageNum > endPageNum)
{
int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum;
} if (resolution <= 0)
{
resolution = 128;
} //先将excel转换为pdf临时文件
string tmpPdfPath = originFilePath + ".pdf";
excel.Save(tmpPdfPath, Aspose.Cells.SaveFormat.Pdf); //再将pdf转换为图片
Pdf2ImageConverter converter = new Pdf2ImageConverter();
converter.ConvertFailed += new CbGeneric<string>(converter_ConvertFailed);
converter.ConvertSucceed += new CbGeneric(converter_ConvertSucceed);
converter.ProgressChanged += new CbGeneric<int, int>(converter_ProgressChanged);
converter.ConvertToImage(tmpPdfPath, imageOutputDirPath); //删除pdf临时文件
File.Delete(tmpPdfPath); if (this.ConvertSucceed != null)
{
this.ConvertSucceed();
}
}
catch (Exception ex)
{
if (this.ConvertFailed != null)
{
this.ConvertFailed(ex.Message);
}
} this.xls2ImageConverter = null;
} void converter_ProgressChanged(int done, int total)
{
if (this.ProgressChanged != null)
{
this.ProgressChanged(done, total);
}
} void converter_ConvertSucceed()
{
if (this.ConvertSucceed != null)
{
this.ConvertSucceed();
}
} void converter_ConvertFailed(string msg)
{
if (this.ConvertFailed != null)
{
this.ConvertFailed(msg);
}
}
}
#endregion
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Mime;
using System.Web;
using Aspose.Words; namespace SMES.LocaleManagerWeb.DoucmentManager
{
public static class AsposeLicenseHelper
{
public const string Key =
"PExpY2Vuc2U+DQogIDxEYXRhPg0KICAgIDxMaWNlbnNlZFRvPkFzcG9zZSBTY290bGFuZCB" +
"UZWFtPC9MaWNlbnNlZFRvPg0KICAgIDxFbWFpbFRvPmJpbGx5Lmx1bmRpZUBhc3Bvc2UuY2" +
"9tPC9FbWFpbFRvPg0KICAgIDxMaWNlbnNlVHlwZT5EZXZlbG9wZXIgT0VNPC9MaWNlbnNlV" +
"HlwZT4NCiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1p" +
"dGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+DQogICAgPE9yZGVySUQ+MTQ" +
"wNDA4MDUyMzI0PC9PcmRlcklEPg0KICAgIDxVc2VySUQ+OTQyMzY8L1VzZXJJRD4NCiAgIC" +
"A8T0VNPlRoaXMgaXMgYSByZWRpc3RyaWJ1dGFibGUgbGljZW5zZTwvT0VNPg0KICAgIDxQc" +
"m9kdWN0cz4NCiAgICAgIDxQcm9kdWN0PkFzcG9zZS5Ub3RhbCBmb3IgLk5FVDwvUHJvZHVj" +
"dD4NCiAgICA8L1Byb2R1Y3RzPg0KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl" +
"0aW9uVHlwZT4NCiAgICA8U2VyaWFsTnVtYmVyPjlhNTk1NDdjLTQxZjAtNDI4Yi1iYTcyLT" +
"djNDM2OGYxNTFkNzwvU2VyaWFsTnVtYmVyPg0KICAgIDxTdWJzY3JpcHRpb25FeHBpcnk+M" +
"jAxNTEyMzE8L1N1YnNjcmlwdGlvbkV4cGlyeT4NCiAgICA8TGljZW5zZVZlcnNpb24+My4w" +
"PC9MaWNlbnNlVmVyc2lvbj4NCiAgICA8TGljZW5zZUluc3RydWN0aW9ucz5odHRwOi8vd3d" +
"3LmFzcG9zZS5jb20vY29ycG9yYXRlL3B1cmNoYXNlL2xpY2Vuc2UtaW5zdHJ1Y3Rpb25zLm" +
"FzcHg8L0xpY2Vuc2VJbnN0cnVjdGlvbnM+DQogIDwvRGF0YT4NCiAgPFNpZ25hdHVyZT5GT" +
"zNQSHNibGdEdDhGNTlzTVQxbDFhbXlpOXFrMlY2RThkUWtJUDdMZFRKU3hEaWJORUZ1MXpP" +
"aW5RYnFGZkt2L3J1dHR2Y3hvUk9rYzF0VWUwRHRPNmNQMVpmNkowVmVtZ1NZOGkvTFpFQ1R" +
"Hc3pScUpWUVJaME1vVm5CaHVQQUprNWVsaTdmaFZjRjhoV2QzRTRYUTNMemZtSkN1YWoyTk" +
"V0ZVJpNUhyZmc9PC9TaWduYXR1cmU+DQo8L0xpY2Vuc2U+";
public static Stream LStream = (Stream)new MemoryStream(Convert.FromBase64String(Key)); static readonly string LicensePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\DoucmentManager\\Aspose.Total.lic";
public static void SetWordsLicense()
{
var l=new License();
l.SetLicense(LicensePath);
}
public static void SetPdfLicense()
{
var l = new Aspose.Pdf.License();
l.SetLicense(LicensePath);
}
public static void SetSlidesLicense()
{
var l = new Aspose.Slides.License();
l.SetLicense(LicensePath);
}
/// <summary>
/// Excel
/// </summary>
public static void SetCellsLicense()
{
var l = new Aspose.Cells.License();
l.SetLicense(LicensePath);
}
}
}

下载地址

aspose授权亲测可用配套代码的更多相关文章

  1. jdbc连接数据库以及crud(简单易懂,本人亲测可用 有源代码和数据库)

    今天呢!重新整理了一边jdbc的相关操作:现在来说对于很多框架都使用mybatis和hibernate来操作数据库 ,也有很多使用自己简单封装的ssm或者是其他的一些框架来操作数据库,但是无论使用哪一 ...

  2. 亲测可用!!!golang如何在idea中保存时自动进行代码格式化

    亲测可用,golang在idea中的代码自动格式化 1.ctrl+alt+s打开设置界面,选择[Plugins] -> [Install JetBrains plugin...] -> 搜 ...

  3. Cocos Creator JS web平台复制粘贴代码(亲测可用)

    Cocos Creator JS web平台复制粘贴代码(亲测可用) 1 webCopyString: function(str){ var input = str; const el = docum ...

  4. PHP小程序后端支付代码亲测可用

    小程序后端支付代码亲测可用 <?php namespace Home\Controller; use Think\Controller; class WechatpayController ex ...

  5. mybatis自动生成代码插件mybatis-generator使用流程(亲测可用)

    mybatis-generator是一款在使用mybatis框架时,自动生成model,dao和mapper的工具,很大程度上减少了业务开发人员的手动编码时间 坐着在idea上用maven构建spri ...

  6. Axure RP 9版本最新版授权码和密钥 亲测可用

    分享Axure RP 9版本最新版授权码和密钥 亲测可用 声明:以下资源的获取来源为网络收集,仅供学习参考,不作商业用途,如有侵权请联系博主删除,谢谢! 自新的Axure RP 9.0 Beta版发布 ...

  7. IntelliJ13+tomcat+jrebel实现热部署(亲测可用)

       网上有很多介绍intellij idea整合jrebel插件实现热部署的文章,但是有的比较复杂,有的不能成功,最后经过各种尝试,实现了整合,亲测可用!步骤说明如下:   一.先下载jrebel安 ...

  8. IntelliJ IDEA2017 激活方法 最新的(亲测可用)

    IntelliJ IDEA2017 激活方法(亲测可用): 搭建自己的授权服务器,对大佬来说也很简单,我作为菜鸟就不说了,网上有教程. 我主要说第二种,现在,直接写入注册码,是不能成功激活的(如果你成 ...

  9. [转]QT子线程与主线程的信号槽通信-亲测可用!

    近用QT做一个服务器,众所周知,QT的主线程必须保持畅通,才能刷新UI.所以,网络通信端采用新开线程的方式.在涉及到使用子线程更新Ui上的控件时遇到了点儿麻烦.网上提供了很多同一线程不同类间采用信号槽 ...

随机推荐

  1. zabbix 设备(自己的实践)

    1. 下载源代码包 wget http://sourceforge.net/projects/zabbix/files/ 2.  解压 tar -zxvf zabbix-2.2.3.tar.gz 3. ...

  2. WPF文字描边的解决方法(二)——支持文字竖排和字符间距调整

    原文:WPF文字描边的解决方法(二)--支持文字竖排和字符间距调整 自前天格式化文本效果出来后,今天又添加文本竖排和调整字符间距的功能.另外,由于上次仓促,没来得及做有些功能的设计时支持,这次也调整好 ...

  3. Lua学习 2) —— Android与Lua互调

    2014-07-09 一.Android类调用lua并回调 Android调用Lua函数,同一时候把类作为參数传递过去.然后再Lua中回调类的函数 调用lua mLuaState = LuaState ...

  4. 莱杰:期刊进口流程(文件 ID 1591640.1)

    文档内容   概要   _afrLoop=2068767096030752&id=1591640.1&_afrWindowMode=0&_adf.ctrl-state=qivv ...

  5. 在微信浏览器里使用js或jquery实现页面重新刷新

    function refresh() { var random = Math.floor((Math.random() * 10000) + 1); var url = decodeURI(windo ...

  6. fail2ban防止暴力破解

    安装fail2ban: 将fail2ban 上传到服务器,解压: [root@xuegod1 tmp]# tar -zxvf fail2ban-0.8.14.tar.gz [root@xuegod1 ...

  7. Bootstrap 单按钮下拉菜单

    @{    Layout = null;}<!DOCTYPE html><html><head>    <meta name="viewport&q ...

  8. 【windows】常见的系统环境变量,如%appdata%表示什么意思

    原文:[windows]常见的系统环境变量,如%appdata%表示什么意思 1.介绍 %appdata%就代表了C:Users\用户名\AppData\Roaming这个文件夹. “%”是系统变量的 ...

  9. WPF RichTextBox 导出与加载

    private void Button_Click(object sender, RoutedEventArgs e) { string savePth = System.IO.Path.Combin ...

  10. Qt之使用setWindowFlags方法遇到的问题(追踪进入QWidget的源码分析原因,最后用WINAPI解决问题)good

    一.简述 前段时间在使用setWindowFlags方法时遇到了一个坑,具体情况是想通过窗口界面上一个checkBox来控制窗口当前状态是否置顶,而Qt提供了Qt::WindowStaysOnTopH ...