4D Blog

Home Tips 4D View Pro: End of document loading

4D View Pro: End of document loading

February 1, 2021

Tips

When you use 4D View Pro (especially in offscreen mode) with complex documents, calculating all formulas could take a while and it can be difficult to know when it’s finally finished (and it’s important to wait before you call commands such as export or print).

As a solution, we’ve introduced two new events. One of which is called for every single calculation/formula, which could be used to trigger a timer. If the time expires without another formula being finished, we can assume that the whole document is finished.

HDI 4DVP End Loading

The first event is On VP Range Changed. This event is launched each time a calculation is completed. Since there can be several calculations, the second event is the on Timer event. This event allows you to wait until the next calculation is completed. If an On VP Range Changed event is thrown before the end of the timer, restart it, otherwise, it’s finished.

For example, if you want to load a large document, wait for the end of all calculations, and export it, you’ll need to create this type of class:

Class constructor($pdfPath : Text)
This.pdfPath:=$pdfPath
This.autoQuit:=False
This.isWaiting:=False
 
Function onEvent
Case of
: (FORM Event.code=On VP Ready)
  // Document import
  VP IMPORT DOCUMENT(This.area; $largeDocument4VP)
  This.isWaiting:=True
  // Start a timer to verify if all calculations are finished.
  // If during this period the "On VP Range Changed" is thrown, the timer will be restarted
  // The time must be defined according to the computer configuration.
  SET TIMER(60)
 
: (FORM Event.code=On VP Range Changed)
  // End of calculation detected. Restart the timer
  If (This.isWaiting)
    SET TIMER(60)
  End if
 
: (FORM Event.code=On Timer)
  // To make sure not to restart the timer if you call other 4D View commands after this point
  This.isWaiting:=False
 
  // Stop the timer
  SET TIMER(0)
 
  // Start the PDF export
  VP EXPORT DOCUMENT(This.area; This.pdfPath; New object("formula"; Formula(ACCEPT)))
 
: (FORM Event.code=On URL Loading Error)
  CANCEL
 
End case 

Download the HDI above to see how to use these events to export a large 4D View Pro file in PDF format!

And check out the doc center for more details!

Discuss

Tags 4D View Pro, Programming, v18 R6

Latest related posts

  • June 27, 2025

    SHOWCASE: SMART COMMENT MODERATION WITH AI

  • April 28, 2025

    Tips & Tricks for your 4D Apps – April 2025 Edition

  • April 9, 2025

    Restrict data according to privileges or information saved in session storage

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy