Skip to main content
Skip table of contents

4. PrintFlat subscriptions and calibrations

This section is for v3.1.0, which introduced the new PrintFlat library (.dll and .so, for Windows and Linux, respectively). If you require assistance for earlier versions, please contact your technical representative.

Retrieving OEM ID and PrintFlat expiry from an LDK license

Ensure PrintFlat.dll is loaded through linking the stub library:

CODE
#include "PrintFlat.h"

PrintFlatDetails details;
if (PrintFlatGetLDKPrintFlatDetails(&details) == PF_SUCCESS)
{           
    // details.oemId gives PrintFlat OEM ID which is protection ID from the LDK license.        
    // details.expiryDate gives PrintFlat expiry date from the LDK license. 
}

If there is no LDK license, the method would return PF_LICENSE_ERR.

Generating a PrintFlat subscription

Ensure PrintFlat.dll is loaded through linking the stub library:

CODE
#include "PrintFlat.h"

// Replace OEMID, EXPIRY_DATE, YOUR_LICENSE, YOUR_PASSWORD with your settings.
const PrintFlatDetails printFlatDetails = { OEMID, EXPIRY_DATE };
const PrintFlatPermit permit = { YOUR_LICENSE, YOUR_PASSWORD, printFlatDetails };
PrintFlatSubscription subscription;
if (PrintFlatGetPrintFlatSubscription(&permit, &subscription) == PF_SUCCESS)
{           
    // subscription.subscription contains the generated subscription.        
}

If ScreenPro is licensed by LDK, you can pass in a NULL pointer to the method:

CODE
if (PrintFlatGetPrintFlatSubscription(&permit, &subscription) == PF_SUCCESS) 
{
    // subscription.subscription contains the generated subscription.         
}

The method works out the license, OEM ID, and expiry date from the LDK license. 

If there is an issue, the method returns an error code that you can look up in PrintFlat.h.

Installing a PrintFlat calibration package (pfc file)

Ensure PrintFlat.dll is loaded through linking the stub library:

CODE
#include "PrintFlat.h"

// screenFolder is the screen folder containing the screen, eg "Screens/3drop_pearl_example/"
// pfcFile is a calibration package created by PrintFlat Create using the same credential.
if (PrintFlatInstallPfcPackage(screenFolder , pfcFile) == PF_SUCCESS)
{           
    // The calibration package is installed correctly and screen is updated.
}

If there is an issue, the method returns an error code that you can look up in PrintFlat.h.

You can also use this method in combination with the screen validation API from the ScreenPro library; this ensures the package is only installed if the screen is valid after installation. 

The following example code shows how to do this:

CODE
#include "ScreenPro.h"
#include "PrintFlat.h"

// screenFolder is the screen folder containing the screen, eg "Screens/3drop_pearl_example/"
// pfcFile is a calibration package created by PrintFlat Create using the same credential.
// ToUtf8() converts an Unicode string to an UTF8 string.
int ScreeningCore_InstallPfcPackage(wchar_t* screenFolder, wchar_t* pfcFile)
{
    const auto screenName = fs::path(screenFolder).filename();
    const auto tempScreen = fs::temp_directory_path() / screenName;
    fs::remove_all(tempScreen);
    int result;
    try
    {
        // Make a copy of the screen and install the PFC to the copy. Move the copy back to the
        // original screen only if validation is successful.
        fs::copy(screenFolder, tempScreen);
        result = PrintFlatInstallPfcPackage(ToUtf8(tempScreen.wstring().c_str()).c_str(), ToUtf8(pfcFile).c_str());
        if (result == PF_SUCCESS)
        {
            result = ScreenProValidateScreen(ToUtf8(tempScreen.wstring().c_str()).c_str(), nullptr);
            if (result == SP_SUCCESS)
            {
                fs::remove_all(screenFolder);
                fs::rename(tempScreen, screenFolder);
                return result;
            }
        }
    }
    catch (const std::exception& ex)
    {
        wcerr << L"ScreenPro failed to install PFC package. Error: " << ex.what() << endl;
        result = PF_PFC_ERR;
    }

    // Failed: clean up.
    fs::remove_all(tempScreen);
    return result;
}


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.