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: