Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating pdf with .net6 in aws lambda #105

Closed
IrshadMar opened this issue Apr 16, 2023 · 4 comments
Closed

creating pdf with .net6 in aws lambda #105

IrshadMar opened this issue Apr 16, 2023 · 4 comments

Comments

@IrshadMar
Copy link

I am running the pdf conversion code in aws lambda function using .net6 and aws linux 2.
In the main page documentation, the following instruction is there for creating a docker image.

_Insert the below lines before the WORKDIR /app command

RUN apt update
RUN apt install -y libgdiplus
RUN ln -s /usr/lib/libgdiplus.so /lib/x86_64-linux-gnu/libgdiplus.so
RUN apt-get install -y --no-install-recommends zlib1g fontconfig libfreetype6 libx11-6 libxext6 libxrender1 wget gdebi
RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb
RUN gdebi --n wkhtmltox_0.12.5-1.stretch_amd64.deb
RUN apt install libssl1.1
RUN ln -s /usr/local/lib/libwkhtmltox.so /usr/lib/libwkhtmltox.so_

Please help me to resolve this issue while deploying it to aws lambda using .zip files.
Or what will be the corresponding commands to use when creating a docker image with amazon linux2.
Or please instruct me what base image can be used to make it work.

@IrshadMar IrshadMar changed the title creating pdf with .net in aws lambda creating pdf with .net6 in aws lambda Apr 16, 2023
@stysiok
Copy link

stysiok commented Apr 18, 2023

Have you been able to sort that issue yourself? I'm trying to also set it up on AWS Lambda, but failing miserably. No matter what dependencies I install I always get an exception back that some of the dependencies are missing.

@stysiok
Copy link

stysiok commented Apr 18, 2023

@IrshadMar I think I managed to set it up by adding following lines to my dockerfile

FROM public.ecr.aws/lambda/dotnet:6

RUN yum install -y libXext \
    libXrender

RUN curl -SL "https://github.com/rdvojmoc/DinkToPdf/raw/v1.0.8/v0.12.4/64%20bit/libwkhtmltox.so" --output ./libwkhtmltox.so

To use zip deployments you would need to modify your lambda to install libXext and libXrender and add the lib to /var/task or where do you keep your dlls.

It looks like the code after publish is unable to load libwkhtmltox.so located in runtimes folder.

@IrshadMar
Copy link
Author

I was unsuccessful in solving this issue even after trying the docker solution mentioned by @stysiok above.

While running the docker build I am getting the below error at yum install
image

Used the below command.
RUN yum install -y libXext \ libXrender

After deployment I am still getting ---> System.NotSupportedException: Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported.

@IrshadMar
Copy link
Author

IrshadMar commented May 12, 2023

This solved it for me
https://www.appsloveworld.com/docker/100/58/unable-to-load-shared-library-libgdiplus-or-one-of-its-dependencies-while-runni

Docker file:
FROM public.ecr.aws/lambda/dotnet:6
WORKDIR /var/task

RUN yum clean all && yum update -y
RUN yum install -y amazon-linux-extras
RUN amazon-linux-extras install epel -y
RUN yum install -y libgdiplus

COPY publish/* /var/task/

CMD [ "" ]

Note: You may have to use the libwkhtmltox.so file using the curl command mentioned by @stysiok in the comment above.
Thanks a lot!

@HakanL HakanL closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants