Create form field to export PDF - llPDFLib

General TRichView support forum. Please post your questions here
Post Reply
haidomingo
Posts: 16
Joined: Tue Nov 10, 2009 7:27 pm

Create form field to export PDF - llPDFLib

Post 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
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Create form field to export PDF - llPDFLib

Post 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.
haidomingo
Posts: 16
Joined: Tue Nov 10, 2009 7:27 pm

Re: Create form field to export PDF - llPDFLib

Post 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
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Create form field to export PDF - llPDFLib

Post 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.
haidomingo
Posts: 16
Joined: Tue Nov 10, 2009 7:27 pm

Re: Create form field to export PDF - llPDFLib

Post by haidomingo »

It works perfectly with

Code: Select all

ActiveEditor.ViewProperty.ZoomPercent:=100;
Thanks
Post Reply