ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How exactly does TPDFAnnotation.StringValue work?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
BBriefs Posted - Oct 14 2024 : 09:55:36
Hello,
I recently installed the newest update and I am currently experimenting with the PDF-Annotation functionality.
When I found the attribute TPDFAnnotation.StringValue I thought that maybe it could be used like a Dictionary to establish an internal annotation structure with specified keys and values, but there is something that I don't understand.

Everything worked as expected until I tried something generic like this:


procedure TForm1.Button1Click(Sender: TObject);
Var I : Integer;
begin
//ImageEnView1.PdfViewer.Annotations[0] being an existing text-annotation without assigned StringValues
For I := 0 to 3
  Do ImageEnView1.PdfViewer.Annotations[0].StringValue['XYZ' + I.ToString] := 'Test';

I := 0;

While not (ImageEnView1.PdfViewer.Annotations[0].StringValue['XYZ' + I.ToString] = '')
  Do Begin
     ShowMessage(ImageEnView1.PdfViewer.Annotations[0].StringValue['XYZ' + I.ToString]);

     Inc(I);
     End;
end;


I expected this loop to break at I = 4, instead however it turns out to be an endless loop in which ShowMessage always throws out 'Test'.

Obviously the function behind StringValue is an API-call and the comments declare it to be experimental, but I would simply like to understand it to avoid using it in an erroneous fashion.
Am I doing something wrong in this example or would it be better to avoid using StringValue in this fashion or even alltogether?
4   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Nov 05 2024 : 01:05:57
Hi

This is fixed in the latest beta. You can email me for it.

Nigel
Xequte Software
www.imageen.com
xequte Posted - Oct 16 2024 : 19:44:48


Nigel
Xequte Software
www.imageen.com
BBriefs Posted - Oct 15 2024 : 02:50:40
I continued to experiment around a bit and found out how to make it work and what went wrong:


procedure TForm1.Button1Click(Sender: TObject);
Var I     : Integer;
    AText : String;
begin
//ImageEnView1.PdfViewer.Annotations[0] being an existing text-annotation without assigned StringValues
For I := 0 to 3
  Do ImageEnView1.PdfViewer.Annotations[0].StringValue['XYZ' + I.ToString] := 'Test';

I     := 0;
AText := ImageEnView1.PdfViewer.Annotations[0].StringValue['XYZ' + I.ToString]; 

While not (AText.IsEmpty)
  Do Begin
     ShowMessage(AText);

     Inc(I);
     AText := '';//Loop only works with this. Comment out for endless loop
     AText := ImageEnView1.PdfViewer.Annotations[0].StringValue['XYZ' + I.ToString]; 
     End;
end;


This code works as expected.
The decisive part turns out to be manually emptying the iterator "AText", since assigning a non-existing StringValue apparently doesn't do that.
xequte Posted - Oct 14 2024 : 17:43:01
Hi

Unfortunately the PDFium API functions are just not well documented, but you appear to be using it as I would expect it to work, so I'm not sure why it is failing (other than it being experimental).

I will test this when I am back in the office.

Documentation

Get the string value corresponding to |key| in |annot|'s dictionary. |buffer|
is only modified if |buflen| is longer than the length of contents. Note that
if |key| does not exist in the dictionary or if |key|'s corresponding value
in the dictionary is not a string (i.e. the value is not of type
FPDF_OBJECT_STRING or FPDF_OBJECT_NAME), then an empty string would be copied
to |buffer| and the return value would be 2. On other errors, nothing would
be added to |buffer| and the return value would be 0.

Nigel
Xequte Software
www.imageen.com