Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • using -translator set- to set result color in .pdf-file

    More than 4 years ago I asked nearly the same question, alas with no response. I am trying again ...

    I would like to translate an output file from SMCL format into a PDF file using blue color for results (bold font). To do so, first I am using -translator set- to specify the color (and other things) for the translator smcl2pdf followed by -translate-. However, the color of results in the resulting .pdf-file is black (bold font) instead of blue (bold font).

    In the following I show the colors I would like them to be together with the -translator set- and -translate- commands I am using:
    Code:
    . clear all
    
    . cap log close
    
    . log using "test_2pdf.smcl", replace
    --------------------------------------------------------------------------------------------------------------------------------------------
          name:  <unnamed>
           log:  /home/enzmann/test_2pdf.smcl
      log type:  smcl
     opened on:   4 Nov 2024, 01:38:18
    
    .
    . sysuse auto, clear
    (1978 automobile data)
    
    . sum _all
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
            make |          0
           price |         74    6165.257    2949.496       3291      15906
             mpg |         74     21.2973    5.785503         12         41
           rep78 |         69    3.405797    .9899323          1          5
        headroom |         74    2.993243    .8459948        1.5          5
    -------------+---------------------------------------------------------
           trunk |         74    13.75676    4.277404          5         23
          weight |         74    3019.459    777.1936       1760       4840
          length |         74    187.9324    22.26634        142        233
            turn |         74    39.64865    4.399354         31         51
    displacement |         74    197.2973    91.83722         79        425
    -------------+---------------------------------------------------------
      gear_ratio |         74    3.014865    .4562871       2.19       3.89
         foreign |         74    .2972973    .4601885          0          1
    
    .
    . log close
          name:  <unnamed>
           log:  /home/enzmann/test_2pdf.smcl
      log type:  smcl
     closed on:   4 Nov 2024, 01:38:18
    --------------------------------------------------------------------------------------------------------------------------------------------
    
    .
    . // Create .pdf-file from log file (.smcl):
    . translator set smcl2pdf pagesize A4
    
    . translator set smcl2pdf lmargin 0.586
    
    . translator set smcl2pdf rmargin 0.586
    
    . translator set smcl2pdf tmargin 0.586
    
    . translator set smcl2pdf bmargin 0.586
    
    . translator set smcl2pdf fontsize 8
    
    . translator set smcl2pdf cmdnumber off
    
    . translator set smcl2pdf cust1_result_color 0 0 139  // This should turn the results color to blue
    
    . translator set smcl2pdf cust2_result_color 0 0 139  // This should turn the results color to blue
    
    . translator set smcl2pdf headertext "test_2pdf.do"
    
    . translator query smcl2pdf
    -------------------------------------------------------------------------
                    header | on
                headertext | test_2pdf.do
                      logo | on
                      user |
               projecttext |
                 cmdnumber | off
                  addfonts |
                  autofont | on
    -----------------------+-------------------------------------------------
                  fontsize | 8                         lmargin | 0.59
                  pagesize | A4                        rmargin | 0.59
                 pagewidth | 8.27                      tmargin | 0.59
                pageheight | 11.69                     bmargin | 0.59
    -----------------------+-------------------------------------------------
                    scheme | color
    -----------------------+-------------------------------------------------
        cust1_result_color |   0   0 139    cust2_result_color |   0   0 139
      cust1_standard_color |   0   0   0  cust2_standard_color |   0   0   0
         cust1_error_color |   0   0   0     cust2_error_color | 255   0   0
         cust1_input_color |   0   0   0     cust2_input_color |   0   0   0
          cust1_link_color |   0   0   0      cust2_link_color |   0   0 255
        cust1_hilite_color |   0   0   0    cust2_hilite_color |   0   0   0
         cust1_result_bold | on              cust2_result_bold | on
       cust1_standard_bold | off           cust2_standard_bold | off
          cust1_error_bold | on               cust2_error_bold | on
          cust1_input_bold | off              cust2_input_bold | off
           cust1_link_bold | off               cust2_link_bold | off
         cust1_hilite_bold | on              cust2_hilite_bold | on
      cust1_link_underline | on           cust2_link_underline | on
    cust1_hilite_underline | off        cust2_hilite_underline | off
    -------------------------------------------------------------------------
    
    .
    . translate "test_2pdf.smcl" "test_2pdf.pdf", translator(smcl2pdf)
    file test_2pdf.pdf saved as PDF format
    Is there anything I am doing wrong, for example the specification of the results color as (0 0 139)? Or could it be possible that the color setting simply does not work with Unix (I am using Linux Ubuntu 20.04)?



  • #2
    Dirk Enzmann,

    Thank you for bringing this to our attention. To resolve the issue, you need to set the scheme to custom1 or custom2, rather than color. smcl2pdf supports four schemes: monochrome (default), color, custom1, and custom2. monochrome and color use pre-defined color, bold, and underline styles. monochrome uses the default settings of custom1 while color uses the default settings of custom2, which are defined as follows:

    Code:
    -----------------------+-------------------------------------------------
        cust1_result_color |   0   0   0    cust2_result_color |   0   0   0
      cust1_standard_color |   0   0   0  cust2_standard_color |   0   0   0
         cust1_error_color |   0   0   0     cust2_error_color | 255   0   0
         cust1_input_color |   0   0   0     cust2_input_color |   0   0   0
          cust1_link_color |   0   0   0      cust2_link_color |   0   0 255
        cust1_hilite_color |   0   0   0    cust2_hilite_color |   0   0   0
         cust1_result_bold | on              cust2_result_bold | on
       cust1_standard_bold | off           cust2_standard_bold | off
          cust1_error_bold | on               cust2_error_bold | on
          cust1_input_bold | off              cust2_input_bold | off
           cust1_link_bold | off               cust2_link_bold | off
         cust1_hilite_bold | on              cust2_hilite_bold | on
      cust1_link_underline | on           cust2_link_underline | on
    cust1_hilite_underline | off        cust2_hilite_underline | off
    -------------------------------------------------------------------------
    These predefined settings for monochrome and color schemes are not customizable. Therefore, even you set cust1_result_color or cust2_result_color for color scheme, the change will not be applied. To use customized settings, you can do the following:

    Code:
    translator set smcl2pdf scheme custom1
    translator set smcl2pdf cust1_result_color 0 0 139
    or

    Code:
    translator set smcl2pdf scheme custom2
    translator set smcl2pdf cust2_result_color 0 0 139
    This will allow you to apply the custom color as needed.
    Last edited by Zhao Xu (StataCorp); 05 Nov 2024, 07:31.

    Comment


    • #3
      Thanks, that finally solves the issue!

      A follow-up question: The manual states that I can change translator parameter settings via
      Code:
      translator set [tname setopt setval]
      However, where can I find the possible setopt and setval values for tname smcl2prn? I searched the manual but can't find it.

      Comment


      • #4
        Yon can type

        Code:
        translator query smcl2prn
        to get the setting information.

        Comment


        • #5
          Zhao Xu (StataCorp) : Yes, this shows me the actual settings. My question is: Where can I find which parameters are possible? For example, I my example in #1 the default (?) scheme "color" was used. But where in the documentation can I see that the schemes "custom1" and "custom2" are possible, as well?
          Last edited by Dirk Enzmann; 08 Nov 2024, 08:57.

          Comment

          Working...
          X