Skip to main content
Announcements
Defect acknowledgement with Nprinting Engine May 2022 SR2, please READ HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
berryandcherry6
Creator II
Creator II

alignment of numbers to center, yet left justified in NPrinting.

Hi,

I have a table with columns, where i need to align numbers to center, with left justified.

I know i can do this using padding by left alignment, but this will be burdensome if there are multiple columns with different width.

Is there any option in NPrinitng to this?

1 Solution

Accepted Solutions
Daniel_Jenkins
Specialist III
Specialist III

Hi Supriya,

If you want to automatically change the padding depending on the width you will need to do it in script.

If you have two fields in label1 & label2 like this:

Open the Scripts Editor

Here is example C# code for label1:

private void label1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {

XRLabel label = (XRLabel)sender;

int lx = label.Width;

if (lx < 50) {

label.Padding = new PaddingInfo(0,0,0,0);

}

else if (lx > 250) {

label.Padding = new PaddingInfo(75,0,0,0);

}

else {

label.Padding = new PaddingInfo(25,0,0,0);

}}

Adjust as required and repeat for label2 as well. You will get padding based on the width of your label (see arrows).

HTH - Daniel.

View solution in original post

5 Replies
Daniel_Jenkins
Specialist III
Specialist III

Hi Supriya,

I assume (based on your previous questions) that you are using PixelPerfect.

Won't one of the Text Alignment options (perhaps Middle Left) serve the purpose?

HTH - Daniel.

berryandcherry6
Creator II
Creator II
Author

Its partially helping me.

see this images

vaer1.PNG

Ver2.PNG

Check the properties i am applying, where i need to give left padding to each column if they of diiferent width to make it to center.

I need it to take Automatically to center left align.

Daniel_Jenkins
Specialist III
Specialist III

Hi Supriya,

If you want to automatically change the padding depending on the width you will need to do it in script.

If you have two fields in label1 & label2 like this:

Open the Scripts Editor

Here is example C# code for label1:

private void label1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {

XRLabel label = (XRLabel)sender;

int lx = label.Width;

if (lx < 50) {

label.Padding = new PaddingInfo(0,0,0,0);

}

else if (lx > 250) {

label.Padding = new PaddingInfo(75,0,0,0);

}

else {

label.Padding = new PaddingInfo(25,0,0,0);

}}

Adjust as required and repeat for label2 as well. You will get padding based on the width of your label (see arrows).

HTH - Daniel.

berryandcherry6
Creator II
Creator II
Author

Thanks Daniel,

This works fine.

I digged up some information on NP with scripts.

i have some questions regarding scripting in NP

1.) Can we use Winforms or ASP.Net controls in NP also?

2.) Can i connect NP to VisualStudio and is it any useful?(i know it sounds silly,need to know some information)

3.)Can we create table Programmatically and put that to NPrinting End user display?

4.)Currently i get script option to visual basic,c#, js. If i need to script with other language like java what should be done?

Daniel_Jenkins
Specialist III
Specialist III

Hi Supriya,

1), 2) & 3) As far as I know the answer is "No"

4) Only C#, Visual Basic & JScript .NET are supported

HTH - Daniel.