1
Watermark text colour inconsistency causing re-caching of document needlessly
Problem reported by Aron Craig - 1/20/2023 at 1:56 AM
Resolved
I have a text watermark for a document, the colour of which is stored as hex "#FF0000".
To use it as a watermark text colour it is translated so: System.Drawing.ColorTranslator.FromHtml("#FF0000")

This document keeps re-caching (viewing for first time) and when I check the cached json I can see that in a previously cache the watermark FontColor is "Red" and in the current one it is "255, 0, 0" which is obviously the exact same colour just expressed in a different format.

Can anyone provide a suggestion as to how I can stop this happening as this is affecting multiple documents in my system that use that very same watermark.

1 Reply

Reply to Thread
0
Cem Alacayir Replied
Employee Post Marked As Resolution
FYI,
This now fixed in Version 6.7.0 - February 23, 2023:
:
  • Improved: DocumentCache will now serialize properties of type System.Drawing.Color
    to html hex color code #RRGGBBAA (#RRGGBB if alpha is 255 - means not set). This format is more universal and can be recognized easily.
    The reason for the change is that if you set a property of type System.Drawing.Color (e.g. TextWatermark.FontColor)
    to a named color (e.g. Color.Red), this is serialized as it is in json (e.g. "Red" due to System.Drawing.Color.ToString behaviour).
    However if you set the property to a color without name (e.g. Color.FromArgb(255, 0, 0) or ColorTranslator.FromHtml("#FF0000")),
    this was serialized as a byte array RGBA (e.g [255, 0, 0, 0]).
    So this inconsistency caused re-caching of a file if you changed TextWatermark.FontColor from e.g. Color.Red to Color.FromArgb(255, 0, 0),
    although they were the same colors.

    With this version, DocumentCache will migrate this change automatically for you, it will scan the cache folder,
    update all .json cache info files, regenerate cache keys (due to json serialization change) and rename cache files to match the new cache keys.
    This migration will be run on first access to the cache, it can take few seconds to complete (may take longer for cloud folders).
    You can check the details and results of the migration in CacheMigrate.log in cache folder.
    After the migration, even if you change TextWatermark.FontColor for already cached document
    from e.g. Color.Red to Color.FromArgb(255, 0, 0) - same color but different argument - no re-caching will occur
    and already cached document will be load witout waiting.

  • Improved: DocumentCache will now log information and errors about trimming and migrating.

    • Migration related details and errors will be logged to CacheMigrate.log in cache folder (and important one also to GleamTech.log).

    • Trimming related details and errors will be logged to CacheTrim.log in cache folder (and important one also to GleamTech.log).

    • Updated cache versioning, CacheVersion's first 2 parts are FileCache version, second 2 parts are sub-class cache version.
      e.g. 2.0.1.0 -> FileCache, 2.0.2.0 -> DocumentCache, 2.0.3.0 -> ThumbnailCache.

    • Improved migration handling (especially in FileCache sublasses) and stability.



Reply to Thread