Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Istvan_Horvath
Contributor II
Contributor II

PixelPerfect Script - Delete files

Hallo,

 

I created one NPrinting PixelPerfect Report, which generates  to a folder every time a new file, where filename is with timestamp. Unfortunately I am forced to do so, because overwriting the file would not work for the endgoal.

Also files are like: report_20220622_110000.pdf, report_20220622_120000.pdf, report_20220622_130000.pdf, ...

 

I set up in the "publish task" - Report to keep: 1; but as far as I understand this only applies to hub, and not to folder destination...

 

So I tried to build a c# script.

I tried the same script in c# app, and it works, but in NPrinting nothing happens... I dont get any error message, but the files are still there...

The script is:

using System;
using System.IO;
private void PixelPerfect_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
string rootFolder = @"\\192.168.111.111\sharefolder\reportsfolder";
string[] files = Directory.GetFiles(rootFolder);
foreach (string file in files)
{
File.Delete(file);
}
}

 

Any suggestion?

Thanks!

Br,

István

Labels (2)
1 Solution

Accepted Solutions
Ruggero_Piccoli
Support
Support

Hi,

The publish task parameter Days to keep and Reports to keep are related only to the Qlik NPrinting NewsStand https://help.qlik.com/en-US/nprinting/May2021/Content/NPrinting/DistributionSchedulesAutomation/Dist.... There are not similar parameters for Qlik Sense Hub and Folders as destination.

Your C# code is related to a PixelPerfect script. On recent versions their execution must be enable in the Settings https://help.qlik.com/en-US/nprinting/May2021/Content/NPrinting/AdministeringQVNprinting/Admin-setti... otherwise they are ignored. Maybe this is your issue. PixelPerfect scripts could be a security issue so they need to be explicitly enabled.

Best Regards,

Ruggero



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.

View solution in original post

7 Replies
Frank_S
Support
Support

Hi @Istvan_Horvath

I see you are a new member so welcome to the Qlik Community!

 

You should be able to use the built in tools in NPrinting Publish Tasks and NPrinting Report Dynamic naming to distribute your reports without overwriting anything.

You might also prefer to create a unique Qlik Variable that you can use in your dynamic report name (and if needed, use the report cycle tool to further ensure you get a different report name. Cycle will create a different workbook for each cycled dimension value)

Further, it is true that NPrinting will not delete reports in the Qlik Sense hub, network nor local folders and email of course.

The days to keep and reports to keep only affect NPrinting Newsstand reports.

 

So a deletion batch file is likely your best best to  delete files stored in local or network folders.

Reports in the Qlik Sense hub currently may not be deleted using a global interface in Qlik Sense.

To vote for this feature visit:

For more information regarding NPrinting configuration and training, feel free to have a look at these pages.

Kind regards...

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Istvan_Horvath
Contributor II
Contributor II
Author

Hello,

thank you, but not this is my problem.
New files with dynamic names are working fine!
What I need: delete the old file before creating the new file!

Br, István
Frank_S
Support
Support

One of the things I mentioned is that you could use a batch file.

"So a deletion batch file is likely your best best to  delete files stored in local or network folders"

Feel free to do your own search in google or check out this third party link which describes the command line syntax. (Note: Use this external link at your own discretion or do not use at all and do your own search to retrieve the necessary command line syntax that will accommodate your specific requirement)

One you've designed your batch file, you can then use the Windows server task scheduler (where the files are stored) to schedule and execute the batch file.

Then you can schedule execution of your NPrinting reports 'after' your batch file runs. 

Example of schedules for deletion of report files and subsequent execution of your NPrinting Publish Task 

  • Schedule the deletion batch file at midnight with windows task scheduler
  • Schedule NPrinting publish task trigger to execute at 1 am. (one hour later).

Just something to consider...

Please remember hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Istvan_Horvath
Contributor II
Contributor II
Author

I would be happier if I could make one solution (1 which delete old file and after creates the new report); and not 2 solutions (1 for delete and 1 for create) because I do this in every 10 minutes...

Of course, if this is not possible even with c# scripting, then I will use the method, what you also suggested.

[Or I try to write a little console app in c# which delete the file and after over API start the generating.]

Thank for your tips!

 

Can somebody help with the script? Is there limitations within the script? Or theoreticly should it works? How can I find which c# version is implemeted?

Thanks!

Ruggero_Piccoli
Support
Support

Hi,

The publish task parameter Days to keep and Reports to keep are related only to the Qlik NPrinting NewsStand https://help.qlik.com/en-US/nprinting/May2021/Content/NPrinting/DistributionSchedulesAutomation/Dist.... There are not similar parameters for Qlik Sense Hub and Folders as destination.

Your C# code is related to a PixelPerfect script. On recent versions their execution must be enable in the Settings https://help.qlik.com/en-US/nprinting/May2021/Content/NPrinting/AdministeringQVNprinting/Admin-setti... otherwise they are ignored. Maybe this is your issue. PixelPerfect scripts could be a security issue so they need to be explicitly enabled.

Best Regards,

Ruggero



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.
Istvan_Horvath
Contributor II
Contributor II
Author

I had only to enabled the script executions in admin settings, and now works like a charm! 😉 

Thank you very much!!!

ps: why dont give me NPrinting any clue/message for that in logs...  🙄

 

Ruggero_Piccoli
Support
Support

Hi @Istvan_Horvath ,

That is a good suggestion, thanks!

Best Regards,

Ruggero



Best Regards,
Ruggero
---------------------------------------------
When applicable please mark the appropriate replies as CORRECT. This will help community members and Qlik Employees know which discussions have already been addressed and have a possible known solution. Please mark threads with a LIKE if the provided solution is helpful to the problem, but does not necessarily solve the indicated problem. You can mark multiple threads with LIKEs if you feel additional info is useful to others.