Conduct Exam
New member
- Joined
- Feb 29, 2024
- Messages
- 4
- Programming Experience
- Beginner
I tried this solution But it can't be set to "9x6".
9x6" I created this in the print server properties of the Printer.
But it can't be set into CrystalReportViewer>Print Report>Preferences>Advance>Paper Size I want to Set PaperSize ="9x6" the in PaperSize DropDown.
9x6" I created this in the print server properties of the Printer.
But it can't be set into CrystalReportViewer>Print Report>Preferences>Advance>Paper Size I want to Set PaperSize ="9x6" the in PaperSize DropDown.
C#:
private void LoadReport()
{
string customPaperSizeName = "9x6";
int customPaperSizeID = GetCustomPaperSizeID(customPaperSizeName);
ReportDocument report = new ReportDocument();
report.Load("WithdrawalAdvice.rpt");
report.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)customPaperSizeID;
crystalReportViewer.ReportSource = report;
}
static int GetCustomPaperSizeID(string paperSizeName)
{
PrintDocument printDoc = new PrintDocument();
// Loop through available paper sizes for the default printer
foreach (PaperSize size in printDoc.PrinterSettings.PaperSizes)
{
if (size.PaperName.Equals(paperSizeName, StringComparison.OrdinalIgnoreCase))
{
return size.RawKind; // Return the PaperSize ID (RawKind)
}
}
// Return -1 if the custom paper size is not found
return -1;
}
Last edited by a moderator: