cancel
Showing results for 
Search instead for 
Did you mean: 

SelectPrinter details

patrick_simons2
Participant
0 Kudos

Could someone explain me what SelectPrinter (RDC) internally replace in the report?

If I replace with SelectPrinter the Printer saved in the Report with an existing one on the pc, all props should be replaced? Exceptions?

If the report has a saved "No Printer", does this has an impact on SelectPrinter?

Tx,

Patrick

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi Patrick

Perhaps the better way to approach this is with a question:

What is behind your queries? Or, what are you trying to achieve?

Unfortunately RDC is a technology left in the dark ages, so finding detailed info on how it worked may be a rather difficult project...

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow me on Twitter

patrick_simons2
Participant
0 Kudos

Hi Ludek,

We have some wrong behaviors printing reports to different printers (f.ex color vs. bw-printing, ...).

I read your wikis about CR Basics about designing and Printer Drivers, the "No Printer"-Flag (see ). BTW. the 1st two links (Basics and The Basics) point to the same page.

So in our case we have distributed reports, designed in our house with a default printer but then at the end of designing, the "No Printer"-flag is always set !

On the other side (customer), our erp-program (with RDC or RAS) always opens the report and always sets the new printer to the report before viewing, printing or exporting the report. RDC is used with SelectPrinter to set the Printer, additionally Orientation, PaperSource, PrinterDuplex, PaperSize are set with their corresponding properties. RAS has no SelectPrinter, the props are set on another way...

By doing this no additional info should remain in the report from the old designing printer, also "No Printer" was set.

But f.ex. for the color printing case the customer installed two same drivers for the same printer, one for color printing, the other for black/white printing. The correct printer is set by the erp but the page is printed out in color by the bw/driver or vice versa...

I just want to understand the logic, actually it is always like playing Russian roulette.... after a long period of playing you'll have the chance to get it work or not...

Thanks,

Patrick

0 Kudos

Hi Patrick,

What version of CR Designer are they using to design/edit the reports?

What version of the .NET SDK are you using?

There was an issue with printing color but that should be fixed now in CR for VS SP 13.

Is this a Windows or WEB application?

Highly recommended to stop using the XI R2 RDC to alter reports. See below for more info as to why.

In CR 2008 we introduced the ability to set the Area and Section paper Orientation and User Defined paper sizes that are not dependent on printer drivers. With this change if you use XI R2 to design report or edit reports that functionality is removed.

So first thing to do is update to the latest CR 2008, 2011 or 2013 Report Designer because those versions now save the printer and paper size in the RPT files.

So if you DO NOT go into Page Setup in the Print Report UI you do not get printer info:

To save the printer info simply change one option and change it back and hit the OK button.

Now what you see in the printer dialog box is:

Now in the .NET SDK when printing you can now get the Saved Printer Name and Saved Paper name.

Using the Engine or RAS CopyTo/CopyFrom you can take the printer info from the report and set the printer or take the printer info and set the Report to use that info.

So as long as Dissociate is checked on, CR SDK will "look" for the "family" of printers on the workstation or app server and use that default printer info and set the paper size according to the paper size ENUM. In SP 13 if using a custom paper size CR will look for the Saved Paper Size Name defined in the printer and set it automatically to use the paper by name and no longer by paper size ENUM. Most printers and according to Microsoft's Paper Size ENUM definitions up to about 143 or 138 ( somethign like that ) all Printer makers use the same paper size ENUM. 256 is supposed to be reserved for "User Defined" but some makers have set their paper size to that number.

The biggest reason for setting Dissociate on is to stop CR from "looking" on your Domain for that printer, if it finds it it will try to print to it. By checking on that box CR will use your default printer and try to apply the Orientation, paper size, margins, colour, and Duplex option as set/saved in the report file.

So back to how this works....

No Printer should NOT be used if you are designing for a specific layout. When you set the No Printer option on what this does in the SDK is the Format Engine uses usp10.dll to render the object placement and therefore has no dependency on any printer driver. But there are problems with that dll, we use version 1.4 but MS has released an updated 1.6 dll but we can't use it right now. R&D is looking into updating our rendering engine to use it.

By using No Printer this can cause formatting differences so in a Windows Desktop app you should use a specific printer and check on Dissociate. Why this does is it removes the specific dependency on the printer the report was designed with but this is only good for standard paper sizes. Labels are a different beast and that I'll explain later if you are printing labels.

So, if your reports are using standard papers sizes, A4, letter, Legal, etc. then do not use No Printer and use Dissociate. When printing now the user will be prompted for the printer to use, unless you created your own print button. All they have to do is select the correct printer and it should work.

WARNING: There is a bug in SP 13 that even though it should use the printer settings when using the Viewers Print Button or when using PrintToPrinter ( same as the print button ) it ignores what is saved in the report and simply uses the first paper settings it finds in the printer.

The work around is for now you need to select the printer again in the UI.

This should be fixed in SP 14... Also, I have a new Enhancement request being integrated into SP 14, as long as all goes well with testing.  The Desktop Viewer will give you the ability to use either PrintToPrinter (P2P) which is the default, or PrintOutputController (POC). P2P uses the framework to print, POC uses an activeX dll that looks and feels like CR Designers Print function.

Just testing this now and waiting for the latest Build so I can test more....

So back to the question:

1. Upgrade your report Designer ( 2008, 2011 or 2013 ) to the latest service pack and update each report manually ( unfortunately has to be done this way ) and the paper size and printer name will be saved in the report.

2. Do not use No Printer

3. USE Dissociate

4. Save the report

Advantage is if the SDK finds the same printer installed locally it will simply print to that printer. So as long as the printer name is the same CR will simply print to that printer. If Dissociate is used it will use the printer and paper settings saved in the RPT and try to apply those values to the default or selected printer.

I am putting together a new test app that hopefully explains how CR .NET prints and should explain how it all works.... Along with a WIKI to explain it also....

Hope that helps

Don

patrick_simons2
Participant
0 Kudos

Hi Don,

Thanks for this huge explanation!

But as you know, I'm still analyzing the final migration from RDC to RAS, because we have still a performance issue on SetTableLocation (Incident 939478) when using generic/distributed reports taht the customers won't accept.... but that's another story... BTW. preparing the reports on customers side (database rename, table rename) won't be an option... I'm still investigating...

What we are using:

  • old system: RDC from CR XI R2 SP 6 FP2
  • new "beta" system: RAS from CR for VS 2010 SP13, with CR 2011 SP10 as designer
  • only windows apps

I discovered the new feature "Printer saved in report" yesterday in CR 2013 SP5. Where is this feature in CR 2011?

But my question was principally directed to RDC. When I always execute a SelectPrinter on the customer-side, has "No Printer" still an influence on printing? The original printer used in design time is never the printer on customers side, it's always replaced by the SelectPrinter-method!

When do you expect CR VS2010 SP14?

Patrick

0 Kudos

Hi Patrick,

Our CR download page has finally been updated and made public and updates are there now:

Downloads for SAP Crystal Reports and others

I'm using CR 2011 SP 11, so download that patch and you should see it also.

Update a report and see what happens now...

SP 14 should be out in a month or so...

Thanks again

Don

patrick_simons2
Participant
0 Kudos

Ok, I installed SP 11, the new fields are present. I thought this bug was corrected, unfortunately not - maybe in SP12?

Could you or Ludek give me an answer to this:


But my question was principally directed to RDC. When I always execute a SelectPrinter on the customer-side, has "No Printer" still an influence on printing? The original printer used in design time is never the printer on customers side, it's always replaced by the SelectPrinter-method!

Thanks,

Patrick

0 Kudos

Hi Patrick,

Try SP 13 now. It has more updates to Printers, one problem though is when printing CR selects the first paper tray so you have to manually select it.

As I tried to explain, No Printer is not ideal now. In the RDC some people suggested using it as a work around but in .NET No Printer should only be used for WEB app's and only when generic paper sizes are used.

patrick_simons2
Participant
0 Kudos

SP13? I was asking for CR2011 SP12, not CRVS2010 SP12. For CRVS2010 I have already SP13.

Concerning RDC SelectPrinter: so you or Ludek can't give me information what SelectPrinter internally does or overwrites ?

Thanks,

Patrick

0 Kudos

Ah yes, sorry about that.

That post you found is for the start page when CR Designer starts up. I have no idea why you think that has something to do with printing????

RDC source code has been archived and we don't have access to even install VB 6 anymore so unfortunately we can't look to see what the RDC did do...

Don

patrick_simons2
Participant
0 Kudos

BTW. I know that has nothing to do with printing, but it's very annoying to get 5 messages each time while starting CR 2011. Perhaps you can ask R&D to correct this for CR2011 SP12...

So RDC is definitely dead

Another question with RAS in the same context: when I set explicitly on customer side the printername with PrintOutputController.GetPrintOptions.PrinterName and also other props like PrinterDuplex, PaperSource and PaperSize (with CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintOptions), will be some printerinfo left from the report used to print the report on customer side (<> design PC)?

Thanks,

Patrick

0 Kudos

The Script errors are because your test PC does not have Internet access or your IT department is blocking our site.

If you don't have access then change this key:

HKEY_CURRENT_USER\Software\SAP BusinessObjects\Suite XI 4.0\Crystal Reports\StartPage - Show Online Resources = No

If you search for this you would have found it.

Not really clear what you are asking about RAS and the Engine?

If you are modifying the printer info using RAS then set the output to the ReportClientDocument (RCD) object. If you change it using the Client Document ( Engine ) then set the output to the CD object.

Don

patrick_simons2
Participant
0 Kudos

Concerning the script error in CR 2011: my Windows 8.1-PC has Internet access and the addresses are not blocked by the firewall. Your registry key does not work, I still get the script errors:

After clicking several times on "No" the pages are displaying...
Dell Stinnett-Christy wrote: "SAP has acknowledged that this is a know issue..."

Concerning RAS & Printer: Ludek's wiki (see Printing Crystal Reports) is only describing the behavior when you're designing a report on PC A, deploying it on PC B and let it run on PC B with the same or a different printer. He doesn't describe the fact that you could have a .Net-program on PC B (= customer side) that uses RAS to prepare the report to view, print or export it. The is no CR- designer on PC B.

Now when the .Net program prepares the report on PC B using the methods as described in my previous post, what printing-relative-definitions out the report will still influence the printing...?

f.ex. my .Net-program uses ReportDocument.PrintToPrinter to print out the report...

Thanks,

Patrick

0 Kudos

Hi Patrick,

That was a problem but it should be fixed. So latest Service Pack should fix it. We are currently having issues with Service Market Place and the case management system but I don't believe it should affect the start page in CRD. I see it fine.

Anyways not related to this post...

PrintToPrinter uses the default printer as defined on the USERS PC.

That API is the same one used in the Viewer and simply pop's up a Windows Common Dialog box. There is a bug in SP 13 where it always selects the first paper size in the list so you have to manually browse to the one being used. Same issue in P2P API.

Work around is to use OutputController to do the printing.

In POC the PrintControl.dll is ActiveX and searches the users PC for the printer and paper size and auto-selects it as the default printer when printing using POC.

P2P does not do that, it's the print routine for the version of CR in VS called CR Basic... To get full control use RAS.

So we stop going back and forth open the attached test app. It's the next step in the Printing Crystal Reports series which should explain how printing works in code...

See if this explains things for you.

Open the attached zip file and unzip it. Then rename the *.txt file to *.zip and unzip it and you should have the complete project.

I'm still testing and validating the app so there may be bugs in it but should explain how this works.

If you find issues let me know...

You will need to rebuild it, I'm using the latest SP 14 to test the new feature in the Viewer to set the default Printer API P2P to POC as the default, it uses the same Printer UI you see in CR Designer. It also searches the local PC for the printer and paper size, so it it's found the user simply has to click Print and it goes to the same printer as defined/saved in the report.

Thanks again

Don

patrick_simons2
Participant
0 Kudos

After Rebuilding it, I get "'CrystalDecisions.Windows.Forms.CrystalReportViewer' does not contain a definition for 'PrintMode' and no extension method 'PrintMode' accepting a first argument of type 'CrystalDecisions.Windows.Forms.CrystalReportViewer' could be found (are you missing a using directive or an assembly reference?) " - "Form1.cs    626"

Is it a new property in SP14? btw. I'm on SP13.

Thanks,

Patrick

0 Kudos

Yes it is so you can remove that reference.

I'm using the latest SP 14 build.

Search for it and you'll find this line:

// crystalReportViewer1

//

this.crystalReportViewer1.ActiveViewIndex = -1;

this.crystalReportViewer1.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange;

this.crystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;

this.crystalReportViewer1.Cursor = System.Windows.Forms.Cursors.WaitCursor;

this.crystalReportViewer1.Location = new System.Drawing.Point(8, 362);

this.crystalReportViewer1.Name = "crystalReportViewer1";

this.crystalReportViewer1.PrintMode = CrystalDecisions.Windows.Forms.PrintMode.PrintOutputController;

this.crystalReportViewer1.Size = new System.Drawing.Size(1214, 385);

this.crystalReportViewer1.TabIndex = 34;

this.crystalReportViewer1.UseWaitCursor = true;

//

Remove this line:

.crystalReportViewer1.PrintMode = CrystalDecisions.Windows.Forms.PrintMode.PrintOutputController;

Then it should compile.

Don

0 Kudos

Create a KBA on this also, search for the number:

2163438 - How do I make Crystal Reports for Visual Studio print my reports?


Don

patrick_simons2
Participant
0 Kudos

Just a question to your getPrinterInfoOnOpen()-method: it's clear that SavedDriverName and SavedPrinterName contain the info stored in the report. But what about DriverName and PrinterName when opening the report without changing anything? Does CR already use some logic to find the PrinterName?

Where can I find some help about these props?

What about the if-block-order in this function, does the order matters?

Patrick

0 Kudos

Hi Patrick,

That printer info also requires and update version of CR Designer and then save the report manually, exporting to RPT may work. Because R&D changed the bits in the RPT file it does require the rpt to be updated also.

Also explains why I had them add being able to get the last version the RPT was saved unsing this API:

for (int x = 0; x < rpt.HistoryInfos.Count; x++)
{
    cbLastSaveHistory.Items.Add(rpt.HistoryInfos[x].BuildVersion.ToString() + ": Date: " + rpt.HistoryInfos[x].SavedDate.ToString());
}

cbLastSaveHistory.SelectedIndex = 0;

If the last version is not greater than the SP xx then it will not have the info...

Yes I wish I had time to clean that part of the code up, I was testing it with updates to the runtime as required and so as you can see it is confusing.

So yes, the order is required...

Basically CR Designer was updated so it saved the printer by name and paper by ENUM and Name. Because crpe32 always looked for paper size by ENUM this is where the biggest problem was. Now it looks for it by name and then enum, depending on if it's standard paper sizes or not. If you play enough with it you'll notice CR and SDK does have logic in it to try to "find the best match" if it cannot find the design printer or paper size.

Dissociate is the biggest feature and with SP 9 or 10 User Defined paper size now returns in code as User Defined and not DefaultPaperSize.

So yes there is a logical work flow but it is very manual.... in my app.

One other thing, I updated the KBA with a new version that gets and sets the Duplex property for both the Saved printer info and what the printers are defaulting to as defined in the printers.

One thing to watch out for, some network Admin's do not allow users to change the behavior without Admin rights so changing the Duplex in code may or may not work...

So download the latest version, search for this KBA:

2163438 - How do I make Crystal Reports for Visual Studio print my reports?

PS - may have to wait 24 hours before the KBA gets replicated over to SCN search. I added a note to explain this change so if you don't see it it's not available yet...

Don

patrick_simons2
Participant
0 Kudos

Btw. as you can use a Duplex-property why did CR never implement a Color-property to override the printer settings?

In the .Net framework you can find "System.Drawing.Printing.PrintDocument.PrinterSettings.DefaultPageSettings.Color"

Patrick

0 Kudos

Hi Patrick,

I don't know the exact reasoning behind why we set some and not others, likely our Page Formatting component needed to have those values accessible.

For Color, for that very reason, you can access it via the Windows Collection.

Typically for a user it's set on the printer itself and for network printers in Corporations they may set Color printers to BW by default and if the user wants color they have to be granted access to enable Color.

For most reports BW is all that is needed.

Adding a property in CR really is not required, it can all be handled Printer side...

If you want though add your request to Idea Place and DEV can look into adding a new property. If it gets enough votes they will seriously look into adding it...

Thanks again

Don

patrick_simons2
Participant
0 Kudos

Back to your sample: what is the relation between

CrystalDecisions.CrystalReports.Engine.PrintOptions.SavedPrinterName

and

CrystalDecisions.ReportAppServer.ReportDefModel.ISCRPrintOptions.SavedPrinterName

Are the values always the same?

Patrick

0 Kudos

Hi Patrick,

Yes they are always the same, just two different collections, Engine and RAS is all... Depending on what engine you are using depends on which collection to start from...

As you may have noticed, and what I have seen, sometimes you need to use ClientDoc ( engine ) to get info and sometimes use ReportClientDocument ( RAS ) to get the info. Some functions do not have a realted API in the other collection to get the info. And sometimes you can copy that info over and sometimes you need to Clone the object info before being able to modify it.

The Engine is CR Basic, meaning most things you cannot modify, only set at runtime.

Cloning mostly depends on what you are doing to the report object. Object Browser is a good indicator, if the part is read only you then need to clone it before being able to modify it, but not always true either. Some parts can only be modified in the Report Designer.

So depending on what you are doing or wanting to do depends on which collection to start with...

AND I mostly used them just to see if it would work for what I was attempting to test at the time...

Don

patrick_simons2
Participant
0 Kudos

BTW. as your sample is entitled "How do I make Crystal Reports for Visual Studio print my reports" you could also add a method to switch the active sql-server datasource and also the active database(s) using ReplaceConnection or SetTableLocation....

I think this belongs also to the topic.

Patrick

Answers (0)