Working 128 barcode example

blackc2005blackc2005 Member Posts: 18
Hi, I need to generate barcodes in reports in NAV2013. I have downloaded multiple of the examples from the files section but none of them seem to work/scan. Some of them have unprintable chars in the barcode (start and stop chars) others print but don't scan at all.
I've tried these:
https://mibuso.com/downloads/barcode39-in-pure-c-al
https://mibuso.com/downloads/barcode-128-with-fonts-sample

Can anyone point me to one that's actually working or tell me an alternative to creating basic barcodes in NAV?

Thanks.

Answers

  • SanderDkSanderDk Member Posts: 502
    edited 2019-08-10
    What is your case?
    Do you need to print a label? add a bar code to a invoice?
    What kind of barcode do you need?
    For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.
  • ResolusResolus Member Posts: 40
    I've used https://mibuso.com/downloads/ean-8-13-code-39-128-barcode-creator-v1.5 and it worked great.

    I did have to change something to get black and white barcodes (instead of black and dark grey), but I can't entirely remember what it was.
  • midegomidego Member Posts: 51
    For barcode scanners, sometimes you have to add the start and stop character, we use * as start and stop and add this as a character before and after the barcode.
  • blackc2005blackc2005 Member Posts: 18
    Resolus wrote: »
    I've used https://mibuso.com/downloads/ean-8-13-code-39-128-barcode-creator-v1.5 and it worked great.

    I did have to change something to get black and white barcodes (instead of black and dark grey), but I can't entirely remember what it was.

    Would you happen to still be using this? Could you send me a FOB of the files? The one I downloaded doesn't seem to scan at all.
  • blackc2005blackc2005 Member Posts: 18
    edited 2019-08-12
    midego wrote: »
    For barcode scanners, sometimes you have to add the start and stop character, we use * as start and stop and add this as a character before and after the barcode.

    Does this work with the 128 codes? I thought the 128 needed special chars for start and stop.
  • midegomidego Member Posts: 51
    Why don't you try it, it works here.
  • ftorneroftornero Member Posts: 524
    Hello @blackc2005

    you can use a DLL from ZXing and get a code128 image from the code you need to print

    qpcj94tco6dz.png

    This is the report with the example:
    OBJECT Report 50001 Label Cod128
    {
      OBJECT-PROPERTIES
      {
        Date=14/08/19;
        Time=10:22:31;
        Modified=Yes;
        Version List=COD128;
      }
      PROPERTIES
      {
        Permissions=TableData 297=rm;
      }
      DATASET
      {
        { 7141745; ;DataItem;                    ;
                   DataItemTable=Table27;
                   DataItemTableView=SORTING(No.);
                   OnAfterGetRecord=BEGIN
                                      BarCod128("No.", 1000, 2250, tmpBlob);
                                    END;
    
                   ReqFilterFields=No. }
    
        { 7141744;1;Column  ;CodBarras           ;
                   SourceExpr=tmpBlob.Blob }
    
        { 1000000000;1;Column;ItemNo             ;
                   SourceExpr=Item."No." }
    
      }
      REQUESTPAGE
      {
        PROPERTIES
        {
        }
        CONTROLS
        {
        }
      }
      LABELS
      {
      }
      CODE
      {
        VAR
          tmpBlob@7141753 : TEMPORARY Record 99008535;
    
        PROCEDURE BarCod128@1000000001(pcodBarcode@7141743 : Code[1024];pHeight@7141747 : Integer;pWidth@7141748 : Integer;VAR pTmpTempBlob@7141754 : TEMPORARY Record 99008535);
        VAR
          BarCodeFormat@7141745 : DotNet "'zxing, Version=0.16.0.0, Culture=neutral, PublicKeyToken=830ae994e36ac27d'.ZXing.BarcodeFormat";
          Options@7141746 : DotNet "'zxing, Version=0.16.0.0, Culture=neutral, PublicKeyToken=830ae994e36ac27d'.ZXing.Common.EncodingOptions";
          BarCodeWriter@7141749 : DotNet "'zxing, Version=0.16.0.0, Culture=neutral, PublicKeyToken=830ae994e36ac27d'.ZXing.BarcodeWriter";
          Bitmap@7141753 : DotNet "'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.System.Drawing.Bitmap";
          ImagingFormat@7141751 : DotNet "'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.System.Drawing.Imaging.ImageFormat";
          MemStr@1000000001 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.MemoryStream";
          OutStr@1000000000 : OutStream;
        BEGIN
          CLEAR(pTmpTempBlob);
    
          BarCodeFormat := BarCodeFormat.CODE_128;
    
          Options := Options.EncodingOptions;
          Options.Height := pHeight;
          Options.Width := pWidth;
    
          BarCodeWriter := BarCodeWriter.BarcodeWriter;
          BarCodeWriter.Format := BarCodeFormat;
          BarCodeWriter.Options := Options;
          Bitmap := BarCodeWriter.Write(pcodBarcode);
    
          MemStr := MemStr.MemoryStream();
          Bitmap.Save(MemStr, ImagingFormat.Png);
    
          pTmpTempBlob.Blob.CREATEOUTSTREAM(OutStr);
          COPYSTREAM(OutStr, MemStr);
        END;
    
        BEGIN
        END.
      }
    
    

    Regards

  • ftorneroftornero Member Posts: 524
    edited 2019-08-14
    Here is the RDLDATA that does not fit in a single message, you need to add the two parts.
      RDLDATA
      {
        <?xml version="1.0" encoding="utf-8"?>
    <Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition">
      <DataSources>
        <DataSource Name="DataSource">
          <ConnectionProperties>
            <DataProvider>SQL</DataProvider>
            <ConnectString />
          </ConnectionProperties>
          <rd:DataSourceID>3b60dfeb-6f42-4c45-8183-0f3a4bc4f0dc</rd:DataSourceID>
        </DataSource>
      </DataSources>
      <DataSets>
        <DataSet Name="DataSet_Result">
          <Fields>
            <Field Name="CodBarras">
              <DataField>CodBarras</DataField>
            </Field>
            <Field Name="ItemNo">
              <DataField>ItemNo</DataField>
            </Field>
            <Field Name="ItemDescription">
              <DataField>ItemDescription</DataField>
            </Field>
          </Fields>
          <Query>
            <DataSourceName>DataSource</DataSourceName>
            <CommandText />
          </Query>
          <rd:DataSetInfo>
            <rd:DataSetName>DataSet</rd:DataSetName>
            <rd:SchemaPath>Report.xsd</rd:SchemaPath>
            <rd:TableName>Result</rd:TableName>
          </rd:DataSetInfo>
        </DataSet>
      </DataSets>
      <Body>
        <ReportItems>
          <Tablix Name="Tablix1">
            <TablixBody>
              <TablixColumns>
                <TablixColumn>
                  <Width>4.11417in</Width>
                </TablixColumn>
              </TablixColumns>
              <TablixRows>
                <TablixRow>
                  <Height>5.82677in</Height>
                  <TablixCells>
                    <TablixCell>
                      <CellContents>
                        <Rectangle Name="Rectangle2">
                          <ReportItems>
                            <Image Name="Image1">
                              <Source>Database</Source>
                              <Value>=Fields!CodBarras.Value</Value>
                              <MIMEType>image/jpeg</MIMEType>
                              <Sizing>Fit</Sizing>
                              <Top>0.50271cm</Top>
                              <Left>0.31751cm</Left>
                              <Height>3.02805cm</Height>
                              <Width>9.86791cm</Width>
                              <Style>
                                <Border>
                                  <Style>None</Style>
                                </Border>
                              </Style>
                            </Image>
                          </ReportItems>
                          <KeepTogether>true</KeepTogether>
                          <Style>
                            <Border>
                              <Style>Solid</Style>
                            </Border>
                          </Style>
                        </Rectangle>
                      </CellContents>
                    </TablixCell>
                  </TablixCells>
                </TablixRow>
              </TablixRows>
            </TablixBody>
            <TablixColumnHierarchy>
              <TablixMembers>
                <TablixMember>
                  <TablixMembers>
                    <TablixMember />
                  </TablixMembers>
                </TablixMember>
              </TablixMembers>
            </TablixColumnHierarchy>
            <TablixRowHierarchy>
              <TablixMembers>
                <TablixMember>
                  <TablixMembers>
                    <TablixMember>
                      <Group Name="Group1">
                        <GroupExpressions>
                          <GroupExpression>=Fields!ItemNo.Value</GroupExpression>
                        </GroupExpressions>
                      </Group>
                      <SortExpressions>
                        <SortExpression>
                          <Value>=Fields!ItemNo.Value</Value>
                        </SortExpression>
                      </SortExpressions>
                      <TablixHeader>
                        <Size>0.98425in</Size>
                        <CellContents>
                          <Textbox Name="Group1">
                            <CanGrow>true</CanGrow>
                            <KeepTogether>true</KeepTogether>
                            <Paragraphs>
                              <Paragraph>
                                <TextRuns>
                                  <TextRun>
                                    <Value>=Fields!ItemNo.Value</Value>
                                    <Style />
                                  </TextRun>
                                </TextRuns>
                                <Style />
                              </Paragraph>
                            </Paragraphs>
                            <rd:DefaultName>Group1</rd:DefaultName>
                            <Style>
                              <Border>
                                <Style>Solid</Style>
                              </Border>
                              <PaddingLeft>2pt</PaddingLeft>
                              <PaddingRight>2pt</PaddingRight>
                              <PaddingTop>2pt</PaddingTop>
                              <PaddingBottom>2pt</PaddingBottom>
                            </Style>
                          </Textbox>
                        </CellContents>
                      </TablixHeader>
                      <TablixMembers>
                        <TablixMember />
                      </TablixMembers>
                    </TablixMember>
                  </TablixMembers>
                </TablixMember>
              </TablixMembers>
            </TablixRowHierarchy>
            <DataSetName>DataSet_Result</DataSetName>
            <PageBreak>
              <BreakLocation>End</BreakLocation>
            </PageBreak>
            <Height>14.8cm</Height>
            <Width>12.94999cm</Width>
            <Style>
              <Border>
                <Style>None</Style>
              </Border>
            </Style>
          </Tablix>
        </ReportItems>
        <Height>14.8cm</Height>
        <Style />
      </Body>
      <Code>Public Function BlankZero(ByVal Value As Decimal)
        if Value = 0 then
            Return ""
        end if
        Return Value
    End Function
    
    Public Function BlankPos(ByVal Value As Decimal)
        if Value &gt; 0 then
            Return ""
        end if
        Return Value
    End Function
    
    Public Function BlankZeroAndPos(ByVal Value As Decimal)
        if Value &gt;= 0 then
            Return ""
        end if
        Return Value
    End Function
    
    Public Function BlankNeg(ByVal Value As Decimal)
        if Value &lt; 0 then
            Return ""
        end if
        Return Value
    End Function
    
    Public Function BlankNegAndZero(ByVal Value As Decimal)
        if Value &lt;= 0 then
            Return ""
        end if
        Return Value
    End Function
    </Code>
      <Width>12.94999cm</Width>
      <Page>
        <PageHeight>14.8cm</PageHeight>
        <PageWidth>10.5cm</PageWidth>
        <ColumnSpacing>1.27cm</ColumnSpacing>
        <Style />
      </Page>
      <Language>=User!Language</Language>
      <ConsumeContainerWhitespace>true</ConsumeContainerWhitespace>
      <rd:ReportID>0eeb6585-38ae-40f1-885b-8d50088d51b4</rd:ReportID>
      <rd:ReportUnitType>Cm</rd:ReportUnitType>
    </Report>
        END_OF_RDLDATA
      }
    }
    
  • blackc2005blackc2005 Member Posts: 18
    midego wrote: »
    Why don't you try it, it works here.

    I did try it and it didn't work. Thanks.
  • ResolusResolus Member Posts: 40
    blackc2005 wrote: »
    Resolus wrote: »
    I've used https://mibuso.com/downloads/ean-8-13-code-39-128-barcode-creator-v1.5 and it worked great.

    I did have to change something to get black and white barcodes (instead of black and dark grey), but I can't entirely remember what it was.

    Would you happen to still be using this? Could you send me a FOB of the files? The one I downloaded doesn't seem to scan at all.

    I'm sorry for the delayed response.
    I'll send you a txt version.
  • blackc2005blackc2005 Member Posts: 18
    ftornero wrote: »
    Hello @blackc2005

    you can use a DLL from ZXing and get a code128 image from the code you need to print

    Dumb question but where do you get a DLL? I have googled and can only seem to find the github project.
  • ftorneroftornero Member Posts: 524
    Hello @blackc2005 ,

    This is the link to the DLL

    https://github.com/micjahn/ZXing.Net/releases

    Regards
  • blackc2005blackc2005 Member Posts: 18
    ftornero wrote: »
    Hello @blackc2005 ,

    This is the link to the DLL

    https://github.com/micjahn/ZXing.Net/releases

    Regards

    Thanks... I wonder if maybe it's because I'm on NAV 2013 but no matter which DLL I choose I get an error saying "Could not load type ''." I even tried to use 16.0.0
  • ftorneroftornero Member Posts: 524
    Hello @blackc2005,

    Where do you copy the DLL and what dotNet version ?

    The example I posted is runnign in a NAV2013 version.

    Regards
  • ftorneroftornero Member Posts: 524
    Other thing is that you need to select the new dotNet vars after the copy of the DLL in the add-in folders.

    For the latst version (0.16.4) and net2.0 it looks like this:
          BarCodeFormat@7141745 : DotNet "'zxing, Version=0.16.4.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60'.ZXing.BarcodeFormat";
          Options@7141746 : DotNet "'zxing, Version=0.16.4.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60'.ZXing.Common.EncodingOptions";
          BarCodeWriter@7141749 : DotNet "'zxing, Version=0.16.4.0, Culture=neutral, PublicKeyToken=4e88037ac681fe60'.ZXing.BarcodeWriter";
    

    Rergards
  • blackc2005blackc2005 Member Posts: 18
    YES! It's working. Thanks for the help.

    In case anyone in the future.. You have to right click on the DLL and click "Unblock" and then also move it into the addon's folder in the services directory.
Sign In or Register to comment.