Blog
All Blog Posts | Next Post | Previous PostAte too much candy? Calculate and export your BMI to PDF with FNC for the WEB!
Wednesday, July 3, 2019
Ate too much candy?
We all have those moments in life where we are proud of what we have achieved, be it in sports, school, at work... . Whenever we have reached a goal, were hard work lies at the base of it, we tend to reward ourselves with something that makes us even more excited of what we have achieved. For me, that something is candy. I know, I should be eating less of it, but hey!, I have earned it! As I'm obviously eating too much of it, I created a BMI calculation app to track if I should stop eating, or if there is still room for one tiny sweet piece of candy.FNC for the web!
The application, which calculates the BMI, is written with the help of TMS FNC UI Pack, TMS FNC Dashboard Pack and TMS WEB Core and is running in the webbrowser. It allows entering your name, height (cm) and your weight (kg). The calculate button will indicate your BMI in the grid, allowing you to know if you should loose or gain some weight, or if you are absolutely perfect.PDF for the web!
The BMI application is allowing you to export your data to PDF. Typically, when generating a report, invoice, or any other PDF data file in the browser, this is done on a back end server. The costs to handle the load, scalability can quickly rise and the maintenance gives a lot of headaches. With the TTMSFNCPDFLib and TTMSFNCGraphicsPDFIO components that are both used in the BMI application you no longer need a backend to generate a PDF in your web application. The components completely generate the PDF at the client-side (front end).The TTMSFNCPDFLib component is used to generate the PDF, and the TTMSFNCGraphicsPDFIO component is a bridge to export FNC UI controls such as the TTMSFNCPlanner, TTMSFNCGrid, TTMSFNCChart and many more. In the BMI web application, both are used to combine the custom PDF exporting capabilities with the TTMSFNCGrid and TTMSFNCWidgetGauge components.
The code behind this is actually very simple.
procedure TPDFLibBMILogic.GeneratePDF; var fn: string; o: TTMSFNCPDFIOExportObjectArray; r: TTMSFNCPDFIOExportRectArray; ms: TMemoryStream; begin {$IFDEF ANDROID} fn := TPath.GetSharedDocumentsPath + PathDelim + 'BMI.pdf'; {$ENDIF} {$IFDEF MACOS} fn := TPath.GetDocumentsPath + PathDelim + 'BMI.pdf'; {$ENDIF} {$IFNDEF ANDROID} {$IFNDEF MACOS} fn := 'BMI.pdf'; {$ENDIF} {$ENDIF} p.Options.Header := 'BMI Report for ' + FName; SetLength(o, 2); o[0] := FGauge; o[1] := FGrid; SetLength(r, 2); r[0] := RectF(50, 180, 50 + FGauge.Width, 180 + FGauge.Height); r[1] := RectF(50 + FGauge.Width + 50, 180, 50 + FGauge.Width + 50 + FGrid.Width, 180 + FGrid.Height); ms := TMemoryStream.Create; try p.Save(ms, o, r); ms.SaveToFile(fn); {$IFNDEF WEBLIB} TTMSFNCUtils.OpenFile(fn); {$ENDIF} finally ms.Free; end; end;
Play with the demo yourself!
Curious on how the demo works, or if you want to know if you can eat more candy? Below is a link that shows the demo live! Note that the components, demo is currently not yet released, but we are working hard on a beta of FNC that is coming real soon, so stay tuned!https://download.tmssoftware.com/tmsweb/demos/TMSWeb_FNCPDFLib_BMI/
Pieter Scheldeman
This blog post has received 9 comments.
2. Thursday, July 4, 2019 at 9:34:17 AM
Sorry Holger :)
Bruno Fierens
3. Thursday, July 4, 2019 at 3:34:46 PM
Amazing stuff.. congratulations to the team for such an excellent product. The TMS components make eating candy, much too easy, lol!
Kamran Rana
4. Thursday, July 4, 2019 at 7:40:42 PM
Thanks Rana! Really appreciated!
Pieter Scheldeman
5. Sunday, July 14, 2019 at 9:09:19 PM
Good
I like to see more samples (online or for download)
Thats very good post
I like to see more samples (online or for download)
Thats very good post
M.V
6. Sunday, November 17, 2019 at 11:19:52 PM
Hello! Could explain better:
p.Options.Header := ''BMI Report for '' + FName;
p.Options.Header := ''BMI Report for '' + FName;
MISAEL ELIAS DE MORAIS
7. Thursday, February 13, 2020 at 9:03:08 PM
This sets the header text of the PDF that is generated. You can see this title in the screenshot
Bruno Fierens
8. Friday, March 26, 2021 at 2:19:14 PM
I couldn''t get this example to run. I have a license for all components, but no compilation will give an error.
DE MORAIS MISAEL
9. Friday, March 26, 2021 at 2:25:01 PM
For technical support:
https://www.tmssoftware.com/site/support.asp
https://www.tmssoftware.com/site/support.asp
Bruno Fierens
All Blog Posts | Next Post | Previous Post
thanks to bruno and his team
HOlger
Klemt Holger