I have an application written in Python, which uses the ReportLab package for exporting PDF files.
Of course, the application needs to be tested. Among other tests, the PDF export function needs to be tested to ensure that the visual rendering of PDF files did not unexpectedly change.
Since it is possible to create and save an expected-results PDF file using fabricated test data, the above implies the need to compare two PDF files. It turns out that two PDF files created from the same data at two different dates – are different, due to embedded timestamps.
Hence, the need to compare visual renderings of the PDF files. ImageMagick’s convert knows how to convert PDF files into PNG. However, one needs to set the background and remove the alpha channel.
If you encounter the “Unable to locate WordPress root directory.” error when trying to update your WordPress installation and/or plugins, and your blog is running on a PHP 7 version, installing the SSH SFTP Updater Support plugin may solve your problem. It worked for me.
Do you use reportlab for creating PDF files from your Django application, as instructed in Outputting PDFs with Django?
Do you wish to add your own font files?
Do you need to render Hebrew text?
If yes, the following information will help you.
When installed in a virtualenv, as recommended by good working practices, reportlab searches for font files it uses in your virtualenv/lib/python3.x/site-packages/reportlab/fonts and it is not good idea to add your own font files there.
Instead, add your font files to your_project_root_directory/reportlab_extra_fonts where your_project_root_directory is where your project’s manage.py is located. Add the following to any Python script that uses reportlab (usually views.py), after all regular reportlab import and configuration statements. # The following configures extra reportlab fonts.
from django.conf import settings
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
HEBREW_FONT_NAME = 'your_font_name'
# The above configures extra reportlab fonts.
If you want to properly display Hebrew in your PDF file (the probable reason why you needed to add your own fonts in the first place), you need to convert the text yourself from logical ordering to visual ordering, because reportlab (as of version 3.4.0) does not currently process BiDi text. For this purpose, install the python-bidi package in your virtualenv (using pip install python-bidi) and add the following import statement to your views.py script: from bidi.algorithm import get_display
Now, get_display() will reorder your BiDi text.
Before founding Hamakor, people resorted to other solutions. In one exhibition, we wanted to distribute Linux installation CD-ROMs to the crowd. However, we wanted those CD-ROMs to reach only people who have a serious intent to install Linux. A way to ensure it was to require them to donate money in exchange for their CD-ROM. However, if we collect money, we must issue receipts and do bookkeeping.
Truly Yours had the brilliant idea of inviting other nonprofits to send a representative to collect the donations and issue receipts. It was a win-win-win solution. We get someone to issue receipts and sweat over the bookkeeping. The nonprofits get money for their operations. The people, who paid for their CD-ROMs, treat them seriously.
One of the nonprofits was the Association of the Deaf in Israel.
There are several cases, in which a program has to do operations A,B,C. If an error occurs while doing A, the program needs to undo A. If there is an error while doing B, the program needs to undo B then A. Similarly, an error in C requires undoing of C,B,A in this sequence. Continue reading “A proposed new language construct: do/undo”
Given the announcements about finding more and more Earth-like planets around other Suns and potentially life-friendly regions in Jupiter and Saturn’s satellites, I would like to offer the following predictions.
Actual First Contact has already happened. People do not discuss the distance between Roswell and Alamogordo, which is near the site of the first A-bomb explosion, and which happens to be only 145Km by air.
Since First Contact among two cultures, which significantly differ in their technological sophistication, is usually harmful to the less technologically advanced culture, it was decided not to publicize this fact without preparing the Earth culture for those news.
Furthermore, it was decided that the Earth people are to be the ones to “discover” the alien culture, rather than vice versa.
Several SciFi stories assumed that alien cultures would discover the existence of a technological Earth culture by radiation from its first A-bomb explosions. Arthur C. Clarke’s “2001 Space Odyssey” assumed that this would happen when a certain slab is excavated on the Moon. The Star Trek world assumed that the discovery would by detecting the radiation emitted by Zefram Cochrane‘s first FTL flight using a warp drive system.
However, I believe that the real “Zefram Cochrane” moment would be when the Earth culture proves its ability to defend life on Earth by deflecting or destroying killer asteroids.
Hence, my prediction is that once a dangerous asteroid has been detected and successfully neutralized, it will be announced that some Earth probe ship has at last found signs of alien life.