In a Crystal report I am passing two text strings from C# application. Both parameters are text string paragraphs basically which can have any no of words in them.
The issue is I am not able to manage spacing between both paragraphcs. As they are dynamic I can't fix their hieghts. If there is more text passed one top paragraphc over laps the bottom paragraph but if there is less text in top paragraph report shows big area as empty space.
What ever the amount of text may be, the requriement is paragrachs should have constant space between them (two line breaks). Please guide me how I can manage it.
Thanks
Put these fields in different subsections.
Put those Parameteres inside a Text Object and then set Can Grow property of the Text Object as True.
Try this and get back with your results.
Related
I recently started a project using PDF sharp + Migra Doc and I encounter a problem which I have seen in other posts, there is no fixing automatically. Table row will be generated on the next page if it doesn't have enough space and if there is still not enough space it will just go into the border and the text is lost. I am thinking of a workaround but I am not sure exactly how it can be done.
My think is as follows:
If I am able to check how many lines of text can fit in cell with the given string I can create a variable and increase it every time I add text. with the excess of text I can simply create a new row (which will be automatically be added on the next page) and thus fixing my problem. Even if I am not counting lines, is there a way to check if the row becomes too large for the current page? If at a given time I can check if the cell is too large and will be automatically sent to the next page I can trim the string up to the point it will fit, save the remaining words that didn't fit and maximise the space within the page.
this is how the document is generated currently
Is there a way to workaround this? That white space is useless and a waste of resources when it comes to a 30-40 pages document.
One extreme option: Make the layout in your code and use PDFsharp to draw the text.
See also:
https://forum.pdfsharp.net/viewtopic.php?f=8&t=3192
A MigraDoc cell can contain a mix of different fonts with different font attributes (regular, bold, ...) and sizes. Measuring the size and creating a new row can become complicated if you mix different fonts, but it can be simple if you only use a single font for your cell.
See also:
https://forum.pdfsharp.net/viewtopic.php?f=8&t=3196
The space problem with tables occur if table rows are rather large (more than just one or two lines of text). Maybe tables are not the best option to present the information. How strict are your requirements? Can you get away from tables?
The solution that finally worked was as follows:
set up the style for the document including the header
depending on the data used create a for-loop which will input the desired rows in the table
top of the loop must add a row in the document
save in a variable how many pages the document currently contains(initially declare as 1 before entering the loop)
clone the document checking if the document you are passing contains the same number or more than the current document. If the document contains more pages means that the row you inputted exceeds the page. I was able to achieve this by rendering the document every time I was adding a new row.
an inner loop is necessary to trim the text within the row. The way I did it is split the text into sentences and if it contains more than 3 sentences trim, otherwise just let go to the next page.
make sure you always delete the last row on the inner loop otherwise you will end up with the same data
It might not be the most efficient way but it renders 30+ pages documents in tables under 2 seconds on Azure servers. I hope this helps someone at some point.
I have a problem with the alignment of a few names (changed for this question).
with this code I display the names in a richtextbox where it should be in one row with the "Spalte:" after the Names...but it doesn't. Can anybody help me please?
(only the first for-loop is necessary for my question, the next one does another job)
I added a pic what it looks like and how it should be looking. I know I can do it like its in the commented area (doesn't work in every case), but I need to change the code for a few other things so this needs to work....
Here is what I have:
And here is what I want:
Thanks for helping me :D
You have four options:
Change the code for the RichTextBox to use a fixed-width font. Most fonts have variable widths for each character, meaning you can't line things up neatly based on spacing alone.
Use tabs instead of spaces for the layout (and make sure the tab size is large enough to account for variances in your text).
Use a grid control of some type (DataGrid, GridView, etc)
Use a custom control for each row with labels at specific places (and either calculate positions yourself to place them on the form or use something like a FlowLayoutPanel).
I have tried a lot to maintain long text inside RDLC report's columns but it doesn't seem to be adjustable. When some long text appears inside any column then it disturbs the whole report. How to control it, so the text keeps extending downwards in proper and good manner.
Try and put a fixed Column Width and set CanGrow to False and make sure that the Row has it set on True.
If that doesn't work you'll have to edit your datasource before giving it to the reporter. You must break the value into multiple lines based on the length of the string. You can achieve this by inserting System.Environment.NewLine every time it exceeds the size. The exact length at which you need to insert the line breaks depends on your maximum column width and you'll have to calculate this yourself by trial and error until you find the perfect fit.
Edit: Including step by step process for adding break lines based on text size.
Calculate the length of the string and add Environment.NewLine where needed to force the text to break to a new line.
Use Graphics.MeasureString to calculate the size of your text in pixels.
Check if the width exceeds the maximum length of your TextBox.
If the string fits, add it to the final string and continue to step 4.
If the string doesn't fit, continue to step 3.
Remove a character of the string, insert that character to the front of a new (second) sting and repeat step 1. again until the
first string fits.
Check if the second string is empty.
If the second string is empty, we're finished. (The final string can be added to the TextBox / new datasource).
If the second string isn't empty, add an Environment.NewLine at the end of the final string and replace the first string with the
second one and make the second string empty again, repeat the whole
process.
There might be ways of improving this process. For example by breaking the text in fixed predefined intervals and refining it afterwards. Or if there are actual words divided by spaces you could add and remove words instead of characters.
Cut the long-length textbox.
Drag and drop a rectangle there.
Paste the textbox inside the rectangle.
Set rectangle's borders
as the textbox was.
Note: your textbox must be Cangrow:true
I'm trying to add a paragraph in English and another in Arabic in the same cell, is there a way to set the Horizontal Alignment and the Reading Order with different values?
can I use a delimiter to split them and set their alignment and reading order?
Take text field add english then add delimiter then arabic..
Place the field on design and enable can grow property
Coding a split formula to adding specific alignment for each paragraph won't solve the issue.
Referring to crystal reports documentation, one field can't have multiple alignments or reading orders.
i am working in Crystal Reports for VS2010 with asp2.0 .net, can i make the columns of sections, as i have columns of my tables, and i dont want to overlap, as with labels, they overlap some times.
I am not familiar w/ the VS2010 .net interface, but if it is the GUI, you can set insert tab-stops at the desired spacing. The fields will "snap" and anchor to the tab-stop line when you move them. You can shrink/grow each field so that both left and right sides are anchored, constraining that field. You can then take the next field, and anchor it's left side to the right-side tab-stop from the last field, and repeat. When you're through, all fields will be nicely constrained, and you can adjust the placement by moving the tab-stop. The fields will "rubber-band" and grow or shrink w/ the movement of the tab-stops.
This is REALLY good when you need to export to Excel format, and you don't want the CR print engine to include extra lines/columns as it tries to match the "just a little off" layout.
I "think" I need less "air quotes" and more "air guitar".