Yes you can do this. Running the report is fairly straightforward by calling RunDirect method on ARInvoiceSvc. The tricky thing is locating the rendered report and then decoding the file. I wrote a BAQ to get the report (looking for unique values from TaskNote and TaskDescription but you may want something more robust).
BAQ Retrieval Example:
select top (1)
[SysTask].[SysTaskNum] as [SysTask_SysTaskNum],
[SysRptLst].[RptData] as [SysRptLst_RptData]
from Ice.SysTask as SysTask
inner join Ice.SysRptLst as SysRptLst on
SysTask.Company = SysRptLst.Company
and SysTask.SysTaskNum = SysRptLst.SysTaskNum
where (SysTask.Company = @CurrentCompany and SysTask.TaskDescription = @inTaskDesc and SysTask.TaskNote = @inTaskNote)
order by SysTask.SysTaskNum Desc
PDF Retrieval Example:
var myinvfname = string.Format("ARInvForm_{0}.pdf", InvoiceNumber);
byte[] dataBytes = System.Convert.FromBase64String(myobj.SysRptLst_RptData);
result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(dataBytes);
result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("inline");
result.Content.Headers.ContentDisposition.FileName = myinvfname;
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return result;