i want to convert PDF uploaded by user to HTML file and shown on browser.
so for that is there any simple solution in php , jquery or js.
Thanks in advance.
the supporting software is available, you can use that one:
1. download and unpack the .exe file to a folder: PDFtoHTML
2. Create a .php file, & put this code (assuming, that pdftohtml.exe is inside that folder, and the source test.pdf as well)
<?php
$source_pdf="test.pdf";
$output_folder="MyFolder";
if (!file_exists($output_folder)) { mkdir($output_folder, 0777, true);}
$a= passthru("pdftohtml $source_pdf $output_folder/new_file_name",$b);
var_dump($a);
?>
3. enter MyFolder, and you'll see the converted files
Related
I have over 60 images for my website's gallery. I would like the website to read the image names from a csv file rather than writing all the code by hand. Is that possible? If yes, should I use PHP or Javascript to do that?.
Welcome to stack overflow,
You can use PHP to read the csv file. you can refer below link.
How to parse a CSV file using PHP
you can use python to read the csv and can use exec function to include it in php page
I am using PDF.js to open a PDF file currently and its working fine.
Previously I was using like this:
http://myapp.mycompany.com/web/viewer.html?file=http://myapp.mycompany.com/my-PDF-file.pdf
My Problem:
For some reasons, I really do not want to reveal the file path of my PDF file and want to move my PDF files outside root directory. Is there any other way to provide the pdf file to the viewer.html? or is this the oly way?
NOTE: I have moved all the PDF files outside my root directory. So How can I access the PDF now?
Yes, there is. Call some function instead (and you don't even need PDF.js):
http://www.example.com/getPDF.php?fileName=pdfname.pdf
function fileName() {
$fileName = $_GET['fileName'];
header("Content-type:application/pdf");
header("Content-Disposition:inline;filename='{$fileName}'");
readfile(__DIR__."/../pdfs/private/{$fileName}");
}
Use rawurlencode to encode '/getPDF.php?filename=pdfname.pdf' part:
"http://myapp.mycompany.com/web/viewer.html?file=".rawurlencode("/getPDF.php?filename=".rawurlencode("pdfname.pdf"))
I'm using rich:fileUpload in my application on linux when I try to upload any file containing html code in file name i.e "file<img src=xyz onerror=alert('TEST')>Name.png", it gives me javascript alert before uploading the file. I tried it on live demo and found the same issue there as well. How can I restrict/escape execution of html/script or XSS in file name on linux?
You can try it yourself by following steps on linux.
Create a file with name "file<img src=xyz onerror=alert('TEST')>Name.png"
Access rich:fileUpload demo on richfaces showcase using below url.
Upload file and you will see a javascript alert.
http://showcase.richfaces.org:8000/richfaces/component-sample.jsf?demo=fileUpload&skin=blueSky
I try to upload any file containing html code in file name i.e
"fileName.png".
You are saying html code in file name, but I don't see any html in "fileName.png".
If I'm not wrong file name should be something like file<img src=x onerror=alert('Javascript')>.pdf.
After compressing the JS file in Drupal I got a randomly JS file name.
My question how I can get this file name to add it to my javascript?
Drupal code: import and compress
<?php drupal_add_js(drupal_get_path('theme', 'mytheme') . 'mybigfile.js'); ?>
Random file name Result:
js_2KQpJNjjupC1Beoweoqpok2JCXhe0sJ6YBllaRDUXYQ.js
Trying to Call the mybigfile.js file:
<script>
telInput.intlTelInput({
validationScript: "mybigfile.js"
});
</script>
As far as I know, you can not get the name of the concatenated JavaScript file generated by Drupal using PHP.
Your best option would be to avoid your JavaScript file mybigfile.js from being concatenated and compressed. Then you can apply your validation script by calling the file name.
You will have to set the preprocess property to false inside drupal_add_js $options array, to prevent the file from being aggregated.
drupal_add_js(drupal_get_path('theme', 'mytheme') . '/mybigfile.js', array(
'type' => 'file',
'preprocess'=> false,
));
Update
If you want to compress a single JavaScript file, you have the option to use AdvAgg API.
Unfortunately, I can't find any documentation for how to do that. But you start with the following:
download and install advagg and enable the submodule advagg_js_compress.
inside the advagg_js_compress submodule folder, find the file advagg_js_compress.advagg.inc and open in your text editor. Here you can find a few helper functions that will help you compressing your JavaScript file.
I am trying to add an external javascript file to Codeigniter application.
I have placed my external js file in the "projectname/js/" folder.
Below is the script tag src in my view page.
src="http://localhost/needpcbcodeigniter/js/registration.js">
But I am getting a "Not found" error for the js file.
Most probably this is because the apache mod_rewrite is dealing with the js folder as a codeigniter controller name (as if you're calling http://localhost/projectname/index.php/js/registration.js)
Check your .htaccess to make sure it doesn't redirect when a valid filename is requested. Check it here
You should add an external javascript file to codeigniter in assets folder.
You should check some following steps :-
1) first fix your project base_url which is set in application/config/config.php like-
$config['base_url'] = 'http://localhost/yourprojectname/'
2) create a folder(e.g: js) in assets folder(at root of folder) for save all javascript files(e.g : registration.js).
3) on final step where you want to use javascript file use code like this-
<script src="<?php echo base_url();?>/assets/js/registration.js"></script>