Is it possible to insert a pdf into telerik reporting ? I have a set of reports generated using telerik reporting in pdf format and i want to append another generated pdf. Do you have this feature ?
thanks
13 Answers, 1 is accepted
Tomas
The feature is not supported in Telerik Reporting as the main goal is data presentation which includes exporting it to various formats. Merging already created PDF files or byte streams can be performed with another software (you can check the forum for other members post about their choice). If you need to unite several reports on export, we can suggest you to use the ReportBook document where you can add different report definitions and export them at once in a single PDF document without additional file merges.
Let us know if you have nay further questions.
Greetings,
Stef
the Telerik team
See what's new in Telerik Reporting Q1 2013. Register for the March 4 webinar to witness the impressive new visualizations in Telerik Reporting. Just for fun, 10 webinar attendees will be randomly selected to win a Telerik T-shirt and a $50 Gift Certificate to ThinkGeek. Register now! Seats are limited!
Hey guys
I know I'm late to the party, but has there been any update on this? While I did read the reply from Stef, I think this would be an awesome feature to have, and would address a large short-fall that I've found in T-Reporting...
I basically need an advanced HTML control to render inside a report. Since T-Reporting couldn't do this (table layouts, etc.), I have created my own PDF using the Rad Editor export to PDF. I now need to imbed it into my report...
any ideas?
Merging already existing files in a report or rendering of HTML documents is not supported. The workarounds I can suggest you are:
- Export the HTML as an Image and use a PictureBox item in the report. Please consider the example here.
- Export reports programmatically and merge documents via Telerik Document Processing Libraries.
- Use Telerik UI for AJAX or Telerik Kendo UI to export HTML in image, PDF formats - ClientExportManager.
Regards,
Stef
Telerik by Progress
I vote for this feature :-P
there are some business scenario, which we have to generate report and attach some pdf scan data. f.i. #)expenses report with invoice
#)import summary with customs-document
;-)
Thank you for this feedback.
Please check Telerik Document Processing Libraries which allow you to import, merge and export PDF files.
Regards,
Stef
Telerik by Progress
Hi Telerik
Like Jaw I now have to print an expenses report with attached pdf invoices.
In my code I´m working with reportbooks. I use them to render them as pdf, to show them in the ReportViewer or to send them directly to the printer. In my architecture it is not really meaningful to merge invoice pdfs after an pdf of the report is created...
I really want the possibility to add some pdf files to the report book. Or at least the possibility to include them in a report just like I can add a picture with a PictureBox.
What solutions do you have for me?
Regards,
Michael
Inserting a PDF document into a report is still not supported and it is not in our short-term plans to add this feature. To insert a PDF it would be necessary to use third party libraries for merging documents or merge the files programmatically. You can check Stef's post for more suggestions.
Regards,
Katia
Progress Telerik
For those looking for a possible solution, here is a code snippet using open source PDFSharp with Telerik Reporting. (You can also get the source code for free) In this code, I am loading a PDF from a file, creating my own Telerik report and attaching it by pages to that document, and then adding a footer document from a file. ReportProcessor & RenderingResult are Telerik classes, and PdfDocument and PdfReader are PDFSharp classes:
protected void ExportToPDF(InstanceReportSource reportSource)
{
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, null);
long classID = Int64.Parse(Request["cl"]);
PdfDocument reportHeader = (classID > 1) ?
PdfReader.Open(Server.MapPath("~\\Reports\\ClassHeader.pdf"), PdfDocumentOpenMode.Import) :
PdfReader.Open(Server.MapPath("~\\Reports\\UnclassHeader.pdf"), PdfDocumentOpenMode.Import);
PdfDocument reportMain = PdfReader.Open(new MemoryStream(result.DocumentBytes), PdfDocumentOpenMode.Import);
PdfDocument reportFooter = (classID > 1) ?
PdfReader.Open(Server.MapPath("~\\Reports\\ClassFooter.pdf"), PdfDocumentOpenMode.Import) :
PdfReader.Open(Server.MapPath("~\\Reports\\UnclassFooter.pdf"), PdfDocumentOpenMode.Import);
// Originally tried creating a new PdfDocument and combining all three PDFs,
// but I could not figure out how to transfer fields from the header page to the combined document.
// To solve this, I attached the main and footer PDF to the first page.
// If the footer also has fillable fields, this will be a problem.
foreach (PdfPage p in reportMain.Pages)
{
reportHeader.AddPage(p);
}
foreach (PdfPage p in reportFooter.Pages)
{
reportHeader.AddPage(p);
}
Response.Clear();
Response.ContentType = result.MimeType;
using (var ms = new MemoryStream())
{
reportHeader.Save(ms, false);
ms.WriteTo(Response.OutputStream);
}
Response.End();
}
Since it has been 3 years since the last reply, I wanted to check if this functionality is now supported or not yet!
As others have stated, this is a very useful functionality.
You can do it in code. My snippet above works; however, I have since changed the code so that it's all done through the Telerik libraries and have removed the PDFSharp library from my project. (I think Telerik may share some internals with it as many properties are similarly named.) The problem I had with the above code was that it was not keeping the fillable fields, but I have since solved that problem. My updated code is below. It inserts a PDF document before my generated documents and adds a footer PDF to the end. You can strip out the digital signature call.
protected void ExportToPDF(InstanceReportSource reportSource, params string[] signatures)
{
ReportProcessor reportProcessor = new ReportProcessor();
RenderingResult result = reportProcessor.RenderReport("PDF", reportSource, null);
RadFixedDocument docHeader = new RadFixedDocument();
RadFixedDocument docFooter = new RadFixedDocument();
RadFixedDocument document = new RadFixedDocument();
PdfFormatProvider provider = new PdfFormatProvider();
// Choose approprate selected cover sheets
long classID = Int64.Parse(Request["cl"]);
string headerPath = (classID > 1) ? Server.MapPath("~\\Reports\\ClassHeader.pdf") : Server.MapPath("~\\Reports\\UnclassHeader.pdf");
string footerPath = (classID > 1) ? Server.MapPath("~\\Reports\\ClassFooter.pdf") : Server.MapPath("~\\Reports\\UnclassFooter.pdf");
// Header page to insert
using (var fs = new FileStream(headerPath, FileMode.Open, FileAccess.Read))
{
docHeader = provider.Import(fs);
}
// Main generated document
using (var ms = new MemoryStream(result.DocumentBytes))
{
document = provider.Import(ms);
foreach (string sig in signatures)
{
AddDigitalSignature(document, sig);
}
}
// Footer page to insert
using (var fs = new FileStream(footerPath, FileMode.Open, FileAccess.Read))
{
docFooter = provider.Import(fs);
}
// Entry fields on a form are stored at a document level
// and must be added to the main document in addition to the page to be retained
FormFieldCollection headerFields = docHeader.AcroForm.FormFields;
while (docHeader.Pages.Count > 0)
{
RadFixedPage headerPage = docHeader.Pages[0];
docHeader.Pages.Remove(headerPage);
document.Pages.Insert(0, headerPage);
}
foreach (FormField field in headerFields)
{
document.AcroForm.FormFields.Add(field);
}
// This might allow the fields on the last page to be retained as well
// Currently the customer hasn't noticed or needed them.
FormFieldCollection footerFields = docFooter.AcroForm.FormFields;
while (docFooter.Pages.Count > 0)
{
RadFixedPage footerPage = docFooter.Pages[0];
docFooter.Pages.Remove(footerPage);
document.Pages.Add(footerPage);
}
foreach (FormField field in footerFields)
{
document.AcroForm.FormFields.Add(field);
}
Response.Clear();
Response.ContentType = result.MimeType;
using (var ms = new MemoryStream(provider.Export(document)))
{
ms.WriteTo(Response.OutputStream);
}
Response.End();
}