Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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...
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
Just something to consider...
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!
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
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... 🙄
Hi @Istvan_Horvath ,
That is a good suggestion, thanks!
Best Regards,
Ruggero