none
change font size of files

    Question

  • Hello everyone, I apologize for my English, I'm using google translator
    I wanted to ask if you can through the small basic to display a text file or a Word file on the characters in a different way, such as font size 40 and in bold.

    T.U.

    Thursday, January 07, 2016 5:11 PM

Answers

  • Show VDX656.

    Best Regards Martin

    Thursday, January 07, 2016 6:08 PM
  • A text file is a simple text only. There are no properties for FontSize, -Color, etc. These properties you'll have to set from the viewer for the text file (like in GraphicsWindow, Notepad, Browser etc.) To show your text in defined color, size, formating, etc. use Martin's example from above (in GraphicsWindow) resp. as a TextShape (Shapes.AddText) or LDProcess.Start("notepad.exe", txtFile) to open it in Notepad, LDControls.AddBrowser(width, height, ""file:///" + locTxtFile) lets you zoom in/out, or load it into LDControls.AddRichTextBox.

    Friday, January 08, 2016 12:32 PM
    Answerer
  • I agree with Pappa Lapub, rtf is the best way to do simple formatted text, either using Richtextbox or you can actually just output the formatting as text with formatting info.

    http://www.biblioscape.com/rtf15_spec.htm

    e.g.

    {\rtf1\ansi
    {\fonttbl\f0\fswiss Helvetica;}
    
    \f0\pard\qc{\fs45\b LitDev 1.2.4.0 DE Extension API}\par
    
    \f0\pard\sb300\shading2000{\fs36\b LD3DView}\par
    \f0\pard{\fs20 3D Visualisierung im GraphicsWindow.{\line}{\line}Koordinaten haben folgende Richtungen und keinen Bezug zu GraphicsWindow Koordinaten:{\line}X - Links(-) bis Rechts(+){\line}Y - Unten(-) bis Oben(+){\line}Z - Fern(-) bis Nahe(+){\line}{\line}F?r weitere Details zu untergeordneten Methoden s. http://msdn.microsoft.com/library/ms747437.aspx (?bersicht zu 3D-Grafiken).{\line}Folgende Methoden verwenden HelixToolkit (rekompiliert und angepasst f?r SB, http://helixtoolkit.codeplex.com): {\line}LoadModel, AddSphere, AddTube.}\par
    \f0\pard\sb75{\fs24\b example}\par
    \f0\pard{\fs20 3D-samples\\*.sb}\par
    
    \f0\pard\sb180\shading1000{\fs30\b AddAmbientLight(shapeName,colour) \fs18\b0\i OPERATION}\par
    \f0\pard{\fs20 F?gt eine umgebende Lichtquelle hinzu (Intern: Light#).}\par
    \f0\pard\sb75{\fs24\b shapeName}\par
    \f0\pard{\fs20 Das 3DView Objekt.}\par
    \f0\pard\sb75{\fs24\b colour}\par
    \f0\pard{\fs20 Die Lichtfarbe.}\par
    \f0\pard\sb75{\fs24\b returns}\par
    \f0\pard{\fs20 Der 3DView Lichtname.}\par
    }

    Save test.rtf.

    This is how I create formatted documentation

    Tuesday, January 12, 2016 7:27 PM
    Moderator

All replies

  • Show VDX656.

    Best Regards Martin

    Thursday, January 07, 2016 6:08 PM
  • You can read text file with File.ReadLine().

    WordPad file (.rtf) is a text file.  So, you can read with File.ReadLine().

    But Word file (.docx) is zipped text files.  So you need to rename .docx to .zip and unzip the .zip file and get word\document.xml to use File.ReadLine().


    Nonki Takahashi

    Thursday, January 07, 2016 11:49 PM
    Moderator
  • I can see this dimension also in the text file?
    Friday, January 08, 2016 7:27 AM
  • A text file is a simple text only. There are no properties for FontSize, -Color, etc. These properties you'll have to set from the viewer for the text file (like in GraphicsWindow, Notepad, Browser etc.) To show your text in defined color, size, formating, etc. use Martin's example from above (in GraphicsWindow) resp. as a TextShape (Shapes.AddText) or LDProcess.Start("notepad.exe", txtFile) to open it in Notepad, LDControls.AddBrowser(width, height, ""file:///" + locTxtFile) lets you zoom in/out, or load it into LDControls.AddRichTextBox.

    Friday, January 08, 2016 12:32 PM
    Answerer
  • The example of Martin was very clear, the problem is that I have to bring, through a search, the values of a text file in a particular format, and then to print
    Tuesday, January 12, 2016 11:48 AM
  • To read/load the text content(s) of a text file, as well to save the modified text back to (another) text file, see the Methods in the File Class

    To modify/format the loaded text to your needs, see the Methods in the Text Class

    resp. LDFile Class and/or LDText Class

    For printing you can use LDFile.PrintFile and LDUtilities.ShowPrintPreview

    Perhaps make a text search (eg. from notepad) in LitDev.xml for 'Print', to see more 'print' related Methods in LitDev extension.

    Tuesday, January 12, 2016 12:31 PM
    Answerer
  • I've tried to see the classes and LDFile LDText, but neither contains a function that allows me to make the change of the size of a character within a text file = (
    Tuesday, January 12, 2016 2:28 PM
  • In a simple textfile you cannot change fontsize. If you use a wordprocessor (e.g. Word) you can change that sort of things:

    There is no need to use Small Basic for this!


    Jan [ WhTurner ] The Netherlands


    Tuesday, January 12, 2016 2:56 PM
    Answerer
  • unfortunately I need the small basic, because I'm creating all programmatically, but I is created in small size, and was wondering if this was possible (somehow) by operations, make a change of font, size, bold etc etc
    Tuesday, January 12, 2016 3:38 PM
  • See LDGraphicsWindow.Print or the print settings of yor printer.

    Or other solution: LDControls.RichTextBoxSave to rtfDoc, then open the LDProcess.Start("write.exe", rtfDoc) and press "Print'.

    resp. LDProcess.Start("shellCommand", rtfDoc)

    where shellCommand is "%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE" /p  or "..\system32\write.exe" /p    for 'Print' ;

    or "%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE" /pt  resp. ..\system32\write.exe /pt  for 'PrintTo'.

     .. see HKCR\rtffile\shell\print(to)\command


    PS: About RichTextBox, LitDev provides a great sample in 'other-samples\RichTextBox.sb'
    Tuesday, January 12, 2016 4:34 PM
    Answerer
  • I agree with Pappa Lapub, rtf is the best way to do simple formatted text, either using Richtextbox or you can actually just output the formatting as text with formatting info.

    http://www.biblioscape.com/rtf15_spec.htm

    e.g.

    {\rtf1\ansi
    {\fonttbl\f0\fswiss Helvetica;}
    
    \f0\pard\qc{\fs45\b LitDev 1.2.4.0 DE Extension API}\par
    
    \f0\pard\sb300\shading2000{\fs36\b LD3DView}\par
    \f0\pard{\fs20 3D Visualisierung im GraphicsWindow.{\line}{\line}Koordinaten haben folgende Richtungen und keinen Bezug zu GraphicsWindow Koordinaten:{\line}X - Links(-) bis Rechts(+){\line}Y - Unten(-) bis Oben(+){\line}Z - Fern(-) bis Nahe(+){\line}{\line}F?r weitere Details zu untergeordneten Methoden s. http://msdn.microsoft.com/library/ms747437.aspx (?bersicht zu 3D-Grafiken).{\line}Folgende Methoden verwenden HelixToolkit (rekompiliert und angepasst f?r SB, http://helixtoolkit.codeplex.com): {\line}LoadModel, AddSphere, AddTube.}\par
    \f0\pard\sb75{\fs24\b example}\par
    \f0\pard{\fs20 3D-samples\\*.sb}\par
    
    \f0\pard\sb180\shading1000{\fs30\b AddAmbientLight(shapeName,colour) \fs18\b0\i OPERATION}\par
    \f0\pard{\fs20 F?gt eine umgebende Lichtquelle hinzu (Intern: Light#).}\par
    \f0\pard\sb75{\fs24\b shapeName}\par
    \f0\pard{\fs20 Das 3DView Objekt.}\par
    \f0\pard\sb75{\fs24\b colour}\par
    \f0\pard{\fs20 Die Lichtfarbe.}\par
    \f0\pard\sb75{\fs24\b returns}\par
    \f0\pard{\fs20 Der 3DView Lichtname.}\par
    }

    Save test.rtf.

    This is how I create formatted documentation

    Tuesday, January 12, 2016 7:27 PM
    Moderator
  • thanks for the help, but it's not that you can send me a small example? I'm losing the various functions of LitDev
    Wednesday, January 13, 2016 9:39 AM
  • Carmenello, this is a simple sample.  Reference is here.

    ' simple rich text file editor
    path = "c:\Users\Nonki\test.rtf"  ' Please correct folder name for you
    GraphicsWindow.BrushColor = "Black"
    rtbox = LDControls.AddRichTextBox(600, 380)
    LDControls.RichTextBoxLoad(rtbox, path, "False")
    Shapes.Move(rtbox, 10, 10)
    save = Controls.AddButton("Save", 10, 400)
    s12 = Controls.AddButton("12", 100, 400)
    s40 = Controls.AddButton("40", 200, 400)
    Controls.ButtonClicked = OnButtonClicked
    Sub OnButtonClicked
      btn = Controls.LastClickedButton
      If btn = save Then
        LDControls.RichTextBoxSave(rtbox, path)
        LDProcess.Start("wordpad.exe", path)
      ElseIf btn = s12 Then
        LDControls.RichTextBoxSelection(rtbox)
        LDControls.RichTextBoxFontSize = 12
      ElseIf btn = s40 Then
        LDControls.RichTextBoxSelection(rtbox)
        LDControls.RichTextBoxFontSize = 40
      EndIf
    EndSub


    Nonki Takahashi


    Wednesday, June 08, 2016 5:26 AM
    Moderator