Print Page | Close Window

FlattenFormField & EasEurope char

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3867
Printed Date: 02 May 24 at 2:21AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: FlattenFormField & EasEurope char
Posted By: PeterAnderko
Subject: FlattenFormField & EasEurope char
Date Posted: 03 Dec 20 at 12:10PM
Hi, help me please

i tried in Delphi 2010 this simply code to testing flattenformfield function


procedure TForm1.Button3Click(Sender: TObject);
var Okw,px:Integer;
begin
PDFDok:=TDebenuPDFLibrary1613.Create;
OKw:=PDFDok.UnlockKey(':-)');
if OKw<>1 then begin
   Showmessage('ERROR');
   Exit;
   end;
 PDFDok.SetPageSize('A4');
 PDFDok.SetOrigin(1);
 PDFDok.SetMeasurementUnits(0);
 PDFDok.NormalizePage(1);
 PDFDok.SetLineWidth(0.3);

PDFDok.LoadFromFile(AdresarExe+'POZ_2019.pdf','');   // this file contain formfield
PDFDok.CombineContentStreams;
PDFDok.FindFonts;

// I select formfield with index=8,  realy existing in POZ_2019.pdf
px:=8;
PDFDok.SetFormFieldValue(px,'Pľuščeňko');

PDFDok.SetNeedAppearances(1);
okw:=PDFDok.FlattenFormField(px);
if OKw<>1 then begin
   Showmessage('ERROR');
   Exit;
   end;

PDFDok.SaveToFile(ExtractFilePath(Application.exeName)+'OutPutForm.PDF');
end;


formfield is succesfully flattened 
the problem is that char ľ č ň  is replaced to space.
I tried a lot tricks and function from quickPDF - zerro effect
see picture:


Please help me someone Cry





Replies:
Posted By: Ingo
Date Posted: 03 Dec 20 at 7:33PM
Hi Peter,

you're using FindFonts and do nothing with the result?
Seems the standard font which QuickPDF is used doesn't support unicode...
Not all fonts are able to show all characters - so you have to select the right one ;-)
Here's a link to a thread from a user who had the same prob with greek characters:
http://www.quickpdf.org/forum/filling-form-fields-with-greek-letters_topic2207.html

Cheers and welcome here,
Ingo



-------------
Cheers,
Ingo



Posted By: PeterAnderko
Date Posted: 04 Dec 20 at 7:44AM
Hi Ingo,

tahnks for your response.

I upgrade my testing program with AddTrueTypeSubsettedFon:


procedure TForm1.Button3Click(Sender: TObject);
var Okw,px,fid,ffid:Integer;
begin
PDFDok:=TDebenuPDFLibrary1613.Create;
OKw:=PDFDok.UnlockKey(':-');
if OKw<>1 then begin
   Showmessage('ERROR');
   Exit;
   end;
 PDFDok.SetPageSize('A4');
 PDFDok.SetOrigin(1);
 PDFDok.SetMeasurementUnits(0);
 PDFDok.NormalizePage(1);
 PDFDok.SetLineWidth(0.3);

PDFDok.LoadFromFile(AdresarExe+'POZ_2019.pdf','');   // this file contains form fields
PDFDok.CombineContentStreams;

text:='ABCČDĎEÉFGHIÍJKLĽĹMNŇOÓÔPQRSŠTŤUÚVXYÝZŽabcčdďeéfghiíjklľĺmnňoóôpqrsštťuúvxyýyž1234567890-+.,;()" /\$&*@';
fid:=PDFDok.AddTrueTypeSubsettedFont('Aral77', text, 0);
PDFDok.SelectFont(fid);
ffid:=PDFDok.AddFormFont(fid);

// I select formfield with index=8,  realy existing in POZ_2019.pdf
px:=8;
PDFDok.SetFormFieldFont(px,ffid);
PDFDok.SetFormFieldValue(px,'Pľuščeňko');

PDFDok.SetNeedAppearances(1);
okw:=PDFDok.FlattenFormField(px);
if OKw<>1 then begin
   Showmessage('ERROR');
   PDFDok.Free;
   Exit;
   end;

PDFDok.SaveToFile(ExtractFilePath(Application.exeName)+'OutPutForm.PDF');
PDFDok.Free;
end;



This upgrade is one of the tricks I tried before I wrote here.
For the form field, they will keep the characters I need, but the "SetFormFieldFont" command will change the original font for the formfield.

In the original font, a special character spacing is set, which I need to fill in the form correctly.
Is it possible to achieve in some way that I set the character spacing for this formfield?
As the command does "DrawSpacedText"

thank you for answer. Thumbs Up







Posted By: Ingo
Date Posted: 05 Dec 20 at 3:53PM
the font is really named "Aral77"? ;-)



-------------
Cheers,
Ingo



Posted By: PeterAnderko
Date Posted: 06 Dec 20 at 4:18PM
This is a really inspiring question

The font name is OK.
But I thought about why you were asking me that.
I read the description of the AddTrueTypeSubsettedFont command again.
I found that this font is not installed in Windows \ fonts.

I did a procedure where I selected this font from my form using the "SaveFontToFile" command. I installed that font file in Windows and then I ran my original test program,
but it didn't help.Confused

Then I modified the "AddTrueTypeSubsettedFont" command as follows:
 
fid: = PDFDok.AddTrueTypeSubsettedFont ('Aral77', text, 2);

It worked.Smile

My formfield has preserved the letters č ľ ť ň ... and also maintains the spacing between the letters.

However, this has the disadvantage that I have to ensure that the appropriate font is installed in the program.


Peter.






Posted By: Ingo
Date Posted: 06 Dec 20 at 11:10PM
"...However, this has the disadvantage that I have to ensure that the appropriate font is installed in the program...." which you can check before by an individual routine. To check which fonts are installed on a system isn't a big prob...



-------------
Cheers,
Ingo



Posted By: PeterAnderko
Date Posted: 07 Dec 20 at 9:11AM
Yes, it's not complicated anymore.
If anyone later reads this thread, let them learn.

For example:


Function IsInstaledFont(MenoFontx:String):boolean;
begin
Result:=Screen.Fonts.IndexOf(MenoFontx)>= 0;
end;


Procedure InstalTTF(CestaMenox:PWideChar);
begin
AddFontResource(CestaMenox);
SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);
end;

Procedure UnInstalTTF(CestaMenox:PWideChar);
begin
RemoveFontResource(CestaMenox);
SendMessage(HWND_BROADCAST,WM_FONTCHANGE,0,0);
end;

thank you Ingo for moving me forwardThumbs Up


Posted By: Ingo
Date Posted: 07 Dec 20 at 8:19PM
Hi Peter :)

Thanks a lot - this will help other guys coming around here...

Cheers,
Ingo


-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk