I would like to know if you can have different footer sizes for a report.
What I want to achieve is the following:
I've tried using subreports but sadly the header & footer of the subreport doesn't show and I found out that it is the design limitation in RDLC.
How can I achieve this? TIA.
I was unable to find a solution to this problem using RDLC. It is stated in the documentation for this technology that the space used for both header and footer will be reserved for all pages even if you are hiding the header/footer for the particular page and that subreports will only use the main report's header and footer. I also read articles stating that RDLC has less control over the design compared to Crystal Reports which based on my experience is true.
With this, I resorted to my last option which was to build 2 separate PDF files and merged them using iTextSharp. Good thing that iTextSharp has a function to get the pdf's page count.
PdfReader pdfReader = new PdfReader(renderedBytes);
// renderedBytes is the byte array generated by localReport.Render
pageCount = pdfReader.NumberOfPages;
Here's a portion of my code:
int subreportPageCount = 0;
double gpa = 0;
byte[] subreportBytes = GenerateTranscriptOfRecordsSubreportPDF(unitOfWork, student, torType, out subreportPageCount, out gpa);
byte[] mainBytes = GenerateTranscriptOfRecordsMainPDF(unitOfWork, student, torType, torPurpose, subreportBytes, subreportPageCount, gpa);
byte[] renderedBytes = MergePDF(new List<byte[]>() { mainBytes, subreportBytes });
string reportFormat = Constant.REPORT_FORMAT_PDF;
string fileExtension = GetReportFileExtension(reportFormat);
string fileName = Constant.REPORT_TOR_FILENAME;
string fileNameWithExtension = string.Format("{0}{1}", fileName, fileExtension);
string mimeType = "application/pdf";
string fileNameExtension = "pdf";
string fileInfoName = string.Format("{0}.{1}", fileName, fileNameExtension);
ReportFile reportFile = new ReportFile();
reportFile.Content = renderedBytes;
reportFile.FileName = fileInfoName;
reportFile.MimeType = mimeType;
Session[Constant.SESSION_REPORT_FILE] = reportFile;
MergePDF:
byte[] MergePDF(ICollection<byte[]> pdfs)
{
byte[] renderedBytes = null;
using (MemoryStream ms = new MemoryStream())
{
Document document = new Document();
PdfCopy pdf = new PdfCopy(document, ms);
PdfReader pdfReader = null;
try
{
document.Open();
foreach (byte[] pdfBytes in pdfs)
{
pdfReader = new PdfReader(pdfBytes);
pdf.AddDocument(pdfReader);
pdfReader.Close();
}
}
catch (Exception)
{
renderedBytes = null;
}
finally
{
if (pdfReader != null)
{
pdfReader.Close();
}
if (document != null)
{
document.Close();
}
}
renderedBytes = ms.ToArray();
return renderedBytes;
}
}
I made this my last resort because I will not be able to generate XML and DOC files for my report unless I build them up again from scratch. Luckily my requirement is to simply generate a PDF file.
Hope this help!