misc Posted February 17, 2014 Posted February 17, 2014 Maybe i'm lacking understanding of uniGUI, but I tried to add a THtmlViewer to TuniHiddenPanel, and I always get the message "Cannot assign nil to a font." at runtime. Even when I create it at runtime.I want to use the THtmlViewer to load some Html and save it as PDF. The Fastreport engine does not create nice tables without having to buy the full product, and IMO it's a little heavy for my task. I want to do something like this: HtmlViewer1:= THtmlViewer.Create(Self); HtmlViewer1.Parent:= UniHiddenPanel1; //must have a parent control ... load some html code into htm HtmlViewer1.LoadTextStrings(htm); //"cannot assign nil to a font" with THtml2Pdf.Create do begin Viewer := HtmlViewer1; MarginLeft := 10; MarginRight := 10; ScaleToFit := true; Orientation := poLandscape; DefaultPaperSize := psA4; DrawPageNumber := true; DrawPageNumberText := fname + ' - Page %d/%d'; Execute; SaveToFile(fname); Free; end; Does anybody have an alternative, or knows how to overcome this? Quote
ZigZig Posted February 17, 2014 Posted February 17, 2014 You cannot use visual components (like THtmlViewer) other than uniGui components in a uniGui project. Quote
Administrators Farshad Mohajeri Posted February 17, 2014 Administrators Posted February 17, 2014 Using standard VCL controls is not safe. Using them can lock or crash your server. Quote
misc Posted February 18, 2014 Author Posted February 18, 2014 I got the THtmlViewer working by placing it on a VCL form and creating it (without showing). Maybe not an intended solution, but no crash so far However, I could not get THtml2Pdf working, because it needs a VCL canvas. The THtmlViewer/THtml2Pdf combination works superb in VCL applications, but I cannot get it to work under uniGUI. So the question that remains: Has anybody found a solution to convert HTML to PDF without the large fingerprint of FastReport and likewise report engines? Quote
Administrators Farshad Mohajeri Posted February 18, 2014 Administrators Posted February 18, 2014 You can use a PDF printer and print to it. Quote
misc Posted February 19, 2014 Author Posted February 19, 2014 Got the above code to work. I set the Margins too high - they are counted as cm/in, not pixels. I mistook the error message for an uniGUI problem. It's possible to create VCL forms at runtime and put VCL components on it. At least in my case no crashes. So my solution is a free and lean way of converting HTML to PDF. @ Farshad, at this point I must say, you had a truely amazing idea with uniGUI. Quote
Administrators Farshad Mohajeri Posted February 19, 2014 Administrators Posted February 19, 2014 It's possible to create VCL forms at runtime and put VCL components on it. At least in my case no crashes. Of course you can do this, but when there are many active sessions, trying to access your VCL form and its VCL methods may lead your app into deadlocks or even a crash. Your method may work for a few session but since it is not thread-safe you can't rely on it. i.e. your app will not be scalable. Quote
Administrators Farshad Mohajeri Posted February 19, 2014 Administrators Posted February 19, 2014 @ Farshad, at this point I must say, you had a truely amazing idea with uniGUI. Thank you. Quote
eelias Posted August 6, 2014 Posted August 6, 2014 Since I stated using UniGUI I have made my own set of components inheriting from the UniGUi Ones. However today I tried to use my version of TUniEdit and at runtime it gives me "Cannot assign nil to a font." Like what was said in this post. However, I am not using ANY vcl component, just a wapper around it. I am not even changing any properties etc. I have all the other components working like this, based on a wrapper, why is this different? Quote
Administrators Farshad Mohajeri Posted August 6, 2014 Administrators Posted August 6, 2014 Pls send a copy of your package. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.