Coordinate system in Crystal Reports - crystal-reports

I'm working with CR version 13.0.25 - I believe the actual latest version as of this date is 13.0.26, so, basically the latest version of CR. What I am working with is re-positioning elements on the report dynamically from the C# code.
There are a couple of the reports where the original rpt (designed a number of years ago) spans multiple pages. These in particular are giving me issues, but they are not the only ones. The issue here focuses on the y (vertical) dimension.
CR documents use a coordinate system that is based in the upper left corner of the document, and is also based on twips (1440 twips/in). So, in theory, I should be able to set the Top value for a ReportObject to 1440 and that element should be printed 1" from some benchmark (either top of the page or bottom of the margin - I'm fairly sure it's bottom of the margin).
My results do not seem to reflect this - at least not exactly.
When I set the Top value, it appears that with some of the documents, the y dimension is scaled. In fact, I can apply a constant scaling factor (it varies according to the document) and I can make the fields appear with a relative 1" spacing all of the way to the bottom of the page. However, that scaling factor varies from document to document.
So, besides experimenting in our production code, I have also done the following:
I created a C# console app that opens an rpt file, grabs some of the elements on it, and re-positions them, then sends it to the printer. I designed a new rpt file with headers and footers sized as small as I could get them, and put 10 text fields in the details section. I iterate through the fields (via ReportDocument and ReportObjects and re-position them at 0, 1440 (1"), 2880 (2") etc.
This works perfectly with a document that has the default margins (.167 inches by default on each side). The first element has its top butted against the bottom of the margin, the second element is 1" from the top of the first element to the top of the second element, and so on down the page. If, however, I reduce the margins to zero - either programmatically or in the design, I get this scaling effect. The elements are all now about 7/8" or so apart, instead of the 1" that I would expect.
Does anyone know of any magic formula(s) or documentation on why the coordinate system appears to be changing? I could understand that if I change the margin that could offset everything on the page (assuming that the margin is our baseline) but it would seem to me that the inter-element spacing, being 1440 should still render at 1".

I believe Y is the vertical distance from the top of that section, not from the top of the page.

Related

Vertical & Horizontal data arrangement in same page of Crystal Reports

I am importing data from a single data set in my crystal reports. I have just a single column table in my report. I want to arrange some data vertically say 10 rows of the table (In two vertical lines) and some data horizontally say next 10 rows of the same table (In two horizontal lines). I have managed to do the first part that is arranged the vertical lines side by side (By using the option Format With Multiple Columns in the section expert. I am facing difficulty in arranging horizontal lines on the same page (side by side of vertical lines). Any hints how can I achieve this. Any help will be appreciated.
Note: I have tried the subreports method, but was unsuccessful. The subreports shows one row per page for horizontal data and vertical data also limits then one row per page when I use subreports.
Image also attached for reference
Make sure to choose the correct printing direction. Tick `Across then Down':
Go to Section Expert.
Select the section you want to make it multiple column under "Sections" (usually it's 'Details')
Make sure you have "Format with Multiple Columns" is checked under Common Tab
Now you should see Layout Tab on the top right corner, select that.
Set Width to 2" or whatever you want under Detail Size.
Then under "Printing Direction" set "Across then Down" option.
Click OK and you are all set :)

Vertically center report footer in remaining space on page

Is it possible to vertically center my report footer in the leftover space at the end of the page? The size of this leftover section depends on number of data rows.
There's no easy way to vertically center things in Crystal. Frustrating as it may be, there's no Vertical Alignment property on most things, and the Size/Position of things is static except when other objects push them around to make room for themselves.
However there is a ridiculously silly hack you can do to make this work.
Write a formula, let's call it SillySpaceFormula, that uses a loop to generate a certain number of return characters. Based on the number of records on this page, SillySpaceFormula will grow or shrink inversely. Set Silly's font size to be half the size of your details section. Then place this formula in a section above the orange-outlined box and set "Can Grow" to True.
If you do this just right, SillySpaceFormula will grow by one line when a record is removed and shrink by one line when a record is added. Because the formula field Can Grow, the orange box in your screenshots will be moved up and down automatically.

ag-grid is not rendering all my rows.

I am scratching my head on this one but I am starting to think it may be a bug in ag-grid.
I have a grid that is (inconsistently) only rendering 3 rows of data when I am expecting 5. There is a blank space for the 2 missing rows.
The pager says 5 rows, and the grid seems to know there are 5 rows (when I step through the javascript debugger). In fact, if I sort on the grid, or resize the window such that the grid provides scrollbars, the other 2 rows suddenly appear.
Has anyone seen anything like this?
----More detail but may not be relevant:
On this particular page, I have 2 grids. There is a main grid that has links in it, and when you click into a link, it hides the main grid and shows you the other grid. I was concerned that that was coming into play somehow, but I actually have seen this on another page I'm working on that has just 1 grid.
Based on various explanations I have seen online, I tried this and it appears to be working:
setTimeout(function ()
{
$scope.gridOptions.api.refreshView();
}, 0);
I call this after
params.successCallback(pResponse.data);
which invokes the grid's callback
Based on your observations that sorting or resizing the window makes the data appear, I get the feeling that the code needs to force the screen refresh somehow.
this.gridOptions.api.refreshView();
I had a similar issue and discovered that my gridOptions.rowHeight value did not match the actual height of my rows (I had a checkbox element in each row that was pushing the height taller).
As it turns out, the AgGrid row renderer uses absolute pixel location to calculate which rows should be visible. So if your actual row heights result in the rows not being in the exact position they are expected to be in, the renderer will skip them.
Ironically, the positioning code uses actual position, so the rows that do get rendered are positioned as if the skipped rows are still there, resulting in the blank space described by the OP.

Crystal Reports fields won't align

I have several items that I want to line up. The Width and Height of all fields match. Usually I just use the Align, but it's making it worse. My out of line field which is slighly lower, moves way up, way out of line (with align tops)
So I tried using the Size and Position to set it manually. Several objects have a Y of 0.056, but my last one has 0.061. I change the last one to 0.056 and save it. It doesn't appear to be different, and when I look at it again, it's still 0.061. (When I used align, it went up to 0.028!)
I do NOT have Snap to Grid set (my grid size is 0.083). (Nor does turning on Snap to Grid make them align.) The fields have exactly the same formatting. But unless I can magically make them align by hand, they refuse to align. Why?
You've already done a lot of the regular troubleshooting steps. One more ting that I sometimes do is to select all the fields I want to align, then use the arrow keys and move them up into the section above and then back down into their original section. That usually puts them all into the 0 position. If it dosn't work with all of them selected, try each one separately.

Programmatically move a FormulaFieldDefinition object

Given that FormulaFieldDefinition does not have a Top, Bottom, Left, or Right properties...is there any way to move/resize the formula at runtime?
You're looking at it the wrong way - a FormulaFieldDefinition is simply the definition of the formula itself, and not an object on the report. Therefore manipulating the size or position of it makes no sense.
What is actually shown on the report is an IFieldObject which displays the result for the given formula. This is how you can (if needed) show the same formula several times on a report.
You need to find the name of the IFieldObject that is displaying the formula, and manipulate the location of that instead. This can be done using ReportDefinition.ReportObjects("NameOfIFieldObject") and the Top, Left, Width and Height properties of it. Remember that the Top and Left values are relative to the section the object is in, not to the report.