Been playing around with the code over a cup of coffee this morning and found a 
few problems sorry to say.

Firstly, the algorithm that I have used to replace the placeholders is not at 
all efficient as it always starts from the beginning of the block of text. This 
has fairly obvious performance problems if you are dealing with large blocks of 
text.

Secondly, if you are processing complex documents - ones that contain pictures, 
tables, etc, then the code will create a 'broken' file. Reading through the 
document paragraph by paragraph also retrieves all of those pictures, tables, 
etc and processing them through the replacement method causes data corruption 
as you would expect. I have tried calling the type() method that is defined on 
the paragraph class hoping that would help but it does not seem to. All I have 
found to work so far is to check the length of the text in the paragraph. 
Pictures and quite possibly tables seem to contain very little text and you 
could use this as a condition - for example checking to see if the length of 
the text was greater than or equal to the placeholder's length.



      

Reply via email to