Modification of pdf in nodejs - javascript

I want to Modify the pdf such that.
First we need to search the string in the pdf after that Replace by the same string but now I want to string Font size is increased or Make the string Bold.
I am able to replace String with other string.
Please help me with proper code.
This is part of PDF
As shown in the image suppose i have search string is 9.R&R Continuous ridge vent - shingle after that bold all the content in this line
R&R Continuous ridge vent - shingle- 92.46 LF 10.1823.30241.141,205.68(0.00)1,205.68
like that
This is the link for my pdf https://surajpdf.s3.ap-south-1.amazonaws.com/1672653281338

Related

How do i convert a Text with formattings maintained and convert in Markdown Expression form using showdown.js

I want some solution which can covert text that may have formatting and convert it into markdown expressions.
for instance :-
Heading
Sub-heading
Another deeper heading
Paragraphs are separated
by a blank line.
Two spaces at the end of a line leave a
line break.
Text attributes italic, italic, bold, bold, monospace.
and this text should be converted into the bellow format:-
Heading
=======
Sub-heading
-----------
### Another deeper heading
Paragraphs are separated
by a blank line.
Two spaces at the end of a line leave a
line break.
Text attributes _italic_, *italic*, __bold__, **bold**, `monospace`.
Is there any way of doing this using any of the javascript markdown expressions api .
Thank you.

How to replace all periods in a string that aren't in an html tag?

I need to replace all periods in a user submitted paragraph of text that will most likely be copy and pasted from a microsoft word document so the text will have formatting on it.
For example, text pasted in from word looks like this:
<p class="MsoNormal" style="margin-bottom: 5.75pt; text-indent: 0.5in;"><span style="font-size:12.0pt;font-family: etc...
I need to edit all of the periods not within these tags and put span tags around them, so I can't just grab the html and do .replace.
:(
Use this answer to find text nodes, then do the replace on them.
If you have it as a string, convert into document fragment first.

Automatically recognize an image from textarea (like StackOverflow)

I would like to create my own "editor" (only code-view, no WYSIWYG) and I have a problem with inserting images. Uploading and selecting images is done via blueimp-jQuery-File-Upload.
What I would like to do is insert them into my textarea in the same way that StackOverflow does it (so without some fancy galleries, modules etc). I upload it and it automatically add's in a textarea in this format
![imageDescription][1]
[1]: http://i.stack.imgur.com/image.jpg
My question is how to do (probably with jQuery/JavaScript) automatic recognition if some image is present in my text area (so if I have these two lines in my textarea), below textarea those images are displayed (or their links) but if I delete them (text lines) - those links/images below disappear.
Probably I should do some "scanning" line by line on every keypress? Maybe with regular expression so if it's true (for both lines) - then display the image below, instead it's just a regular text.
If you want to show those images instantly below your editor, you have no choice but binding that thing to an keypress event. When you get the text you could do some regex action to catch the image and insert it into an <img src="my image">. After that check after every press if the imageurl is still present in that editor (maybe a history is a good choice). If not, delete the <img> tag.
If it's still needed, here's some reference that I made.
Javascript regex replacements:
.replace(new RegExp("\_img_([^ ].+?[^ ])\_img_", "g"),"<img src='$1' />")
Its actually a pattern that could be applied to just about any tag. The regex is as follows:
.replace(new RegExp("\___what ever signifier here ___([^ ].+?[^ ])\_____end sign____", "g"),"<tag>$1</tag>")
*remember to escape special characters in the regex like * with twp forward slashs like so: \\*
also, if you want to add more parameters, just add another ([^ ].+?[^ ]) block and then name where the next parameter will go with $2 like so:
.replace(new RegExp("\\[([^ ].+?[^ ])\\]\\(([^ ].+?[^ ])\\)", "g"),"<a href='$1'>$2</a>")
notice that I escaped [ ] ( ) with double forward slashes.
See it in action: http://jsfiddle.net/xwTGr/

Need to color the tags in an xml, displayed in a textarea

I need to color the tags in an XML string, which is displayed in the textarea of an html page.
say for example, im having an xml string stored in a variable 'xmldata'.
the textarea tag in html is as below
<textarea id="xmlfile" cols="20" rows="30"></textarea>
using the below javascript statement, im displaying the xml string in the textarea
document.getElementById("xmlfile").value=xmldata;
But the xml string is displayed as a plain text in the textarea.
Is there any javascript function to color the tags in xml ?
I don't want any external javascript and css code work like "google-code-prettify"
All i need is a simple javascript function that colors the tags in an xml string which is displayed in the textarea.
Please help me with a solution.
-Dinesh
Since the contents of your text area are not separate DOM elements I don't believe you'll be able to individually set their attributes (since they don't have individual attributes). You might find some variation on a rich text editor that you can plug in. This may or may not violate your stipulation that you don't want external javascript libraries.
As replied here have a look at a self contained prettifier that works for most cases does nice indenting for long lines and colorizes the output if needed. Nevertheless I guess it might not help if you need it inside a textarea.
function formatXml(xml,colorize,indent) {
function esc(s){return s.replace(/[-\/&<> ]/g,function(c){ // Escape special chars
return c==' '?' ':'&#'+c.charCodeAt(0)+';';});}
var se='<p class="xel">',tb='<div class="xtb">',d=0,i,re='',ib,
sd='<p class="xdt">',tc='<div class="xtc">',ob,at,sz='</p>',
sa='<p class="xat">',tz='</div>',ind=esc(indent||' ');
if (!colorize) se=sd=sa=sz='';
xml.match(/(?<=<).*(?=>)|$/s)[0].split(/>\s*</).forEach(function(nd){
ob=nd.match(/^([!?\/]?)(.*?)([?\/]?)$/s); // Split outer brackets
ib=ob[2].match(/^(.*?)>(.*)<\/(.*)$/s)||['',ob[2],'']; // Split inner brackets
at=ib[1].match(/^--.*--$|=|('|").*?\1|[^\t\n\f \/>"'=]+/g)||['']; // Split attributes
if (ob[1]=='/') d--; // Decrease indent
re+=tb+tc+ind.repeat(d)+tz+tc+esc('<'+ob[1])+se+esc(at[0])+sz;
for (i=1;i<at.length;i+=3) re+=esc(' ')+sa+esc(at[i])+sz+"="+sd+esc(at[i+2])+sz;
re+=ib[2]?esc('>')+sd+esc(ib[2])+sz+esc('</')+se+ib[3]+sz:'';
re+=esc(ob[3]+'>')+tz+tz;
if (ob[1]+ob[3]+ib[2]=='') d++; // Increase indent
});
return re;
}
For demo see https://jsfiddle.net/dkb0La16/

how to show arabic alert from left to right

How to show java script alert of arabic characters/text from ltr(Left to right) format.In html we have ltr tag.
This is largely operating system dependent. Simply reversing the string is not 100% correct, since this does not render punctuation correctly.
If you need 100% locale independence in the browser, I would suggest using an HTML dialog, like jQuery UI, instead of alert().
You can't do it using the regular javascript alert()
however, you can use some custom javascript alert box (you can use HTML inside it)
some like this http://slayeroffice.com/code/custom_alert/ or http://jdstiles.com/java/jsalert.html
Hi, this is possible using unicode control characters:
- variable 'g' without ucc
var g="أكتب تعليقا!\nWrite a comment!\n";
variable 'g' with ucc
var g="‫أكتب تعليقا!\n‪Write a comment!\n";
or
var g="‫أكتب تعليقا!\n‪Write a comment!\n";
simply:
place (LRE) character (‪‪‪) in multi-dir texts where embedded texts start from left-to-right;
place (RLE) character (‫) in multi-dir texts where embedded texts start from right-to-left.
or on your win notepad right click where embedded text start, insert unicode..., (LRE) or (RLE)

Categories

Resources