C1FlexRepot Label Printing Issues

Posted by: mwebster on 4 April 2019, 3:25 pm EST

    • Post Options:
    • Link

    Posted 4 April 2019, 3:25 pm EST

    I am having all manner of problems trying to get simple labels to print correctly with C1FlexReport. The printer in Question is a label printer than prints 2 1/4" wide by 1 1/4" high labels on a continuous sheet. Here are the issues that I am having:

    1. I specifically set the length and width properties of the report to the correct size but could not find any way of setting the paper size property. If I clicked the page Setup button on the designer, the nearest I can get is selected Custom paper size but it gives no means of entering the paper size and it resets to letter every time you click the button anyway.

    2. When I open the report preview in the FlexViewer, it appears as letter size paper oriented landscape even though I explicitly set the orientation to portrait. I assume this is because the width is greater than the height of the label but when the label is oriented portrait it IS wider than it is high. I even used the following code to force it to portrait:

       C1FlexReport1.PageSettings.Landscape = False
       C1FlexReport1.Layout.Orientation = OrientationEnum.Portrait
      

    That works until I select the label printer and then it resets to landscape.

    1. Once I select the label printer, it keeps the letter size paper size setting rather than changing to the paper size actually specified in the printer settings itself. I have to click Page setup. There is then a delay of about 30 seconds and then I have to manually choose the correct paper size - it always ignores the printer setting and defaults to the first one in the list.

    2. Once you select a paper size, it again resets to landscape rather than portrait.

    To get my labels to print correctly, users are forced to:

    1. Hit the print button to get the preview.
    2. Click Print report in the FlexViewer.
    3. Select the correct printer.
    4. Click Apply.
    5. Click Cancel
    6. Click Page setup and select the correct paper size (defaults to letter size regardless of the paper size setting in the printer.)
    7. Click Ok.
    8. Click Print Report again.
    9. Set the orientation back to portrait (it ignores or overrides the printer default and flips to landscape on it own).

      10 Click Print.

    Any help would be appreciated. This thing seems to be fighting me at every turn. Basically I need to:

    1. Set the paper size in code at design time and have that paper size be selected in the FlexViewer without user intervention.

    2. Have it orient to Portrait and not landscape as per the settings I did in code and the settings of the printer.

    3. Allow the user to change from the default printer to the label printer without it losing all of the above settings and defaulting to letter size paper landscape oriented.

  • Posted 4 April 2019, 3:43 pm EST

    Ok I solved the size issue. But the issue of orientation still exists. I set the portrait orientation in the setup of the report and in code using:

    C1FlexReport1.PageSettings.Landscape = False

    C1FlexReport1.Layout.Orientation = OrientationEnum.Portrait

    When the report preview loads in FlexViewer, it appear correct, however, as soon as I select the label printer, it jumps over to landscape. If I click the Portrait button on the toolbar, both portrait and landscape are selected and it prints correctly. I need to stop it from changing to landscape every time someone selects a different printer. The issue appears to be that the component incorrectly assumes that if the layout is wider than it is high, it is landscape. In the case of this label printer, that is not the case. The portrait orientation is 2.25" wide by 1.25" high. Any suggestions?

  • Posted 4 April 2019, 3:55 pm EST

    Just to clarify, here is where we are at:

    The size issue is resolved but when the FlexViewer shows the preview the setting in the printer to Portrait is ignored. The portrait setting in the report properties is ignored. The code below is ignored:

        C1FlexReport1.PageSettings.Landscape = False
        C1FlexReport1.Layout.Orientation = OrientationEnum.Portrait
    

    To print the labels correctly, the user has to:

    1. Click Print.
    2. Select the label printer.
    3. Click Apply.
    4. Click Cancel.
    5. Select portrait (which causes both portrait and landscape to be highlighted in FlexViewer).
    6. Click Print Report.
    7. Click Print.

    The crux of it is the issue with it forcing the orientation to landscape at every turn.

  • Posted 5 April 2019, 3:14 am EST

    Hello,

    Thanks for the final clarification.

    I understand that the size issue is resolved for you now.

    As per the orientation related issue, the two properties should work fine to set the required orientation.

    >>The portrait orientation is 2.25" wide by 1.25"

    Here, if I am not wrong, the width of the paper is more than the height and hence, you might be facing issues while setting the orientation. To specify the orientation explicitly while printing, you can use the below mentioned code snippet:

    c1FlexReport1.Layout.Orientation = OrientationEnum.Portrait
    Dim options As C1.Win.C1Document.C1PrintOptions = New C1.Win.C1Document.C1PrintOptions
    options.PageSettings = New System.Drawing.Printing.PageSettings
    options.PageSettings.Landscape = False
    options.PrinterSettings = New System.Drawing.Printing.PrinterSettings
    options.PrinterSettings.PrinterName = "PrinterName"
    FlexReport.Print(options)
    c1FlexReport1.Print(options)
    

    If the issue persists, kindly share a small video showing the same and how following the steps you have mentioned,the issue is resolved for you. This will help me investigate the issue further.

    Thanks.

  • Posted 5 April 2019, 8:03 am EST

    Thanks for the reply. I tried that but I am getting an error now when it tires to actually print. The error is “System.InvalidOperationException: ‘Operation is not valid due to the current state of the object.’” and it occurs on the line: C1FlexReport1.Print(options)

    I double checked and the name of the printer is correct.

  • Posted 5 April 2019, 9:01 am EST

    Getting closer. I had to add this code: C1FlexReport1.Generate() before the line: C1FlexReport1.Print(options).

    Now it print but, the size issue has returned. If I print it on a regular printer, it prints portrait oriented but it prints in huge characters. If I print it to the label printer, I get a blank label and I believe it is only printing the top corner of the page which is indeed blank. I have the report configured to print only 1 single page. I think I need to specify the paper size in code rather than in the report definition in order for this to work. So far no luck in doing that.

  • Posted 5 April 2019, 9:53 am EST

    Solved the problem! Thanks for your help. Here is the code I ended up using:

        Dim LabelAdapter As New LabelDataTableAdapters.ULLabelsTableAdapter
        LabelAdapter.Insert(txtCompanyName.Text, txtSerialNumber.Text, dtpMFGDate.Value, txtAmp.Text, txtVolt.Text, txtHz.Text)
        Dim LabelID As Integer = LabelAdapter.GetLastInertedULLabelID
        Dim rptPath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) & "\Label.flxr"
        Dim WhereClause As String = ""
        Dim PaperSize As New Printing.PaperSize
        PaperSize.RawKind = Printing.PaperKind.Custom
        PaperSize.Width = 225
        PaperSize.Height = 125
        C1FlexReport1.Load(rptPath, "Label")
        C1FlexReport1.DataSource.Filter = "[LabelID] = " & LabelID
        C1FlexReport1.Layout.Orientation = OrientationEnum.Portrait
        Dim options As C1.Win.C1Document.C1PrintOptions = New C1.Win.C1Document.C1PrintOptions
        options.PageSettings = New System.Drawing.Printing.PageSettings
        options.PageSettings.Landscape = False
        options.PageSettings.PaperSize = PaperSize
        options.PrinterSettings = New System.Drawing.Printing.PrinterSettings
        options.PrinterSettings.PrinterName = "DYMO LabelWriter 450"
        C1FlexReport1.Generate()
        C1FlexReport1.Print(options)
    
  • Posted 20 April 2023, 5:12 am EST

    The most common reasons why labels don’t print in the right place are: Your printer settings are not adapted. Your labels contains too much text information or the font size is too big. You might not be using the correct label templates.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels