a month ago
Hi
i am developing a software in c# for a Pathology, there are nearly 20 different types of test available, i have made table for each test and accordingly made separate report in crystal report for every test, so there are 20 reports. Out of which some are single line test, some are 2,3 or 8 to 10 lines of test values. Lets suppose we number it from A,B,C and so on for 20 test. Suppose a patient comes in and select 3 test to do , suppose A, D, F. Out of which A is single line( for ex just Post meal or fasting sugar test ), D is 3 line test and F is 8 line test.
After getting test values operator enters the values for three test, now if i wish to print those test then the for single line Test report it will be print a single line so whole page is wasted, same is case with other two. Is it possible in crystal report that to print the A and D test on one page and F on 2nd page to save one page.
Suppose another patient select test E, J, N, which are all 2 line then they should get printed on single page , or another patient select different report and those are big then it should get printed on different page. Thus this activity is totally run time to merge different types of reports depending on types of report. I save test values in their respective table and there is one table which contains the Patient Name, OPDTestID , and all the test which the patient will be doing. How i can perform this, does crystal report have any thing similar kind of thing like Mail Merge of word, can i do this thing in crystal report. Or kindly suggest any other solution. At the moment i have given them option of printing every test report separately, but single line report waste their page. so kindly suggest me some option.
Thanks in advance.
Request clarification before answering.
Difficult to provide a good response without a clear sense of the data model.
If a single table you can simply get the data as multiple records. Otherwise, here are a few options:
Use a view/stored procedure/command to UNION the results into a single record set.
Use Subreports, suppressing blank ones.
Use multiple detail sections (Detail a, Detail b, ...) and sql expressions, with conditional suppress expressions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi As i mention i will explain the details about the code which i am using. Here i am with the solution.
I am using ITextSharp library for merging the PDF. I found this library , and its Open source and specially designed for .net.
Suppose i have three report to be merged (.rpt) then , what i do is i export them instead of showing up in report viewer to PDF, so i get three PDF and using the above library i merge them to a single pdf and later i can open and print them as single report. But there is twist, the thing is when i merge the PDF all the reports come one separate pages. What i wanted is suppose two reports are very small then they should be merged on one page and the big one should be on 2nd page.
I am giving below the code for merging and exporting the .rpt to PDF without showing up on screen.
Below code is for exporting to PDF
------------------------------------------------------------------------------------------------------------------------------------------
ReportDocument cryRpt = new ReportDocument();
string selectionFormula = "{pathologyreports1.reportNo}='" + clsConnect.newInvoiceNo + " '";
cryRpt.Load(@"D:\repoCPKMPReport.rpt");
cryRpt.RecordSelectionFormula = selectionFormula;
cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"D:\CPKMB.pdf");
MessageBox.Show("Exported Successful");
--------------------------------------------------------------------------
So if i have three report then all reports will be exported to their respective PDF. After this i used iTextSharp library to combing the above three PDF as below
------------------------------------------------------------------
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
string[] lstFiles=new string[3];
lstFiles[0]=@"D:\CPKMB.pdf";
lstFiles[1]=@"D:\ASD22.pdf";
lstFiles[2]=@"D:\ASD23.pdf";
PdfReader reader = null;
Document sourceDocument = null;
PdfCopy pdfCopyProvider = null;
PdfImportedPage importedPage;
string outputPdfPath=@"D:/new.pdf";
sourceDocument = new Document();
pdfCopyProvider = new PdfCopy(sourceDocument, new System.IO.FileStream(outputPdfPath, System.IO.FileMode.Create));
//Open the output file
sourceDocument.Open();
try
{
//Loop through the files list
for (int f = 0; f < lstFiles.Length; f++)
{
int pages =get_pageCcount(lstFiles[f]);
reader = new PdfReader(lstFiles[f]);
//Add pages of current file
for (int i = 1; i <= pages; i++)
{
importedPage = pdfCopyProvider.GetImportedPage(reader, i);
pdfCopyProvider.AddPage(importedPage);
}
reader.Close();
}
//At the end save the output file
sourceDocument.Close();
}
catch (Exception ex)
{
throw ex;
}
}
private int get_pageCcount(string file)
{
using (StreamReader sr = new StreamReader(File.OpenRead(file)))
{
Regex regex = new Regex(@"/Type\s/Page[^s]");
MatchCollection matches = regex.Matches(sr.ReadToEnd());
return matches.Count;
//
}
----------------------------------------------------------------
This is the code i am using to merge , but the data is getting merged on separate pages.
Now my issue is how to make them on same pages if they are very short report.
Can you provide me the solution if you know this library and how i can merge them on one page.
Thanks in advance.
User | Count |
---|---|
76 | |
30 | |
10 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.