I am using the KNPSnappy Bundle with the Google Tool Wkhtml2pdf.
That is working with the Firefox 31 I use for the development (and Opera).
On our Company Computers is IE9 available.
With the IE I get an error:
There is the Question about open or save the file.
If I choose save it will tell note(3) couldn't be downloaded.
If I click retry it will freeze the IE.
I did check that the webpage is local internet with Low security level.
Working on an Centos/Apache Server.
Did not find an error in log off Apache or Symfony or Eventlog.
Where to find and information?
The File name 'note' that comes with error in IE is not the filename that was created in Firfox.
I did find the problem that was breaking the IE9.
The 201 as a response code was the problem just changed it to 200 and also the IE was working fine like the Firefox and the Opera did.
return new Response (
// use wkhtmltopdf options
$this->get ( 'knp_snappy.pdf' )->getOutputFromHtml ( $html, array (
'orientation' => 'Portrait',
'images' => true
) ), 201, array (
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="Invnr_' .$id. '.pdf"',
'Charset' => 'UTF-8',
'images' => true,
'print-media-type' => true
) );
Related
I've a multisite installation of Drupal 8, the "main" website expose some REST webservices, locally i've some troubles on testing them, because there's no way for the various sites to see each other, when i try to do something like that
try {
$response = $this->httpClient->get($this->baseUri . '/myendpoint', [
'headers' => [
'Accept' => 'application/json',
'Content-type' => 'application/hal+json',
],
'query' => [
'_format' => 'json',
'myparameters' => 'value'
],
]);
$results = $this->serializer->decode($response->getBody(), 'json');
}
catch (RequestException $e) {
$this->logger->warning($e->getMessage());
}
return $results;
I always receive a timeout and there's no way i can make it work, i've my main website with the usual url project.ddev.site (and $this->baseUri is https://myproject.ddev.site ) and all the other websites are in the form subsite.ddev.local
If i ssh in the project and run ping myproject.ddev.site i see 172.19.0.6
I don't understand why they cannot see each other...
Just for other people who can have a similar problem: my issue was with xdebug i have it with the autoconnect, so when the request from the subsite to the main site was made, it get stuck somewhere (phpstorm didn't stop anywhere by the way) so it made the request time out.
By disabling, or configuring only for the subdomain, and avoiding it to accept the external connenction from unconfigured servers (in phpstorm) it started working, still have to do some work as i need to debug "both sides" of the request, but in this way i can work with that...
I've not thought before to try disabling xdebug because actually it didn't came into my mind...
I am testing my controller from Symfony2 with PHPUnit and the class WebTestCase
return self::$client->request(
'POST', '/withdraw',
array("amount" => 130),
array(),array());
$this->assertEquals(
"You can withdraw up to £100.00.",
$crawler->filter("#error-notification")->text());
But I get this error:
Expected: "You can withdraw up to £100.00."
Actual: "You can withdraw up to £100.00."
The thing is that in the webpage and the source code it looks fine, so I am thinking that maybe PHPUnit is having some trouble to fetch the text as UTF8?
What am I missing?
solution:
Make sure the mbstring extension is enabled.
There was a bug about failing tests with iconv reported in the kohana bugtracker.
tips:
As proposed in this question/answer - you can test for correct UTF-8 output:
$this->assertEquals(
mb_detect_encoding(
crawler->filter("#error-notification")->text(),
'UTF-8'
),
'UTF-8'
);
You can include accept-charset headers with requests sent by the client:
$client->request(
'POST', '/withdraw',
array("amount" => 130),
array(),
array(),
array('HTTP_ACCEPT_CHARSET' => 'utf-8')
);
Following some of the many posts related to the subject I finally came up with this version of the "force download" code:
public function downloadAction(Request $request){
$filename= 'test.jpg';
$response = new Response();
$response->headers->set('Content-Type','image/jpg');
$response->headers->set('Content-Disposition', 'attachment; filename="' . basename($filename) . '"');
$response->sendHeaders();
$response->setContent(file_get_contents($filename));
return $response;
}
Now, this works fine with zip files (obviously using the right content-type), but for jpg something different happens. When using HexCompare to check both original and downloaded JPG I found that the downloaded version adds "EF BB BF" at the beginning of the file. This seems to be enough for the Windows Image Viewer, which ends reporting a corrupt file error.
On the other hand, the same downloaded jpg opens perfectly in Adobe Photoshop (less strict perhaps?)
Ideas? anyone?
Thanks in advance.
Z
UPDATE: Downloaded Zip files using this code can only be opened with WinRAR or WinZIP, Windows Explorer Zip Extract shows a Corrupt File Error message.
UPDATE2: OK, I know now is a BOM issue. Now, how can I get rid of that nasty "EF BB BF" from the file_get_content result?
Please try the following as suggested here
// Set headers
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', mime_content_type($filename));
$response->headers->set('Content-Disposition', 'attachment; filename="' . basename($filename) . '"');
$response->headers->set('Content-length', filesize($filename));
// Send headers before outputting anything
$response->sendHeaders();
$response->setContent(readfile($filename));
If you're using apache with mod_xsendfile, try:
return new Response('', 200, array(
'X-Sendfile' => $filename,
'Content-type' => 'application/octect-stream',
'Content-Disposition' => sprintf('attachment; filename="%s"', $filename)),
// ...
));
If you're using nginx's X-Accel read here. and use
return new Response('', 200, array(
'X-Accel-Redirect' => $filename,
'Content-type' => 'application/octect-stream',
'Content-Disposition' => sprintf('attachment; filename="%s"', $filename)),
// ...
));
to gain more control with nginx additional available options are ...
// ...
'X-Accel-Limit-Rate' => '1024',
'X-Accel-Buffering' => 'yes', // yes|no
'X-Accel-Charset' => 'utf-8',
// ...
I'm working with SiteCore and I need to pull some data out of the software via either that API or the SQL database using a PHP script. The reason I say both are possible is because even if the database changes later on, that doesn't matter to me.
Anyway...
I'm trying to pull any data fields that I can get from a particular issue. This is my SOAP code so far, and it connects to the service and such, but the return isn't what I need...
try
{
$client = new SoapClient('http://localhost:8083/sitecore/shell/webservice/service.asmx?WSDL');
$credentials = array('Password' => 'mypassword','Username' => 'sitecore\myusername');
$Current_Issue = array(
'id' => '{043B69BA-3175-4184-812F-C925CE80324E}',
//'language' => 'en',
//'version' => '1',
//'allFields' => 'true',
'databaseName' => 'web',
'credentials' => $credentials
);
$response = $client->GetItemMasters($Current_Issue);
print_r($response);
}
catch(SoapFault $e)
{
echo $e->getMessage();
}
catch(Exception $e)
{
echo $e->getMessage();
}
This is my output:
stdClass Object
(
[GetItemMastersResult] => stdClass Object
(
[any] => <sitecore xmlns=""/>
)
)
ANY help is appreciated. If anybody knows an example SQL query that I can use, that would be just as useful as an alternative method.
Thanks
If you are running Sitecore 6.5 / 6.6 you may want to take a look at the Sitecore Item Web API which was released yesterday (5/11/12).
http://sdn.sitecore.net/Products/Sitecore%20Item%20Web%20API.aspx
This allows you to perform RESTful operations against Sitecore items without the need for the old web service / SOAP interface. Using this module you can receive a JSON representation of a Sitecore item or collection of items and even post back changes. You may find it easier to work with :)
If you have to use the SOAP interface, are you sure that your items are published ? Try changing the databaseName -> 'master' and see if you get any results. Other things to check are the permissions of the user credentials you are using.
I'm using CentOS 5.5 Linux (without X), PHP 5.3 and Drupal 7.0.
The core language of my site is Russian (not English)!
I've created a game.info and the following game.module which generates 3 blocks for the front page:
function game_block_info() {
return array(
'game_main' => array(
'info' => t('Set FlashVars and show the flash game.'),
'cache' => DRUPAL_NO_CACHE,
),
'game_winner' => array(
'info' => t('Show the winner of the last week.'),
'cache' => DRUPAL_NO_CACHE,
),
'game_leader' => array(
'info' => t('Show the leader of the current week.'),
'cache' => DRUPAL_NO_CACHE,
);
}
function game_block_view($block_name = '') {
global $user;
if ($block_name == 'game_main') {
if (user_is_logged_in()) {
$content = t('User is logged in.');
} else {
$content = t('User is an anonymous user.');
}
drupal_set_message("<pre>$output</pre>\n");
return array(
'subject' => t('Main Game'),
'content' => $content,
);
} else if ($block_name == 'game_winner') {
....
} else if ($block_name == 'game_leader') {
....
}
}
It works ok, but I need all strings to be in Russian and do not want to hardcode them into my game.module file.
Do I need to create the 3rd file called game.po and add it to the game.info?
How can I create a .po file? I would prefer a simple editing of that file if possible, without obscure tools.
I've also tried a tool:
# xgettext -n game/game.module --keyword=t
xgettext: warning: file `game/game.module' extension `module' is unknown; will try C
game/game.module:87: warning: unterminated character constant
game/game.module:100: warning: unterminated character constant
These should be the steps:
To generate the .pot file, install the module Translation template extractor
Go to the "Extract strings" tab on the Locale administration interface, select your module and submit the form. You will get one single template file generated.
Then you can translate the strings with a tool like Poedit (http://www.poedit.net).
When you are done, files should be copied to a "translations" sub-folder in the module folder, so they are automatically imported by Drupal when installing your game module.
Please, give feedback and tell what problems did you have. Thanks