Develop PDF417 with Delphi

Asked

Viewed 241 times

2

Good afternoon.
I use an old report generator for Delphi XE7 (pReport). I have the source code of it, and I’ve already made many changes to it. Now one more challenge, I need to include a new type of Barcode in the generator. It would be the PDF417.
Does anyone have any idea how to do that?

From what I saw in the report generator project, it uses the Vgr_barcode, which would be a free but no longer maintained library. This library was made by Andreas Schmidt but when generating 2D barcodes, the library has been discontinued. Does anyone use this library? If so, it has already evolved?
I hope I was specific in the question.

  • Your question is a bit wide. Do you already know how to generate the code? Can you draw the code? Can you calculate the pattern? It would be important to [Dit] the question and make clear the exact doubt, with the specific difficulty it is having (preferably with the current state of the respective code).

  • A good outline of the pattern is: http://www.morovia.com/manuals/PDF417-Font-ware-Writer-SDK-4/chapter.overview.php

  • In that case, I suggest you find a specific component for barcode generation, and use it within your component. The correct thing would be for you to abandon this framework, and move on to a newer one. Never make changes to a component that is not yours, so create a base class of that component and make your edits there. Imagine if you had to update these guys today?

  • So @Victorzanella tried not to touch the component, but I have over 1000 reports generated in this generator, and many are client specific. Using a new generator is almost impossible as I would have to convetere each report and on each customer (I have tried to do but without much success).

  • @Bacco In fact the answer is no to all your questions. Hence the question a little wide. In the generator I use, only 1D barcodes are accepted.

  • In this case, I suggest you find another lib that generates the code in the desired format. Having this in hand, just implement this functionality within this current generator. Basically, you will inject an extension into what you already have today, what do you think of the idea ? If you agree we can sequence with codes.

  • @Victorzanella I fully agree, I think this is really the way out. I’ve found the lib you mentioned Pdf417lib. I’m trying to implement it within the generator, but with difficulties, it’s another standard... The report generator I use can be found in pReport. Thank you.

  • Come on, it’s just a short while before I can give you an answer. I installed this lib, and it worked perfectly. What’s been your difficulty in including this guy inside your report generator ?

  • I will try to explain the difficulty, in the report generator I can put objects on the page. When I insert a BarCode, I select the type (EAN13, Code39 etc), I was able to insert the PDF417. Looking at the source code of the generator, I discovered where the image is generated mounted with the barcode, and at this point I’m not getting inject the lib code you downloaded.

Show 4 more comments

1 answer

4


Taking into account that just add the functionality of generating the barcode and format PDF417 with the "Pdf417lib", follows toturial:

No need to install dpk that comes along, unless you want to implement something in design time.

First step is to add in the project’s search path ( Ctrl+Shift+F11 ) the following directories:

...\pas417lib-master\vcl
...\pas417lib-master\src

Now follow the code of the implemented classes:

Barcodegenerator - Interface

unit BarcodeGenerator;

interface

uses
  Graphics;

type
  IBarcodeGenerator = interface
    ['{BDBF2DC5-29CB-413F-9920-579D4213B638}']

    function GetPdf417(AValue: String): TBitmap;    
  end;

implementation

end.

Barcodegeneratorimpl - Implementation

unit BarcodeGeneratorImpl;

interface

uses
  Graphics, PDF417Barcode, BarcodeGenerator;

type
  TBarcodeGeneratorImpl = class(TInterfacedObject, IBarcodeGenerator)

  private
    MyCodeBar: TPDF417BarcodeVCL;

  public
    constructor Create;
    destructor Destroy; override;   
    function GetPdf417(AValue: String): TBitmap;   
  end;

implementation

uses
  SysUtils;

{ THelperBarcodeGenerator }

constructor TBarcodeGeneratorImpl.Create;
begin
  MyCodeBar := TPDF417BarcodeVCL.Create(nil);
end;

destructor TBarcodeGeneratorImpl.Destroy;
begin
  FreeAndNil(MyCodeBar);
  inherited;
end;

function TBarcodeGeneratorImpl.GetPdf417(AValue: String): TBitmap;
begin
  MyCodeBar.Lines.Add(AValue);
  Result := MyCodeBar.Bitmap;
end;

end.

Now in this example, a normal Unit was created, with the visual part, a Tedit, a Timage and a Tbutton were added.

Example of use

unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
   Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    Image1: TImage;
    procedure Button1Click(Sender: TObject);    
  end;

var
  Form2: TForm2;

implementation

uses
  BarcodeGenerator, BarcodeGeneratorImpl;

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
var
  FBarcodeGenerator: IBarcodeGenerator;
begin    
  FBarcodeGenerator     := TBarcodeGeneratorImpl.Create;
  Image1.Picture.Bitmap := FBarcodeGenerator.GetPdf417(Edit1.Text);   
end;

end.

I believe that with the 2 Barcodegenerator and Barcodegeneratorimpl Units, it is easy to inject this function into your framework.

  • Vlw Zanella... today is no longer time.. but I believe it is the solution I needed. Thank you very much (again)!

  • If it doesn’t, says here, that we take a look.

  • I’m having trouble injecting the code into the report generator. Now I will abuse your good will, I need someone to exchange ideas about the report generator I commented a few days ago (pReport). If you can download and install it, it would be very helpful. Thank you very much. @Victor Zanella

  • First I will need the sources of this component, and after the changes you have customised on it. You can pass me this data?

  • All you need is in this Link Including a basic component installation tutorial. These fonts already have the changes I made. Thank you for your attention.

  • Dude, dpk tries to create files inside P:/disk. I don’t have P:/ disk and even creating, it will give more errors. Tell me which Unit you want to put the Generation of PDF417, that I mount something here.

  • Well, in mode Designer of the report I have the possibility to insert an object CodeBar. My interest is that this component is added in the list the option PDF417. This barcode is placed in the layout, then visualized (Preview) and finally printed when the user requests. I believe that the units are those which refer to Codebar. But I’m trying to do it another way, which would be to insert a Image and create the bar code on it, I think that was your original idea. If I can do it, I’ll let you know. Thank you.

  • OK, anything warns you

  • Very good, I used to create a documentation. Someone made a code to read PDF417 too?

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.