Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Build archives on the fly

Featured Replies

For 13.1 we get new Archive functions to build a zip archive on the fly. One of the use of deprecated ZipFile functions was to assemble an archive in memory from various files or containers. You can now do that with our Archive.Create function. Just call it to either start an on-disk or in-memory archive using the compression format and compression filter of your choice. We usually use zip for maximum compatibly, but you can also do tar or 7zip. 

 

Next you can add content. For that you may use Archive.AddContainer to pass a container value as variable or pass a field reference. We read the content of the container and compress it in memory. If you have existing files on disk, you can use Archive.AddFile function. Please note that you can pass a list of files with relative path parts, e.g. "Documents/email.pdf¶Documents/answer.pdf" and then the base path to find them like "C:\Users\cs\Desktop\". The relative file paths end up in the archive, so they are used when expanding the archive. If you like to add a file based of text, you can use Archive.AddText to create a text file directly in the new archive.

 

Let us show you an example script to zip up a few PDFs in records:

Set Variable [ $r ; Value: MBS( "Archive.Create"; "zip"; "deflate") ] 
If [ MBS("IsError") ] 
	Show Custom Dialog [ "Failed to create zip archive." ; $r ] 
	Exit Script [ Text Result:    ] 
End If
# 
Go to Record/Request/Page [ First ]
Set Variable [ $destPage ; Value: 1 ] 
Loop
	Set Variable [ $r ; Value: MBS( "Archive.AddContainer"; Merge PDFs::InputPDF) ] 
	Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
Set Variable [ $zip ; Value: MBS( "Archive.Close"; "test.zip") ] 
If [ MBS("IsError") ] 
	Show Custom Dialog [ "Failed to create zip archive." ; $r ] 
Else
	Set Field [ Merge PDFs::FinalPDF ; $zip ] 
End If

As you see, we create an in-memory archive, loop over records and add PDF containers to it. Then we close the archive passing the file name and store it in a container field.

 

You can do the same with an archive file on disk by passing a native file path to the Archive.Create function:

Set Variable [ $path ; Value: MBS( "Path.AddPathComponent"; MBS( "Folders.UserDesktop" ); "test.zip" ) ] 
Set Variable [ $r ; Value: MBS( "Archive.Create"; "zip"; "deflate"; $path) ] 
If [ MBS("IsError") ] 
	Show Custom Dialog [ "Failed to create zip archive." ; $r ] 
	Exit Script [ Text Result:    ] 
End If
# 
Go to Record/Request/Page [ First ]
Set Variable [ $destPage ; Value: 1 ] 
Loop
	Set Variable [ $r ; Value: MBS( "Archive.AddContainer"; Merge PDFs::InputPDF) ] 
	Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
Set Variable [ $r ; Value: MBS( "Archive.Close") ] 

 

Otherwise the script is the same and does the same functionality.

 

You may have noticed, that we don't use reference numbers here. That is because we keep the current archive stored in memory in relation to the current thread. This allows each script on a server to have their own current archive without using numbers.

 
Please try the functions and let us know your questions. The example script above is included in the Merge PDFs 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.