Hijack Posted September 18, 2013 Posted September 18, 2013 Anyone number of a way to align text in web viewer? GetAsCSS will preserve the font formatting of text from a field being pulled into a web viewer but the alignment is lost. I've searched a fair bit but I can't find any way of preserving the original text alignment (center, right, etc). Thanks for any advice.
Raybaudi Posted September 18, 2013 Posted September 18, 2013 try this: http://fmforums.com/forum/index.php?app=core&module=attach§ion=attach&attach_id=20313
Hijack Posted September 18, 2013 Author Posted September 18, 2013 Thanks for the sample! I'm still trying to decipher the custom function but in tinkering with the output I can see that there are some quirks such as truncation of a line if a substring within a line of the source is changed on color, size, highlight, font, etc. apart from the rest of the line. It just seems that outputing a field in a web viewer is only suitable for very basic needs.
Raybaudi Posted September 19, 2013 Posted September 19, 2013 Your question was about the alignment of the text; the custom function must be modified to take in account other styles inside the paragraph
Raybaudi Posted September 19, 2013 Posted September 19, 2013 Anyway you could try this file. It is based on a new custom function: /* TextToCSS ( text ) custom function Author Daniele Raybaudi Type Recursive Returns a valid CSS, including all alignments, styles and colors of the original text. ( GetAsCSS ( ) can't do it !! ) A Web Viewer set as: "data: text / html, <style type='text/css'> body {border: none; overflow: hidden;} </ style>" & TextToCSS ( YourTable :: text ) shows exactly the content of the field. 09/19/2013 v1 09/20/2013 v1.1 ( minor bug corrected ) */ Let([ $i = $i + 1 ; v = GetValue ( text ; $i ) ; css = GetAsCSS ( v ) ; pos1 = Position ( css ; "text-align:" ; 1 ; 1 ) + 11; pos2 = Position ( css ; ";" ; pos1 ; 1 ) ; align = If ( PatternCount ( css ; "text-align:" ) ; Middle ( css ; pos1 ; pos2 - pos1 ) ); div = If ( IsEmpty ( v ) ; "<BR>" ; "<div style='text-align:" & align & ";'>" & css & "</div>" ) ]; Case( $i ≤ ValueCount ( text ) ; List ( div ; TextToCSS ( text ) ) ; Let ( $i = "" ; "" ) ) ) TextToCSS.zip
Hijack Posted September 24, 2013 Author Posted September 24, 2013 Raybaudi, Thank you for the revised custom function. It works very well. It handles all mid-string formatting changes and paragraph alignment as expected (after adding some font tags to set the desired font in the web viewer). The web viewer output matches the source text field. There are still annoying quirks (in FileMaker Go) with the web viewer such as needing to tap in the viewer first before it can be be scrolled and text shifting in the web viewer when tapped when the virtual scroll bar activates, causing text to wrap at different points. But, it DOES allow for the displaying of large text blocks without the virtual keyboard popping up which was my main goal. Thank you again for the excellent addition to my systems.
Recommended Posts
This topic is 4188 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now