Page 1 of 1

Create form field to export PDF - llPDFLib

Posted: Fri Apr 28, 2017 5:01 pm
by haidomingo
An rvf document that contains tables and text like {*/SPXX/*} in few cell, this file rvf should be exported to pdf.
You have to search the text like {*/SPXX/*} inside the cells, get the text coordinate (Rect of Cell), store the coordinates, and delete the text {*/SPXX/*}.
At the time of export, you must create empty fields to be signed at the corresponding few cells:
create the signature field using the TPDFDigitalSignatureAnnotation.Create function to which the cell coordinates will be passed.
(for all {*/SPXX/*} result).
Can this be done?
Thanks

Re: Create form field to export PDF - llPDFLib

Posted: Sat Apr 29, 2017 8:22 am
by Sergey Tkachenko
Ideas:

1) Search for fields, create a list of cells containing them. Remove fields. It must be done before formatting and drawing, because removing text may change positions of objects.
2) Assign OnDrawBorder event to tables. Draw nothing, but remember coordinates for cells that in the list created on the step 1.

Re: Create form field to export PDF - llPDFLib

Posted: Sat Apr 29, 2017 9:22 am
by haidomingo
This code find all

Code: Select all

SetLength(Firme, 0);
  while ActiveEditor.RichViewEdit.SearchText('{PS01}',[rvseoDown]) do begin
    inc(i);
    SetLength(Firme, i+1);
    ActiveEditor.RichViewEdit.GetItemCoords(ActiveEditor.RichViewEdit.CurItemNo, Firme[i].X,Firme[i].Y);
    Firme[i].page:=ActiveEditor.CurrentPage;
  end
but

Code: Select all

ActiveEditor.RichViewEdit.GetItemCoords(ActiveEditor.RichViewEdit.CurItemNo, Firme[i].X,Firme[i].Y)
return TopLeft coord Table.
I need TopLeft coord Cell.
Thanks

Re: Create form field to export PDF - llPDFLib

Posted: Sat Apr 29, 2017 1:05 pm
by Sergey Tkachenko
I did not know you use ScaleRichView.
Yes, in this case you can use methods returning coordinates.

However, do not use methods of TRichViewEdit (i.e. TSRichViewEdit.RichViewEdit), they return coordinates in internal RichViewEdit, not coordinates on a page.

You can use TSRichViewEdit.GetItemCoords100 instead.

However, if you need cell coordinates, it's more difficult. There are no documented methods to get them. You can still use my advice about OnDrawBorder event.
Or, if you need a function, it is below. It returns coordinates of the cell containing the caret, relative to its page.

Code: Select all

var
  RVData: TCustomRVFormattedData;
  R, PageR: TRect;
begin
  RVData := TCustomRVFormattedData(
    ActiveEditor.RichViewEdit.TopLevelEditor.RVData.GetSourceRVData);
  if not (RVData is TRVTableCellData) then
    exit;
  // Cell rect in coordinates relative to this cell
  R := Rect(0, 0, TRVTableCellData(RVData).Width, TRVTableCellData(RVData).GetHeight);
  // Cell rect in client coordinates of ActiveEditor.RichViewEdit
  RVData.RotateRectFromDocToScreen(R, rvtrbAbsRoot);
  // Cell rect in client coordinates of ActiveEditor
  R.TopLeft := ActiveEditor.ConvertRVToSRV(R.TopLeft, ActiveEditor.RichViewEdit);
  R.BottomRight := ActiveEditor.ConvertRVToSRV(R.BottomRight, ActiveEditor.RichViewEdit);
  // Page rect in client coordinates of ActiveEditor
  PageR := ActiveEditor.GetPageClientRect(ActiveEditor.CurrentPage);
  // Cell rect in coordinates relative to this page
  OffsetRect(R, -PageR.Left, -PageR.Top);
end;
You can call it after SearchText, when the caret is in the correct cell.
There is one problem: the returned coordinates are scaled according to ActiveEditor.ZoomPercent. You can get size in 100% by multiplying coordinates in R by 100/ActiveEditor.ZoomPercent (by calling ActiveEditor.ZoomRectOut(R, ActiveEditor.ZoomPercent/100).
Or assign ActiveEditor.ZoomPercent = 100.

Re: Create form field to export PDF - llPDFLib

Posted: Sat Apr 29, 2017 2:06 pm
by haidomingo
It works perfectly with

Code: Select all

ActiveEditor.ViewProperty.ZoomPercent:=100;
Thanks