Insert RichText (RTF) in FreeText Annot

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Paul - Tracker Supp, Chris - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Insert RichText (RTF) in FreeText Annot

Post by espens » Fri Jul 15, 2016 12:17 am

Copy & paste from WordPad into a FreeText / Text Box annot works through the UI and I want to do the same from code.

Playing with the sample found in IPXC_Page::InsertNewAnnot I can easily insert plain text, but trying to set an RTF string ({rtf1\ansi...) using the RichContent of the IPXC_AnnotData_FreeText doesn't do much.

Any suggestions?

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1928
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Insert RichText (RTF) in FreeText Annot

Post by Vasyl-Tracker Dev Team » Fri Jul 15, 2016 12:44 am

Currently you cannot just put the RTF-text directly to the RichContent. Its required to convert it to the XFA Rich Text Format before (XML based format).
Probably in the future we will add feature for converting from RTF to XFA RTF..
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Insert RichText (RTF) in FreeText Annot

Post by espens » Fri Jul 15, 2016 12:54 am

Would it be possible to put the RTF in the clipboard and then invoke a paste command, as it is working through the UI.

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1928
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Insert RichText (RTF) in FreeText Annot

Post by Vasyl-Tracker Dev Team » Fri Jul 15, 2016 1:07 am

Technically - yes. But you must have activated TextEditor control in UI for corresponding text-annotation before executing the Paste command.
I'm not sure that it is what you want..
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Insert RichText (RTF) in FreeText Annot

Post by espens » Fri Jul 15, 2016 1:38 am

It's basically what I want. Which brings up another question.

I want the user to place a Text Box on the Page though the UI and as it's placed on the page and before the user starts typing I want to inject a default string (In Rich Format). Looking at the events i see that e.annots.inserted is raised as the text box looses focus after it is inserted. This is too late as the user would then have started typing. I do not want to inject my text into just any text box as the editor gets actived (e.document.textEditor.started) but only when the textbox is a new text box.

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1928
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Insert RichText (RTF) in FreeText Annot

Post by Vasyl-Tracker Dev Team » Tue Jul 19, 2016 12:53 am

Hi, Espens.

We will improve some moments with text-editor notifications by providing additional info with such events.
Also we'll provide detailed information about this improvement a bit later, please wait..

Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Insert RichText (RTF) in FreeText Annot

Post by espens » Wed Oct 12, 2016 8:56 am

Any updates to text box events?

I'm trying to add a feature that inserts a custom text into a textbox when a text box is placed on a page.

Would also want to see this for form fields.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13508
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Insert RichText (RTF) in FreeText Annot

Post by Tracker Supp-Stefan » Thu Oct 13, 2016 9:52 am

Hello espens,

I checked with a colleague from the European dev office, but they say that this will need Vasyl's attention, and he is in Canada, so I will ask him to post an update as soon as he can!

Regards,
Stefan

User avatar
Vasyl-Tracker Dev Team
Site Admin
Posts: 1928
Joined: Thu Jun 30, 2005 4:11 pm
Location: Canada

Re: Insert RichText (RTF) in FreeText Annot

Post by Vasyl-Tracker Dev Team » Sat Oct 15, 2016 1:15 am

Hi Espens.
Any updates to text box events?
Sorry for delay with that. In next couple days we will add new features that will provide full access to our text-edit control.
When it is ready (should be by next week) - we will notify you and you will be able to try it using our technical builds.

Cheers.
Vasyl Yaremyn
Tracker Software Products
Project Developer

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.

User avatar
Sasha - Tracker Dev Team
User
Posts: 4310
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Insert RichText (RTF) in FreeText Annot

Post by Sasha - Tracker Dev Team » Tue Oct 25, 2016 2:52 pm

Hello espens,

We've updated the code. Now you can change the TextBox text when inserting by using this code:

Code: Select all

if (e.nEventID == nIDS[(int)IDS.e_document_textEditor_started])
{
	IntPtr outPtr = new IntPtr(e.pEvent.Param1);
	PDFXEdit.IPXV_TextEditor tEdit = (PDFXEdit.IPXV_TextEditor)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
	tEdit.EditCtl.AppendText("Test Text");
	//RichText
	//tEdit.EditCtl.SetRichText(); //This one uses IStream as an input - check out the IStreamWrapper in the FullDemo
You can do that by using the latest DevBuild available here:
http://www.tracker-software.com/forum3/ ... 66&t=25943

Also, an example on how to get\set the RTF\XFA for the FreeText annotation:

Code: Select all

PDFXEdit.IOperation op = pdfCtl.Inst.CreateOp(pdfCtl.Inst.Str2ID("op.annot.setData"));
PDFXEdit.IPXC_Document cdoc = pdfCtl.Doc.CoreDoc;
PDFXEdit.IPXC_Page pg = cdoc.Pages[0];
uint cnt = pg.GetAnnotsCount();
for (uint i = 0; i < cnt; i++)
{
	PDFXEdit.IPXC_Annotation a = pg.GetAnnot(i);
	if (a.IsMarkup)
	{
		PDFXEdit.IPXC_AnnotData_Markup ad = (PDFXEdit.IPXC_AnnotData_Markup)a.Data;
		string rc = ad.RichContent;
		string rtf = pxcInst.ConvertRC2RTF(cdoc, rc, "", (int)PDFXEdit.PXC_ConvertRCFlags.PXC_ConvertRC_AnnotText);

		ad.RichContent = pxcInst.ConvertRTF2RC(cdoc, rtf, (int)PDFXEdit.PXC_ConvertRCFlags.PXC_ConvertRC_AnnotText);

		PDFXEdit.ICabNode pr = op.Params.Root;
		pr["Input"].Clear();
		pr["Input"].Add().v = a;
		pr["Options.NewData"].v = ad;

		op.Do(0);
	}
}
Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

espens
User
Posts: 45
Joined: Wed Jan 14, 2009 7:31 am

Re: Insert RichText (RTF) in FreeText Annot

Post by espens » Tue Nov 08, 2016 6:05 pm

Thank you.

This will work for us

John - Tracker Supp
Site Admin
Posts: 8202
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Re: Insert RichText (RTF) in FreeText Annot

Post by John - Tracker Supp » Tue Nov 08, 2016 6:22 pm

Excellent :)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

Post Reply