Need to print in same line in WPF C#

Aug 19 2014 11:25 AM

public bool UseSameLine
        {
            get { return useSameLine; }
set { useSameLine = value; }
        }
 


  if (printObjects != null && printObjects.Count > 0)
                {
                    List<IProjPrintPrimitive> printPrimitives = new List<IProjPrintPrimitive>();
                    for (int index = 0; index < printObjects.Count; index++)
                    {
                        switch (printObjects[index].ContentType)
                        {
       case ContentTypes.Text:
                                {
                                    List<ProjPrintContent> textPrintContents = new List<ProjPrintContent>();
                                    StringBuilder sameLine = new StringBuilder();//
                                    index -= 1;
                                    do
                                    {
                                        index += 1;
                                 //textPrintContents.Add(printObjects[index]);
                                        if (printObjects[index].UseSameLine)
                                            sameLine.Append(printObjects[index]);  
                                                                                      
                                        
                                    } while (index + 1 < printObjects.Count - 1 && printObjects[index + 1].ContentType == ContentTypes.Text);

                                    ProjPrintContent cnt = new ProjPrintContent();
                                    cnt.Content = sameLine;
                                    textPrintContents.Add(cnt);

                                    ProjPrimitiveText primitiveText = new ProjPrimitiveText();

primitiveText.ConstructVisual(textPrintContents, printConfiguration, band, pageAvailWidth, pageAvailHeight);
                                }

In the above code "contentType.Text" i have to print the datas in the same line.
        For exampe: hi
                             hello
         have to print in same line like (hi hello)
         the value of bool useSameLine will be passed in view level.

i used Stringbuilder if the property 'UseSameLine' true. Append each item to stringbuilder object. logic to append the value (printObjects[index]); value) in the below loop

                                     do
                                    {
                                        index += 1;
                                        textPrintContents.Add(printObjects[index]);

                                    }

while (index + 1 < printObjects.Count - 1 && printObjects[index + 1].ContentType == ContentTypes.Text); I have added the highlighted code in the above code.

But data is not displaying.

I think problem is in ProjPrintContent cnt = new  ProjPrintContent();
                                    cnt.Content =  sameLine;
                                    textPrintContents.Add(cnt);

If i add  //textPrintContents.Add(printObjects[index]); line alone instead of highlighted lines.Data is displaying but in sameline.

But i need to display in sameline. and i need space between each line eg: Hi Hello..

PLs help.







Answers (1)