Debugging

Verbose Mode

Turning on verbose mode on the SDK in your application can help in debugging.

Verbose mode will allow you to see the JSON-data that is sent to the Cloud Office Print server together with some more information about the requests and responses to and from the server.

To turn on verbose mode:

You can turn on verbose mode by setting the argument cop_verbose to True when creating a PrintJob object:
printJob = cop.PrintJob(
    data=collection,
    server=server,
    template=cop.Resource.from_local_file('PATH_TO_TEMPLATE_FILE'),
    cop_verbose=True # set cop_verbose to true
)
Or just set the cop_verbose property of your PrintJob object to True:
printJob.cop_verbose = True
Documentation
You can turn on verbose mode by setting the argument copVerbose to true when creating a PrintJob object:
const printJob = new cop.PrintJob(
    collection,
    server,
    cop.Resource.fromLocalFile('PATH_TO_TEMPLATE_FILE'),
    undefined,
    undefined,
    undefined,
    undefined,
    true // set copVerbose to true
);
Or just set the copVerbose property of your PrintJob object to true:
printJob.copVerbose = true;
Documentation
You can turn on verbose mode by setting the argument copVerbose to true when creating a PrintJob object:
const printJob = new cop.PrintJob(
    collection,
    server,
    cop.Resource.fromLocalFile('PATH_TO_TEMPLATE_FILE'),
    undefined,
    undefined,
    undefined,
    undefined,
    true // set copVerbose to true
);
Or just set the copVerbose property of your PrintJob object to true:
printJob.copVerbose = true;
Documentation
You can turn on verbose mode by calling .setVerbose(true) on your Server object that you have created:
Server copServer = new Server("https://api.cloudofficeprint.com/");
copServer.setAPIKey(APIKey);
copServer.setVerbose(true); // set verbose to true
Documentation

Local Debugging

If you you receive an error and need some help, you could try local debugging.

In local debugging, we will download the JSON file created by the SDK instead of downloading the report.
This is similar to using verbose mode.

You can view the JSON generated by the SDK by accessing the json or as_dict property of your PrintJob object:
printJob = cop.PrintJob(
    data=collection,
    server=server,
    template=cop.Resource.from_local_file('PATH_TO_TEMPLATE_FILE'),
)
print(printJob.json) # JSON format
print(printJob.as_dict) # Dictionary format
Documentation
You can view the JSON generated by the SDK by calling the asDict() method on your PrintJob object:
const printJob = new cop.PrintJob(
    collection,
    server,
    cop.Resource.fromLocalFile('PATH_TO_TEMPLATE_FILE')
);
console.log(printJob.asDict());
Documentation
You can view the JSON generated by the SDK by calling the asDict() method on your PrintJob object:
const printJob = new cop.PrintJob(
    collection,
    server,
    cop.Resource.fromLocalFile('PATH_TO_TEMPLATE_FILE')
);
console.log(printJob.asDict());
Documentation
You can view the JSON generated by the SDK by calling the getJSON() method on your PrintJob object:
PrintJob printJob = new PrintJob(data, copServer, output, base64Resource, null, null, null, null);
System.out.println(printJob.getJSON())
Documentation

Investigate the received JSON:

  • JSON is valid, and valid output: this is how it should be.

  • JSON is invalid: this is a problem with the SDK or application, click the button "Sent to Support" and contact support@cloudofficeprint.com.

  • JSON is valid, but invalid Office file (Word, Excel, PowerPoint): this means that AOP couldn't merge your data with the template you provided. If the template and requested output is the same format (e.g. your template is in Word and you request a Word document); check your template again if all substitution strings are correct. If you believe everything is ok, contact support@apexofficeprint.com.

  • JSON is valid, but invalid PDF (or other output format): if the template and output format are different, a conversion is going on handled by LibreOffice or MS Office. Either the conversion goes wrong, or most likely the initial file before the conversion was already wrong. To debug further, set the output format to the same format as your template and run your report again. If the output is invalid, follow previous steps (see JSON is valid, but invalid Office file). If the output is ok, send an email to support@apexofficeprint.com as it means there's a bug in the conversion.

If you didn't find a solution yourself, please send the JSON file to support@apexofficeprint.com

Remote Debugging

If you receive an error and need some help, you could try remote debugging.

In remote debugging, the Cloud Office Print server will log the JSON sent to the server and this can be seen later when you login to cloudofficeprint.com.

To enable remote debugging:

You can turn on remote debugging by setting the argument cop_remote_debug to True when creating a ServerConfig object:
server = cop.config.Server(
    SERVER_URL,
    cop.config.ServerConfig(
        api_key=API_KEY,
        cop_remote_debug=True # set cop_remote_debug to true
    )
)
Or just set the cop_remote_debug property of your ServerConfig object to True:
serverConfig.cop_verbose = True
Documentation
You can turn on remote debugging by settings the argument copRemoteDebug to true when creating a ServerConfig:
const server = new cop.config.Server(
    SERVER_URL,
    new cop.config.ServerConfig(
        API_KEY,
        undefined,
        undefined,
        undefined,
        undefined,
        true // set copRemoteDebug to true
    )
);
Or just set the copRemoteDebug property of your ServerConfig object to true:
serverConfig.copRemoteDebug = true;
Documentation
You can turn on remote debugging by settings the argument copRemoteDebug to true when creating a ServerConfig:
const server = new cop.config.Server(
    SERVER_URL,
    new cop.config.ServerConfig(
        API_KEY,
        undefined,
        undefined,
        undefined,
        undefined,
        true // set copRemoteDebug to true
    )
);
Or just set the copRemoteDebug property of your ServerConfig object to true:
serverConfig.copRemoteDebug = true;
Documentation
You can turn on remote debugging by setting the argument copRemoteDebug to true when creating a ServerConfig object:
PrintJob printJob = new PrintJob(
    data,
    copServer,
    output,
    base64Resource,
    null,
    null,
    null,
    true // set copRemoteDebug to true
);
Or just set the call .setCopRemoteDebug(true) on your PrintJob object that you have created:
printJob.setCopRemoteDebug(true);
Documentation

You can then login to cloudofficeprint.com and go to Remote Debug.

Click on the magnifying glass, and the JSON that was generated by the SDK and was sent to the Cloud Office Print server will be shown.

Investigate the received JSON:

  • JSON is valid, and valid output: this is how it should be.

  • JSON is invalid: this is a problem with the SDK or application, click the button "Sent to Support" and contact support@cloudofficeprint.com.

  • JSON is valid, but invalid Office file (Word, Excel, PowerPoint): this means that Cloud Office Print couldn't merge your data with the template you provided. If the template and requested output is the same format (e.g. your template is in Word and you request a Word document), check your template again if all substitution strings are correct. If you believe everything is ok, click the button "Sent to Support" and contact support@cloudofficeprint.com.

  • JSON is valid, but invalid PDF (or other output format): if the template and output format are different, a conversion is going on handled by LibreOffice or MS Office. Either the conversion goes wrong, or most likely the initial file before the conversion was already wrong. To debug further, set the output format to the same format as your template and run your report again. If the output is invalid, follow previous steps (see JSON is valid, but invalid Office file). If the output is ok, click the button "Sent to Support" and send an email to support@cloudofficeprint.com as it means there's a bug in the conversion.

Debugging Connections to Cloud Office Print Server

Open a first command prompt or shell and run Cloud Office Print in verbose mode:

$ ./CloudOfficePrintLinux64 —-verbose

Copy the test.json file to your server where Cloud Office Print is running in the /tmp folder.

In another command prompt or shell go to /tmp folder and run:

$ curl -X POST -H 'Content-Type: application/json' -d @test.json http://127.0.0.1:8010/ > output.docx

If you are in a windows environment you can download curl from curl.haxx.se/download.html#Win64

This should show the below output and have created an output.docx file

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  164k  100 68310  100   97k   335k   492k --:--:-- --:--:-- --:--:--  494k

Check the first shell, Cloud Office Print should have printed:

Prinjob received.
Sending back response.
Prinjob completed.

Try to run the same curl command but with your server name

$ curl -X POST -H 'Content-Type: application/json' -d @test.json http://<your server name>:8010/ > output.docx

Same as before for output.

Go to the database server copy the test.json in the /tmp folder and run the curl command again

$ curl -X POST -H 'Content-Type: application/json' -d @test.json http://<your server name>:8010/ > output.docx

This should do the same as before.

Instead of using curl you can also use a RESTClient like Postman. You will have to add the header 'Content-Type: application/json' and give the data from the test.json into the body section.

In the shell where Cloud Office Print is running you should see the incoming connection.

Hopefully the below steps give you more insight where your connection is failing so you can correct accordingly.