Crystal report viewer does not observe the PaperSize and PageOrientation setting

Hi:
My application is a 3 tier application, where the WinForm client is connected to the WCF Services hosted in IIS server.
The report is generated on server side using WCF service, and export as.rpt with data, the .rpt file is then sent to the WinForm client, the Crystal Report viewer is used to load the .rpt file for preview and print.
On server side I've Microsoft XPS Document Writer installed and set as default printer. On the client side if the default printer is XPS or Nitro PDF creator, the report can be view and print correctly, report design in landscape will be able to show in the landscape in CR viewer, report design using custom paper size (e.g. Half Letter), CR viewer able to show it in Half Letter.
The problem that I'm facing is when the default printer is set to HP LaserJet P1120 or others (I've tried Epson ESC/P Standard driver), the report is always shown in the portrait, and it will not be able to show in custom paper size either. Here is my code:
     Dim settings As New System.Drawing.Printing.PrinterSettings
     Dim rep as New ReportDocument
     rep.Load(sOutputFileName)     'The report is download from server and save in sOutputFileName
     SetReportPaperSize(rep, sPaperSizeName, False, settings) ' sPaperSizeName store the name of the custom paper used in the report
     CrViewer.ReportSource = rep
   Public Shared Sub SetReportPaperSize(rep As ReportDocument, paperSizeName As String, isHardCopy As Boolean, settings As Printing.PrinterSettings)
      Dim installedPrinters As Printing.PrinterSettings.StringCollection = Printing.PrinterSettings.InstalledPrinters
      Dim printers As New List(Of String)
      Dim sPrinter As String
      If installedPrinters.Count = 0 Then
         Return
      End If
      SetPrinterDefaultPaperSize(rep.PrintOptions, paperSizeName, settings)
      With rep.PrintOptions
         .PrinterName = settings.PrinterName
         .PaperSource = PaperSource.Auto
         If paperSizeName.Trim.Length > 0 Then
            .PaperSize = DirectCast(GetPapersizeId(paperSizeName, settings, rep.PrintOptions.PaperSize), CrystalDecisions.Shared.PaperSize)
         End If
      End With
   End Sub
   Public Shared Sub SetPrinterDefaultPaperSize(printOptions As PrintOptions, paperSizeName As String, settings As Printing.PrinterSettings)
      With settings.DefaultPageSettings
         If paperSizeName.Trim.Length = 0 Then
            . PaperSize = GetPaperSize (printOptions.PaperSize, settings)
         Else
            For Each size As Printing.PaperSize In settings.PaperSizes
               If size.PaperName.EqualsTo(paperSizeName) Then
                  .PaperSize = size
                  Exit For
               End If
            Next
         End If
         .Landscape = printOptions.PaperOrientation = PaperOrientation.Landscape
         .Margins.Top = printOptions.PageMargins.topMargin
         .Margins.Left = printOptions.PageMargins.leftMargin
         .Margins.Bottom = printOptions.PageMargins.bottomMargin
         .Margins.Right = printOptions.PageMargins.rightMargin
      End With
   End Sub
   Public Shared Function GetPaperSize(paperSizeId As Integer, defaultPrinterSettings As Printing.PrinterSettings) As Printing.PaperSize
      Dim settings As Printing.PrinterSettings = defaultPrinterSettings
      Dim result As Printing.PaperSize
      If settings Is Nothing Then
         settings = New Printing.PrinterSettings
      End If
      ' Default paper Size defined in the printer
      result = settings.DefaultPageSettings.PaperSize
      For Each size As Printing.PaperSize In settings.PaperSizes
         If size.RawKind = paperSizeId Then
            result = size
            Exit For
         End If
      Next
      Return result
   End Function
   Public Shared Function GetPapersizeId(paperSizeName As String, defaultPrinterSettings As Printing.PrinterSettings Optional defaultpaperSizeId As CrystalDecisions.Shared.PaperSize = CrystalDecisions.Shared.PaperSize.DefaultPaperSize) As Integer
      Dim settings As Printing.PrinterSettings = defaultPrinterSettings
      Dim result As Integer = defaultpaperSizeId
      If settings Is Nothing Then
         settings = New Printing.PrinterSettings
      End If
      If Not String.IsNullOrEmpty(paperSizeName) Then
         For Each size As Printing.PaperSize In settings.PaperSizes
            ' Height and Width in Printing.PaperSize is measure in hundredths of an inch
            If size.PaperName.EqualsTo(paperSizeName) Then
               result = size.RawKind
               Exit For
            End If
         Next
      End If
      Return result
   End Function
Setting the PrintOptions.PaperSize and PageOrientation seem like no effect on the viewer. My code to load the report to CR viewer is much more complicated than the code I show above, I've a background worker thread to download the report, and when the worker thread finished download the report from the server, it will assign the report to CRViewer. Do the changes in report PrintOption before assign to CRViewe and after assigning to CRViewer make any different?
I'm using VS2010, CR XI R2 (Version 11.5.3700.0). Please Help. Thanks
Regards
JC Voon

Hi JC,
CRXI R2 is a no go with VS 2010, these two are not compatible.
With CR 11.5 use VS 2005.
Or Use VS 2010 and CR for VS 2010 (13.0)
Once you have the supported / compatible conbination of CR and VS, use the In Proc RAS .NET code from below KBA.
http://search.sap.com/notes?id=0001561333&boj=/sap/bc/bsp/spn/scn_bosap/notes.do?access=69765F6D6F64653D3939382669765F7361706E6F7465735F6E756D6265723D30303031353631333333
Also, see the KBAs returned by below search. The top right corner search box on this page is quite helpful.
http://search.sap.com/ui/scn#query=crystal%252C+paper%252C+orientation%252C+.net%252C+sdk&startindex=1&filter=scm_a_site(scm_v_Site11)&filter=scm_a_modDate(*)&timeScope=all
- Bhushan
Senior Engineer
SAP Active Global Support
Follow us on Twitter
Got Enhancement ideas? Try the SAP Idea Place
Getting started and moving ahead with Crystal Reports .NET applications.

Similar Messages

  • The "next" button of crystal report viewer does not work

    hi
    I use crystal report viewer control to show my crystal report on my aspx page.
    like:
    <CR:CrystalReportViewer id="CRViewer" runat="server" HasRefreshButton="False" PrintMode="ActiveX" DisplayGroupTree="False"
    AutoDataBind="True"
    SeparatePages="TRUE"
    Height="520px"
    Width="900px">
    </CR:CrystalReportViewer>
    however when I try to navigate to next page by click "Next" arrow button on the crystal report viewer toolbar, it only can navigate to the page 2, whatever I click the "Next" button, it still stay on page 2,
    actually this report has 10 pages.
    On the other hand, if I input the page number, such as 5 on the "goto" textbox, it will jump to page 5 correctly.
    Could you give me any good advices to solve this problem?
    Thanks.

    There are a few threads discussing the issue in this forum. See if these provide some guidance:
    "Next Page" wont go beyond page 2 in Html Viewer (Crystal.NET for VS 2008)
    Re: Crystal Reports .NET Visual Studio 2005
    Problem in CrystalReportViewer
    Ludek

  • Project View does not show the Path and Filename when errors occur

    I have the problem, that errors occur in the project but in the colum that shows the "Resource" I can only see the "Project Name". Normally it should show the filename. The "Path Column" is completely empty. The "Location column" shows the correct line number in the file (but unfortunately I have no Idea which file). Double clicking on the row does not do anything.
    I'm sure it had worked, but no idea since when this problem occurs. I am using Flash Builder 4.7.

    I was able to resolve this by repairing permissions, even though no permissions error was listed specifically for that file.
    I could also have recovered it through Time Machine, but I'm interested in knowing how not to have this happen again!
    I was afraid of rebooting and possibly losing track even of the ghost.
    I did not try EasyFind - I'll keep that in mind next time.
    Thanks for all the comments.

  • I have an iphone 5s and it is synced to itunes and works fine. previously I have downloaded audiobooks to my wifes 6th gen nano using this account - now I tunes does not recognize the device and also it seems that it is not being read by the computer?

    I have an iphone 5s and it is synced to itunes and works fine. previously I have downloaded audiobooks to my wifes 6th gen nano using this account - now I tunes does not recognize the device and also it seems that it is not being read by the computer?

    Hey Stan1958,
    Thanks for the question. I understand you are experiencing issues with your iPod nano and iTunes. Based on your symptoms, you may find the following resources helpful in resolving this issue:
    Windows
    iPod appears in Windows but not in iTunes
    iPod not recognized in 'My Computer' and in iTunes for Windows
    iTunes reports that "iTunes cannot recognize this iPod at this time"
    Thanks,
    Matt M.

  • When I plug in my iPhone to sync, it starts but does not complete the process and several pieces of data are not being transferred to my iPhone from my MacBook Air.

    Problem:
    When I plug in my iPhone to sync, it starts but does not complete the process and several pieces of data are not being transferred to my iPhone from my MacBook Air.
    Any help that you can provide in helping my iPhone accurately sync with iPhoto and iTunes will be greatly appreciated.
    Symptoms:
    1)   Sync:  It’s not completing the sync.  Below, I’ve provided all of my settings from the iTunes Summary tab so that you might tell me if I’ve selected any incorrect options.  I prefer to sync the “old school” way – by connecting to the computer – as opposed to syncing over the cloud. Perhaps this is what’s causing the problem? Here is a list of the steps displayed in the iTunes window as the sync progresses:
    waiting for sync to start (step 1 of 7)
    backing up (step 2 of 7)
    preparing to sync (step 3 of 7)
    determining apps to sync (step 4 of 7)
    preparing apps to sync (step 5 of 7)
    importing photos (step 6 of 7)
    waiting for changes to be applied (step 7 of 7)
    syncing apps / copying 1 of 4 (App name) (step 7 of 7)
    canceling sync
    apple icon
    2)   Photos: I've selected only certain of my iPhoto albums to sync to my iPhone.  All of the albums are correct/complete in iPhoto.  All of the albums are listed on my iPhone, both before and after the sync, but the albums are empty (no actual photos) before and after the sync. Perhaps this is tied to the fact that the sync isn’t completing, but because “importing photos” is one of the steps that the incomplete sync displays, I don’t know.
    3)   Apps: When I launch iTunes and click on the Apps folder under the Library listing, then click on the Updates tab, iTunes searches for any Apps needing to be updated and provides a list.  If I click on Update All, the Apps are successfully updated in iTunes.  But, when I plug in my iPhone so that the updates will transfer to the apps on my iPhone, the updates don’t transfer to the apps on my iPhone and those apps still reflect that they need updating on the iPhone.
    Other Potential Pertinent Info:
    The flash memory hard drive on my MacBook Air recently died (perhaps a month or two ago).  Apple had emailed me about a known issue and literally the next day, my MacBook Air crashed.  I installed a new flash memory drive and re-installed everything from a backup off of an external hard drive.  Everything seems to be working fine; it recreated accurately all of my software and data, including iPhoto and iTunes, the pictures and songs (respectively) for which are stored on that hard drive, as opposed to being on the flash memory in the MacBook Air itself.  However, I don’t recall if the start of the sync problem described herein started happening at the same time that I replaced the flash memory drive.  All I know is that the computer is working perfectly in all respects and that even as the sync is failing, it at least says that it’s doing the right things and looking in the right places (e.g., the list of albums on my iPhone matches the list of albums in iTunes, etc.).
    Settings/Status:
    MacBook Air
    OSX v. 10.9
    iPhoto ’11 v. 9.5 (902.7)
    iPhone iOS 7.0.4
    iTunes v. 11.1.3 (8)
    Summary Tab
    Backups (This Computer)
    Options
    Automatically sync when this iPhone is connected
    Sync only checked songs and videos
    Photos Tab
    Sync Photos from iPhoto (429 Photos)
    Selected albums, Events, and Faces, and automatically include (no Events)
    Albums – 9 are selected

    You need to download iTunes on your computer. iOS 6 requires the latest version of iTunes which is 10.7.

  • The application does not use the  screen and run in the background

    Hi
    I have downloaded a package of j2me Midlet
    from [link] here [link]
    and try to reuse the code
    but I get the following error when running the code:-
    The application does not use the screen and run in the background
    I think the error into one of these two classes
    package main;
    import javax.microedition.midlet.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.Manager;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.Player;
    import java.io.IOException;
    import java.io.InputStream;
    public class MainMidlet extends MIDlet implements CommandListener {
        private SSGameCanvas gameCanvas ;
        private Command exitCommand ;
        private Player player = null;
        public void startApp() {
      try {
           //   create new game thread
              gameCanvas = new SSGameCanvas();
              gameCanvas.start(); // start game thread
              exitCommand = new Command("Exit",Command.EXIT,1);
              gameCanvas.addCommand(exitCommand);
              gameCanvas.setCommandListener(this);
                Display.getDisplay(this).setCurrent(gameCanvas);
       catch (java.io.IOException e)
                e.printStackTrace();
            try {
                // start sounds
                InputStream in = getClass().getResourceAsStream("/resource/startfly.wav");
                player = Manager.createPlayer(in,"audio/x-wav");
                player.setLoopCount(1);
                player.start();
            catch (MediaException ex)
                ex.printStackTrace();
             catch (IOException ex)
                ex.printStackTrace();
        public void pauseApp() {
        public void destroyApp(boolean unconditional) {
            if (player != null) {
                player.close();
            System.gc();
      public void commandAction(Command command, Displayable displayable) {
           if (command == exitCommand)
                 destroyApp(true);
                 notifyDestroyed();
    package main;
    import java.io.IOException;
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.game.*;
    public class SSGameCanvas extends GameCanvas implements Runnable {
        protected GameManager gameManager;
        protected boolean running;
        private int tick=0;
        private static int WIDTH;
        private static int HEIGHT;
        private int mDelay = 20;
        Form mainForm;
        Display display;
        //private int MaxTime;
        public SSGameCanvas() throws IOException{
            super(true);
            gameManager = new GameManager(5,5,getHeight()-10,getWidth()-10,this);
        public void start() {
                this.running = true;
                Thread t = new Thread(this);
                t.start();
        public void stop() {
            running = false;
        public void render(Graphics g) {
            WIDTH = getWidth();
            HEIGHT = getHeight();
            // Clear the Canvas.
            g.setColor(0, 0, 50);
            g.fillRect(0,0,WIDTH-1,HEIGHT-1);
            // draw border
            g.setColor(200,0,0);
            g.drawRect(0,0,WIDTH-1,HEIGHT-1);
            // draw game canvas
            gameManager.paint(g);
        public void run() {
            while (running) {
                // draw graphics
                render(getGraphics());
                // advance to next graphics
                advance(tick++);
                // display
                flushGraphics();
                try { Thread.sleep(mDelay); }
                catch (InterruptedException ie) {}
        public void advance(int ticks) {
            // advance to next game canvas
            gameManager.advance(ticks);
            this.paint(getGraphics());
    }Edited by: VANPERSIE on Jul 10, 2012 12:26 PM

    Hi Andi,
    Thanks for your reply.
    Yes, I have waited for a while and the result doesn't change.
    The Porblem here is the application is seen started in visual administrator.Only restart brings up the page back.
    Can you please suggest anything.
    Thanks and regards
    Nagaraj

  • HT4993 I updated to ios 7, put in a password but now it does not recognize the password and will not let me get into my phone.  what do i do?

    Yesterday I decided to finally update my iphone 4S to the latest operating system 7.  It asked me for a password when upgrading but now does not recognize the password and will not let me in.  FRUSTRATED.  What do i do????

    Hi Rachel,
    Welcome to the Support Communities!
    The article below may be able to help you with this.
    Click on the link to see more details and screenshots. 
    iOS: Forgotten passcode or device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    Cheers,
    - Judy

  • I have a gen 3 ipod and can't get it into disk mode.  In itunes it does not have the option and I cant figure out how to do it on the ipod touch itself.  Any ideas?

    I have a gen 3 ipod and can't get it into disk mode.  In itunes it does not have the option and I cant figure out how to do it on the ipod touch itself.  Any ideas?

    Recovering your iTunes library from your iPod or iOS device: Apple Support Communities

  • Hi, I have quick question about use of USEBEAN tag in SP2. When I specify a scope of SESSION for the java bean, it does not keep the values that I set for variable in the bean persistent.Thanks,Sonny

     

    Make sure that your bean is implementing the serializable interface and that
    you are accessing the bean from the session with the same name.
    Bryan
    "Sandeep Suri" <[email protected]> wrote in message
    news:[email protected]..
    Hi, I have quick question about use of USEBEAN tag in SP2. When I
    specify a scope of SESSION for the java bean, it does not keep the
    values that I set for variable in the bean persistent.Thanks,Sonny
    Try our New Web Based Forum at http://softwareforum.sun.com
    Includes Access to our Product Knowledge Base!

  • I am having issues with adjusting the duration of time for each still frame and transition in imovie 11.  Each time that I adjust these times, the app does not accept the change, and automatically enters its own time. Am I doing something wrong?

    I am having issues with adjusting the duration of time for each still frame and transition in imovie 11.  Each time that I adjust these times, the application does not accept the change, and instead automatically enters its own time. Is there a work around this? Or am I doing something wrong? Please Help!
    Thank you,
    lagrl

    Have you tried turning off automatic transitions ? Choose file - project properties and follow the dialogue box to change duration with a slider.  iMovie also doesn't allow a transition to be more than 50% duration of the clip its attached to. In other words if the clip is 4 seconds the transition cannot be more than 2 seconds and remember that relates to the first clip as the following clip (right side) is pulled back to overlay it.
    Does this help.  Perhaps you already know this ?

  • Hi, we have a G5 Blade server running OS X 10.5.8 with a dual Fibre Channel card. The OS does not read the card and cannot establish connection to the RAID controller. I have tried to move the card to another port with no luck. Ran all the updated softwar

    Hi, we have a G5 Blade server running OS X 10.5.8 with adual Fibre Channel card. The OS does not read the card and cannot establishconnection to the RAID controller.
    I have tried to move the card to another port with no luck.Ran all the updated software possible. Please can someone advice

    Hi,
    Was the card previously working in that machine? If it was and you have a G5 tower you could try the card in there. Here is a list of Apple fibre cards and cables which show what's compatible with what. http://support.apple.com/kb/HT1769
    The card should appear in the System Profiler under Fibre Channel and PCI Cards.
    All the best
    Beatle

  • HT4972 i got my new iphone 4s , can not download the OS 5 it says error 9006 on my windows 7. also the phone does not show the capacity and serial number details on the itunes summery ?? please help

    i got my new iphone 4s , can not download the OS 5 it says error 9006 on my windows 7. also the phone does not show the capacity and serial number details on the itunes summery ?? please help

    Hi Kevin,
    The iPhone 4S comes automatically loaded with iOS 5, and any updates after iOS 5.0 can be completed directly from on the phone in Settings > General > Software Update. If you are having trouble using iTunes to update software, I suggest you reset iTunes so that you can pair your phone to the computer again, because if you can't see the serial number and capacity, that generally means your phone isn't paired.  For any problems this doesn't fix, please contact Apple directly through their automated help line, 1(800)MYAPPLE.

  • Power Adapter Does Not Charge the Battery and Charge Light Is On?

    Power Adapter Does Not Charge the Battery and Charge Light Is On?
    My power adapter doesn't charge my computer anymore. however the charge light is on.
    Please help my battery is draining fas

    So, with your power adaptor connected not only does the battery not charge but the powerbook is not running on ac power. Then I guess the power adaptor is faulty. In as much as you've verified this with a known good one a new one is in order. Try yours in another powerbook to make sure.

  • TS1538 after a restore, the itouch screen has a "USB arrow to iTunes" picture.  Now iTunes does not see the itouch and my itouch is non-responsive

    i was restoring my itouch and after completed, the itouch screen has a "USB arrow to iTunes" picture.  Now iTunes does not see the itouch and my itouch is non-responsive

    Try DFU mode and then restore
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings

  • HT3986 I installed windows 7 successfull, but when I start the mac in windows I does not see the wifi, and others things. How do I get the drivers?

    I installed windows 7 successfull, but when I start the mac in windows I does not see the wifi, and others things. How do I get the drivers?
    I remember that with Snow Leopard you could download them from the Apple website.
    Cheers!

    Read the Boot Camp Documentation while you run Boot Camp Assistant to download the Windows Support Software which was the first step in the Boot Camp Setup procedure.

Maybe you are looking for