I am using ng2-pdf-viewer library to display some pdfs. I was asked to include a search bar for these pdfs and I did by using this command available in PdfFindController from pdf.js
this.pdfFindController.executeCommand('find', {
caseSensitive: false,
findPrevious: false,
highlightAll: true,
phraseSearch: phraseSearch,
query: stringToSearch
});
However most of my pdfs are in french and so they use weird characters such as è û etc. So what I need is to know if there is an option in findcontroller parameters to set this find function to find all matching no matter if they have accents or stress. And if not what workaround do you advice me to do.
I also found this issue on pdfjs github page https://github.com/mozilla/pdf.js/issues/8101 about it but they don't give a straight answer.
Thank you guys for your help !
So you have to modify lib in order to accept this characters. This can be tricky and may depend on pdfjs lib version. In my case I modify version 2.4.456. Here is source code for pdf-find-controller.js https://drive.google.com/file/d/1pbDG7gmeBpPp8soC1MNOyXVRYxf5AomD/view?usp=sharing this the only file you should change.
Then you should compile library again using these commands:
npm install -g gulp-cli
npm install
gulp generic
And you should get pdf-viewer.js result file as this one https://drive.google.com/file/d/1tWOW_P6-O8ATiQc9cOVt2LAToRB-niHc/view?usp=sharing
This fix is specially designed for french language but is adaptable to every language. My advice is to do a comparison between original files and modified and then you'll see the logic you should add.
Also to force npm to use new version of library without it being a pain read about npm-force-resolutions
Related
I have a golang project, but am using a bit of c++. I downloaded a header file dependency, nlohmann/json, and is 22875 lines long, so naturally my github languages is not showing the proper language (Go) and is instead showing c++. How can I remove the json.hpp from the github linguist? I know that the .gitattributes file exists and I can change the language of some files, but how can I remove a file entirely from the linguist?
You can't tell Linguist to skip a file entirely. But I don't think that's actually what you want, as you don't care if it remains highlighted, right? You can tell Linguist to ignore some files when computing language statistics. In your case, the best way to do that would be to declare these C++ files vendored, with e.g.:
*.hpp linguist-vendored
See Linguist's README for more information.
I am automating a process and I use GPG2.exe for it.
Because I need to parse console output - potentially from different systems I need to set the languge to a controlled value.
I am following the Instructions from the manual which states that
LANGUAGE
Apart from its use by GNU, it is used in the W32 version to override the
language selection done through the Registry. If used and set to a valid and
available language name (langid), the file with the translation is loaded from
gpgdir/gnupg.nls/langid.mo. Here gpgdir is the directory out of which the
gpg binary has been loaded. If it can’t be loaded the Registry is tried and as
last resort the native Windows locale system is used.
I found a thread from 2011 that goes into a bit more detail regarding this problem, but this may actaully concern a different version.
I created a batch file for manual testing.
#echo off
REM C is meant to display untranslated messages according to one internet source
set LANGUAGE="C"
call "C:\Program Files (x86)\GNU\GnuPG\gpg2.exe" --version
pause
I ecpext the output to be english but it is still german.
The manual states something about there beegin a "gnupg.nls" folder somewhere.
I was not able to locate this folder, which makes me wonder where german is loaded from.
Is there an error in the man page?
The pdf Version of the man page shows the same content as the man page that came with the installation.
Can someone shed some light on this?
I had the same problem that the output was in Swedish though I wanted it in English. The Windows display language was set to English, and I also tried setting environment variables but what solved it for me was to remove the Swedish translation for gnupg file found here:
C:\Program Files (x86)\gnupg\share\locale
After having removed the "sv" directory all output was in English.
The language directory can be pulled from the registry or I suppose it can also have a fixed path since I can not find the information in my registry.
On my testsysten the path is 'C:\Program Files (x86)\GNU\GnuPG\share\locale'.
This path contains folders for each language - not all of them contain translation files for gpg2 as far as I can tell.
The environment variable for language is not LANGUAGE but LANG. Setting it to C causes gpg2 to default to english.
I successfully tested the following call.
#echo off
set LANG=C
call "C:\Program Files (x86)\GNU\GnuPG\gpg2.exe" --version
User bignose is still correct when he states that I should use the API instead but within my current restrictions I do not see a straight forward way to do so.
This isn't a programming question, as noted in the votes to close.
To answer a different question that could be asked from a programming perspective: Don't parse inherently-changeable console output, when there is a well-defined library API for the same functionality.
There are various features fo the SQL filetype plugin mentioned in this helpfile that do not seem to work for me. I have installed the following files in to the correct places (all called sql.vim)
syntax - http://www.vim.org/scripts/script.php?script_id=498
ftplugin - http://www.vim.org/scripts/script.php?script_id=454
Was this even necessary? The syntax highlighting is now correct, but should something that is in the help files by default require downloading plugins?
Anyway, for example, the functions [[,]],[] and ][ do not work as described, and :SQLSetType is not a recognised command. Do I need to do more to enable these?
Thank you in advance for any help
The SQL syntax and filetype plugins by David Fishburn are indeed distributed with the Vim runtime; you only need to install them into your ~/.vim/ directory if you want a newer version than what is delivered by your current Vim version. (So usually, no.)
If the syntax is working but the filetype definitions aren't, you're likely missing
:filetype plugin indent on
in your ~/.vimrc. You can check the :scriptnames output and with :verbose nmap ]].
I would like to start using Less rather than writing CSS from scratch, but is it possible to use Less in such a way that all the following things are true:
I can write Less within my own text editor (TextMate)
I don't have to compile the CSS manually after each edit, but can just save the Less file
my CSS is not reliant on JavaScript (at least not in production).
I've tried to Google the answer to these questions, but I can't figure out a clear answer. Thanks for your help.
The short practical answer
There are several tools out there that help you to compile your LESS into CSS on the fly each time you save your LESS file. Most tools do much more than just compiling LESS, they also come with "live reload" functionality, compile coffeescript, handlebars, SCSS, run JSlint, combine JS, etc.
LESS compile tools selection:
http://gruntjs.com/ < open source, comand line interface
http://koala-app.com/ < GUI, cross platform, free
http://crunchapp.net/ < GUI, cross platform, free, based on AIR
http://wearekiss.com/simpless < GUI, cross platform, free
http://alphapixels.com/prepros/ < GUI, windows, freemium
http://incident57.com/less/ < GUI, Mac, small simple tool, free
http://incident57.com/codekit/ < GUI, Mac, commercial, powerful
https://github.com/Mte90/Plessc < GUI, Linux, free
Please consider project size. most of the tools work really great if you work alone, but for team work you'll need some sort of configuration standard (config file).
When using LESS CSS, you still have to write your css styles from scratch. Not unless you have and use your own css framework. If you use or have as such, you may just have to define your VARIABLE and MIXINS,and your additional custom styles.
Such LESS CSS Framework includes Twitter Bootstrap. You don't have write CSS from scratch when you use it in your font-end development, you only need to add/adjust your own customizations.
You can write LESS with your editor (TextMate). Since LESS file is also a CSS file with an extension of LESS (style.less). Only that your browser cannot parse the LESS file without using LESS in client side (by linking to less.js file in your document head). If you checkout this page, you can see that TexTMate is listed as one of the Editors that supports LESS (It has syntax highlighting).
You don't have to compile LESS to CSS file manually.
When compiling LESS file to CSS file, you have the Command Line compilers and the GUI compilers. When using Command Line compiler, you'll have to use of course your terminal to command the compiling ($ lessc style.less style.css). When you opt to use the Command line option, you'll have to install NPM and Node.js. Install NPM first, before Installing Node.js, since NPM will let you install Node.
You will not rely on JavaScript in production, if using LESS, because you only use LESS during development. You will be using JavaScript (less.js) when you opt to use LESS in Client Side (browser side).
Here are some links that will give more info about LESS Usage http://lesscss.org/#synopsis:
This
This
This
LESS CSS is a CSS Pr-processor just like Sass
Some LESS Examples
Using Variables: Using variables during development, makes your work flow faster. Changing colors is just a breeze using variables.
#black: #000;
#grayDarker: #222;
body {
color: #grayDarker;
background: #black;
}
Read more examples from the given links.
How can I detect images in a document say doc,xls,ppt or pdf ?
I came across with Apache Tika, I am trying its command line option.
http://tika.apache.org/1.2/gettingstarted.html
But not quite sure how it will detect images.
Any help is appreciated.
Thanks
You've said you want to use a command line solution, and not write any Java code, so it's not going to be the prettiest way to do it... If you are happy to write a little bit of Java, and create a new program to call from Python, then you can do it much nicer!
The first thing to do is to have the Tika App extract out any embedded resources within your file. Use the --extract option for this, and have the extraction occur in a special temp directory you app controls, eg
$ java -jar tika.jar --extract ../testWORD_embedded_pdf.doc
Extracting 'image1.emf' (application/x-emf)
Extracting '_1402837031.pdf' (application/pdf)
Grab the output of the extraction if you can, and parse that looking for images (but be aware that some images have an application/ prefix on their canconical mimetype!). You might need to run a second --detect step on a few, I'm not sure, test how the parsers get on with the extraction.
Now, if there were images, they'll be in your test dir. Process them as you want. Finally, zap the temp dir when you're done with the file!
Having used Tika in the past I can't see how Tika can help with images embedded within Office documents or PDFs I was wrong to answer No. You will have may still try to resolve to native APIs like Apache POI and Apache PDFBox. Tika does use both libraries to parse text and metadata but no embedded image support.
Using Tika makes these APIs automatically available (side effect of using Tika).
UPDATE:
Since Tika 0.8: look for EmbeddedResourceHandler and examples - thanks to Gagravarr.