Para tal, nós precisamos setar certos valores nos parâmetros de impressão antes de rodar o relatório.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // Variables PrintJobSettings printJobSettings; ReportRun myReportRun; ... // Recuperando os parâmetros do relatório printJobSettings = myReportRun.printJobSettings(); // Configurando nossos parâmetros printJobSettings.setTarget(PrintMedium::File); printJobSettings.preferredTarget(PrintMedium::File); printJobSettings.format(PrintFormat::PDF); printJobSettings.preferredFileFormat(PrintFormat::PDF); printJobSettings.fileName("c:\\attachment.pdf"); // Salvando os valores myReportRun.unpackPrintJobSettings(printJobSettings.packPrintJobSettings()); // Rodando o relatório myReportRun.run(); |
Antes de rodar o relatório, podemos configurar os valores da query:
1 2 3 4 5 6 7 8 | query = myReportRun.query(); qbds = query.dataSourceNo(1); qbds.range(1).value(_custTable.CustAccount); qbds.range(2).value(""); qbds.range(3).value(queryvalue(NoYes::Yes)); myReportRun.run(); |
Nota: Para usar uma impressora PDF como o “PDFCreator”, simplesmente configure o nome do dispositivo como:
1 | myReportRun.deviceName("PDFCreator"); |
Fonte: http://olondono.blogspot.com.
[]s
Pichler
| Rio De Janeiro, Brazil | 2 |
| Osasco, Brazil | 1 |
| Curitiba, Brazil | 1 |
| Amman, Jordan | 1 |
| São Paulo, Brazil | 1 |
3 Responses
Mindaugas
24|Mar|2010 1Olá, Ricardo
Thanks for the example. I was researching alternative ways of generating PDF from Ax and stumbled upon your post.
I have “PDFCreator” installed, but cannot make the “this.deviceName(“PDFCreator”);” line to work. Ax still generates PDF using it’s own engine. Have you been able to do so?
Ricardo Pichler
24|Mar|2010 2Mindaugas, are you sure that your code is running in the client tier?
Regards.
Mindaugas
25|Mar|2010 3Yes, it’s running on client.
I was looking for a way to print sales invoices to PDFCreator automatically without popping up of a “Save as.. ” dialog. I was hoping, that PDFCreator would make some use of printJobSettings.fileName(“c:\\attachment.pdf”); but it’s just not the way it works :)
I found no way to pass file name to PDFCreator from Ax. It has AutoSave mode, but it is also not very usable in my case.
I found an acceptable solution with Bullzip PDF Printer which has option to silently generate file name from the document name, which contains Ax invoice Id, so I can easily locate the PDF file.
Have a nice day!
Leave a reply