Jump to content
Server Maintenance This Week. ×

Text Alignment in Web Viewer


Hijack

This topic is 3874 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 3874 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.