Jump to content

Recommended Posts

Posted

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?

Posted

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?

Posted

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.

  • Administrators
Posted

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.

  • 5 months later...
Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...