How to have Aspose.Cells 19.10 correctly render fonts in Linux .Net Service? - aspose

I am building a .net service in docker that will take .xlsx files and render them as .tiff. When I run my service locally on a windows environment the images correctly render with Times New Roman text. When I spin up a docker container and submit the same file it returns a blank .tiff image.
I have tried numerous approaches to have Aspose.Cells work correctly in the docker container based off the Aspose documentation relating to setting the default font source, default font folder, and font substitution but none of the suggested methods work. Below I listed the approach that I believe should work with Aspose.Cells
Installed fonts-liberation fontconfig and ttf-mscorefonts-installer on the docker container to get access to fonts located in /usr/share/fonts/truetype/
In the service I have set my source to the following:
FontConfigs.SetFontFolder("/usr/share/fonts/truetype/", true);
The true in this statement will scan subfolders to find the .ttf font files. I expect Aspose to use this file path in the docker container to get needed fonts for rendering.
I verified that I have fonts available in the "/usr/share/fonts/truetype/" folder under sub-folders of liberation and msttcorefonts.
Can anyone offer advice of another approach or potential issue I am running into? I can provide more information if needed as well.

Well, there are some guidelines using Aspose.Cells (especially for rendering features) to work on docker container or similar environments which you should refer to. We also recommend you to kindly try using latest version/fix (e.g Aspose.Cells v20.3)
Here are our steps:
The docker we used was: microsoft/dotnet, install it first:
sudo docker pull microsoft/dotnet
When running it, we got an issue in this docker when saving to PDF or image.
We did the following things to sort it out:
We installed libgdiplus:
apt-get update
apt-get install -y libgdiplus
cd /usr/lib && ln -s libgdiplus.so gdiplus.dll
And install libc6-dev:
apt-get install -y --no-install-recommends libc6-dev
Hope, this helps a bit.
PS. I am working as Support developer/ Evangelist at Aspose.

Related

How do I install fontconfig on AWS lambda?

This is a continuation of How do you install phantomjs on AWS lambda? I've figured out how to get phantomjs running on an aws lambda, but when I use it to generate pdfs (using the html-pdf nodejs library), the content is missing text. If I create a docker container that's using FROM node:10.16.0-jessie on it, the pdfs render fine. If I create a docker container using FROM amazonlinux:2.0.20190508 (which I think is similar to the AWS lambda container), the text is missing on my PDFs.
I've fixed this problem in amazonlinux:2.0.20190508 by running yum install fontconfig. But, I don't know how to do the equivalent of a yum install fontconfig inside a real lambda. If you look at the link above, you'll see that an answer there attempts to provide that information, but for whatever reason, it still doesn't work correctly. I believe the reason is there's still a missing step on how to get the fontconfig install properly extracted from the amazonlinux:2.0.20190508 container.
In summary, here is my question: After I run yum install fontconfig in amazonlinux:2.0.20190508, how do I extract it from the container and package it up so that an AWS Lambda can use it?
By the way, I'm sure there are other answers that seem to be answering this question, but the AWS lambda built-in dependencies change so frequently, none of those answers work anymore.
In my case, I did this:
Create a Docker file with content:
FROM amazonlinux:2.0.20190508
RUN yum -y install fontconfig freetype
and build it as example:latest
Run docker and mount folder:
docker run -v D:\dockerFiles:/mnt --rm -it example:latest
Found libraries inside docker by path /lib64
libbz2.so.1 libexpat.so.1 libfontconfig.so.1 libfreetype.so.6 libpng15.so.15
Copy it to /mnt/lib. Take lib from D:\dockerFiles and zip folder lib.
Create aws lambda layer and add to lambda.

Can I load additional libraries in Gitpod without creating my own Docker image?

I have recently tried out Gitpod, which seems to be a quite cool tool.
For testing purposes, I have opened some C++ GitHub repository of mine that uses Boost (among other libraries). Unfortunately, Boost does not seem to be installed in the Docker image, so my code does not compile.
I know about the possibility of creating own Docker images, but I was wondering if there are alternative, easier options as well. Does Gitpod provide any Environment Modules-like option to dynamically load/unload certain "commonly used" libraries or do I always have to provide my own Docker instance in this case?
I work on Gitpod. Thank you for trying it and the compliment :)
We didn't want to invent yet another module system for Gitpod.
Instead, we decided to support Dockerfiles and build them on-demand, because Dockerfiles allow using all those amazing module systems that are already out there: Debian's packages, Alpine's packages, Node Version Manager (NVM), Ruby Version Manager (RVM), SDKman, etc. Basically any Linux-compatible package manager down to simple wget.
You can also use own Docker images, but I find Dockerfiles more convenient because you can check them into git and thereby version them together with your source code. It's dev-environment-as-code and should be shared across the team. Also, you don't need to bother with building and pushing them to a registry (e.g. hub.docker.com).
What Gitpod does offer, hoever, is a selection of Docker images (src). The most prominent one is gitpod/workspace-full, which it Gitpod's default image.
To get back to your question about the easiest way to get the right modules into your Gitpod development environment:
inheriting from gitpod/workspace-full is very convenient.
If you don't want (2), copy'n'pasting sections from gitpod/workspace-full is convenient.
Often, putting RUN apt-get update && apt-get install -y libboost-all-dev into your Dockerfile is enough. This is APT to install the package libboost-all-dev.
Most software projects have documentation on how to build them under Linux. These instructions usually work in Dockerfiles, too.
Search on hub.docker.com for useful Docker images. You can inherit from those images or find their Dockerfiles and copy'n'paste sections from there.

Blender on IBM Cloud (Cloud Foundry)

I'm currently developing a web application (Django 2.0) application.
My app will be deployed on IBM Cloud (Cloud Foundry) using python build-pack.
One of my requirements is to install blender.
Everything else is very well, but for blender installation.
What I've tried so far was:
I tried access my app using SSH connection, but surely I don't have root access to apt-get install blender!!
And tried to include blender in packages.json file and push that file using cf push my-app.
But nothing worked for me.
In another shorter question: what is the main approach in Cloud Foundry Apps to install packages like when we use apt-get install in Ubuntu / Debian.
Please correct me if I did anything wrong, or guide me with headlines to solve this problem!!
I see a couple options for you to install packages if they cannot be installed using the regular requirements file (which is the preferred way):
Download the relevant libraries and put them in subfolders of the app before pushing it. The libraries will be uploaded. That is how I would do it.
Once you have an SSH connection, use secure copy (scp) to upload the files and place them in the subfolders where they are expected.
Regarding Blender, the question is what you need in addition to having the code copied over. Does it need a running daemon? Are there more dependencies? You would need to share more information about your specific app to answer that. Maybe, packaging everything as one or more containers and run it on Kubernetes or a combination of Cloud Foundry and Kubernetes is a better way.

Use package manager in a Cloud Foundry instance

Can I use apt-get or other package managers in Cloud Foundry buildpacks or .profile scripts that come with apps; and if I can, how to do it? I expect to do it the same way as in a dockerfile, but it doesn't work with or without sudo in my case.
Can I use apt-get or other package managers in Cloud Foundry buildpacks or .profile scripts that come with apps; and if I can, how to do it?
No. Running apt-get or a package manager would typically require root access and you do not get root access when the build pack runs or when your application runs (this is a difference w/Docker).
That said, you can do anything that doesn't require root access, so if you found a package manager that installed in the vcap user's home directory and didn't need root then you could use that.
It depends on what you're trying to install, but in some cases you can work around this by downloading the .deb or .rpm file and manually extracting the binaries. This typically works OK for things like shared libraries. Just download the precompiled binary that matches your stack (cflinuxfs2 == Ubuntu Trusty). For other things, you can build your own binaries from source. This is what the build pack's do, see binary-builder.
Hope that helps!

AWS Lambda : How to use Pillow library?

I'm trying to create an AWS lambda function in order to create thumbnail of my uploaded images.
My script is running well locally, I followed this tutorial to deploy my function but I have a problem with the Pillow library, indeed when I'm testing my function I can see this following log :
I found this post with the same issue but in my case I can't execute command line on the machine.
You must include the libjpeg.so in your lambda package, but it will also require some tweaking with the patchelf utility. Assuming that you prepare the lambda package via "pip install module-name -t" (rather than via virtualenv), do the following:
cd into/your/local/lambda/package/dir
cp -L $(ldd PIL/_imaging.so|grep libjpeg|awk '{print $3}') PIL/
patchelf --set-rpath PIL PIL/_imaging.so
# zip, deploy and test the package
This script works for Pillow version 3.2.0.
Regarding patchelf: under Ubuntu it can be 'apt install'ed, but under other Linuxes it may need to be built from source.
The problem here is that Pillow uses native libraries that must be built for the exact correct environment.
I solved this by installing my requirements in a Docker container that replicates very closely the AWS Lambda environment, lambci/lambda. I used the build-python3.8 version.
I installed my requirements there and zipped up the whole contents of /var/lang/lib/python3.8/site-packages/ directory along with my lambda function file.
I tried this with a standard Amazon Linux Docker image and it didn't work. Only the lambci/lambda image worked for me.