Shaiwal Tripathi

Shaiwal Tripathi

  • NA
  • 129
  • 5.7k

Cannot print the custom paper size in crystal report c#

May 5 2020 3:56 AM
I am trying to print custom paper size (8.5in Wt. x 5.5in Ht.)
 
My Printer does not allow to create custom paper size when Width greater than Height. So I decided to do it dynamically through c#. Here are the steps I have done.
 
Step1:- Created a custom paper size from Print Server Properties under Devices And Printers and named it JVD
 
Step2:- My C# Code
  1. using (DataSet Ds = GetPrintDetails(Dt, Con))  
  2. {  
  3. HospDataSet.Tables["ME_ProductSale"].Merge(Ds.Tables[0]);  
  4. HospDataSet.Tables["ME_ProductSale_Detail"].Merge(Ds.Tables[1]);  
  5. HospDataSet.Tables["ME_Identity"].Merge(Ds.Tables[2]);  
  6. ReportPath = Environment.CurrentDirectory + "\\Reports_ME\\rptProductSale.rpt";  
  7. rptDoc.Load(ReportPath);  
  8. rptDoc.SetDataSource(HospDataSet);  
  9. PrintDocument PD = new PrintDocument();  
  10. for (int i = 0; i <= PD.PrinterSettings.PaperSizes.Count - 1; i++)  
  11. {  
  12. if (PD.PrinterSettings.PaperSizes[i].PaperName == "JVD")  
  13. {  
  14. rptDoc.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)PD.PrinterSettings.PaperSizes[i].RawKind;  
  15. break;  
  16. }  
  17. }  
  18. rpvHospitalReportViewer.ReportSource = rptDoc;  
  19. rpvHospitalReportViewer.Refresh();  
  20. }  
But still not able to print custom paper size. What I am doing wrong?
Any help will be appreciable.

Answers (1)