diff --git a/LICENSE b/LICENSE index cd4c9a2..7536adc 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,5 @@ -This code example is provided "as is" without warranty of any kind. Developer Express Inc ("DevExpress") disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. +This code example is provided "as is" without warranty of any kind. Developer Express Inc ("DevExpress") disclaims all warranties, +either express or implied, including the warranties of merchantability and fitness for a particular purpose. -For licensing terms and conditions of DevExpress product(s) required for, or associated with the use of this code example, please refer to the applicable End-User License Agreement at https://www.devexpress.com/Support/licensingfaq.xml \ No newline at end of file +For terms and conditions governing use of DevExpress product libraries, including product libraries used in this sample, +please review the applicable DevExpress End-User License Agreement at the following address: https://www.devexpress.com/Support/licensingfaq.xml \ No newline at end of file diff --git a/VB/ChiseledDocker.vbproj b/VB/ChiseledDocker.vbproj index 342c54d..b2bd96a 100644 --- a/VB/ChiseledDocker.vbproj +++ b/VB/ChiseledDocker.vbproj @@ -2,7 +2,7 @@ On Exe - net10.0 + net9.0 enable enable false @@ -14,7 +14,11 @@ - - + + Always + + + PreserveNewest + \ No newline at end of file diff --git a/VB/Program.vb b/VB/Program.vb index eaebabc..5328424 100644 --- a/VB/Program.vb +++ b/VB/Program.vb @@ -1,14 +1,17 @@ Imports DevExpress.Drawing Imports DevExpress.XtraRichEdit +Imports DevExpress.XtraRichEdit.API.Native +Imports System.Drawing Friend Module Program Public Function Main(ByVal args As String()) As Integer Try - Dim baseDir = AppContext.BaseDirectory - Dim docxPath = If(args.Length >= 1, args(0), Path.Combine(baseDir, "fontTest.docx")) + ' Use the Skia Drawing Engine + Settings.DrawingEngine = DrawingEngine.Skia + Dim fileName As String = Path.Combine(AppContext.BaseDirectory, "fontTest.docx") ' Include Fonts in the Application - Dim fontFiles As String() = _("Inter-Regular.ttf", "NotoSans-Regular.ttf") + Dim fonts As String() = _("Inter-Regular.ttf", "NotoSans-Regular.ttf") ''' Cannot convert LocalDeclarationStatementSyntax, System.InvalidCastException: Unable to cast object of type 'Microsoft.CodeAnalysis.VisualBasic.Syntax.EmptyStatementSyntax' to type 'Microsoft.CodeAnalysis.VisualBasic.Syntax.ExpressionSyntax'. ''' at ICSharpCode.CodeConverter.VB.CommonConversions.RemodelVariableDeclaration(VariableDeclarationSyntax declaration) in C:\builds\CS2VB\CodeConverter-master\CodeConverter\VB\CommonConversions.cs:line 478 ''' at ICSharpCode.CodeConverter.VB.MethodBodyExecutableStatementVisitor.VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node) in C:\builds\CS2VB\CodeConverter-master\CodeConverter\VB\MethodBodyExecutableStatementVisitor.cs:line 59 @@ -16,28 +19,36 @@ Friend Module Program ''' at ICSharpCode.CodeConverter.VB.CommentConvertingMethodBodyVisitor.DefaultVisit(SyntaxNode node) in C:\builds\CS2VB\CodeConverter-master\CodeConverter\VB\CommentConvertingMethodBodyVisitor.cs:line 24 ''' ''' Input: -''' string[] fontPaths = [.. fontFiles.Select(f => Path.Combine(baseDir, f))]; +''' string[] fontFiles = [.. fonts.Select(f => Path.Combine(AppContext.BaseDirectory, f))]; ''' -''' ' Use the Skia Drawing Engine -Settings.DrawingEngine = DrawingEngine.Skia - ' Register fonts before loading documents - For Each fp In fontPaths +''' ' Register fonts before loading documents +For Each fp In fontFiles Call DXFontRepository.Instance.AddFont(fp) Next - Dim richEditDocumentServer = New RichEditDocumentServer() - richEditDocumentServer.LoadDocument(docxPath, DocumentFormat.Docx) - Dim exportedPdf = New MemoryStream() - richEditDocumentServer.ExportToPdf(exportedPdf) - exportedPdf.Position = 0 - Dim ouput = Console.OpenStandardOutput() - exportedPdf.CopyTo(ouput) - ouput.Flush() - Program.Log("Done.") - Return 0 - Catch ex As Exception + Using wordProcessor = New RichEditDocumentServer() + Dim doc As Document = wordProcessor.Document + doc.AppendText("This document is generated by Word Processing Document API: Inter font" & Microsoft.VisualBasic.Constants.vbCrLf) + Dim cp As CharacterProperties = doc.BeginUpdateCharacters(doc.Paragraphs(0).Range) + cp.FontName = "Inter" + doc.EndUpdateCharacters(cp) + doc.AppendText("This document is generated by Word Processing Document API: NotoSans font") + Dim cp1 As CharacterProperties = doc.BeginUpdateCharacters(doc.Paragraphs(1).Range) + cp1.FontName = "Noto Sans" + doc.EndUpdateCharacters(cp1) + wordProcessor.SaveDocument(fileName, DocumentFormat.Docx) + Dim exportedPdf = New MemoryStream() + wordProcessor.ExportToPdf(exportedPdf) + exportedPdf.Position = 0 + Dim ouput = Console.OpenStandardOutput() + exportedPdf.CopyTo(ouput) + ouput.Flush() + Program.Log("Done.") + Return 0 + End Using + Catch e As Exception Program.Log("ERROR:") - Log(ex.ToString()) + Log(e.ToString()) Return 1 End Try End Function