WPTools v4.21 incorrect loading Cell-width

  • Hi Julian,

    WPTools v4.21 with WPXMLFILE.pas is currently not loading the tablecell-width correctly. When you drag the cell-border to, say, 20% and you save the HTML file. The page is saved correct.

    But, when you reopen the page the cell-width is read incorrectly.

    Can you reproduce & fix this problem?

    Regards,
    Janno de Wit

    • Offizieller Beitrag

    Thanks!

    To fix the problem please change the line 731 in WPXIMFile.PAS from

    str := Format('style="border:1px black;padding:1px;width:%s%%;margin-left:%.2fin;margin-right:%.2fin"', [str, l / 1440, r / 1440]);

    to

    FParams.Add('width=' + str + '%'); str := Format('style="border:1px black;padding:1px;margin-left:%.2fin"', [l / 1440]);


    Julian

  • Hi Julian,

    This is not the solution !? This is a change in WPXMLWriter. The problem is not the writer, but seems to be the xml-reader!

    The output of Wpxmlwriter is like this:

    Code
    <table width="100%" style="padding:1px;margin-left:0.00in">
    <tr>
      <td style="width:7%;border:0px;">

    You see the cell-width is correctly saved. But the reader does not read it correctly...

    Regards,
    Janno.

  • Hi Julian,

    Found the following:

    Writer does not save <td WIDTH=XX%>, but saves the column-width in STYLE="width:XX%".
    Reader only reads <td WIDTH=XX%>

    Okay, but now the following problem:

    Code
    FMemo.TextTables.GetLeftRight(FMemo.GetParObjectTable(save_par).TableTag, l, r);      n := FMemo.Header.PageWidth - FMemo.Header.LeftMargin -        FMemo.Header.RightMargin;      str := FormatFloat('0', ((n - (l + r)) / n) * 100); // <= ALWAYS 100??      c := DecimalSeparator;      DecimalSeparator := '.';      [..]      FParams.Add('width=' + str + '%');

    str = always 100. So always "100%" is now the str-result??

    So i searched for another problem: line ~796

    Code
    EXTRACSSStyle := 'width:' + FormatFloat('0', (save_par^.celldef^.CWidthPC / 255) * 100) + '%;';
    
    
        // jdw
        if (Pos('width:', EXTRACSSStyle) > 0) then
            FParams.Add( StringReplace(EXTRACSSStyle, ':', '=', []) );
        // jdw

    Last 2 lines of code is to save the cell-width?

    Maybe not as tidy as it should, can you fix it?

    Janno.