Synfusion File Formats: Doc
Posted: Mon Nov 06, 2017 8:34 pm
Hi all,
Dick gave us an advice (Dick's advice ) to use free software recently.
This was really good. Thanks Dick!.
One of the first things I tried is the file format library. They have PDF, DocIO (Word, all Versions down to Word97), Presentation and XlsIO. The good thing is: we don't need Acrobat or Office installed on our machines nor on the client machines. They fully implemented the document object models.
Here I will show how simple the creation of a word document is (partially translated to X# from File Formats User Guide):
All we need is references to
System
System.Drawing
and
Syncfusion.DocIO.Base.dll
Compiled with X#/Core.
Hope this helps someone like it helped me.
Cheers
Frank
Dick gave us an advice (Dick's advice ) to use free software recently.
This was really good. Thanks Dick!.
One of the first things I tried is the file format library. They have PDF, DocIO (Word, all Versions down to Word97), Presentation and XlsIO. The good thing is: we don't need Acrobat or Office installed on our machines nor on the client machines. They fully implemented the document object models.
Here I will show how simple the creation of a word document is (partially translated to X# from File Formats User Guide):
Code: Select all
USING Syncfusion.DocIO // Syncfusion.DocIO.Base.dll
USING Syncfusion.DocIO.DLS
USING System.Drawing // System.Drawing (GAC)
FUNCTION Start( ) AS VOID
System.Console.WriteLine("Hello x#!")
LOCAL Document AS WordDocument
Document := WordDocument{}
// Set PageSettings
LOCAL Section AS IWSection
Section := Document:AddSection()
LOCAL FirstParagraph AS IWParagraph
FirstParagraph := Section:AddParagraph()
FirstParagraph:ParagraphFormat:HorizontalAlignment := HorizontalAlignment.Justify
LOCAL firstTextRange AS IWTextRange
firstTextRange := FirstParagraph:AppendText("Lorem")
//sets the font formatting of the text range
firstTextRange:CharacterFormat:Bold := TRUE
firstTextRange:CharacterFormat:FontName := "Calibri"
firstTextRange:CharacterFormat:FontSize := 14
//Adds another text range into the paragraph
LOCAL secondTextRange AS IWTextRange
secondTextRange := firstParagraph:AppendText(" ipsum dolor sit"+;
"amet, consectetur adipiscing elit, sed DO eiusmod tempor incididunt ut"+;
"labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud"+;
"exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ")
//sets the font formatting of the text range
secondTextRange:CharacterFormat:FontName := "Courier New"
secondTextRange:CharacterFormat:FontSize := 11
secondTextRange:CharacterFormat:OutLine := TRUE
firstParagraph := Section:AddParagraph()
firstTextRange := FirstParagraph:AppendText("Bold 12364")
//sets the font formatting of the text range
firstTextRange:CharacterFormat:Bold := TRUE
firstTextRange:CharacterFormat:FontName := "Courier New"
firstTextRange:CharacterFormat:FontSize := 11
firstTextRange:CharacterFormat:Bold := TRUE
firstParagraph := Section:AddParagraph()
firstTextRange := FirstParagraph:AppendText("Cond 123456")
//sets the font formatting of the text range
firstTextRange:CharacterFormat:Bold := TRUE
firstTextRange:CharacterFormat:FontName := "Courier New"
firstTextRange:CharacterFormat:FontSize := 11
firstTextRange:CharacterFormat:CharacterSpacing := -2.0
firstTextRange := FirstParagraph:AppendText("Blauer Text")
//sets the font formatting of the text range
firstTextRange:CharacterFormat:Bold := TRUE
firstTextRange:CharacterFormat:FontName := "Arial"
firstTextRange:CharacterFormat:FontSize := 14
firstTextRange:CharacterFormat:TextColor := Color.Blue
firstTextRange := FirstParagraph:AppendText("Roter Text")
//sets the font formatting of the text range
firstTextRange:CharacterFormat:Bold := TRUE
firstTextRange:CharacterFormat:FontName := "Times New Roman"
firstTextRange:CharacterFormat:FontSize := 12
firstTextRange:CharacterFormat:TextColor := Color.Red
Document:Save( "Result.docx" )
document:Close()
Document := NULL
RETURN
System
System.Drawing
and
Syncfusion.DocIO.Base.dll
Compiled with X#/Core.
Hope this helps someone like it helped me.
Cheers
Frank