Recently, I am studying winform printing files, which need to support word, excel, ppt, pdf, and pictures. I cannot rely on related software environments. After research, I decided to use the Aspose suite to convert all related files into pdf and print them.
WrodToPDF
Using 11.9, it is necessary to crack with license file
//Remove the watermarkstring licenseFile = ""; if ((licenseFile)) { license = new (); (licenseFile); } //Convert doc = new (FileFullName); (SaveFileName, );
ExcelToPDF
Use 8.3 (cracked version)
//Convert Workbook excel = new Workbook(FileFullName); (SaveFileName, );
PPTToPDF
Use 16.9 (need to be cracked with code)
//Remove the watermark string[] stModule = new string[8] { "\u0002\u2006\u2006\u2003", "\u0003\u2006\u2006\u2003", "\u0005\u2005\u2000\u2003", "\u0003\u2000", "\u000F", "\u0002\u2000", "\u0003", "\u0002" }; Assembly assembly = (typeof()); Type typeLic = null, typeIsTrial = null, typeHelper = null; foreach (Type type in ()) { if ((typeLic == null) && ( == stModule[0])) { typeLic = type; } else if ((typeIsTrial == null) && ( == stModule[1])) { typeIsTrial = type; } else if ((typeHelper == null) && ( == stModule[2])) { typeHelper = type; } } if (typeLic == null || typeIsTrial == null || typeHelper == null) { throw new Exception(); } object lic = (typeLic); int findCount = 0; foreach (FieldInfo field in ( | | )) { if ( == typeLic && == stModule[3]) { (null, lic); ++findCount; } else if ( == typeof(DateTime) && == stModule[4]) { (lic, ); ++findCount; } else if ( == typeIsTrial && == stModule[5]) { (lic, 1); ++findCount; } } foreach (FieldInfo field in ( | | )) { if ( == typeof(bool) && == stModule[6]) { (null, false); ++findCount; } if ( == typeof(int) && == stModule[7]) { (null, 128); ++findCount; } } if (findCount < 5) { throw new NotSupportedException("Invalid version"); } //Convert Presentation ppt = new Presentation(FileFullName); (SaveFileName, );
Image ToPDF
Use 9.4 (requires code cracking)
//Remove the watermark private const string Key = "PExpY2Vuc2U+DQogIDxEYXRhPg0KICAgIDxMaWNlbnNlZFRvPlNoYW5naGFpIEh1ZHVuIEluZm9ybWF0aW9uIFRlY2hub2xvZ3kgQ28uLCBMdGQ8L0xpY2Vuc2VkVG8+DQogICA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4OUozSGlkaThCeE43aHFiR1BERXNaWGo2RlYxaGl1N2MxWmUyNEp3VGc2UnpsNUNJRHY1YVhxbDQyczBkSGw4eXpreDRBM2RTTU5KTzRiQ094a2V2OFBiOWxSaUc3ST08L1NpZ25hdHVyZT4NCjwvTGljZW5zZT4="; private static Stream LStream = (Stream)new MemoryStream(Convert.FromBase64String(Key)); var l = new (); (LStream); //Convert Document doc = new Document(); Page page = (); image = new (); = FileFullName; (image); PrintFileName = (ConvertPDFName); (PrintFileName);
PDF file printing
Use the print file to set the printer name, score, direction, etc. directly
ps = new (); = PrinterName; = Copies; = Direction; PdfViewer viewer = new PdfViewer(); (PrintFileName); (ps); ();
Note: There is no table line after Excel converts pdf, and the printing will be cut off after ppt converts pdf. You need to adjust the direction and paper size settings yourself.
The above is the detailed content of the example of using Aspose to print files in c#. For more information about using Aspose to print files in c#, please pay attention to my other related articles!