Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Text Alignment in Web Viewer

Featured Replies

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.

Solved by Hijack

Go to solution
  • Author

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.

Your question was about the alignment of the text; the custom function must be modified to take in account other styles inside the paragraph

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

  • Author
  • Solution

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.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.