You are not logged in.
Pages: 1
Hi all,
I have been investigating the library for creating PDF documents of my TRichEdit content. I came upon the sample at http://synopse.info/forum/viewtopic.php?id=76 and things seem to be good so far.
I would now like to add an index of selected words to the end of the PDF but I do not understand how to do this from any of the documentation and there does not seem to be any sample code. Can anyone help me out with this please?
Regards
Last edited by mogulza (2015-03-02 11:12:00)
Offline
Online
Thanks ab .... your suggestion can work for adding the entries. The problem would then be ... how do I know on which page (or pages) each of the index entries has ended up on, after feeding the TRichEdit content to TGDIPages ..... ?
Offline
Thanks ab ... will look into this
Offline
Hi ab ... managed to get it all done! The heart of the changes is redefining AppendRichEdit by adding an lst parameter as follows:
procedure AppendRichEdit(RichEditHandle: HWnd; lst : TList = NIL); // rev change by mogulza
The first line of AppendRichEdit() code has the following line added:
if lst <> NIL then lst.Clear; // rev line added by mogulza
and further down
LastChar := SendMessage(RichEditHandle, EM_FORMATRANGE, 1, Integer(@Range));
if lst <> NIL then lst.Add(pointer(LastChar)); // rev line added by mogulza
On return from AppendRichEdit, each entry of the lst variable represents a page and each page value contains the lastchar value for the page i.e. the lastchar for page 1 would be integer(lst.Items[0]) and page 2 would be integer(lst.Items[1]) etc.
Hope this all makes sense
Thanks for your help
Offline
I've added an optional EndOfPagePositions parameter to TGDIPages.AppendRichEdit().
See http://synopse.info/fossil/info/d1e476884d
It could be handy in your case - a TIntegerDynArray does make better sense to me than casting a TList to integers.
Thanks for sharing!
Online
Thanks AB .... downloaded your update and amended my code accordingly !!
Offline
Hi ab ... I decided to bite the bullet and bypass the TRichEdit component by writing directly to the TGDIPages component. The issue I have at the moment is that I am unable to write multi-coloured lines.
I have lines that typically have red text followed by blue text followed black text .... but the DrawText() method always adds a new line and so each of my colored texts appear on a separate line. Is there any way to achieve multicolored text lines? Essentially we need a new DrawText method that is able to able to draw text from the current YPos and XPos without adding a new line after each call.
The other thought I had was adding a method called:
DrawColouredText(const StringArray: array of SynUnicode; const Color: array of integer)
which could happily add a new line at the end
Are you able to do something along these lines for us?
Regards
Offline
Hi ab ...
I have been moving on with respect to replacing TRichEdit with TGDIPages ... still have not resolved the issue above ... but the next issue is DrawTextAcrossCols for my index, whereby I would like each index entry to hot link to a bookmark. It turns out we need
procedure DrawTextAcrossCols(const StringArray: array of SynUnicode; const BookmarkArray: array of string; BackgroundColor: TColor=clNone);
I am really trying my best to add this new methods to the as well as
procedure DrawColouredText(const StringArray: array of SynUnicode; const Color: array of integer)
as mentioned previously but it I am really battling
Regards
and
Offline
Hi ab ...
I have succeeded in implementing multicolored lines by changing
procedure TGDIPages.DrawText(const s: string);
to
procedure TGDIPages.DrawText(const s: string; bWithNewLine : Boolean = TRUE);
and thereafter changing all subsequent calls to contain the bWithNewLine parameter as required. I have also had to add a new class member variable that keeps the remembers the last leftOffset.
Question : would you be interested in these changes? If so .... please email me and I will send you the original and changed mormotreport.pas files
Offline
ab,
I just want to be sure that you have received my emails. First email with changes as discussed above. Second email which also contains code for adding link support to DrawTextAcrossCols
Regards
Mike
Offline
Yes, I received the emails.
Should be implemented by http://synopse.info/fossil/info/525eb2f95b
I've modified your patch a little, so that it would be more compatible with existing code.
Thanks a lot!
Online
Pages: 1