How do I combine numerous PDF blob files into a single PDF so that can then be printed?
<?php
include 'config.php';
include 'connect.php';
$session= $_GET[session];
$query = "
SELECT $tbl_uploads.username, $tbl_uploads.description,
$tbl_uploads.type, $tbl_uploads.size, $tbl_uploads.content,
$tbl_members.session
FROM $tbl_uploads
LEFT JOIN $tbl_members
ON $tbl_uploads.username = $tbl_members.username
WHERE $tbl_members.session= '$session'";
$result = mysql_query($query) or die('Error, query failed');
while(list($username, $description, $type, $size, $content) =
mysql_fetch_array($result))
{
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: inline; filename=$username-$description.pdf");
}
echo $content;
mysql_close($link);
exit;
?>
How do I combine numerous PDF blob files into a single PDF so that can then be printed?
You don't - at least not by simply combining the byte streams. You will need to process each file, and merge them into a new PDF document.
Some pointers, maybe one of the solutions, depending on the platform you're on, works for you:
PHP - How to combine / merge multiple pdf’s
How to combine images inside pdf by programme?
Need to merge multiple pdf’s into a single PDF with Table Of Contents sections
pdftk will merge multiple PDF files, as well as PDFsam..
Related
I have a API result that contains multiple photo's in a set / list / childs (I do not know the right term), the result looks like this.
"photos":[{"small":"https:\/\/pararius-office-prod.global.ssl.fastly.net\/10379\/files\/photos\/api-little\/52016521.1667319824-357.jpeg?fit=crop&width=100&height=100",
"big":"https:\/\/pararius-office-prod.global.ssl.fastly.net\/10379\/files\/photos\/api-export\/52016521.1667319824-357.jpeg?width=600",
"huge":"https:\/\/pararius-office-prod.global.ssl.fastly.net\/10379\/files\/photos\/api-huge\/52016521.1667319824-357.jpeg?width=1000&fit=bounds",
"middle":"https:\/\/pararius-office-prod.global.ssl.fastly.net\/10379\/files\/photos\/api-middle\/52016521.1667319824-357.jpeg?width=1000&fit=bounds",
"category":"photo"}]
I want to shot the big photo but I don't know how.
The rest is working fine.
I tried to load it with '. $property->city . ' but that does not work.
I assume you need to get the 'big' photo from "photos".
I start by copying your photo data into $results.
echo '<pre>';
$results = '"photos":[{"small":"https:\/\/pararius-office-prod.global.ssl.fastly.net\/10379\/files\/photos\/api-little\/52016521.1667319824-357.jpeg?fit=crop&width=100&height=100",
"big":"https:\/\/pararius-office-prod.global.ssl.fastly.net\/10379\/files\/photos\/api-export\/52016521.1667319824-357.jpeg?width=600",
"huge":"https:\/\/pararius-office-prod.global.ssl.fastly.net\/10379\/files\/photos\/api-huge\/52016521.1667319824-357.jpeg?width=1000&fit=bounds",
"middle":"https:\/\/pararius-office-prod.global.ssl.fastly.net\/10379\/files\/photos\/api-middle\/52016521.1667319824-357.jpeg?width=1000&fit=bounds",
"category":"photo"}]';
echo "$results\n\n";
I then get a substring from the 10th character, removing photos:[
Remove the slashes.
And trim the trailing ].
We now have valid JSON.
$results = stripslashes(trim(substr($results,10),']'));
echo "$results\n\n";
To confirm the JSON is now valid I convert it to an array.
$results = json_decode($results,1);
var_export($results);
I then get the 'big' photo src.
$src = $results['big'];
echo "\n\nsrc = $src\n\n";
echo '</pre>';
Then show the photo:
echo "<img src=\"$src\" />";
The Result:
How Can I display the below XML into an HTML page: http://weather.maltairport.com/xml/WeatherReport_21032014.xml
XML Sample:
<WeatherForecast>
<date>2014-03-21</date>
<publishedtime>17:00:14</publishedtime>
<forecast>
<time>16:40</time>
<forecastvalid>Outlook for Tomorrow</forecastvalid>
<conditiontoday>SUNNY</conditiontoday>
<temperature>16</temperature>
<humidity>76</humidity>
<atmospressure>1021</atmospressure>
<wind>SE 8 Knots</wind>
<sunrise>06:05</sunrise>
<forecastimage>
http://weather.maltairport.com/assets/img-design/weatherconditions/52.png
</forecastimage>
<sunset>18:14</sunset>
<dayforecast day="1">
<forecastdate>2014-03-22</forecastdate>
<condition>MAINLY CLOUDY</condition>
<high>17</high>
<low>12</low>
<heat_stress>17</heat_stress>
<wind_direction>ESE</wind_direction>
<wind_force>F3 --> SSE F3 to 4</wind_force>
<uvindex>5</uvindex>
<forecastimage>
http://weather.maltairport.com/assets/img-design/weatherconditions/21.png
</forecastimage>
</dayforecast>
I am a newbie to these types of XML files so any help/guidance is truly appreciated.
You need a couple things:
A) An XSL file that transforms the XML into an output type of your choice, in this case HTML.
B) A PHP (or other) script to merge and process the transform. I use the following script in a project of mine:
<?php
$xml = new DOMDocument;
$xml->load('index.xml');
$xsl = new DOMDocument;
$xsl->load('index.xsl');
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
echo $proc->transformToXML($xml);
?>
I have created similar table to this one
http://rtfm.modx.com/display/ADDON/MIGX.Simple+opening+hours+table
I have successfully exported data to resource, but i want to show it in a chunk so i can display it in getresources.
I use getresources to display resources and besides title and intro text i would like to show datesTV data.
I use template chunk for migx:
[[+date:notempty=`<td>[[+date:strtotime:date=`%d.%m.%Y, %H.%M`]]</td>`:default=`<td colspan="2">No show!</td>`]]
If i use this in other chunk for getresources [[+tv.datesTV]] i get this array out:
[{"MIGX_id":"1","date":"2012-10-28 21:00:00"},{"MIGX_id":"2","date":"2012-10-28 01:45:00"},{"MIGX_id":"3","date":"2012-10-30 02:45:00"}]
How can I display this data as it should be in a chunk.
Ok here you can se how my snippet looks like..
<?php
$strJSON = $modx->resource->getTVValue('spored');
$arrJSON = $modx->fromJSON($strJSON);
foreach($arrJSON as $arrJSONDataSet)
{
foreach($arrJSONDataSet as $key => $value)
{
echo $key . ' => ';
echo $value;
echo '<br />';
}
}
With MIGX you need a snippet to parse and format the raw TV data as it's stored as JSON.
For a rough example of how to do this, refer back to the link you mentioned and try the getImageList snippet:
http://rtfm.modx.com/display/ADDON/MIGX.Simple+opening+hours+table#MIGX.Simpleopeninghourstable-ParsingtheData
You'll need to include that snippet call in your getResources chunk which is going to be really inefficient; it would be better to code up a custom snippet to retrieve the necessary data.
But see how that goes first...
I'm using Zend framework with Mysql. My application loads the data from a csv file into the mysql database. The table has two columns (id and name). The application uses file_get_contents to read the csv file and uses $this->insert($data) of Zend_Db_Table. The file has exactly two columns similar to the table.
The problem I'm facing is, while inserting data, it inserts around 500 rows only. Remaining rows are not inserted in database. No errors are shown in the browser and the application works like nothing happened. I tried with different data but the problem is the same.
$file = file_get_contents($filename, FILE_USE_INCLUDE_PATH);
$lines = explode("\n", $file);
$i=1;
for($c=1; $c < (count($lines)-1); $c++) {
list($field1, $field2) = explode(",", $lines[$i]);
$borrower= new Application_Model_DbTable_TempB();
$borrower->uploadborrower($field1, $field2);
$i++;
The uploadborrower function simply makes array $data and insert by using this->insert($data) – A
Can anyone help me to find where the problem is and how to solve the problem?
Can it be a problem of timeout? If the CSV is massive, it can happen.
Try:
set_time_limit(0);
before to execute your code.
$file = file_get_contents($filename, FILE_USE_INCLUDE_PATH);
$lines = explode("\n", $file);
set_time_limit(0);
$i=1;
for($c=1; $c < (count($lines)-1); $c++) {
list($field1, $field2) = explode(",", $lines[$i]);
$borrower= new Application_Model_DbTable_TempB();
$borrower->uploadborrower($field1, $field2);
$i++;
i am using this query to get image saved in medium blob in mysql which calls download function in brands controller
SELECT *,CONCAT(\"<img src='../../brands/download/?file_id=\",id,
\"&name=\",logo_name,\"'/>\") AS file
FROM c_brands WHERE merchant_id=" .$merchant_session;
DOWN LOAD FUNCTION
function download()
{
//$this->view = 'Media';
Configure::write('debug', 1);
$id = $_GET["file_id"];
$file = $this->Brand->findById($id);
header('Content-type: ' . $file['Brand']['logo_type']);
header('Content-length: ' . $file['Brand']['logo_size']);
header('Content-Disposition: inline; filename='.$file['Brand']['logo_name']);
echo $file['Brand']['logo'];
exit();
}
But somehow it is just displaying the placeholder for image.
Can you explain more? I mean, what's the relation between the first query (the one with Concat) and the download() action, plus how are you using this query? Also, I notice that you are putting <img src='../../brands/download/?file_id=\", and that relative path is wrong. It must be src="/brands/download".
Still, your question is not clear.