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
 Watermark on PDF

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
aleatprog Posted - May 17 2024 : 15:55:44
Hi,

I need to insert a watermark below the text of a PDF document.

Adding an image using e.g. ImageEnView1.PdfViewer.Objects.AddImage(100, 800, 200, 200, bmp), is it somehow possible to assign it the background index in order to insert it below the other objects? Or do I need to cut & paste each object on top of the watermark using a loop?

Ale
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - May 20 2024 : 00:20:24
It is not possible to do this using PDFium.

PDFium does not support clipboard or object streaming, so the process you use below is not going to be 1:1. At this stage PDFium does not provide methods to get all the properties of an object, nor all the the methods to set the properties of an object, so information will be lost.

Nigel
Xequte Software
www.imageen.com
aleatprog Posted - May 18 2024 : 03:50:10
Hi Nigel,

as mentioned in the opening post, I tried to change the z-order with cut & paste using the following code:

for i := 0 to ImageEnView1.PdfViewer.Objects.Count - 1 do
  if ImageEnView1.PdfViewer.Objects.Items[i].ObjectType = ptText then
    begin
      ImageEnView1.PdfViewer.SelectedObject := i;
      ImageEnView1.PdfViewer.CutToClipboard();
      ImageEnView1.PdfViewer.PasteFromClipboard();
    end;
ImageEnView1.PdfViewer.ApplyChanges;
ImageEnView1.PdfViewer.SaveToFile(path);


The result was inproper (see attached images). Following the main issues:

- While iterating, the number of objects resulting from ImageEnView1.PdfViewer.Objects.Count decreased causing the error 'Argument "Index" (i) out of range' due to i > ImageEnView1.PdfViewer.Objects.Count;
- Occasionaly, object position changed;
- Occasionaly, object/text content disappeared;
- Frequently, object formatting (e.g. text size, text style) changed.

With the above code, quite no text object had been copied properly. The correct objects in the output image should be objects which had been excluded from the iteration as I manually reduced the range in order not to get out of range.

Is there a way to improve the code in order to get proper results?

Ale

Output:


Input:
xequte Posted - May 17 2024 : 18:46:49
Hi Ale

Unfortunately there is not a method to set the z-order with PDFium.

Nigel
Xequte Software
www.imageen.com