How do I attach a .pdf to a report (at the end)? I already looked at Report Footer but there is no place to attach a file (only images).
Thanks in advance.
Good morning,
I know this is an old thread but figured I would ask to see if anyone has been able to leverage any advancements in the MT Cloud to attach a .pdf to a report? We have taken similar approaches to what has been described but was interested to see if there are any new approaches to this common issue.
Thanks
Jeff
I'm also trying to find ways to attach our TC's and sharing our approach. since our TC is a whole page with two columns with underlines and bolds that change every few months, reportviewer is not a good option for us. also the user prefers to have it on a single PDF's instead of two PDF's (Merge the Report output With Another PDF saved in Object Document)
Right now I'm still in progress to make it work in the cloud.
i've already tested this on prem.. if youre on prem you can use the pdfsharp-gdi.dll in csi directory to merge TWO PDF's
On Prem Steps in custom assembly called by taskpostperform
1) Grab the binary TC's pdf in Object Documents
2) Grab the binary in output folders use the code below to merge (convert it to Custom Assembly Code)
3) Overwrite the output files with the merged pdf's binary.
byte[] TCbyteArr = DocResponse.Items[0].PropertyValues[0].GetValue<Byte[]>(); byte[] PDFbyteArr = DocResponse.Items[0].PropertyValues[1].GetValue<Byte[]>();
PdfSharp.Pdf.PdfDocument pdfDocument; using (MemoryStream TCStream = new MemoryStream(TCbyteArr)) { var TCMem = PdfSharp.Pdf.IO.PdfReader.Open(TCStream, PdfSharp.Pdf.IO.PdfDocumentOpenMode.Import); using (MemoryStream PDFStream = new MemoryStream(PDFbyteArr)) { var PDFMem = PdfSharp.Pdf.IO.PdfReader.Open(PDFStream);
foreach (PdfSharp.Pdf.PdfPage PDFPage in TCMem.Pages) { PDFMem.AddPage(PDFPage); } pdfDocument = PDFMem; } }
MemoryStream MemStream = new MemoryStream(); pdfDocument.Save(MemStream, true);
byte[] PDFWithTC = MemStream.ToArray();
4) Overwrite or save it as new file to customize the pdf name and send via email using FileServerExtension
fileServer.EmailFilesFromFileServerAsAttachment(ref errMsg, fileServerName, logicalFolderName, "reports", OuputPath,"test@test.com "Email Subject", "Email Message", "", "", "", OuputPath, 0, 0);
Note: If autoview is enabled, sometimes the PDF opened contains the TC sometimes it doesnt (pdf is not over written yet). I always open it via report output files or via File Explorer.
In CLOUD custom assembly called by taskpostperform (this is still in POC)
Note: Since third party dll's dont work in cloud because of partial trust we can only do the merge on prem.
1) grab and save the TC's in Object Document and save it to table
2) Grab the output file in File Server Logical Folder for output files (we cant read the output directly in cloud). You need to grant permission to file server logical folder to read - you can test it via file maintenance form
FileServerExtension fileServer = new FileServerExtension(); SuccessfulRead = fileServer.GetFileContent(folderTemplate + "\" + PDFFileName, fileServerName, logicalFolderName, ref ReportOutputByte, ref ParsedFileSpec, ref errMsg);
3) Create an exe on prem to poll and to pull the bytes for TC and Output File (Load Collection API). Merge them on prem using the gdi and update the PDF with TC bytes back to cloud (Update Collection API).
4) after we have the PDF with TC bytes in cloud, Overwrite or save as new PDF the one saved in File Server Logical Folder
FileServerExtension fileServer = new FileServerExtension(); SuccessfulRead = fileServer.SaveFileContent(ref errMsg,ref saved, TCbyteArr, folderTemplate + "\" + OuputPath, fileServerName, logicalFolderName, 1, "");
5) you can then send this new pdf thru email using the "FileServerExtension".
fileServer.EmailFilesFromFileServerAsAttachment(ref errMsg, fileServerName, logicalFolderName, "reports", OuputPath, "test@test.com "Email Subject", "Email Message", "", "", "", OuputPath, 0, 0);
thanks for sharing, have you got any luck in the Cloud?