How to get variable from php file to actionscript? - php

I will write the text that getting from php file in adobe flash . how can I?

let your php-script do the output in form of a xml, which should be easy to load and processed with actionscript.

Related

get data from pdf string and display

I'm creating a pdf from formdata using fpdf (http://www.fpdf.org/).
Using Jquery I'm able to send the data to the pdf-creating script, and make the pdf appear in browser.
Now I'm trying to return the pdf-data to the formpage using fpdf's option to get the pdf as a string and echoing it.
$pdf_file_contents = $pdf->Output("","S");
echo $pdf_file_contents
My question now is
How do I use this data to preview the pdf under the form?
Do I need to use an pdf-viewer or can I use an <iframe> and am I doing this the correct way by returning the variable in an echo?
I can think of two options:
Embed a PDF viewer and handle that call in JS. (Wait for the response from PHP and display the outputted file inline)
Trigger a redirect or load an iframe which displays $pdf->Output($filename,"F") from a temp file.
The result of $pdf->Output() is displayed using the browser's built-in viewer. If there is any output above that in the page FPDF will return an error to say FPDF error: Some data has already been output, can't send PDF.
FPDF error: Some data has already been output, can't send PDF
There might be some other option I'm missing but those would be my first suggestions.

Getting data from an SVG file using PHP

I'm not sure if this is a duplicate question or not but I'll ask it anyway.
How do I take image data from an SVG file and pass it into PHP, then output the info with HTML? I know it can be done in Javascript, but that's not how this particular project needs to be done.
you can use file_get_contents to read svg file data in php.
$templateString= array(
'front' => file_get_contents($svgUrl, FILE_USE_INCLUDE_PATH)
);
echo $templateString;
Now complete svg data is in $templateString variable.
This is what I did and got my SVG XML content from URL.
$svg_file = file_get_contents($url);
echo $svg_file;

Preview pdf file created with TCPDF in embed tag after Ajax call

So my application generates pdf files using TCPDF, and that works fine. That is done inside php file, called with ajax. I'm using embed tag to preview them like:
$.ajax({
url: 'create_pdf_file.php',
success: function(){
/* https://stackoverflow.com/questions/17083018/jquery-loads-cached-file-inside-ajax-success-function */
$('#pdf_placeholder embed').attr('src','output/my_file.pdf?v=' + Math.random()');
}
});
Because many users could generate my_file.pdf at the same time, there could be a case when one user will preview a file generated for another user. So my question at this point is how to force TCPDF to output directly into that tag, not using temp file
Output('my_file','I')
not working here after ajax.
There is an advice here to echo pdf directly back, but i don't know how to do that or is it possible at all. Anyway will try with success(data) to receive that like json.
Other workaround is to give session-bond file name for each user, but is using session_id() and appending to the file name is safe? Most probably I will end with generating UID for each session.
Any general advices are welcome.
You should try passing what TCPDF will produce in a way widely used in embeding images: Data Uri
Embedding Base64 Images
This however might choke browser - i haven't test this.
I would rather save pdf file on server, print filename to browser or other ID of produced file so it could be read with "success" of the ajax request. Then calmly pass proper filename to Embed element. If you wish to do it more safely you can encode it using already used session-exclusive data like session cookie or data that is assosiated with that cookie on a server. You can bond pdf file access to IP that sent request to produce it and timestamp of request that caused production.

PHP Parse a PHP file echoing XML data

I have a php file which generates and echo's XML data.
So basically it shows a XML but it's a PHP file.
I need to read and parse this data.
I've seen this: simplexml_load_file('some.xml'); but in this case I cannot do this as I've got the xml as a php file.
How can I do this?
Just the same way, the file extension doesn't matters (.xml or .php) what it really matters is the actual contents of the file, so if your file have a .php extension but its contents are valid xml then you should have no problem:
simplexml_load_file('somepage.php'); //this is fine
Set mime type to xml header('Content-Type:text/xml');

How to print out file with help PHP

Is there any way to print out (to cups for example) html file with help PHP (linux server without X) ?
except shell_exec(), system() etc...
And when i mean print html file means print not source code, means print rendered result.
is it possible with help PHP ?
I know thath there is some possibilities like,
- run X server,
- run browser,
- exec terminal command which will ask browser open and print out html file
but without shell_exec is it possible ?
You'll need to render the file yourself into some sort of printable format such as a postscript or PDF file. There is a good PHP5 library to create PDFs from HTML called dompdf.
So generate the HTML output and store it into a string, you may want to use output buffering to do this. See the PHP manual.
Then you can use dompdf to render the HTML contents into a PDF file. Storing it into a temp directory probably makes sense if you don't need to keep the file.
Then, you can use the cups cli to print the file, see the cups documentation. e.g.
shell_exec('lp '.$filename);

Categories