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');
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.
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;
Is it compatible with these versions of Lazarus / FPC is not possible constantsNo, probably an:
to define in a class?
For a reference I would be very grateful.
{$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.
- 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!
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;
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)
Cyrillic characters are not displayed ((
Text(2,18,'АБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя');
in pdf looks as —¡—¢—£—⁄—¥—ƒ—§—¤—'—“—«—‹—›—fi—fl—?—–—†—‡—·—???—¶—•—‚—„