Discussion:
Saving PDF report to file AX 2009
(too old to reply)
AgNi00
2009-12-03 09:46:01 UTC
Permalink
I want my invoice created to file an not printed to screen.
Is there anything else that I have to do with the printjobsettings to get it
to work? Tried this job where I set the filename, format and printmedium but
it still just prints to screen.

static void job(Args _args)
{
CustInvoiceJour InvJTbl;
SalesId Id;
ReportRun report;
RecordSortedList List = new RecordSortedList(62);
SalesFormLetter_Invoice SalesFormLetter;
;
salesformletter = new SalesFormLetter_Invoice(false);


Id = "100000002";

Select InvJTbl Where InvJTbl.SalesId == Id;
List.ins(InvJTbl);
report = new ReportRun(new Args(ReportStr(SalesInvoice)));
report.args().caller(null);
report.args().object(List);
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().fileName("C:\\Temp\\Test.pdf");
report.run();

}
Klaas Deforche
2009-12-03 11:03:03 UTC
Permalink
Hi there,

Check this out, it will help you:
http://www.axaptapedia.com/Printer_Settings_and_Run_From_Code
Remember to pack/unpack the printersettings at the end.

I would advise trying it with a simple report first (like cust), because the
reason it doesn't work is probably because you printersettings are
overwritten in the report itself.
See fetch() method of the salesInvoice report:
salesFormLetterReport.loadPrintSettings(...).
Here, your settings are overwritten with setup (I don't know where this is
set up...).

Hope this helps,
Best regards,
Klaas.
----------------
http://www.artofcreation.be
Post by AgNi00
I want my invoice created to file an not printed to screen.
Is there anything else that I have to do with the printjobsettings to get it
to work? Tried this job where I set the filename, format and printmedium but
it still just prints to screen.
static void job(Args _args)
{
CustInvoiceJour InvJTbl;
SalesId Id;
ReportRun report;
RecordSortedList List = new RecordSortedList(62);
SalesFormLetter_Invoice SalesFormLetter;
;
salesformletter = new SalesFormLetter_Invoice(false);
Id = "100000002";
Select InvJTbl Where InvJTbl.SalesId == Id;
List.ins(InvJTbl);
report = new ReportRun(new Args(ReportStr(SalesInvoice)));
report.args().caller(null);
report.args().object(List);
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().fileName("C:\\Temp\\Test.pdf");
report.run();
}
AgNi00
2009-12-04 07:39:01 UTC
Permalink
Thanks for helping me out here. It was correct that my code was overwritten
in the fetchmethod. I moved my printersettings to fetch and now it works just
fine.
Post by Klaas Deforche
Hi there,
http://www.axaptapedia.com/Printer_Settings_and_Run_From_Code
Remember to pack/unpack the printersettings at the end.
I would advise trying it with a simple report first (like cust), because the
reason it doesn't work is probably because you printersettings are
overwritten in the report itself.
salesFormLetterReport.loadPrintSettings(...).
Here, your settings are overwritten with setup (I don't know where this is
set up...).
Hope this helps,
Best regards,
Klaas.
----------------
http://www.artofcreation.be
Post by AgNi00
I want my invoice created to file an not printed to screen.
Is there anything else that I have to do with the printjobsettings to get it
to work? Tried this job where I set the filename, format and printmedium but
it still just prints to screen.
static void job(Args _args)
{
CustInvoiceJour InvJTbl;
SalesId Id;
ReportRun report;
RecordSortedList List = new RecordSortedList(62);
SalesFormLetter_Invoice SalesFormLetter;
;
salesformletter = new SalesFormLetter_Invoice(false);
Id = "100000002";
Select InvJTbl Where InvJTbl.SalesId == Id;
List.ins(InvJTbl);
report = new ReportRun(new Args(ReportStr(SalesInvoice)));
report.args().caller(null);
report.args().object(List);
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().fileName("C:\\Temp\\Test.pdf");
report.run();
}
Justin Biggs
2009-12-22 21:24:06 UTC
Permalink
You shouldn't need to change anything in the fetch() method in this case.
All you need to do is pass your printJobSettings into the SalesFormLetter
class and pass that class as the caller (instead you're setting the caller to
null). The salesFormLetterReport.loadPrintSettings(...) call will unpack the
printer settings in the salesFormLetter class passed as the caller.
--
Best Regards,
Justin
Post by AgNi00
Thanks for helping me out here. It was correct that my code was overwritten
in the fetchmethod. I moved my printersettings to fetch and now it works just
fine.
Post by Klaas Deforche
Hi there,
http://www.axaptapedia.com/Printer_Settings_and_Run_From_Code
Remember to pack/unpack the printersettings at the end.
I would advise trying it with a simple report first (like cust), because the
reason it doesn't work is probably because you printersettings are
overwritten in the report itself.
salesFormLetterReport.loadPrintSettings(...).
Here, your settings are overwritten with setup (I don't know where this is
set up...).
Hope this helps,
Best regards,
Klaas.
----------------
http://www.artofcreation.be
Post by AgNi00
I want my invoice created to file an not printed to screen.
Is there anything else that I have to do with the printjobsettings to get it
to work? Tried this job where I set the filename, format and printmedium but
it still just prints to screen.
static void job(Args _args)
{
CustInvoiceJour InvJTbl;
SalesId Id;
ReportRun report;
RecordSortedList List = new RecordSortedList(62);
SalesFormLetter_Invoice SalesFormLetter;
;
salesformletter = new SalesFormLetter_Invoice(false);
Id = "100000002";
Select InvJTbl Where InvJTbl.SalesId == Id;
List.ins(InvJTbl);
report = new ReportRun(new Args(ReportStr(SalesInvoice)));
report.args().caller(null);
report.args().object(List);
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().fileName("C:\\Temp\\Test.pdf");
report.run();
}
Axel Kühn
2009-12-03 19:23:01 UTC
Permalink
Hi,
please take a look at an article i wrote about how to post and print
salesorders with x++.
In the article you can find an example on how you can print a confirmation
to pdf.

http://translate.google.com/translate?client=tmpg&hl=de&u=http%3A%2F%2Fblog.ak-home.net%2FPermaLink%2Cguid%2C5cb22557-acb4-41ec-9546-c65d681e3a3d.aspx&langpair=de|en

Hope this hepls you.
--
Sincerely yours
Axel Kühn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by AgNi00
I want my invoice created to file an not printed to screen.
Is there anything else that I have to do with the printjobsettings to get it
to work? Tried this job where I set the filename, format and printmedium but
it still just prints to screen.
static void job(Args _args)
{
CustInvoiceJour InvJTbl;
SalesId Id;
ReportRun report;
RecordSortedList List = new RecordSortedList(62);
SalesFormLetter_Invoice SalesFormLetter;
;
salesformletter = new SalesFormLetter_Invoice(false);
Id = "100000002";
Select InvJTbl Where InvJTbl.SalesId == Id;
List.ins(InvJTbl);
report = new ReportRun(new Args(ReportStr(SalesInvoice)));
report.args().caller(null);
report.args().object(List);
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().fileName("C:\\Temp\\Test.pdf");
report.run();
}
Eduardo Arias
2011-03-28 19:12:00 UTC
Permalink
Check this post - This is the basis to save a report as PDF

http://axwonders.blogspot.com/2011/02/save-microsoft-dynamics-ax-2009-report.html

This post will give you more specifics about how to create an email class and other things related to saving and sending a report in PDF through Outlook

http://axwonders.blogspot.com/2011/02/save-microsoft-dynamics-ax-2009-report_23.html
Post by AgNi00
I want my invoice created to file an not printed to screen.
Is there anything else that I have to do with the printjobsettings to get it
to work? Tried this job where I set the filename, format and printmedium but
it still just prints to screen.
static void job(Args _args)
{
CustInvoiceJour InvJTbl;
SalesId Id;
ReportRun report;
RecordSortedList List = new RecordSortedList(62);
SalesFormLetter_Invoice SalesFormLetter;
;
salesformletter = new SalesFormLetter_Invoice(false);
Id = "100000002";
Select InvJTbl Where InvJTbl.SalesId == Id;
List.ins(InvJTbl);
report = new ReportRun(new Args(ReportStr(SalesInvoice)));
report.args().caller(null);
report.args().object(List);
report.printJobSettings().setTarget(PrintMedium::File);
report.printJobSettings().format(PrintFormat::PDF);
report.printJobSettings().fileName("C:\\Temp\\Test.pdf");
report.run();
}
Post by Klaas Deforche
Hi there,
http://www.axaptapedia.com/Printer_Settings_and_Run_From_Code
Remember to pack/unpack the printersettings at the end.
I would advise trying it with a simple report first (like cust), because the
reason it does not work is probably because you printersettings are
overwritten in the report itself.
salesFormLetterReport.loadPrintSettings(...).
Here, your settings are overwritten with setup (I do not know where this is
set up...).
Hope this helps,
Best regards,
Klaas.
----------------
http://www.artofcreation.be
Post by Axel Kühn
Hi,
please take a look at an article i wrote about how to post and print
salesorders with x++.
In the article you can find an example on how you can print a confirmation
to pdf.
http://translate.google.com/translate?client=tmpg&hl=de&u=http%3A%2F%2Fblog.ak-home.net%2FPermaLink%2Cguid%2C5cb22557-acb4-41ec-9546-c65d681e3a3d.aspx&langpair=de|en
Hope this hepls you.
--
Sincerely yours
Axel K??hn (visit my Dynamics AX blog at: http://blog.ak-home.net)
Post by AgNi00
Thanks for helping me out here. It was correct that my code was overwritten
in the fetchmethod. I moved my printersettings to fetch and now it works just
fine.
You should not need to change anything in the fetch() method in this case.
All you need to do is pass your printJobSettings into the SalesFormLetter
class and pass that class as the caller (instead you are setting the caller to
null). The salesFormLetterReport.loadPrintSettings(...) call will unpack the
printer settings in the salesFormLetter class passed as the caller.
--
Best Regards,
Justin
Loading...