I want to generate pdf file from my php script that support utf-8 "arabic language"
like -> "السلام عليكم "
that support RTL
i make small search and i found some library like fpdf but it's aint support arabic and also tpdf
and i found tcpdf but it's need as i "think" using laravel in my project ?
i am not using MVC i just using normal web development .
If you want to programtically generate the pdf and send it in email attachment the TCPDF library is the best solution for you. The TCPDF provides fonts for Arabic and Farsi. However, it looks like the TCPDF does not support RTL.
I would also suggest you to give DOMPDF a try. DOMPDF generates PDF with HTML with ease. Read more here: https://github.com/dompdf/dompdf
I have used both to generate the PDF for all kind of non-latin chars.
EDIT:
Don't forget to add dir="rtl" in the html. Please read more here: https://www.w3.org/International/questions/qa-html-dir
Also, please show your code if you can. So I can help you more.
If your page has Arabic words
<script>
window.print();
<script>
This will give you option to print or save PDF. Hope this will work.
I have to create a .ics file with Javascript. I haven't got the possibility to use jquery.
Is there a way to create this file?
Thanks for your help
You can use one of the methods described here to write a file in Javascript, then the content of the .ics file is up to you to determine. It's quite trivial since the ics format is simple. (complete RFC)
In my new Ruby on rails application I want to find the users country code.
So I am using MaxMind GeoIp. when I downloaded the gzip file after gunzip it gives me a GeoIP.dat file and I am stuck here. Can any one help.
If their is a program to open it or some procedure to use it.
Or if any one can suggest me the other way.
As #Kyle pointed out, you can download "human-readable" CSV files instead of binary DAT files. MaxMind's "GeoLite" downloads are here.
The CSV file format is described here.
But note (from the link above):
Due to the large size of geolocation databases, we generally recommend using our binary format with one of our APIs, since they are highly optimized for speed and disk space. On the other hand, if you have a requirement to import the data into a SQL database, the CSV format is recommended.
The APIs are listed here. There is no Javascript API listed, but there are a couple of options for Ruby.
So to answer your question directly: You would not "open" the dat file directly as you would a spreadsheet document. Instead you would write your own program that uses their API to read the dat file, and perform whatever tasks or queries you design it to do. Check out their API documentation for details of how you might get started with that.
.dat is just a file extension. The contents could be anything. Text. Binary data etc...
There is no way anyone could reliably tell you how to open the file.
I would attempt to view the contents of the file from the command line:
less file_name.dat
You can open the file and read line by line in ruby like this:
IO.readlines('file_name.dat').each do |line|
# do something with the line
end
Edit: I think I found the file you're refering to. Why not go here and download a csv version? The .dat version is not in plain text.
From what i understand, This usually has to be done server side. However i have read that it is possible to point to the csv file in a .js file. This would be more useful to me as i am not messing around with server side code and stuff for this project and will be all on my local machine. I saw an article with example code to do this somewere however i can't locate that article atm. Anyone know how to do this?
To access any file from the system you have to use directX in IE or read up on how to use NPAPI for mozilla support.If you are willing to use HTML5, check out its filereader API here.
My site works fine on localhost, my javascript is loading and working fine. But when I deploy the site the script is not working. When I right click the page and say view source and then view the linked script file, it has some strange characters at the start of the file (function($){
On localhost, my script file starts like this (function($){
What is causing these characters to be prepended to my javascript file?
You have to re-save the file in encoding "UTF-8 without BOM".
You can use Notepad++ or other editors.
In visual studio:
By default, Visual Studio uses UTF encoding with the BOM; however, you can save it to a different encoding if you'd prefer. When you go to the Save As dialog, you can expand the Save button to see the 'Save with Encoding' option. This will prompt you for a different encoding, and I think one of the Unicode options will leave out the BOM (somewhere in the list is UTF-8 without signature).
Source: http://forums.silverlight.net/forums/t/144306.aspx
I think Briedis is right about the problem, but I suggest a different solution.
When you serve the file, is it being served with a Content-type like
Content-Type: text/javascript;charset=US-ASCII
?
If so, make sure to serve it with a charset of UTF-8 instead.
I just hit this same problem, and have found a fix.
As an answer to Martjin's question, the problem is that these URF-8 BOM characters invalidate the javascript when the client is expecting pure ASCII. So it will say there is an error at char 1, line 1 or some such, basically, right at the beginning of the file because it makes the codefile look like there's a typo in the first few bytes of the script.
In my case, I have a Site in IIS that is an ASP.NET app, and an Application underneath it that is also an ASP.NET app. This had caused some complications with inheriting web.configs, and the solution was to put a tag that negates inheritance from that point on.
I then discovered that all my .js in the child site was throwing an error for that stupid UTF-8 encoding symbol that was the first 3 bytes of every file. I am reasonably confident, that it is caused by some confusion in the httphandlers from my 2-tier solution for web.configs.
My solution, however was to convert the .js files back to pure ASCII, as that's what IIS was sending out and the client was expecting. For me, I have a build.bat that copies all the web files, removes any source control and project files and puts them all in a final build directory for copying to the test or production server. I made a modification to that script to also convert all the .js files to ASCII format.
It uses a combination of DOS batch (because that's where I started) and PowerShell (because that's the only way I found to convert without adding even more utility programs):
set DIRTOCONVERT=whatever path you want it to convert all the files for
ECHO remove UTF-8 BOM chars ï»? from front of files
for /r %DIRTOCONVERT% %%g in (*.js) do (
powershell -command "gc -en utf8 \"%%g\" | Out-File -en ascii .\tmp.txt"
move /y .\tmp.txt "%%g"
)
Note, a few people online (even in StackOverflow) had the idea to try:
type badfile.txt > goodfile.txt
but that still carries over the UTF-8 encoding. Apparently, it did not used to do that.
I had a similar issue, and found the fix when stumbling on this thread.
There was indeed a problem with the files not being UTF-8 (without BOM), but re-saving my js files as utf-8 didn't work, instead, it was my HTML file that imported these scripts that was the culprit. After I saved that file as UTF-8, the issue was resolved.