SAP Knowledge Base Article - Public

1331213 - The paper orientation in the custom paper size is ignored when printing to printer from a Crystal Reports 2008 for VS .NET Application

Symptom

  • The report designed in custom paper size (Width 8 inch x Height 4 inch) cannot be printed as original paper orientation
  • Paper orientation setting is ignored
  • The report is cut off by 4 inch

Reproducing the Issue

  1. Open Printers and Faxes from Windows Operating System (OS).
  2. Click File > Server Properties.
  3. Click Forms tab.
  4. Check Create a new form.
  5. Type Form name. (i.e. 8x4) 
  6. Select "English" as Units in the Form Description.
  7. Type 8 inch as Width of Paper size.
  8. Type 4 inch as Height of Paper size.
  9. Click Save Form.
  10. Click Close.
  11. Launch Crystal Reports 2008.
  12. Click File > New > Blank Report.
  13. Click Cancel in the Database Expert window.
  14. Click File > Page Setup.
  15. Select a specific Printer (i.e. Microsoft XPS Document writer) which is able to print the custom paper size.
  16. Check Dissociate Formatting Page Size and Priter Paper Size.
  17. Select customer paper size (i.e. 8x4) you create.
  18. Select "Portrait" in the Orientation.
  19. Click OK.
  20. Design the report.
  21. Click File > Save As.
  22. Type File name and click Save.
  23. Print the report from .NET application.
  • Crystal Reports 2008 SP1 Fix Pack 1.2 or later
  • Visual Studio 2005
  • Visual Studio 2008

Here is the sample VB code to print out.

Dim myReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument

myReport.Load("C:\custompapersize8x4.rpt")

Dim myPrintOptions As PrintOptions = myReport.PrintOptions

myPrintOptions.PrinterName = "Microsoft XPS Document Writer"

myPrintOptions.PaperOrientation = PaperOrientation.Portrait

' 119 is the value of custom paper size (8x4 inch) in the local Windows OS.

myPrintOptions.PaperSize = CType(119, PaperSize)

myReport.PrintOptions.DissociatePageSizeAndPrinterPaperSize = True

myReport.PrintToPrinter(1, False, 1, 1)

Resolution

To print the report in proper paper orientation, use the following steps and VB.NET code. 

  1. Create a new custom paper size (Width: 4 inch x Height: 8 inch).
  2. Set the value of custom paper size (Width: 4 inch x Height: 8 inch).

Dim myReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument

myReport.Load("C:\custompapersize8x4.rpt")

Dim myPrintOptions As PrintOptions = myReport.PrintOptions


myPrintOptions.PrinterName = "<PRINTER NAME>"

myPrintOptions.PaperOrientation = PaperOrientation.Portrait

' 120 is the value of custom paper size (4x8 inch) in the local Windows OS.

myPrintOptions.PaperSize = CType(120, PaperSize)

myReport.PrintOptions.DissociatePageSizeAndPrinterPaperSize = True

myReport.PrintToPrinter(1, False, 1, 1)

Keywords

user defined paper size, devcap.exe, Microsoft XPS Document Writer, VS2005, VS2008, CR2008 , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

Crystal Reports 2008 V1