#1 2013-03-17 01:23:36

Musef
Member
Registered: 2013-03-17
Posts: 4

Bug: Can' t Show readable text after first page with TPdfDocumentGDI

After run this code

procedure TForm1.Button2Click(Sender: TObject);
var i,j: Integer;
begin
  with TPdfDocumentGDI.Create do
  try
    for j := 0 to 2 do
    begin
         AddPage;

         VCLCanvas.Font.Assign(Label1.Font); // Try any font like Arial,Tahoma ....
         VCLCanvas.Font.Size:=VCLCanvas.Font.Size+j*2;
         UseUniScribe := true;

         VCLCanvas.TextOut(100,500, 'بسم الله الرحمن الرحيم'); //This is Arabic Text Font
    end;

    UseUniScribe := true;
    SaveToFile('testunicode_GDI.pdf');
    ShellExecute(Handle,nil,'testunicode_GDI.pdf',nil,nil,SW_SHOWNORMAL);
  finally
    Free;
  end;

end;

First page show arabic font fine

but all other pages has un-readable font

I think the problem com from

Line  =8228
EnumEnhMetaFile(fDoc.FDC,MF.Handle,@EnumEMFFunc,E,R);

but

Other way can work perfect
like this source

procedure TForm1.Button3Click(Sender: TObject);
var   i,j: Integer;
begin
  with TPdfDocument.Create do
  try
    for j := 0 to 2 do
    begin
         AddPage;
         UseUniScribe := true;

         Canvas.SetFont('Microsoft sans serif',12,[fsItalic,fsBold]); // Try any font like Arial,Tahoma ....
         Canvas.BeginText;
         Canvas.MoveTextPoint(100,500);

         Canvas.ShowText('بسم الله الرحمن الرحيم', True); //This is Arabic Text

         Canvas.EndText;
    end;
    SaveToFile('testunicode.pdf');
    ShellExecute(Handle,nil,'testunicode.pdf',nil,nil,SW_SHOWNORMAL);
  finally
    Free;
  end;


end;

thanks

Offline

#2 2013-03-17 08:37:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Bug: Can' t Show readable text after first page with TPdfDocumentGDI

Did you retrieve the latest unstable version from http://synopse.info/fossil/wiki?name=Get+the+source ?

Which version of Delphi are you using?
An Unicode one should be better, here...

I suspect you should better set UseFontFallBack := true if the font does not include arabic glyphs.

Offline

#3 2013-03-17 10:36:54

Musef
Member
Registered: 2013-03-17
Posts: 4

Re: Bug: Can' t Show readable text after first page with TPdfDocumentGDI

Thank you very much for your fast response


My test is in Delphi XE3

Unit Name "SynPdf.Pas" version 1.18

and i already try
      set  UseFontFallBack := true
but nothing happening



Please remember my problem is only in next pages not in first one.
I do not have any problems in first Page.




Pdf File show in first page
shape 1 :

بسم الله الرحمن الرحيم

and that is good

and showing something Like this  (I copy this from PDF file)
in other pages
shape 2 :

š∏&Ò´Ê=Ž¨&Ò´Ê=∂´´Ê=š*!

and that is bad and no one can read this
this is not a language



I think when calling

FCanvas.RenderMetaFile

it has different source structure for processing next pages than first page
only in case "UseUniScribe := true"

ab wrote:

Did you retrieve the latest unstable version from http://synopse.info/fossil/wiki?name=Get+the+source ?

My answer is No

Offline

#4 2013-03-17 13:16:09

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Bug: Can' t Show readable text after first page with TPdfDocumentGDI

AFAIK UseUniscribe is global, so it should not make any difference with the page...

Please try with the latest version from our source code repository.
Some fixes are included, since the one you are using.

Offline

#5 2013-03-17 15:53:25

Musef
Member
Registered: 2013-03-17
Posts: 4

Re: Bug: Can' t Show readable text after first page with TPdfDocumentGDI

Many Thanks!! for your fast response.
Please be patient

This not "AFAIK" !!
of course I get latest version from your source code repository

please run my example
then see what i am tooking about
this is real and very real
I like your PDF tools  and I see its very smart tools
but this problem stop me .

Example :

procedure TForm1.Button2Click(Sender: TObject);
var i,j: Integer;
begin
  with TPdfDocumentGDI.Create do
  try
    for j := 0 to 2 do
    begin
         AddPage;

         VCLCanvas.Font.Assign(Label1.Font); // Try any font like Arial,Tahoma ....
         VCLCanvas.Font.Size:=VCLCanvas.Font.Size+j*2;
         UseUniScribe := true;

         VCLCanvas.TextOut(100,500, 'بسم الله الرحمن الرحيم'); //This is Arabic Text Font
    end;

    UseUniScribe := true;
    SaveToFile('testunicode_GDI.pdf');
    ShellExecute(Handle,nil,'testunicode_GDI.pdf',nil,nil,SW_SHOWNORMAL);
  finally
    Free;
  end;

end;

I know UseUniscribe is global
but the problem come from
TPdfDocumentGDI technique

I already test many copies and with same Problem

Offline

#6 2013-03-17 18:15:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Bug: Can' t Show readable text after first page with TPdfDocumentGDI

Thanks to your code, I was able to reproduce the problem.

There was a unexpected GDI font object unselection during printing.

The following commit seems to fix this issue:
http://synopse.info/fossil/info/07289c1fcd

Thanks for the feedback!

Offline

#7 2013-03-17 18:41:47

Musef
Member
Registered: 2013-03-17
Posts: 4

Re: Bug: Can' t Show readable text after first page with TPdfDocumentGDI

Many Thanks!! .

It work perfect with All Right to left language now

Thanks again

Offline

Board footer

Powered by FluxBB