Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Formfield-Font |
Post Reply
|
| Author | |
Josef Gschwendtner
Beginner
Joined: 23 Mar 16 Location: Germany Status: Offline Points: 14 |
Post Options
Thanks(0)
Quote Reply
Topic: Formfield-FontPosted: 19 Apr 16 at 4:01PM |
|
Hi,
below I inserted some code, showing how we create formfields. Everything works except the font-setting does not work correct. Some field have the correct font, some have not. It would be great if somebody would look over the code (the bold sections) and maybe tell us how to make it better ![]() Thank you very much, Josef Gschwendtner procedure TfmMain.GeneratePDFDocument; var PDF: TDebenuPDFLibrary; begin PDF := TDebenuPDFLibrary.Create; UnlockResult := PDF.UnlockKey(cDebenuLicenseKey); try if (UnlockResult = 1) then begin PDF.LoadFromFile('C:\Temp\Template.pdf', ''); // Set the paper size PDF.SetPageSize('A4'); // Set the origin to the top-left corner PDF.SetOrigin(1); // Set the measurement units to millimetres PDF.SetMeasurementUnits(1); AddPDFFormField(PDF, 'Field1', 'Field 1', 1, qrffctTextbox, 20, 28, 50, 5.5, 'Arial', 10, clBlack, [fsBold]); AddPDFFormField(PDF, 'Field2', 'Field 2', 1, qrffctTextbox, 20, 48, 50, 5.5, 'Arial', 10, clBlack, [fsBold]); // Compress the contents of the file PDF.CompressContent; PDF.SaveToFile('C:\Temp\Test.pdf'); end; finally PDF.Free; end; end; procedure TfmMain.AddPDFFormField(APDF: TDebenuPDFLibrary; AName, AValue: String; APageNumber: Integer; AControlType: TQrffControlType; ALeft, ATop, AWidth, AHeight: Double; AFontName: String; AFontSize: Integer; AFontColor: TColor; AFontStyle: TFontStyles; AAlign: TQrsAlign; AFlatten, AReadOnly, AMultiLine, ATransparent, AShowBorder: Boolean; ABackgroundColor, ABorderColor: TColor; InTestMode: Boolean); var vFieldIndex, vFontID, vFormFontID, vAlign: Integer; vColor: TRGBTriple; begin if (Trim(AFontName) = '') then AFontName := 'Arial'; if (fsBold in AFontStyle) and (fsItalic in AFontStyle) then AFontName := AFontName + ' [BoldItalic]' else if (fsBold in AFontStyle) then AFontName := AFontName + ' [Bold]' else if (fsItalic in AFontStyle) then AFontName := AFontName + ' [Italic]'; vFontID := APDF.AddTrueTypeFont(AFontName, 0); vFormFontID := APDF.AddFormFont(vFontID); if (AControlType = qrffctCheckbox) then vFieldIndex := APDF.NewFormField(AName, 3) else vFieldIndex := APDF.NewFormField(AName, 1); // Position APDF.SetFormFieldBounds(vFieldIndex, ALeft, ATop, AWidth, AHeight); APDF.SetFormFieldPage(vFieldIndex, APageNumber); // Pagenumber APDF.SetFormFieldFont(vFieldIndex, vFormFontID); // Font APDF.SetFormFieldTextSize(vFieldIndex, AFontSize); // FontSize vColor := RGBValue(AFontColor); APDF.SetFormFieldColor(vFieldIndex, (vColor.rgbtRed/255), (vColor.rgbtGreen/255), (vColor.rgbtBlue/255)); // FontColor // Alignment ( 0 = Left, 1 = Center, 2 = Right) vAlign := 0; case AAlign of qaLeftJustify : vAlign := 0; qaCentered : vAlign := 1; qaRightJustify : vAlign := 2; end; APDF.SetFormFieldAlignment(vFieldIndex, vAlign); if InTestMode then begin vColor := RGBValue(clSilver); APDF.SetFormFieldBackgroundColor(vFieldIndex, (vColor.rgbtRed/255), (vColor.rgbtGreen/255), (vColor.rgbtBlue/255)); APDF.SetFormFieldBorderColor(vFieldIndex, (vColor.rgbtRed/255), (vColor.rgbtGreen/255), (vColor.rgbtBlue/255)); APDF.SetFormFieldBorderStyle(vFieldIndex, 1, 0, 0, 0); end else begin vColor := RGBValue(ABackgroundColor); APDF.SetFormFieldBackgroundColor(vFieldIndex, (vColor.rgbtRed/255), (vColor.rgbtGreen/255), (vColor.rgbtBlue/255)); if AShowBorder then begin vColor := RGBValue(ABorderColor); APDF.SetFormFieldBorderColor(vFieldIndex, (vColor.rgbtRed/255), (vColor.rgbtGreen/255), (vColor.rgbtBlue/255)); APDF.SetFormFieldBorderStyle(vFieldIndex, 1, 0, 0, 0); end; end; if (AControlType = qrffctTextbox) and AMultiLine then APDF.SetFormFieldTextFlags(vFieldIndex, 1, 0, 0, 0, 0); if (AControlType = qrffctCheckbox) then begin APDF.SetFormFieldCheckStyle(vFieldIndex, 1, 1); // Style = Check, Centred if AnsiSameText(AValue, 'T') then APDF.SetFormFieldValue(vFieldIndex, 'Yes') else APDF.SetFormFieldValue(vFieldIndex, 'No'); end else APDF.SetFormFieldValue(vFieldIndex, AValue); if AReadOnly then APDF.SetFormFieldReadOnly(vFieldIndex, 1); if AFlatten then APDF.UpdateAndFlattenFormField(vFieldIndex); end; |
|
![]() |
|
Ingo
Moderator Group
Joined: 29 Oct 05 Status: Offline Points: 3530 |
Post Options
Thanks(0)
Quote Reply
Posted: 19 Apr 16 at 6:56PM |
|
Hi,
"... 20, 28, 50, 5.5, 'Arial', 10, clBlack, [fsBold]); ..." if you write code like the line above, you're using the font "Arial" - nothing more. Arial is not the standard - so you have to add this font. If you need - for example - the bold Arial font you have to add the font-file "C:\Windows\Fonts\arialbd.ttf". The real font name is "Arial Bold". First you should try to add the font with the correct name... then you should select it to make it active... and then you can use it. If you don't know the real font names you should call (in windows): System control -> All System control elements -> Fonts On the font file you can choose the properties and the details and there you can see the correct font name. |
|
|
Cheers,
Ingo |
|
![]() |
|
Josef Gschwendtner
Beginner
Joined: 23 Mar 16 Location: Germany Status: Offline Points: 14 |
Post Options
Thanks(0)
Quote Reply
Posted: 20 Apr 16 at 4:21PM |
|
Hi,
could anybody please write down 10 lines of real code how to insert two formfields: First field with font "Arial", second field with "Arial Bold" We are only interested on the code needed for setting the font. Your help is very appreciated. Josef Gschwendtner |
|
![]() |
|
Josef Gschwendtner
Beginner
Joined: 23 Mar 16 Location: Germany Status: Offline Points: 14 |
Post Options
Thanks(0)
Quote Reply
Posted: 20 Apr 16 at 4:29PM |
|
Hi,
you write "Arial" is not the standard. So what would be the standard? Thank you, Josef |
|
![]() |
|
Ingo
Moderator Group
Joined: 29 Oct 05 Status: Offline Points: 3530 |
Post Options
Thanks(0)
Quote Reply
Posted: 20 Apr 16 at 7:23PM |
|
Hi Josef,
standard are the 14 (or so...) fonts inside the library. |
|
|
Cheers,
Ingo |
|
![]() |
|
Ingo
Moderator Group
Joined: 29 Oct 05 Status: Offline Points: 3530 |
Post Options
Thanks(0)
Quote Reply
Posted: 20 Apr 16 at 7:41PM |
|
Hi Josef,
why you don't want to read the sample on page 32 of the developer guide?! http://www.debenu.com/docs/pdf_library_developer_guide/debenu_quick_pdf_library_10_developer_guide.pdf |
|
|
Cheers,
Ingo |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store