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

  • September 15, 2025

    Find the right spot in your 4D Write Pro document with AI

  • September 2, 2025

    Intelligent 4D Write Pro document analysis with AI

  • August 25, 2025

    ORDA – Constructor and touched event – Detailed behaviour through a network

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

  • AI
  • 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 AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming 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