SPSS Statistics

  • 1.  Changing font size in OutputDoc

    Posted Tue July 20, 2021 02:01 PM
    Hello all

    Changing the font size of text within an OutputDocument Item doesn't work the way I'd like it to work. The font size that's passed to SpssClient.SetPreference last takes precedence over sizes passed earlier as the code below shows.
    Would there be a work around for this behaviour?

    Thanks
    _________________________________________________________________________________________________________________________
    begin program.
    import SpssClient
    SpssClient.StartClient()

    SpssClient.SetPreference (SpssClient.PreferenceOptions.TextOutputFontSize , "12")
    print ("I would like to be printed using a small font")
    SpssClient.SetPreference(SpssClient.PreferenceOptions.TextOutputFontSize , "15")
    print ("And a larger font for me, please")

    SpssClient.StopClient()
    end program.

    ------------------------------
    Kees Smit
    ------------------------------


  • 2.  RE: Changing font size in OutputDoc

    Posted Tue July 20, 2021 03:33 PM
    I'm not sure exactly what is happening here, but I could mostly get the separation by breaking the program into two parts --
    begin program python3.
    import SpssClient
    SpssClient.StartClient()
    SpssClient.SetPreference (SpssClient.PreferenceOptions.TextOutputFontSize , "12")
    print ("I would like to be printed using a small font")
    end program.
    begin program python3.
    SpssClient.SetPreference(SpssClient.PreferenceOptions.TextOutputFontSize , "15")
    print ("And a larger font for me, please")

    SpssClient.StopClient()
    end program.

    The text is only  sent to the Viewer after the program ends, so the second font would have been set before any of the text was printed if the code is a single program.

    You might find the TEXT extension command helpful as it lets you provide html or rtf text to display.  I found that the syntax help file for it is missing, but I have restored it to the spe file and requested Development to update the site.  I can send it to you if that looks like a solution.


    --





  • 3.  RE: Changing font size in OutputDoc

    Posted Tue July 20, 2021 03:44 PM
    p.s. I posted the TEXT extension with the syntax  help on my OneDrive site to get it to Development, so you can also get it there if desired.

    --





  • 4.  RE: Changing font size in OutputDoc

    Posted Wed July 21, 2021 03:42 AM
    Thank you, Jon. Unfortunately, splitting the program into two parts didn't work for me, on either V25 nor V27. (I Copy-Pasted your syntax). Does it need any SPSS- wide settings?

    I found TEXT to be a very powerful Extension Command, thanks. The only drawback is to get the end user to install it.

    Regards

    ------------------------------
    Kees Smit
    ------------------------------



  • 5.  RE: Changing font size in OutputDoc

    Posted Wed July 21, 2021 08:52 AM
    I don't know exactly how that mechanism works.  It might be necessary to run a procedure inbetween, but if you look at the source code of TEXT.py in the createText function, you can see how to generate an html text block on your own without using the TEXT extension.

    --





  • 6.  RE: Changing font size in OutputDoc

    Posted Wed July 21, 2021 10:21 AM
      |   view attached
    As you suggested, inserting code between the two BEGIN PROGRAM PYTHON3 - END PROGRAM blocks worked: I produced a FRE of a temporary variable and consequently deleted the FRE-output from the OutputDoc (using OutputDoc.Delete()). The attached .PNG shows the result.

    And indeed, using TEXT.py I will (probalby) be able to generate html without TEXT. Very generous of you and/or IBM to provide the source code of all of these functions!

    Regards
    Kees



    ------------------------------
    Kees Smit
    ------------------------------



  • 7.  RE: Changing font size in OutputDoc

    Posted Mon October 18, 2021 09:47 AM
    Thank you so much :)

    ------------------------------
    Albert Mike
    ------------------------------