Lazarus

Announcements => Third party => Topic started by: jepafi on June 08, 2012, 10:06:06 pm

Title: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: jepafi on June 08, 2012, 10:06:06 pm
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.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: otorres on June 08, 2012, 11:46:04 pm
Amazing, Thanks =)
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Robot on June 09, 2012, 04:16:39 am
i have been searching for this kind of component.
many thanks.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Leledumbo on June 09, 2012, 05:53:06 am
OnDownloading
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: exdatis on June 09, 2012, 08:48:19 am
   Great job! Thanks!  :)
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: ludob on June 09, 2012, 11:18:33 am
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.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: jepafi on June 09, 2012, 02:54:24 pm
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

Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: jepafi on June 09, 2012, 02:57:31 pm
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.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: jepafi on June 09, 2012, 03:48:08 pm
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;

...
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: DirkS on June 09, 2012, 09:16:33 pm
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.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: jepafi on June 09, 2012, 10:48:13 pm
Thanks Dirk. When you have time, I will better organize the files.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: jepafi on June 10, 2012, 03:48:03 pm
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
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: martinrame on July 14, 2012, 08:38:44 pm
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?.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Bernd_G on July 18, 2012, 09:21:30 pm
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
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: herux on July 19, 2012, 03:59:45 am
Great thanks  :D
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Leledumbo on July 19, 2012, 09:06:51 am
Quote
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.
No, probably an:
Code: [Select]
{$IF FPC_FULLVERSION < 20600}
  {$ERROR FPC 2.6.0 or greater required!}
{$ENDIF}
Would be good. Here (http://wiki.freepascal.org/FPC_New_Features_2.6.0#Better_support_for_Delphi-compatible_classes)'s the reference.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: velissariouc on July 19, 2012, 10:28:22 am
As an alternative solution there is the Haru library http://libharu.org/wiki/Downloads#Windows_Binaries
It is writen in C so I guess it's fast and gives pascal files with the external declaration of the C functions.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Blestan on July 19, 2012, 11:13:19 am
Constants definitions in the class are not essential for the code to run ...
As i mentioned in an early post i'm rewriting the code of the lib because it's very very poorly ported from php ... so i day or to i will post it on github
it should run on most fpc versions
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: martinrame on July 21, 2012, 08:36:34 pm
Hi Blestan, did you create an GitHub account to see your code?.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: GioFer on November 14, 2012, 03:14:29 pm


- New method to create Code25 barcodes for bank bills (see example);

First of all.......

Thank you för the wonderful job!

Second.......

Are you going to implement BarCode128?

They are the standard at our hospitals here in Sweden.

Best regards!
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Pierre on February 09, 2013, 12:18:57 am
Hi,

Great job :)

Just some remarks:
- in order to override the header function you need to add "virtual" in the declaration
  =>  procedure Header; virtual;
- the same for the footer  =>  procedure Footer; virtual;
- There is a small bug in SetY. "if (cpY >= 0) then"  must be replace with "if (vY >= 0) then".  With this modification it's possible to use a negative value for Y.

Is it possible to change the line type? It seems that it's not possible...

Pierre
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Pierre on February 09, 2013, 12:00:06 pm
One more thing.

Replace "procedure AliasNbPages(vAlias: string = '/{nb/}');" by "procedure AliasNbPages(vAlias: string = '{nb}');"

"/" isn't necessary. This is a PHP constraint. Like that you can use "{nb}" as the default alias for the total number of page.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Pierre on February 09, 2013, 12:50:02 pm
I have the answer for my question about changing the style of lines. I found the solution in FPDF website (code from yukihiro_o converted by me).
Add the following code to the library:
Code: [Select]
Interface:
Procedure SetDash(black: double = 0.0; white:double = 0.0);

Code:
Procedure TJPFpdf.SetDash(black: double; white:double);
Var s:string;
begin
  if(black<>0) then
    s:=format('[%.3F %.3F] 0 d',[black*pgk,white*pgk],TPDFFormatSetings)
  else
    s:='[] 0 d';
  _out(s);
end;


example of use:
SetDash(0.1,0.2);
Draw the next lines with small dash.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: nomorelogic on November 16, 2013, 11:40:11 am
Compiling progjpfpdf.lpr using heaptrc, I've found 2 lacks of memory in libjpfpdf.

So I've patched libjpfpdf (search for 'nomorelogic' in attachment to find 2 patches).

I wanted to suggest this patch in https://github.com/jepafi/Free-JPDF-Pascal (https://github.com/jepafi/Free-JPDF-Pascal), but if I understand it, to do this I should do a fork on git!?  :o
Title: GetStringWidth broken?
Post by: kpeters58 on January 12, 2014, 05:34:55 am
It seems to me that GetStringWidth is broken in V1.33 (Of course, there is always a chance that there's something I didn't quite get...)

Can someone confirm this?

Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: eldonfsr on March 16, 2014, 09:42:59 pm
I Compile this lib but send me a error UTF8toUTF16 not foun some body has a new version wich include this function.


Thanks.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Blestan on March 17, 2014, 08:04:18 am
just include lazuft8 unit in the uses ....

Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: eldonfsr on March 18, 2014, 04:00:11 am
Thanks for your replay but dosn't work i checked PDFLIb folder don exists any file with such name y send me massage can't find lazuft8.

lazutf8 is not part of lazarus?

thanks.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: engkin on March 18, 2014, 08:21:26 am
You should find UTF8toUTF16 in one or both of LCLProc and LazUTF8.
LCLProc: Lazarus\LCL\lclproc.pas
LazUTF8: Lazarus\components\lazutils\lazutf8.pas
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: kitsaros on May 10, 2014, 12:02:21 pm
do you have any luck using unicode ?
Using SetUTF8(true);   does not seem to work :(
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: kitsaros on May 12, 2014, 10:43:09 pm
It's me again .
I have managed to modify this library in order to "accept" CP1250 CP1251 CP1252 CP1253 codepages .
I have made the "Greek" version of the demo.
The bad news are that sumatra pdf does not recognize the Greek characters [and i dont know why] .
If you use the CP1250 codepage recognizes the polish characters ĄąŻżŹźŚśĘęĆćŃńÓóŁł .
On PDF-XChange Viewer / fox reader and on CoolPDFReader all works fine.
I am based on this trick : http://www.tv.com.pl/stepbystep/pdfinclude/

The modded library can be found here :
https://onedrive.live.com/redir?resid=1024B4FF999DA333!152&authkey=!AITy0grJAhtlPy4&ithint=file%2c.zip 

You are free to mod this lib as well.

Let me know what fdo you think about this "hack"
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: kpeters58 on May 29, 2014, 12:51:48 am

Noticed the bug below - see last line of posted code marked with my initials ...

Code: [Select]
procedure TJPFpdf.Writer(const vHeight: Double; vText: String);
var
  vfamily: TPDFFontFamily;
  vstyle:  TPDFFontStyle;
  vw:      Extended;
  vwmax:   Extended;
  vs:      String;
  vnb:     Integer;
  vnl:     Integer;
  vl:      Integer;
  vj:      Integer;
  vi:      Integer;
  vsep:    Integer;
  vc:      Char;
  fUTF8:   Boolean;

begin
  fUTF8 := False;
  if (pUTF8) then
  begin
    vText := UTF8ToUTF16(vText);
    SetUTF8(False);
    fUTF8 := True;
  end;
  //Output text in flowing mode
  vfamily := Self.cFontFamily;
  vstyle  := Self.cFontStyle;
  if (vfamily in [ffCourier, ffSymbol, ffZapfdingbats]) then
    vstyle := fsNormal;
  //
  vw    := Self.dw - Self.rMargin - Self.cpX;
  vwmax := (vw - 2 * Self.cMargin) * 1000 / Self.cFontSize;
  vs    := StringReplace(vText, #13, '', [rfReplaceAll]);
  vnb   := Length(vs);
  vsep  := -1;
  vi    := 1;// KPKPKP  was 0 - which lead to range error (when range checking was on)   
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: NumberCruncher on January 31, 2016, 03:12:16 pm
Hi, if you insert multiple (different) pictures into the same page, all pictures will be the same. A possible way to fix it:

Code: Pascal  [Select][+][-]
  1. procedure TJPFpdf.Image(vFile: string; vX: double; vY: double;
  2.   vWidth: double; vHeight: double);
  3. var
  4.   i, imgcounter: integer;
  5.   img: TJPImageInfo;
  6.   flag: boolean;
  7. begin
  8.   imgcounter:=0;
  9.   //Put an image on the page
  10.   flag := False;
  11.   if (Length(Self.pImages) > 0) then
  12.     for i := 0 to Length(Self.pImages) - 1 do
  13.     begin
  14.       if (Self.pImages[i].filePath = vFile) then
  15.       begin
  16.         flag := True;
  17.         img := Self.pImages[i];
  18.         imgcounter:=i+1;
  19.         break;
  20.       end;
  21.     end;
  22.   if not (flag) then
  23.   begin
  24.     //First use of image, get info
  25.     SetLength(Self.pImages, Length(Self.pImages) + 1);
  26.     Self.pImages[Length(Self.pImages) - 1].imgSource := TMemoryStream.Create;
  27.     Self.pImages[Length(Self.pImages) - 1] := GetInfoImage(vFile);
  28.     Self.pImages[Length(Self.pImages) - 1].n := Length(Self.pImages);
  29.     Self.pImages[Length(Self.pImages) - 1].filePath := vFile;
  30.     img := Self.pImages[Length(Self.pImages) - 1];
  31.     imgcounter:=Length(Self.pImages);
  32.   end
  33.   else
  34.   //Automatic width or height calculus
  35.   if (vWidth = 0) then
  36.     vWidth := StrToFloat(FloatToStrF((vHeight * img.w / img.h), ffNumber,
  37.       14, 2, TPDFFormatSetings), TPDFFormatSetings);
  38.   if (vHeight = 0) then
  39.     vHeight := StrToFloat(FloatToStrF((vWidth * img.h / img.w), ffNumber,
  40.       14, 2, TPDFFormatSetings), TPDFFormatSetings);
  41.   _out('q ' + FloatToStr(vWidth) + ' 0 0 ' + FloatToStr(vHeight) +
  42.     ' ' + FloatToStr(vX) + ' -' + FloatToStr(vY + vHeight) + ' cm /I' +
  43.     IntToStr(imgcounter) + ' Do Q');
  44. end;
  45.  

Regards
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: useroflazarus on February 20, 2016, 08:07:51 pm
Cyrillic characters are not displayed ((

Code: Pascal  [Select][+][-]
  1. Text(2,18,'АБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя');

in pdf looks as —¡—¢—£—⁄—¥—ƒ—§—¤—'—“—«—‹—›—fi—fl—?—–—†—‡—·—???—¶—•—‚—„
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Graeme on February 22, 2016, 10:43:29 am
@useroflazarus:  I have never used JPDF, but was just wondering. Did you embed a font and select that font to display the Cyrillic text? Obviously not all fonts can display all glyphs.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: jujibo on February 22, 2016, 12:05:25 pm
Cyrillic characters are not displayed ((

Code: Pascal  [Select][+][-]
  1. Text(2,18,'АБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя');

in pdf looks as —¡—¢—£—⁄—¥—ƒ—§—¤—'—“—«—‹—›—fi—fl—?—–—†—‡—·—???—¶—•—‚—„

AFAIK, not supported.

From README:

- Support the main fonts (Helvetica [Arial], Times, Courier, Symbol and Zapfdingbats);
- Support the styles (bold, italic and/or underline);

Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: useroflazarus on February 22, 2016, 02:05:06 pm
hmm, now characters looks as РђР‘Р’Р“Р”Р•РЃР–Р—Р˜РљР›РњРќРћРџР РЎРўРЈР¤РҐР¦Р§РЁР©РЄР«Р¬Р-ЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя

source code:

Code: Pascal  [Select][+][-]
  1.        //Page 1
  2.        AddPage(poDefault,CP1251);
  3.        SetFont(ffTimes,fsNormal,8,CP1251);
  4.        Text(2,25,'АБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя');
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Jan_ on March 01, 2016, 05:36:57 pm
Hey,

got some strange thing here:
Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. uses classes, sysutils,libjpfpdf;
  4.  
  5. var
  6.   i:integer;
  7.    pdfdoc: TJPFpdf;
  8. begin
  9.  
  10.      pdfdoc := TJPFpdf.Create;
  11.      for i:=0 to 100 do
  12.      begin
  13.  
  14.        pdfdoc.AddPage();
  15.        pdfdoc.SetFont(ffTimes,fsNormal,8);
  16.        pdfdoc.Text(20,30,' '+inttostr(i)+' ');
  17.      end;
  18.      pdfdoc.SaveToFile('liste.pdf');
  19.      pdfdoc.Free;
  20. end.
  21.  

when i run the program a pdf with 101 pages is created. only on page 1 stands 0
all other pages are empty.
what had i did wrong?
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: Jan_ on March 02, 2016, 09:52:15 am
i found it.

There is a bug, if you using the same Font over the pages.
just change to another font and back, this worked for me.:
Code: Pascal  [Select][+][-]
  1.        pdfdoc.SetFont(ffTimes,fsBold,8);
  2.        pdfdoc.SetFont(ffTimes,fsNormal,8);



Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. uses classes, sysutils,libjpfpdf;
  4.  
  5. var
  6.   i:integer;
  7.    pdfdoc: TJPFpdf;
  8. begin
  9.  
  10.      pdfdoc := TJPFpdf.Create;
  11.      for i:=0 to 100 do
  12.      begin
  13.  
  14.        pdfdoc.AddPage();
  15.        pdfdoc.SetFont(ffTimes,fsBold,8);
  16.        pdfdoc.SetFont(ffTimes,fsNormal,8);
  17.        pdfdoc.Text(20,30,' '+inttostr(i)+' ');
  18.      end;
  19.      pdfdoc.SaveToFile('liste.pdf');
  20.      pdfdoc.Free;
  21. end.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: useroflazarus on June 07, 2016, 03:00:52 pm
Hello. Some fixes for the Cyrillic encoding.
fixed functions (procedures):
TJPFpdf.Text
TJPFpdf._enddoc
TJPFpdf.Cell
in the attachment an example and source code.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: PhilLu on December 25, 2017, 11:20:11 am
Hello,
is there a way to convert pdf to tif?
Thanks,
Phil

Have a nice X'mas  :P
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: useroflazarus on March 14, 2018, 07:56:18 pm
Compression does not work correctly with fpc 3.1.1.
Title: Re: "Free JPDF Pascal" STABLE VERSION 1.0 - Reports in PDF - Desktop, Mobile and CGI
Post by: jcmontherock on November 05, 2018, 06:13:06 pm
Thanks to useroflazarus for your update. Under Windows I add some more used accented letters for CP1252. It works fine:

Code: Pascal  [Select][+][-]
  1.    end else if Self.pFonts[vu].CodePage = CP1252 then begin
  2.       _newobj();
  3.       _out('<<');
  4.       _out('/Type /Encoding');
  5.       _out('/BaseEncoding /WinAnsiEncoding');
  6.       _out('/Differences [');
  7.       _out('224 /agrave');
  8.       _out('226 /acircumflex');
  9.       _out('228 /adiaeresis');
  10.       _out('231 /ccedilla');
  11.       _out('232 /egrave');
  12.       _out('233 /eacute');
  13.       _out('234 /ecircumflex');
  14.       _out('235 /ediaeresis');
  15.       _out('239 /idiaeresis');
  16.       _out('246 /odiaeresis');
  17.       _out('249 /ugrave');
  18.       _out('252 /udiaeresis');
  19.       _out(']');
  20.       _out('>>');
  21.       _out('endobj');
  22.  
TinyPortal © 2005-2018