I want to use TCPDF library in my ZF2 project. I have the source of library but it is incompatible with Zend Framework 2 namespace (not PSR-0). How to include it in the project? If there are any way to convert it with ZF2 compatible.
If there is a way to use the library as it is then please show the process (where to place library source and how to include it).
Please do not suggest ZendPdf as an alternative.
Thanks
So one way to do this with the command line tool that foozy mentioned, but this leads to altering some one else's code and who wants that headache. You can can also do this with Composer using the autoload:classmap directive since it is a class even though it's not PSR-0.
Basically, you would place the TCPDF files somewhere convenient (vendor folder, lib folder, etc.) and then add the autoload directive to composer.json like so:
{
"autoload": {
"classmap": ["vendor/tcpdf"]
}
}
Assuming you placed the tcpdf folder in the vendor folder and that the TCPDF class is in the root of the tcpdf folder. Then you run php composer.phar update . Composer will then add that folder as a source location to the autoloader function it registers with the SPL autoloder.
Then where ever you want to use the TCPDF class you would do $pdf = new \TCPDF().
NOTE: I'm not 100% on the path being relative to the project root, composer.phar, or the vendor folder.
Related
I'd like to use the dist package from swagger-ui to be able to expose my webservice. The dist pkg is located here: https://github.com/swagger-api/swagger-ui/tree/master/dist
While I can use this: Swagger UI with Tynamo Resteasy for Tapestry 5.4
to create the swagger.json, I'd like to use swagger-ui to expose this json.
Can anyone point me on how to use this dist folder as is in Tapestry (pref. 5.4)?
Note: I tried using the index.html as a tml (by loading all #Imports it needs in the .java page corresponding to the tml, but that did not work, as a lot of assets referenced inside the dist folder give me 404...Also, seems like there should be an easier way to do this?)
To my Grails project, I use ztree library.
In the css of this library, we have the following :
background-image:url("/ztree/img/zTreeStandard.png")
I have 3 directory in assets/
images/
javascripts/
stylesheets/
I don't want to modify the css to change the path of background-image:url("/ztree/img/zTreeStandard.png").
So, here are my questions :
Is that mandatory to create a ztree directory in assets/ ?
Can I put ztree directory in images/ ?
Thanks,
If you store the image at grails-app/assets/images/ztree/img/zTreeStandard.png, the assets-pipeline plugin should be able to resolve it (I haven't tested this). If it doesn't work, the reason will be because of the leading / in the path
background-image:url("/ztree/img/zTreeStandard.png")
I understand that you don't like modifying 3rd party code, but I don't think you'll have any choice other than to change this to
background-image:url("ztree/img/zTreeStandard.png")
I would recommend creating a assets/vendor directory and you can just dump all your third-party libraries in there. It should be smart enough for you not have to change any paths--though the absolute URLs might mess things up since usually grails is running at http://host:port/app-name/.
I am trying to use the NAudio.Lame library in an MVC4 application and am getting the error:
Unable to load DLL 'libmp3lame.32.dll': The specified module could not be found.
I added the library via NuGet. I was able to get the library to work fine with a Windows Forms application, so I believe the problem is specific to MVC4.
I tried the advice from the library author here:
https://stackoverflow.com/a/20065606/910348
The problem turns out to be that the native DLLs (libmp3lame.32.dll and libmp3lame.64.dll) cannot be found because the current directory that the web server process is executing from is not the website's bin folder (where the DLLs reside) and the search path does not include the bin folder.
What you need is to add the bin folder to the PATH environment variable, which will enable the LoadLibrary API call to locate the DLLs.
Here's a method you can call that will do this for you:
public static void CheckAddBinPath()
{
// find path to 'bin' folder
var binPath = Path.Combine(new string[] { AppDomain.CurrentDomain.BaseDirectory, "bin" });
// get current search path from environment
var path = Environment.GetEnvironmentVariable("PATH") ?? "";
// add 'bin' folder to search path if not already present
if (!path.Split(Path.PathSeparator).Contains(binPath, StringComparer.CurrentCultureIgnoreCase))
{
path = string.Join(Path.PathSeparator.ToString(), new string[] { path, binPath });
Environment.SetEnvironmentVariable("PATH", path);
}
}
Place that in your controller and call it right before you create the LameMP3FileWriter instance. It might work if you put it in Global.asax.cs and call it from Application_Start(). Try it and let me know if it works there.
I've put a Wiki article about this on the project site here.
Add the following line to the web.config for your site. This will prevent IIS from copying files and executing your site from a temporary folder (native dlls do not get copied apparently). The downside is that you will have to restart the application pool every time you push changes to your bin folder because IIS will lock the files there.
<system.web>
<hostingEnvironment shadowCopyBinAssemblies="false" />
...
</system.web>
Most probably IIS just can't find native dlls. Be sure to place native dll files into one of Windows DLL search path locations.
I made it work by having the LameDLLWrap assembly as a separate one, rather than embedding it in the main assembly. Since I know that my target system is 32 bit, I can afford having a single assembly -- this is simpler for me than playing with PATH on the hoster's machine.
Here's what I did:
Cloned the source
Checkout the Experimental branch
Removed the embedded assemblies from the main project
Set the reference to the wrapper to Copy Local
Recompiled everything
Is it possible to access files (with build action "AndroidAsset") from a monodroid class library in a monodroid application that references the class library ?
I have created an "Assets" folder in the class lib and added a text file with build action "AndroidAsset", but from the app I could not access it via Assets.Open("file.txt");
I was hoping that the Assets from the class lib and the main application could somehow be "merged"...
No - you a can't access the assets from a class lib - only from the main exe project.
This is similar to the situation with Java Android projects.
One route around this might be to use embedded resources instead - see the answer to this question I asked on xamarin's forums - http://forums.xamarin.com/discussion/186/is-there-a-cross-platform-way-to-include-string-resources-from-class-library-projects - note that I haven't tried this yet
Is it possible to access files (with build action "AndroidAsset") from a monodroid class library in a monodroid application that references the class library ?
Yes. Just access them "as normal" via Context.Assets.Open. There is only one source of assets in the application, so any component can access any and all assets, if they have access to an AssetManager instance.
However, that just takes what you're asking at face-value. Can a Library project use the Context.Assets property? Certainly, if you provide it a Context instance.
But can a Library project provide it's own assets for inclusion into the application? No.
I have created an "Assets" folder in the class lib and added a text file with build action "AndroidAsset", but from the app I could not access it via Assets.Open("file.txt");
Library projects cannot provide assets that will be included in the larger application. Java doesn't support this either, afaik.
Things to remember
1 Build Action is AndroidAsset (Properties)
2 Copy to output directory Do not copy (Properties)
3 Add the file to the Assets folder
var destinationPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "yourfilename.txt");
using (Stream source = Assets.Open("yourfilename.txt"))
using (var dest = System.IO.File.Create (destinationPath)) {
source.CopyTo (dest);
}
Sometimes this will still fail, monodroid bug. The best thing to do is check to see if the files were included correctly.
Load up Eclipse, in the device browser, you should see your simulator.
Go to the directory data/app/ download the file yourappname.apk
This is just a zip file, so change the extension to .zip and open the
zip archive. And goto the folder /assets and see if the file you are trying
to load is in there.
Also if you try to grab a file off a physical device your testing on, some allow it and other don't. This is easiest to test on the simulator.
It is possible to access the Assets files from a library:
var sourcePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
//var files = Directory.GetFiles(sourcePath);
var filePath = Path.Combine(sourcePath, "MyAssetFile.bin");
var content = File.ReadAllBytes(filePath);
I am using Symfony 1.31 for a brand new project. I have just created a module in the backend app, using the admin generator. To my suprise, it seems no theme ((At all) has been applied to the pages. As I mentioned before, this si abrand new project - I have not even modified the /app/backend/layout.php file yet.
I rember having a similar problem before - I dont remmber how I solved it (I think I had to run a task or copy some files over to the /web folder before the styles/images etc came into efect. Can anyone refresh my memory?
You might need to run the plugin:publish-assets command:
php symfony plugin:publish-assets
This will create symlinks to your plugins' web/ directory inside your project's web/, thus enabling access to sfDoctrinePlugin's (or propel depending what ORM you use) admin-gen styles.
Check your apache configuration and files permissions, and especially the alias to the /sf/ subdirectory. It seems that the .css file corresponding to sf_admin pages are not accessible. You can fix it by adding an Alias to your virtualhost configuration, or allowing symlinks.
(By the way, hint: check your html source, find out the .css url, and try to access it directly with your browser)