cancel
Showing results for 
Search instead for 
Did you mean: 

Changing paper size at runtime

Former Member
0 Kudos

I know this has been asked before, but all the answers seem to give the same response, which is not working for me. I am working in VS2008 VB.net. I have a report that is populated with data within the VB code, then exports the report to a pdf file.

I have tried:

dim rpt as CrystalDecisions.CrystalReports.Engine.ReportDocument

rpt.load ('myfile.rpt")

rpt.PrintOptions.DissociatePageSizeAndPrinterPaperSize = true

rpt.PrintOptions.PaperSize = 9 (integer value for A4)

My current default printer has A4 as its paper size.

The report was created when the default printer has a paper size of Letter.

The code above has no effect on the output file. I see in the properties of the PDF file that the document properties show the report page size as Letter.

Is there any way to change this programatically? Is there a document or report setting that I can use to set the paper size?

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hello Jeanne

You mention you've tried a number of things, but I do not know what these were. If I continue much, I'll more than likely repeat the things you have tried, wasting your time. So, first I'd like to know the exact version of CR you are using (telling me the version of crpe32.dll may be best). Next, it may be a good idea to let us know what you what you have actually tried already(?).

- Ludek

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

Former Member
0 Kudos

Ludek -

Sorry about forgetting to put in the CR version - we are using 10.0.5.1506. 

I did provide the code I have tried without success. I have tried it with and without the Dissociate setting. I have tried to change the default printer page size. All the code examples I have seen deal with using a custom page size - I am working with standard page sizes (A4 and Letter).

Do I still have to enumerate the page sizes from the default printer to find the integer values? I know there are default paper size values within the CR objects so I assume that if I use one of them I do not need to get the page size number from the printer.

Also, I have tried setting the page size in my code to different values but the pdf file created always says it is 8.5 x 11.

Former Member
0 Kudos

I have been doing some more research and found

rpt.ReportClientDocument.PrintOutputController.ModifyUserPageSize

and this seems to work. I put in (12240, 15840) for Letter and (11909, 16834) for A4. Since the report was created with Letter as its size the report looks fine. I think I will need to work with either another setting or change the margins so that it keeps the same margins for the A4 report as the Letter report (stretch the text area out or something).

Former Member
0 Kudos

I now have code that will extend boxes and lines to fit the new width. I also move text objects so they appear centered. This all works fine except for vertical lines. If I try to set the Left property of a vertical line I get an exception that only vertical and horizontal lines are supported.I understand that changing just the left property then makes the line angled instead of straight.

The question is how do I move the vertical line?

former_member183750
Active Contributor
0 Kudos

Hello Jeanne

Great news re. the paper size. I do have a caution for you though. Using CR 10.0.5.1506 and VS 2008 was never supported. And I know it almost works, so why not? It's the "almost" part that is the issue. We only support VS 2008 with CR 2008 (version 12.x) and Crystal Reports Basic for Visual Studio 2008 (version 10.5.x).

Re. moving vertical lines. You'd have to use the InProc RAS SDK for that. But going to CR 2008 should be your 1st step.

- Ludek

Former Member
0 Kudos

Ludek -

Unfortunately upgrading to CR2008 is not an option at this time.

Where can I find a download of the RAS SDK? And once I have it, how do I move the vertical line?

former_member183750
Active Contributor
0 Kudos

RAS SDK is not a download. It is part of all CR stand-alone versions of CR. E.g.; you'd have obtain and then upgrade to CR 2008. Alternatively, the RAS SDK is also part of CR for VS 2010 / 2012.

- Ludek

Former Member
0 Kudos

Well, I mis-spoke. It turns out that when the development computer I am working on was rebuilt CR10 was put on by mistake. We do have 2008 and our code is actuall written using the RAS objects (I think).

I believe what you refer to is the ability to declare something like this:

dim objLine as ReportAppServer.ReportDefModel.LineObject

Is that correct? If so, I still do not know how to move the vertical line using this object. I can access the left and right components, but if I try to adjust one of them it gives me an exception as I mentioned previously.

So what code do I need to use to move the vertical line?

former_member183750
Active Contributor
0 Kudos

OK. Since you have CR 2008 and you are using InProc RAS SDK, you have to promise me that you are going to update to SP5 (if you are not there already). One easy way of checking is to see the version of any CR dll. These should be 12.5.x. Alternatively, in the CR 2008 designer, go to Help | About....

CR 2008 SP links are documented here:

http://scn.sap.com/docs/DOC-27917

Then, to move the line up or down, use the RAS SDK to remove the LineObject, then add a new one in the correct spot.  Examples are here:

- Ludek

Answers (0)