Text Extraction from pdf with pdfjs is inaccurate in Vue3 - vuejs3

when I extract the highlighted text from pdf with pdfjs using window.getselection the start position and end position is few characters after and before and also selecting the white space.
This is the highlighted text (img)
And extracted text of the given highlight (img)

Related

How can I replace a part of pre-written text via officer/r in Powerpoint

Is there a way to read the text of a slide from Powerpoint and then replace a part of the text with a value from R. See image 1, the black text is added by an user, and the red text is written by the R notebook.
I want to do the writing part in Powerpoint, I don't want to add the whole text in R. Otherwise it is impossible for people without R to add text to the Powerpoint.
If there is a way to define a variable in Powerpoint (that can be placed inside a textbox), that would also solve the problem. :)
Example text

Truncate label text from the left

I have a Label that displays the full name and path of the file that the app is currently processing.
The way Labels perform text truncation, the "C:\..." part of the path is always shown, while the actual file name is only shown if it fits. I would rather truncate on the left side, so that the file name is always shown, while the "C:\..." part is only shown if it fits.
Is this possible in Xamarin Forms?
If you read the docs these are the options for truncation
HeadTruncation – truncates the head of the text, showing the end.
CharacterWrap – wraps text onto a new line at a character boundary.
MiddleTruncation – displays the beginning and end of the text, with the middle replace by an ellipsis.
NoWrap – does not wrap text, displaying only as much text as can fit on one line.
TailTruncation – shows the beginning of the text, truncating the end.
WordWrap – wraps text at the word boundary.
HeadTruncation appears to be what you're looking for

Make text present in PDF document, but invisible

How can I have text in an HTML document so that it will be “there” in the PDF document (generated via wkhtmltopdf), but invisible when viewed or printed?
Constraints:
The text must appear at the right place, with the right size, because the purpose is to find the text with an automated tool and discover its co-ordinates and size on the page.
The solution must be to do with the text only, because I'm trying to keep this simply about CSS styles. Any “hide it under another element” doesn't address the problem, because there might not be any other element at those co-ordinates.
The solution can't be dependent on what's already on the page; I can't go inspecting the background elements on the page because I can't determine those dynamically. The text should be invisible in its own right.
The text must be findable with an automated tool (e.g. pdfgrep), which means wkhtmltopdf must place the text in the document file.
So a “display: none” style or “opacity: 0” doesn't work, because that makes the text not exist at all in the PDF document.
So I want to have an HTML document, place a text element “FOO” within that document with an inline CSS style, and process it through wkhtmltopdf; then, pdfgrep FOO should find the text, the text location and size should be correct, but the text should not show up in HTML, not appear when the PDF is viewed, and not appear when it's printed.
With a style of color: transparent; the text will be fully transparent on the page, but show up normally for any tool looking in the document for that text.
I.
The PDF syntax supports different "text rendering modes". These lets a PDF creating software (or anybody who authors a PDF with a simple text editor) render any text, regardless the chosen font, as
outlined only,
filled only,
outlined and filled,
neither filled nor outlined (invisible),
plus some more, which deal with clipping.
Here is the illustration from the PDF specification:
However, this is not supported by HTML or CSS (at least AFAIK). So your only option to get it done in a similar way is to...
...either set the background color in HTML to the same as the text color,
...or set the text color to transparent.
Then hope that htmltopdf will translate that into a PDF which represents the same...
II.
The following HTML code (essentially using style="color:transparent") works for me. You'll have to decide whether it fullfills your requirements completely:
<html>
<head></head>
<body>
<div style="color:transparent; background:red; border: 1px dashed currentColor;">
The color of this text is transparent/invisible. <br />
The background of this text is red.
<div style="background:blue; height:9px;"></div>
Above this text is a blue box with a height of 9px. <br />
This block is surrounded by a transparent border.
</div>
</body>
</html>
Then, when opening the PDF I cannot read any text lines, but I can select/mark/highlight them.
When running
pdftotext -layout my.html -
I see the following text:
The color of this text is transparent/invisible.
The background of this text is red.
Above this text is a blue box with a height of 9px.
This block is surrounded by a transparent border.
Make text colored with background color of your PDF (ex. white).

Right justify a single line of text in RMarkdown

I know its possible to change text justification and other setting when RMarkdown generates Word documents using a template.enter link description here.
Is it possible to change the justification of a single line?
For example, text that looks like
Some normal left justified text
some right justified text
Some more left justified text
Flushright works if your output format is .pdf but not for .html or word document.
Some normal left justified text
\begin{flushright}
some right justified text
\end{flushright}
Some normal left justified text
It seems to be important to leave the lines in between empty.

Select/copy hover text in R plotly graph

I would like to be able to select and copy the hover text in plotly graphs. Is that possible with the R API?
For example, in this heatmap, upon mousing over coordinates (X=a, Y=d), one can see the hover text displaying:
x=a,
y=d,
z=0.71886
However, the text is not selectable. The goal would be to e.g. display this text inside a box (perhaps by right-clicking on the corresponding cell) to be able to copy the text contents into the clipboard.
Any help would be greatly appreciated.

Resources