I have a lot of swf files that have the Stage.scaleMode property set to noscale. When embedding the videos they do not scale at all (which would be expected).
I am looking for a way to programmatically change the scaleMode to showAll in my swf files. Ideally I would like to process a swf file using PHP and alter the file. Otherwise some kind of swf library would be nice.
So my question would be is there an easy way to open a swf file in binary mode, jump to the part of the swf file where it stores the scaleMode and alter the file using PHP? Or, is there a swf library that can do it for me?
All swf files are scalable.. its the configuration you put it on the page with which decides its scale mode. but you can easily override it by changing the scale property, in the html you use to include it with. Atleast. since you want to use php to get the job done, i tought you are making a website:
you can set an property scale. Which has 4 diffirent modes : default, exactfit, noborder and noscale
If this is for some reason not possible, you could concider using the ming library in php. But the scale property in html should always be prefered over altering the swf file
Related
Currently working on an offshoot of the idea more adequately addressed here.
Creating a Secure File Hosting Server for PDFs
I'm developing a secure PDF hosting website where certain users can download certain PDF's that I have stored outside of the webroot to prevent people from accessing documents they shouldn't access.
I've got the download working using the first solution, but I want to implement a 'view/preview' feature too. I still don't get content headers as well as I should but I believe what is causing the bulk of my issues is I can't put a 'src' attribute on the embed/object/iframe/whatever. And that's kind of the point of the system.
My question is, is there any way to feed a file (as opposed to a url) to an embed/object? I would like to keep my current system and I'm going for simplicity at the moment so the easier the better.
I saw Recommended way to embed PDF in HTML? and will probably check out pdf.js if I'm trying something that isn't doable.
I have not yet had the chance to play with pdf.js, but it either that or a flash player of some sort.
Or you rely on the browser to display it has a webpage and you can iframe it, but that's so lame... it would work only for a fraction of you users.
PDF2SWF - convert PDF to SWF ( 1 page = 1 SWF).
Use other SWF (reader) to load SWF pages via XML or something else.
Use $_SESSION to store ID of PDF document which should be served through e.g. /preview (same link for previewing all documents)
Don't serve original PDF, put a watermark, or make them low-res.
Otherwise, your PDF will never be "secure".
http://www.swftools.org/
I'm using the jquery file upload script and it's working really well so far. The last obstacle I have is I only want to use jpg images for my website but allow users the option of uploading gif, png, or jpg.
I'm assuming I need to alter or add some additional methods to the upload.class.php file to accomplish this.
Has anyone done this before and if so is this the correct file to modify?
You will need to write some pretty tough conversion functions if you want to implement it in pure JavaScript and you'll be limited to modern browsers that support FileAPI and FileReference. Also the conversion function you'll have to write would manipulate the files at the binary level and will have to respect some pretty strict file structures as specified by GIF/JPEG/PNG standards specifications.
As i recall SWFUpload (a Flash - ActionScript - JavaScript library) has this functionality embedded, you can specify the format in which it should send the file to the server but it only applies if you wish to use the resizing function which sends a resized version of the original file to the server but it has some downsides.
I want to give users a preview of certain files on my site and will be using scribd API. Does anyone know how I can access the full file from my server and save the file under a different name , which I will then show to users..Can't think of a way to do this with PHP for .docx and image files...Help is much appreciated.
For "splitting" images, use an image processing library like gd to crop the image (lots of examples to be found on how to do that all over the place). For Word documents, use a library like PHPWord (or one of the other myriad such libraries) to open the document, remove/extract as much text as you need, then save that into a new Word file.
For other file types, find the appropriate method that allows you to manipulate that format, then do whatever you need to do with it.
I am trying to generate a pdf from a web page which has pictures and swf files.
Final pdf should have pictures (swf should be converted into image, last frame is sufficient).
I am able to generate pdf when only images are there but i am stuck in creating pdf when the web page has swf files.
I've used wkhtmltopdf before to render pdfs programatically from web sites. I'm not sure if it'll cope with swf but it may do since it uses a version of webkit compiled in to qt.
You might be able to use wkhtmltopdf --enable-plugins. But according to this bugreport it might not work http://code.google.com/p/wkhtmltopdf/issues/detail?id=48 with the flash plugin (Java however does!).
Another option is running a browser in headless mode, or on a virtual X. Firefox3 works supposedly if you use the extension "CommandLinePrint".
Xvfb :2 -screen 0 1600x1200x24 &
firefox --display=localhost:2.0 -print http://flashgames.com -printmode pdf -printfile '/tmp/test.pdf'
Infos stolen from http://spielwiese.la-evento.com/xelasblog/archives/31-Headless-Firefox-als-HTML-to-PDF.html (in German however).
But there are a few more guides like this ("headless browser, HTML to PDF"). I would totally link to one of the dupes here on Stackoverflow. But I'm too lazy to search right now.
Since you are wanting to output the target page as a PDF I would look at using .rdlc (Report Definition Language Client). It is part of the Microsoft.Reporting namespace and is designed to work with asp.net. It is freely usable and redistributable.
In many cases the layout of a web page is not "printer friendly". By using this technique you can re-arrange the layout and spacing of the PDF output to a presentation that is more printer friendly.
This will not "directly" convert your page to a PDF, but rather allow you to adapt your page layout and data to a dataset and use that to build a report. That report can then be output programmatically at runtime using the reportviewer control. If this approach interests you, let me know and I will be glad to provide more help getting you through setting it up and using.
How to push new images in a web application, so that the cached is not taken?
When I am having a new JS or CSS file, it's easy.
Because they are in smarty templates, and I am having a version number in the URL (like a.js?v=9).
Now, the problem with images are: -
They are referred from the CSS files, and I can not have a version variable there.
So, how do you do it?
In the middle between cleanest and easiest way, I would :
In the CSS, point to images with URLs containing a distinct marker ; like "image.png?VERSION_NUMBER" (literaly)
this will allow the CSS file to be used while developping
To avoid any problem with cache, I would configure Apache (on the development machine) to indicate files should not be cached by the browser
I would use some kind of "build process", that would replace this VERSION_NUMBER marker by the real version number in every CSS file (and possibly, JS, PHP, HTML, ... )
This would create modified files, containing the right version number
Those files would be the ones deployed to the webserver
Ideally, the VERSION_NUMBER could be the SVN revision of each file ; this way, only files really modified would have to be modified ; but also harder : for each file (each URL in the CSS file !), you have to determine it's revision number before replacing the marker !
If some browser don't cache images/js/css because of the query string, the marker could be included in the files' names.
And now that you have a "build process", you can also use it to make some other manipulations, like minifying JS and CSS files, for instance
As a side note : yes, creating and testing the build process / script takes some time ; it might be easier to server CSS files through PHP, using a variable in those to indicate the version number... But, for performances, serving CSS files (at least one per PHP page ; probably more !) wouldn't be that wise ; so, probably better to take a bit more time to write the build process...
You could manually change the CSS file at the same time that you change the image file, put a "?v=1" onto the end of the image url.
You could also configure your server to send CSS files through the PHP processor, so you could stick some PHP code in there to set the "?v=8" query string on the image url.
As part of my build process, I append a querystring to javascript includes and image URLs that has the file's LastModified date/time as a long. This allows caching to work when it should, and automates something that is easy for the developer to forget.