rtftextbox and hyperlinks/anchors inside document - winforms

A few hours ago I found that it's really easy to display *.rtf document using standart .net 2.0 winforms control (RichTextBox). It's really cool that it can display even pictures, but for me there's one missing feature - hyperlinking.
I prepared *.rtf document with a few hyperlinks to paragraphs inside document. Then I put this file into resources and loaded to rtf property of control but unluckly, clicking on links doesn't work.
Is there possible a hack or workaround to enable hyperlinks?
EDIT:
My customer will prepare one short document (let's say one *.docx file or one *.html file).
It will contain a few chapters and we want to place small table of contents at the top of document.
The expected behaviour is that user click topic and the control scroll its content to desired place in document.
So maybe it's not about links but about bookmarking.
OK, I'll try to describe larger part of needed solution.
My customer will prepare one short document (let's say one *.docx file or one *.html file).
It will contain a few chapters and we want to place small table of contents at the top of document.
The expected behaviour is that user click topic and the control scroll its content to desired place in document.
So maybe it's not about links but about bookmarking.

How are your links formatted and is DetectUrl true?
From codeproject -> only links starting with one of the recognized protocols (http:, file:, mailto:, ftp:, https:, gopher:, nntp:, prospero:, telnet:, news:, wais:, outlook:) are recognized and reformatted.
http://www.codeproject.com/KB/edit/RichTextBoxLinks.aspx
http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.detecturls(VS.80).aspx
The microsoft article has an example on the LinkClicked event.
private void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(e.LinkText);
}

Related

Is there a way to filter the Document chooser when it's opened from a particular block's form? [duplicate]

This question already has answers here:
Limiting file types for a specific DocumentChooserBlock() Block in Wagtail Steamfield
(2 answers)
Closed 1 year ago.
I'm writing a custom StreamBlock that is designed to render a table based on the data in a given CSV file. The CSV files will be stored in the usual Document store, so the block needs to present the Document chooser to let the user pick a CSV file.
I would like to restrict this block's Document chooser to documents whose filenames end in .csv, without affecting any other Document chooser. I dug into the code to try to figure out a way to do that, but after 30 minutes of poking around, it doesn't look like there's any obvious way to determine the source of a request to the admin/documents/chooser/ view, which is what actually renders the Document listing.
My best guess at the moment for how to do this would be to subclass DocumentChooserBlock and AdminDocumentChooser, so that I can tell it to use a custom version of wagtaildocs/js/document-chooser-modal.js. I'd change it to send an extra GET argument, or something like that, whenever CSVTableBlock's Document chooser sends a request to admin/documents/chooser/. Then I could implement construct_document_chooser_queryset to look for that custom GET arg, so it knows when to filter the documents queryset to only .csv files.
But I'm really not at all sure that this is the right way to go about it, or if it's even possible for that strategy to work. Is there a better/possible way to do this?
you actually no need to do anything, almost all use cases for such filtering scenarios, an editor can input the ".csv" in the search box of the chooser modal

Adding Footnotes (or margin notes etc.) to The Quilljs Editor

I'm looking for a way to add footnote / endnote functionality to the QuillJS.com editor. My requirements are that the note 'text' itself can still be edited as if it were document text -- hiding it away in an attribute is probably not going to work very well.
I wonder if this can be achieved?
To take a trivial example of a document:
Here is a document text as usual1
1This is the footnote text
My guess is that the best way to achieve this would be to:
Hold the actual note text as a series of blocks (note-text blocks) at the end of the document. Each block would need a unique name.
Insert the anchors (the numbers in the main text) as either some kind of embedded object or an inline blot of some kind.
When a new note is added, add the anchor inline, and add a new "note-text" block for that anchor at the end of the document, and move the cursor there.
Have some kind of mechanism to keep the order of the notes at the end of the document in sync with the order of the note-anchors in the main text.
Make sure that the block for the note text could only be deleted if its anchor was deleted. Conversely, if an anchor is deleted, remove the note-text block.
Clicking on the note-anchor would take the cursor to the note-text block, and clicking on the number at the start of the note-block (as rendered) would take the cursor back to the anchor.
Numbering would be determined by the order of the anchors in the document.
My question (for people who have experience of extending QuillJS) is: is such a system even possible? The only module that seems to come close to this level of functionality is the better-tables module.
I would really appreciate any insights about whether such a system could be achieved or some hints about how to do it.

AngularJS - highlight text of an existing pdf file in frontend/Browser

I have found the library
PDF creation
With this library it is possible to create different styles of pdf documents.
My question would be if there is a possibility to mark text (and maybe add a link to this marked text) of an existing pdf file with AngularJS?
Or is there any workaround to do this?
The question is a bit too broad as is - not sure what you mean by "mark" - do you mean highlighted in some way or actually selected?
Anyhow, firstly to get to the correct page -- you can use fragment identifiers in hyperlinks to link to a specific page in a PDF via the page parameter. e.g.
page 1
page 2
If you want to highlight a specific section of a page, via a hyperlink, you can use the highlight parameter, note you must also set the page to use the highlight parameter. e.g.
page 1 - highlight
The rectangle values are integers in a coordinate system where 0,0 represents the top left, and the values are given in the order lt, rt, top, btm.
One can also open a PDF file to a "Named Destination", that is a named section in the document via the nameddest parameter. e.g.
my section
This is great as it doesn't matter if pages are inserted, removed etc as the section will always be correctly linked.
You can read about Named Destinations here and also the various Parameters for Opening PDF Files

Redmine: How to link an attached file in a project from its underprojects?

Lets say I have Project A with an attached imageFile.
Then I created 10 different Projects which are underprojects of Project A.
I want to link the ImageFile of Project A to the Wiki of every underproject , so that I can see the ImageFile in the Wiki-Area of each underproject.
What im doing so far is to copy full path of the attached file of Project A in the Wiki of every underproject, like for example:
!>/attachments/download/157/schnittprofil.png!
Is there a better way to achieve that, because every time I update the imagefile, I have to renew the id-numbers of all imagefile-links in the underprojects.
Since an attachment is only actually identified by its ID and all attachments are immutable (i.e. can be changed after upload), new uploads will result in a new ID. Since multiple attachments with different IDs can have the same name, you can also not reliably find an attachment just by using its name in broad contexts.
That said, to solve your issue, you could use the include macro to include a common Wiki page in your sub-project's wiki pages which then displays the image attachment.
For that, you can create a Wiki page named e.g. Schnittprofil in your parent project where you directly upload your file. In the wiki page, just reference the image with
!schnittprofil.png!
Assuming the parent project has an identifier of project-a, you can then include the page in other wiki pages with
{{include(project-a:Schnittprofil)}}
Each time you change the page on the parent project, it will automatically also show the updated content on the child wikis. The only requirement is that the users need to be able to read the wiki of your parent project (e.g. are members of the project with the "Read wiki" permission).

Dynamic Hyperlink in Livecycle Form

I am trying to figure out how to make a hyperlink in a Livecycle Form which points to a URL which will change on different days that the form is rendered. For example on one day I might want the hyperlink to point to:
mywebsite/mypage?option=XXX
and on another day I want it to point to:
mywebsite/mypage?option=YYY
The XXX and YYY can be passed into the form's data pretty easily as XML, but I just don't know how to make it so that the hyperlink is changed to correspond to this.
Any suggestions?
This can be accomplished with JavaScript in LiveCycle Designer. The following script, placed on the Form's docReady event will let you dynamically change the URL of a text object.
form1::docReady - (JavaScript, client)
// If this code is running on the server, you don't want it to run any code
// that might force a relayout, or you could get stuck in an infinite loop
if (xfa.host.name != "XFAPresentationAgent") {
// You would load the URL that you want into this variable, based on
// whatever XML data is being passed into your form
var sURL = "www.stackoverflow.com"; // mywebsite/mypage?option=xxx
// URLs are encoded in XHTML. In order to change the URL, you need
// to create the right XHTML string and push it into the Text object's
// <value> node. This is a super simple XHTML shell for this purpose.
// You could add all sorts of markup to make your hyperlink look pretty
var sRichText = "<body><p>Foo</p></body>";
// Assuming you have a text object called "Text1" on the form, this
// call will push the rich text into the node. Note that this call
// will force a re-layout of the form
this.resolveNode("Text1").value.exData.loadXML(sRichText, false, true);
}
There are a couple of caveats: URLs in Acrobat are only supported in Acrobat 9.0 and later. So if someone using an older version of Acrobat opens your form, the URLs won't work.
Also, as you can see from the "if (xfa.host.name !=...)" line, this code won't run properly if the form is being generated on the server, because forcing a re-layout of a form during docReady can cause problems on certain older versions of the LiveCycle server. If you do need to run this script on the server, you should probably pick a different event then form::docReady.
I a number of complaints from users in WorkSpace that clicking links opened them in the same tab so they lost their WorkSpace form, and there's no option to change that in Designer 11. I think the solution I came up with for that would work for you too.
I made buttons with no border and no background, and in their click event have this line (in Javascript, run at client)
app.launchURL("http:/stackoverflow.com/", true);
It would be easy to add some logic to choose the right URL based on the day and it doesn't cause any form re-rendering.
In some spots where the hyperlink is in line with other text, I leave the text of the link blue and underlined but with no hyperlink, and just place the button (no background, no border, no caption) over it. Does require positioned and not flowed subforms for that to work, so depending on your layout it could get a little clunky.
Wow, just realized I am super late to the party. Well, for anyone using ES4 facing a similar problem . . .
Ended up using a 3rd party component to manipulate the PDF's hyperlinks...wish there was a better solution as this one costs about $1000.

Resources