cancel
Showing results for 
Search instead for 
Did you mean: 

Can't set custom papersize

Former Member
0 Kudos

We got a lable printer (Sato CL608e) that only accepts 4x6 paper sizes. My default printer is set to this on my development computer. I have a VS 2008 ASP.NET app that opens a Crystal Report (CR 10.5) set up to use this printer. The report looks fine in the DotNet designer, but when the report is run through IIS, it shows up with an 8x11 page size. But, the content is only 4x6.

The client (and my development) machine that opens this report through IIS has this same printer set up as their default. I've tried everything I can think of without success. I've tried setting the printer name through code to this printer and setting the papersize. However, the PaperSize enum doesn't have 4x6.

Here's some sample code that I'd used. Is this a bug with CR 10.5? Is there a HotFix? Any help is much appreciated.

ReportDocument rptDoc = MyReport;

rptDoc.PrintOptions.PrinterName = "SATO CL608e";

System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();

doc.PrinterSettings.PrinterName = "SATO CL608e";

for (int i = 0; i < doc.PrinterSettings.PaperSizes.Count; i++)

{

int rawKind = 0;

if (doc.PrinterSettings.PaperSizes<i>.PaperName == "EDI Pallet Label")

{

rawKind = (int)doc.PrinterSettings.PaperSizes<i>.Kind;

rptDoc.PrintOptions.PaperSize = (PaperSize)rawKind; // unfortunately, this always sets it to the default papersize

break;

}

}

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Nick,

The problem is not with your code but with IIS. It can't find or does not have access to the printer so it defaults to 8 1/2 by 11.

Search Microsfts site MSDN on how to give IIS access to your installed printers. Then your app should work as expected.

Thank you

Don

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks for the Reply Don,

What you're saying seems to make sense and I found the two MSDN articles that talk about this:

http://msdn.microsoft.com/en-us/library/aa290045(VS.71).aspx

http://support.microsoft.com/kb/184291

However, I'm still getting the same behavior even after following these two articles. The problem I can see is that the Crystal Report PaperSize enum doesn't list the custom paper size for that printer. So, I don't think the lines:

rawKind = (int)doc.PrinterSettings.PaperSizes<i>.Kind;

rptDoc.PrintOptions.PaperSize = (PaperSize)rawKind;

in my code will ever work. Even if the system does detect the printer on the server, I can't assign the correct papersize to the Crystal Report's document PaperSize.

Nick

0 Kudos

Hi Nick,

Open one of your reports and then File, Page Setup and check on the option to Dissociate Paper.... and save it. Test again. If that works the API to do so in code is below...

Try this API:

public virtual bool DissociatePageSizeAndPrinterPaperSize { set; get; }

Member of CrystalDecisions.CrystalReports.Engine.PrintOptions

Summary:

Gets or sets a value that indicates whether the report page size is dissociated from printer paper sizes. Set to true if using custom page sizes for web-based pagination.

Or if use RAS then one of these:

bool DissociatePageSizeAndPrinterPaperSize { set; get; }

Member of CrystalDecisions.ReportAppServer.ReportDefModel.ISCRPrintOptions

public virtual bool DissociatePageSizeAndPrinterPaperSize { set; get; }

Member of CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptionsClass

Thanks again

Don

0 Kudos

Hi Nick,

I have this code, it uses the Windows Common Printer dialog options to get the printer info but ti populates the drop down boxes to fill in the various option:


		private void btnSetPrinter_Click(object sender, System.EventArgs e)
		{
			System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();
            CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptionsClass();

            CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions MYPRTOpts = new PrintOptionsClass();
			if (rdoCurrent.Checked) 
			{
				pDoc.PrinterSettings.PrinterName = cboCurrentPrinters.Text;

                MYPRTOpts.PrinterName = cboCurrentPrinters.Text;
                MYPRTOpts.PaperSize = (CrPaperSizeEnum)
					pDoc.PrinterSettings.PaperSizes[cboCurrentPaperSizes.SelectedIndex].Kind;
                MYPRTOpts.PaperSource = (CrPaperSourceEnum)
					pDoc.PrinterSettings.PaperSources[cboCurrentPaperTrays.SelectedIndex].Kind; 
				// added the below line to verify the changes work.
                MYPRTOpts.PaperOrientation = CrPaperOrientationEnum.crPaperOrientationLandscape;
			}
			else 
			{
				pDoc.PrinterSettings.PrinterName = cboDefaultPrinters.Text;

                MYPRTOpts.PrinterName = cboDefaultPrinters.Text;
                MYPRTOpts.PaperSize = (CrPaperSizeEnum)
					pDoc.PrinterSettings.PaperSizes[cboDefaultPaperSizes.SelectedIndex].Kind;
                MYPRTOpts.PaperSource = (CrPaperSourceEnum)
					pDoc.PrinterSettings.PaperSources[cboDefaultPaperTrays.SelectedIndex].Kind; 
			}
            rptClientDoc.PrintOutputController.ModifyPrintOptions(MYPRTOpts);
			MessageBox.Show("Printer set.", "RAS", MessageBoxButtons.OK,MessageBoxIcon.Information ); 

			rptClientDoc.PrintOutputController.PrintReport(rasPROpts);
			MessageBox.Show("Printing report.", "RAS", MessageBoxButtons.OK,MessageBoxIcon.Information ); 

		}

You should be able to get the enum values if you select the custom paper size option in the UI.

Thanks

Don

Edited by: Don Williams on Feb 27, 2010 7:42 PM

Former Member
0 Kudos

I don't have the Dissociate Paper option. I'm using Crystal Reports Basic for Visual Studio 2008 on IE 8. The Page Setup menu option is greyed out under the File menu when I open the report.

Also, DissociatePageSizeAndPrinterPaperSize is not available to me under CrystalDecisions.CrystalReports.Engine.PrintOptions and I don't have ReportDefModel under CrystalDecisions.ReportAppServer. Plus I don't have Controllers under CrystalDecisions.ReportAppServer.

Are we looking at different versions of Crystal Reports? Is there an update that I'm missing?

Thanks.

Nick

0 Kudos

Hi Nick,

Sorry my mistake. That option is in Crystal Reports 2008 and not the 10.5 included with .NET.

If the File menu option for page set up is grayed out then you can't change the paper size... Seems to be a limit in the .NET IDE report designer.

Try setting your default printer paper size to what the report needs and see if that works for you. Other than that you may need to upgrade to a full version of CR.

Thank you

Don

Former Member
0 Kudos

Thanks, I thought that might be the case. Setting to the default printer didn't work.

If we upgrade to Crystal Reports 2008, does it still integrate into the Dot Net IDE and work with IIS? We need to run this on an Intranet on a Windows 2008 server. Is this the version we should be getting:

http://store.businessobjects.com/store/bobjamer/DisplayProductDetailsPage/Locale.en_US/Currency.USD/...

Thanks for all your help.

Nick

Former Member
0 Kudos

Strangely, Crystal Reports 9.5 that comes with VS 2003 works when selecting the default printer, but CR 10.5 doesn't! However, I can't seem to get CR 9.5 (or CR 11.5) to work with IIS 7 on Windows 2008 server. I could only get CR 10.5 to work with IIS 7.

Do you know why that's the case (or is that the case)? That's why I'm a bit worry that if I do upgrade to CR 2008, it might not work with IIS 7 on Windows Server 2008 either.

Thanks.

Nick

Former Member
0 Kudos

Upgrading to Crystal Reports 2008 does work. I guess SAP must have introduced this bug (or removed this "feature") in the Crystal Reports that comes with VS 2008 so that they can get users to upgrade. Shame on you SAP!

Edited by: NickTu on Mar 9, 2010 2:31 PM

0 Kudos

Hi Nicktu,

There is no "bug" and if you check the platforms PDF files for what is supported you will see that as of CR 2008 SP 2 we now support Windows 7, Vista and Windows 2008. Also true for the version of IIS we support.

We also use Microsoft's Framework to print reports, if they make changes to the printer routines we follow with either updates in the form of a patch or if the change is too big it requires the latest version. CR 9 used our own print methods, CR 10.2 and 10.5 uses the Windows Framework print methods, CR 2008 is back to using own own print methods so the user has better control over printing.

Thank you

Don