I need help in installation of dompdf. Where should I place the extracted zip file in the directory? I've followed the INSTALL.txt, and it says "Extract the contents of the downloaded package into one of the supported paths." Does it mean placing into "Modules" folder? if so, an error occurs requesting for ".info". And it's not supplied. Please help, I'm confused! Thanks!
The supported paths are listed in the install.txt file:
supported paths:
* print module lib directory (usually sites/all/modules/print/lib)
* libraries directory (sites/all/libraries)
I prefer the second option, it will keep you from having to do this every time you update the module.
In other words it should look like this sites/all/libraries/dompdf
here's how I loaded it
I moved the folder dompdf-0.5.1 to the /sites/all/libraries folder
I edited dompdf_config.inc.php by replacing the DOMPDF_autoload() function with:
Code:
function DOMPDF_autoload($class) {
/* Add this checking - START */
if (mb_strtolower($class)== 'firephp'){
return;
}
/* Add this checking - END */
$filename = mb_strtolower($class) . ".cls.php";
require_once(DOMPDF_INC_DIR . "/$filename");
}
if ( !function_exists("__autoload") ) {
/**
* Default __autoload() function
*
* #param string $class
*/
function __autoload($class) {
DOMPDF_autoload($class);
}
}
now you should be able use it like so in any other module
Code:
require_once(realpath('.')."/sites/all/libraries/dompdf-0.5.1/dompdf_config.inc.php");
spl_autoload_register('DOMPDF_autoload');
$obj = new DOMPDF();
This worked and I was able to use the DOMPDF object/class.
Related
I googled so far and tried to find out the solution but not yet.
I know require() works only with static path, so I want alternative ways to solve my problem. I found this answer here but it doesnt make sense for thousands of resources.
Please advise me the best approach to handle such case.
Background
I have thousand of json files that containing app data, and declared all the file path dynamically like below:
export var SRC_PATH = {
bible_version_inv: {
"kjv-ot": "data/bibles/Bible_KJV_OT_%s.txt",
"kjv-nt": "data/bibles/Bible_KJV_NT_%s.txt",
"lct-ot": "data/bibles/Bible_LCT_OT_%s.txt",
"lct-nt": "data/bibles/Bible_LCT_NT_%s.txt",
"leb": "data/bibles/leb_%s.txt",
"net": "data/bibles/net_%s.txt",
"bhs": "data/bibles/bhs_%s.txt",
"n1904": "data/bibles/na_%s.txt",
.....
"esv": "data/bibles/esv_%s.txt",
.....
},
....
As you can see, file path contains '%s' and that should be replace with right string depends on what the user selected.
For example if user select the bible (abbreviation: "kjv-ot") and the chapter 1 then the file named "data/bibles/Bible_KJV_OT_01.txt" should be imported.
I'm not good enough in react-native, just wondering if there is other alternative way to handle those thousands of resource files and require only one at a time by dynamically following the user's selection.
Any suggestions please.
Instead of exporting a flat file, you could export a function that took a parameter which would help build out the paths like this:
// fileInclude.js
export const generateSourcePath = (sub) => {
return {
bible_version_inv: {
"kjv-ot": `data/bibles/Bible_KJV_OT_${sub}.txt`
}
}
}
//usingFile.js
const generation = require('./fileInclude.js');
const myFile = generation.generateSourcePath('mySub');
const requiredFile = require(myFile);
then you would import (or require) this item into your project, execute generateSourcePath('mysub') to get all your paths.
There are a lot posts about this subjects, but the link to any sloution are not working anymore... I followed this article.
I downloaded TCPDF master.
Upzipped it in the folder Vendor/ tcpdf
Eddited xtcpdf.php
<?php
App::import('Vendor','tcpdf/tcpdf');
class XTCPDF extends TCPDF{
}
Edit config.php (is this the right path?
/**
* Installation path (/var/www/tcpdf/).
* By default it is automatically calculated but you can also set it as a fixed string to improve performances.
*/
define ('K_PATH_MAIN', '/var/www/ppp/app/Vendor/tcpdf');
/**
* URL path to tcpdf installation folder (http://localhost/tcpdf/).
* By default it is automatically set but you can also set it as a fixed string to improve performances.
*/
define ('K_PATH_URL', 'http://localhost/ppp/Vendor/tcpdf');
Create app/View/Layouts/pdf/default.ctp
<?php
header("Content-type: application/pdf");
echo $content_for_layout;
?>
Then in the webpages controller:
public function newpdf(){
$users = $this->User->find('all');
$this->set(compact('users'));
$this->layout = '/pdf/default';
$this->render()->type('application/pdf');
}
and in de view/webcontroller
public function newpdf(){
$users = $this->User->find('all');
$this->set(compact('users'));
$this->layout = '/pdf/default';
$this->render()->type('application/pdf');
}
When i want to test it i get a blank page, without anything...
I made the function in Webpages. Is that all right? Or should I make the function somewhere else?
The path in the configuration file, I work on a localhost on linux. The path: /var/www/ppp/app/Vendor/tcpdf. Is that the right path?
The URL is set is http://localhost/ppp/app/Vendor/tcpdf Is that the right URL?
Thanks in advance
first of all did you checked whether the tcpdf is loaded or not
App::import('Vendor','tcpdf',array('file' => 'tcpdf/tcpdf.php'));
then on path where you want to put the pdf.It must be the real path
$path=realpath('../webroot/pdf/') . '/';
then initialize the tcpdf
$pdf= new tcpdf();
then set desired file options
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Your Name');
$pdf->SetTitle(title);
$pdf->SetSubject('TCPDF');
$pdf->SetKeywords(keywords);
// add a page
$pdf->AddPage();
then get the html which you want to convert to pdf
$html= $this->render('/Elements/Pdf');
write the html to pdf
$pdf->writeHTML($html, true, false, true, false, '');
then output it
$name='pdf.pdf';
$pdf->Output($path.$name, 'F');
Let me know if still have some issues.
So I am trying to make a game in Dart and I decided to check out this asset_pack package. I tried to test the example code (below) but asset.imported prints null..why is this?
I did create /web/test/foo.txt in my project folder and put a little bit of text in it but still I get null printed.
main() {
// Construct a new AssetManager.
AssetManager assets = new AssetManager();
// Register the 'test' pack. No url is needed so the empty string suffices.
AssetPack testPack = assets.registerPack('test', '');
// Register asset 'foo' and load it's contents from 'foo.txt'.
// The asset type is 'text' and there are no arguments for the loader
// or importer.
Future<Asset> futureAsset = testPack.loadAndRegisterAsset('foo', 'foo.txt',
'text', {}, {})
futureAsset.then((asset) {
// Print the contents of foo.txt.
print(asset.imported);
});
}
I think your file has to be in the web/ folder or you have to load test/foo.txt. If you run the example you should see an error that the file was not found in the developer console. This code seems to work:
Future<Asset> futureAsset = testPack.loadAndRegisterAsset('foo', 'text',
'test/foo.txt', {}, {})
I'm trying to upload file but get this error message :
move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: The second argument to copy() function cannot be a directory
I think there's something problem with this file but I've no idea to solve it..
<?php
class FileUploadController extends CController {
public function actionUpload() {
$model = new FileUpload();
$form = new CForm('application.views.fileUpload.uploadForm', $model);
if ($form->submitted('submit') && $form->validate()) {
$form->model->image = CUploadedFile::getInstance($form->model, 'image');
if($model->validate())
{
$model->image->saveAs('/opt/lampp/htdocs/upl/images');
Yii::app()->user->setFlash('success', 'File Uploaded');
$this->redirect(array('upload'));
}
}
$this->render('upload', array('form' => $form));
}
}
?>
You either need to check all files existed at '/opt/lampp/htdocs/upl/images' and check if the same named file is available or not, if available then just rename the file with extra "_1" every time, or you can always upload the file by renaming the file into some machine name sort of thing see the code below,
$name = rand(1000,9999) . time(); // rand(1000,9999) optional
$name = md5($name); //optional
$model->image->saveAs('/opt/lampp/htdocs/upl/images/' . $name . '.jpg');
This is what I usually do with file uploads, provided that you're saving the files references into the database or in any text file.
EDIT
Get Extension.
In case if you're required to get extension of the file rather then of hard-coded, you can use $model->image->getExtensionName(); it will get you the extension of the uploaded file without . (dot)
Finally, I solved it by myself:
The problem was located in line
$model->image->saveAs('/opt/lampp/htdocs/upl/images');
It should be :
$model->image->saveAs('/opt/lampp/htdocs/upl/images/images.jpg');
Now, there's another problem: when I upload 'new image', it will be replace the old file, I want the file(s) being uploaded not replaced the old file or I need something like rename as new file. Does anyone knows?
goto cuploadedfile.php .
over write this function with this
if($this->_error==UPLOAD_ERR_OK)
{
if($deleteTempFile)
return move_uploaded_file($this->_tempName,$file."/".$this->getName());
elseif(is_uploaded_file($this->_tempName))
return copy($this->_tempName, $file."/".$this->getName());
else
return false;
}
thank u.........
What is the easiest method for joining/merging all files in a folder (tab delimited) into a single file? They all share a unique column (primary key). Actually, I only need to combine a certain column and link on this primary key, so the output file would contain a new column for each file. Ex:
KEY# Ratio1 Ratio2 Ratio3
1 5.1 4.4 3.3
2 1.2 2.3 3.2
etc....
There are many other columns in each file that I don't need to combine in the output file, I just need these "ratio" columns linked by the unique key column.
I am running OS X Snow Leopard but have access to a few Linux machines.
use the join(1) utility
I actually spent some time learning Perl and solved the issue on my own. I figured I'd share the source code if anyone has a similar problem to solve.
#!/usr/bin/perl -w
#File: combine_all.pl
#Description: This program will combine the rates from all "gff" files in the current directory.
use Cwd; #provides current working directory related functions
my(#handles);
print "Process starting... Please wait this may take a few minutes...\n";
unlink"_combined.out"; #this will remove the file if it exists
for(<./*.gff>){
#file = split("_",$_);
push(#files, substr($file[0], 2));
open($handles[#handles],$_);
}
open(OUTFILE,">_combined.out");
foreach (#files){
print OUTFILE"$_" . "\t";
}
#print OUTFILE"\n";
my$continue=1;
while($continue){
$continue=0;
for my$op(#handles){
if($_=readline($op)){
my#col=split;
if($col[8]) {
$gibberish=0;
$col[3]+=0;
$key = $col[3];
$col[5]+=0; #otherwise you print nothing
$col[5] = sprintf("%.2f", $col[5]);
print OUTFILE"$col[5]\t";
$continue=1;
} else {
$key = "\t";
$continue=1;
$gibberish=1;
}
}else{
#do nothing
}
}
if($continue != 0 && $gibberish != 1) {
print OUTFILE"$key\n";
} else {
print OUTFILE"\n";
}
}
undef#handles; #closes all files
close(OUTFILE);
print "Process Complete! The output file is located in the current directory with the filename: _combined.out\n";