* * *

Author Topic: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI  (Read 47751 times)

jepafi

  • New member
  • *
  • Posts: 36
The library "Free JPDF Pascal" is written entirely in "Free Pascal" pure. It was created from the conversion of the FPDF library code written in PHP (http://www.fpdf.org).

You do not need the LCL. It can be used to generate PDF reports for Desktop Applications, Web CGI and / or Mobile.

Download: http://github.com/jepafi/Free-JPDF-Pascal

Resources:
- Support Image (JPG or JPEG, PNG, GIF and BMP);
- Support the main fonts;
- Various sizes of paper;
- Select unit of measure;
- Wrapping page or not;
- Text with all types of alignment;
- Power load a text file that is included in the PDF, with line breaks and page automatic (justified, left, right or center);
- Write free text (in any position on the sheet);
- Create tables with the Cell Method;
- Support for line color, background and text;
- Support for border line;
- Possibility to change the orientation (portrait or landscape) of the pages in the same document;
- Support compression (creates smaller PDF);
- Methods to draw rectangles and lines;
- Supports Headers and Footers (to use you need to create a child class, as well as the FPDF PHP);

New in this version:
- The method fpdf moved to Create;
- No need to call the Open after Create;
- Use enumerators in various methods (Gilson Nunes);
- Solved problem with the decimal point in Windows (Gilson Nunes);
- Reduced the number of IF's (from the FPDF) due to the use of enumerators;
- Some internal methods were removed because it became unnecessary;
- Use variable names more readable;
- Support for standard colors (cBlack, cSilver, cRed, etc.);
- Support underlined text (see example);
- New method SetRightMargin;
- New method SetUnderline;
- New method Writer (Write the same as FPDF), lets you change the font style in the same paragraph (only left alignment);
- New method to create Code25 barcodes for bank bills (see example);

Note: This version works with Ansi encoding. Thus, if the text or the file containing the text is in UTF8, use the UTF8ToAnsi to convert the text. This is only necessary if the text contains accents.

otorres

  • Jr. Member
  • **
  • Posts: 94
Amazing, Thanks =)

Robot

  • New member
  • *
  • Posts: 6
i have been searching for this kind of component.
many thanks.

Leledumbo

  • Hero Member
  • *****
  • Posts: 7970
  • Programming + Glam Metal + Tae Kwon Do = Me
OnDownloading

exdatis

  • Hero Member
  • *****
  • Posts: 668
    • exdatis
   Great job! Thanks!  :)

ludob

  • Hero Member
  • *****
  • Posts: 1173
Well done!

Suggestion for improvement: having to specify the line height in Writer, Cell and MultiCell and the size in SetFont is annoying. The ratio between font size and line height is typically fixed for a given font and document. A nice study can be found here https://docs.google.com/spreadsheet/ccc?key=0AsK4MoYiBVMldE12V3FJYk95YVRUZ18xNDJNOVRrSHc&hl=de#gid=0. To avoid proliferation of default values in methods I suggest
-adding a LineHeightFontSizeRatio property that is per default 1.5
-when vHeight is 0 in above methods, calculate the line height from this property.

A GetFont and SetFont that would use a to be defined font structure (including above LineHeightFontSizeRatio)  would also be helpful to manage the few fonts one typically uses in a document. The idea is to simplify font management as in:
Code: [Select]
var
  Title,Body:TJPFFont;
...
SetFont(ffTimes,fsBold,18);
LineHeightFontSizeRatio:=1.7;
GetFont(Title);
SetFont(ffHelvetica,fsNormal,12);
LineHeightFontSizeRatio:=1.5;
GetFont(Body);
...
SetFont(Title);
Cell(0,0,'This is the title');
SetFont(Body);
MultiCell(0,0,'This is the body');
Ln(0);
SetFont(Title);
Cell(0,0,'Title2');
SetFont(Body);
MultiCell(0,0,'This is body2');

If you want I can make a patch for this.

jepafi

  • New member
  • *
  • Posts: 36
If someone is having trouble downloading the library at GitHub, get the package at this link:

http://www.jpsoft.com.br/Free-JPDF-Pascal-1.0-Stable.zip


jepafi

  • New member
  • *
  • Posts: 36
Very cool your suggestion. I see the possibility of including it in a future release.

Well done!

Suggestion for improvement: having to specify the line height in Writer, Cell and MultiCell and the size in SetFont is annoying. The ratio between font size and line height is typically fixed for a given font and document. A nice study can be found here https://docs.google.com/spreadsheet/ccc?key=0AsK4MoYiBVMldE12V3FJYk95YVRUZ18xNDJNOVRrSHc&hl=de#gid=0. To avoid proliferation of default values in methods I suggest
-adding a LineHeightFontSizeRatio property that is per default 1.5
-when vHeight is 0 in above methods, calculate the line height from this property.

A GetFont and SetFont that would use a to be defined font structure (including above LineHeightFontSizeRatio)  would also be helpful to manage the few fonts one typically uses in a document. The idea is to simplify font management as in:
Code: [Select]
var
  Title,Body:TJPFFont;
...
SetFont(ffTimes,fsBold,18);
LineHeightFontSizeRatio:=1.7;
GetFont(Title);
SetFont(ffHelvetica,fsNormal,12);
LineHeightFontSizeRatio:=1.5;
GetFont(Body);
...
SetFont(Title);
Cell(0,0,'This is the title');
SetFont(Body);
MultiCell(0,0,'This is the body');
Ln(0);
SetFont(Title);
Cell(0,0,'Title2');
SetFont(Body);
MultiCell(0,0,'This is body2');

If you want I can make a patch for this.

jepafi

  • New member
  • *
  • Posts: 36
Problem is still giving the decimal separator in languages ​​that use a different character's point. If you have problems generating a PDF blank or invalid, esperimente include the line below before you instantiate the object:

...

  DefaultFormatSettings.DecimalSeparator := '.';
  JPFpdf1 := TJPFpdf.Create;

...

DirkS

  • Sr. Member
  • ****
  • Posts: 251
There's a couple of files in the repository which I would not expect to see there:
* progjpfpdf (example program binary)
* jpfpdfteste.pdf (output of the example program?)
* progjpfpdf.lps (Lazarus session file)

BTW: personally I would put the example stuff in a separate subdirectory.

Gr.
Dirk.

jepafi

  • New member
  • *
  • Posts: 36
Thanks Dirk. When you have time, I will better organize the files.

jepafi

  • New member
  • *
  • Posts: 36
New Version 1.1:
- Fixed problem with underlining of irregular size;
- Fixed problem with multicell underlined;
- Fixed problem with text smaller than a multicell line;

Link: http://github.com/jepafi/Free-JPDF-Pascal

martinrame

  • Jr. Member
  • **
  • Posts: 59
Hi, I'm starting to use your Free-JPDF-Pascal library in one of my programs, so far it looks very good!.

Now I'm trying to implement text-rotation by translating this script:
http://www.fpdf.org/en/script/script2.php

The result is this:

Code: [Select]
procedure TJPFpdf.Rotate(Ang: double; aX, aY: double);
var
  c: double;
  s: double;
  Cx: double;
  Cy: double;
  lRes: string;
begin
  if(aX = -1) then
    aX := Self.GetX;
  if(aY = -1) then
    aY := Self.GetY;
  if(Self.Angle <> 0) then
    _out('Q');
  Self.Angle := Ang; 
  if(Angle <> 0) then
  begin
    Self.Angle := Ang * (PI / 180);
    c := cos(Angle);
    s := sin(Angle);
    Cx := aX * Self.pgK;
    Cy := (Self.dH - aY) * Self.pgK;
    lRes := Format(
          'q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',
          [c, s, -s, c, cx, cy, -cx, -cy]
        );
    writeln(lRes);
    _out(lRes);
  end;
end;

As you can see, it more or less does the same as the PHP version, but I
can't translate correctly two variables:

this->k and this->h

I've translated this->k to Self.pgK and this->h to Self.dH, but the
results are wrong.

PHP Result:
q 0.70711 0.70711 -0.70711 0.70711 2834.65 -28.35 cm 1 0 0 1 -2834.65 28.35 cm

Pascal Result:
q 0.70711 0.70711 -0.70711 0.70711 283.46 274.96 cm 1 0 0 1 -283.46 -274.96 cm

Could you help me implementing this?.

Bernd_G

  • Newbie
  • Posts: 1
Hi,

first time an excuse for my bad English.
I probably have a fundamental problem with 'FreeJPDF'.
I work on Linux (Ubuntu 11.10), Lazarus 0.9.30-2build1 and FPC 2.4.4.
When compiling the unit 'libjpfpdf.pas' I get the error

libjpfpdf.pas (44,3) Fatal: Syntax error, "identifier" expected but "CONST" found

Part of the Unit:
..
..
38:} {TJPFpdf
39:
40: TJPFpdf = class
41: private
42:
43: public
44: const
45: $ {i} inc_fontes.inc
46: FPDF_VERSION = '1 .41 ';
47: var
..
..

Is it compatible with these versions of Lazarus / FPC is not possible constants
to define in a class?
For a reference I would be very grateful.

Greeting
Bernd
« Last Edit: July 19, 2012, 08:39:19 am by Bernd_G »

herux

  • Full Member
  • ***
  • Posts: 100
Great thanks  :D

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus