Using convertapi, I would like to set range and convert only selected area to pdf. Is this possible?
<?php
require_once('vendor/autoload.php');
require_once 'vendor/convertapi/convertapi-
php/lib/ConvertApi/ConvertApi.php';
use \ConvertApi\ConvertApi;
ConvertApi::setApiSecret('secret');
$result = ConvertApi::convert('pdf', [
'File' => 'output/spreadsheet_2.xlsx',
], 'xlsx'
);
$result->saveFiles('output');
?>
Thanks in advance.
Currently you can set only WorksheetName or WorksheetIndex parameters for narrowing down what you want to convert.
If you want to convert a range of sheets, you can only loop on the range, each time converting a separate PDF from one sheet at a time.
No better choice up until now.
Related
I'm trying to convert PNG files to lossless WebP in Perl with Graphics::Magick. Command line for that is:
$ gm convert in.png -define webp:lossless=true out.webp
My Perl code looks something like that:
use Graphics::Magick;
my $image = Graphics::Magick->new();
$image->Read("in.png");
my $image_data = $image->ImageToBlock(magick => "webp");
print $out_fh $image_data;
This code writes lossy WebP files perfectly, but how can I express the "-define" thing in terms of Perl API?
Thanks,
Update: looks like I need to call AddDefiniton API function (http://www.graphicsmagick.org/api/image.html#adddefinition). Looks like it's not exported via Perl API as of now.
I know it is of no help to you, but for those interested in how to do it in PHP, here is how:
$im = new \Gmagick($src);
$im->setimageformat('WEBP');
// Not completely sure if setimageoption() has always been there, so lets check first.
if (method_exists($im, 'setimageoption')) {
$im->setimageoption('webp', 'lossless', 'true');
}
$imageBlob = $im->getImageBlob();
$success = #file_put_contents($destination, $imageBlob);
For more webp options, check out this code
I wrote a function where two insert query have. One is executed and inserting data properly. But next one is not executing. And I cant check the value i want to insert if it is set or not. How to do the stuff? EXPERT's have a look kindly. My function is given below:
add_action( 'save_post', 'cs_product_save' );
function cs_product_save( $post_id ){
global $wpdb;
$cs_product_array = $_POST['cs_product'];
$cs_product_count = count($cs_product_array);
$event_start_date = $_POST['event_start_date'];
$event_end_date = $_POST['event_end_date'];
$event_start_time = $_POST['event_start_time'];
$event_end_time = $_POST['event_end_time'];
$event_all_day = $_POST['event_all_day'];
$event_phone = $_POST['event_phone'];
$event_location = $_POST['event_location'];
$event_map = $_POST['event_map'];
$table_cause_product = "wp_cause_woocommerce_product";
$table_event_info = "wp_cause_info";
for( $i=0; $i < $cs_product_count; $i++ ){
$wpdb->insert($table_cause_product,array(
'cause_ID'=>$post_id,
'product_ID'=>$cs_product_array[$i],
'status'=>'1'
),array('%d','%d','%d'));
}
$wpdb->insert($table_event_info,array(
'cause_ID'=>$post_id,
'event_start_date'=>$event_start_date,
'event_end_date'=>$event_end_date,
'event_start_time'=>$event_start_time,
'event_end_time'=>$event_end_time,
'event_all_day'=>$event_all_day,
'event_phone'=>$event_phone,
'event_location'=>$event_location,
'event_map'=>$event_map
),array('%d','%s','%s','%s','%s','%d','%s','%s','%d'));
}
I don't see any problem here with your code. But be sure to double check your code.
The issues my be with the name of your database table names. Are you sure that $table_cause_product and $table_event_info holds the actual name of the tables? I would recommend to use $wpdb->prefix instead of harcoding table names.
In my case I would check the function in several parts.
Check the $_POST actually holds the data I want.
Use $result = $wpdb->insert( $table, $data, $format ); in all cases for debug purpose as the $result would hold the result of the operation. If its is false then I would be sure that there is definitely something wrong with the operation.
Finally I would use a wp_die() (though its not a standard way to do, but it suffices my purpose) so that I can see the dumped variable data.
One major issue you might face with your code that if the post is edited after saving then it might insert another row for same post data. Again if the post is being autosaved, you need some safeguard. I would recommend a where clause here to check the row already exists or not. If exists then you can simply update the row, or else insert the data.
Hope this might help you.
Somebody could help me to how to change string date with format_date function.
Here is my code$datesql = format_date("2014-04-02 11:11:31", 'custom', 'Y-m-d');
drupal_set_message(t('date '.$datesql));
I suppose drupal to show this message "date 2014-04-02", but drupal just show the message "date", not $datesql. What is wrong in my code.
Thanks
Function "format_date" expects first parameter to be a timestamp, not a string. Try to wrap this first parameter with "strtotime" function and you will get a better result.
PS: do not include a variable in the first parameter of the "t" function. This could result in a lot of translatable strings. Pass it in the second parameter with "#myvar" as key. Check the "t" function documentation for more details.
try this
$date = new DateTime('2014-04-02 11:11:31');
$da = $date->format('Y-m-d H:i:s');
drupal_set_message('date '.$da,'status');
format_date() is use a covert a date in drupal created date not a convert a custom date
format_date($node->created, 'custom', 'Y-m-d');
I'm using formulas in phpexcel and I have a problem using the countif
Wrong number of arguments for COUNTIFS() function: 4 given, 2 expected
But in the documentation countif is:
COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…)
I have for exemple:
COUNTIFS(C$17:D$46,$B55,C$16:D$45,$B55)
It works when I directly use it on excel, is there a way to catch the error and keep the formula ?
Change the definition of COUNTIFS in the /Classes/PHPExcel/Calculation.php file (around lines 499 to 502).
Currently it reads:
'COUNTIFS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
'argumentCount' => '2'
),
add a comma after the argument count to make it
'COUNTIFS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
'argumentCount' => '2,'
),
Note that the COUNTIFS() function isn't actually implemented, so you can't do a getCalculatedValue() on any cell using the function to get the correct result, but it will then save correctly using the Excel2007 Writer.
COUNTIFS in phpexcel is not yet implemented.
1-How do I set the column to be sorted when the grid is created? then upon reloading the grid, it automatically utilize that sort to appropriately display the records.(without me clicing on it)
Can this be done on the grid itself so it is independent of the underlying data store?
2-how do i change Date format displaying in a grid column?
my data render a date like this /Date(1316020760837+0000)/
i tried using renderer: Ext.util.Format.dateRenderer('m/d/Y'),// format: 'm d Y'
but it gives me NaN/NaN/NaN
any help would be appreciated.
thank you
solved:
i used sortOnLoad with sorters
var myStore = new Ext.data.JsonStore({
fields: ['Item1', 'Item2', 'Item3', 'Item4']
, data: []
, sortOnLoad: true
, sorters: { property: 'Item1', direction : 'DESC' }
});
in my c# code i used item.DateEnd.ToString("MMM dd, yyyy").
see this or this for standard and custom format
or better
in extjs4 ,you should specify the dateFormat so Ext can parse it properly and you'll ensure it gets read ok.
{name: 'Item1' , type : 'date',dateFormat :'MS'}
u can see this for available format strings.