Rotativa.AspNetCore
Rotativa.AspNetCore copied to clipboard
How to run on Ubuntu?
My Asp.net core 2.1 app is working perfectly with Rotativa on Windows machine. But when I publish it to my Linux (Ubuntu 16.x) server (I am not using docker), I get 500 internal server error whenever the PDF generation is invoked. I have so far installed wkhtmltopdf on my Linux server, but couldn't figure out how to configure. Please help.
You can try to set the path to your wkhtmltopdf, but I think it won't work. I have the same issue and will create the pull request.
My Asp.net core 2.1 app is working perfectly with Rotativa on Windows machine. But when I publish it to my Linux (Ubuntu 16.x) server (I am not using docker), I get 500 internal server error whenever the PDF generation is invoked. I have so far installed wkhtmltopdf on my Linux server, but couldn't figure out how to configure. Please help.
You can use my fork https://github.com/vbondarev/Rotativa.AspNetCore/tree/develop
For me to correct this error I had to put these files that are available in the link below: https://github.com/MatheusNCarvalho/wkhtmltox-0.12.4 and my Dockerfile looks like this:
### Stage 1 - Obtain the source and generate the Build ###
FROM microsoft/dotnet:2.2-sdk AS build-env
WORKDIR /app
### Copy and restore dependencies ###
COPY . /app
RUN dotnet restore Teste.csproj
RUN dotnet publish Teste.csproj -c Release -o /app/publish
### Stage 2 - Upload the application through the binaries ###
## Build da imagem ###
FROM microsoft/dotnet:2.2-aspnetcore-runtime
RUN ["apt-get", "update"]
RUN ["apt-get", "-y", "install", "libgdiplus"]
WORKDIR /app
COPY --from=build-env /app/publish .
RUN chmod 755 /app/wwwroot/Rotativa/wkhtmltopdf
RUN chmod 755 /app/wwwroot/Rotativa/wkhtmltoimage
ENTRYPOINT ["dotnet", "Teste.dll"]
For me to correct this error I had to put these files that are available in the link below: https://github.com/MatheusNCarvalho/wkhtmltox-0.12.4 and my Dockerfile looks like this:
### Stage 1 - Obtain the source and generate the Build ### FROM microsoft/dotnet:2.2-sdk AS build-env WORKDIR /app ### Copy and restore dependencies ### COPY . /app RUN dotnet restore Teste.csproj RUN dotnet publish Teste.csproj -c Release -o /app/publish ### Stage 2 - Upload the application through the binaries ### ## Build da imagem ### FROM microsoft/dotnet:2.2-aspnetcore-runtime RUN ["apt-get", "update"] RUN ["apt-get", "-y", "install", "libgdiplus"] WORKDIR /app COPY --from=build-env /app/publish . RUN chmod 755 /app/wwwroot/Rotativa/wkhtmltopdf RUN chmod 755 /app/wwwroot/Rotativa/wkhtmltoimage ENTRYPOINT ["dotnet", "Teste.dll"]
Thankyou very much, i am struggling to fix for this error when deploying in Ubuntu 18.04, the error says "No Such File or Directory"
For me to correct this error I had to put these files that are available in the link below: https://github.com/MatheusNCarvalho/wkhtmltox-0.12.4 and my Dockerfile looks like this:
### Stage 1 - Obtain the source and generate the Build ### FROM microsoft/dotnet:2.2-sdk AS build-env WORKDIR /app ### Copy and restore dependencies ### COPY . /app RUN dotnet restore Teste.csproj RUN dotnet publish Teste.csproj -c Release -o /app/publish ### Stage 2 - Upload the application through the binaries ### ## Build da imagem ### FROM microsoft/dotnet:2.2-aspnetcore-runtime RUN ["apt-get", "update"] RUN ["apt-get", "-y", "install", "libgdiplus"] WORKDIR /app COPY --from=build-env /app/publish . RUN chmod 755 /app/wwwroot/Rotativa/wkhtmltopdf RUN chmod 755 /app/wwwroot/Rotativa/wkhtmltoimage ENTRYPOINT ["dotnet", "Teste.dll"]
I tried this but the images and styles are not displayed correctly. Do I have to include all files and folders from https://github.com/MatheusNCarvalho/wkhtmltox-0.12.4/tree/master/Rotativa or did you include only wkhtmltopdf and wkhtmltoimage?
Hi @vborza ! I have the same problem: images and styles are not displayed correctly too! Do you solved the problem?
Hi @vborza ! I have the same problem: images and styles are not displayed correctly too! Do you solved the problem?
I've solved it following this approach.... https://github.com/webgio/Rotativa.AspNetCore/issues/7#issuecomment-455063816
@MatheusNCarvalho on Linux whith Docker container, PDFs are generated without CSS formatting and images not showed, but on Windows without contantainer, PDF successfully generated. Did you have this problem?
@MatheusNCarvalho on Linux whith Docker container, PDFs are generated without CSS formatting and images not showed, but on Windows without contantainer, PDF successfully generated. Did you have this problem?
Yes, how did you fixed it?
@ayazzali I fix this problem, put physical file reference (using "file://") in and tags. Look at this example https://github.com/jlnpinheiro/bufunfa/blob/master/src/frontend/web/bufunfa-web/Helpers/CustomHtmlHelper.cs. See "CriarTagLinkCssPorOS" method.
Only this way works for my on Docker environment.
@ayazzali I fix this problem, put physical file reference (using "file://") in and tags. Look at this example https://github.com/jlnpinheiro/bufunfa/blob/master/src/frontend/web/bufunfa-web/Helpers/CustomHtmlHelper.cs. See "CriarTagLinkCssPorOS" method. Only this way works for my on Docker environment.
Thx, but today I'l did debuging, and found another "fix" see https://github.com/webgio/Rotativa.AspNetCore/issues/60#issuecomment-605624966
@vivekanandpv maybe close issue?
Sure
Get Outlook for iOShttps://aka.ms/o0ukef
From: ayazzali [email protected] Sent: Sunday, March 29, 2020 5:34:02 PM To: webgio/Rotativa.AspNetCore [email protected] Cc: Vivekanand P V [email protected]; Mention [email protected] Subject: Re: [webgio/Rotativa.AspNetCore] How to run on Ubuntu? (#17)
@vivekanandpvhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fvivekanandpv&data=02%7C01%7C%7C10ad6458d4a4439898cf08d7d3d94633%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637210802450502136&sdata=KIo11VEfZzyyakd%2B6GIVUOlsiHqwT5yx%2FmZDrd8v%2BDE%3D&reserved=0 maybe close issue?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fwebgio%2FRotativa.AspNetCore%2Fissues%2F17%23issuecomment-605625702&data=02%7C01%7C%7C10ad6458d4a4439898cf08d7d3d94633%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637210802450512118&sdata=KusLxzMS6eRzRWkuAlM48u5Cgx%2BpCXpZjL21%2BX0W1HM%3D&reserved=0, or unsubscribehttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABOZPH6QJ2UO5AJGOZM2NWLRJ42LFANCNFSM4FYESHLQ&data=02%7C01%7C%7C10ad6458d4a4439898cf08d7d3d94633%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637210802450522102&sdata=JLn7olWz6K1EbksWPJCgOPjBkjXrWF3Faq1lBLEwJ8A%3D&reserved=0.
This is probably because Rotativa injects the base URL property in your HTML. See https://github.com/webgio/Rotativa.AspNetCore/issues/60#issuecomment-605624966 . The base URL is set to the internal port your website is listening to, but that port is only accessible by docker. Another port is used for incoming requests.
The fix of @jlnpinheiro works because by setting the absolute path the base URL isn't used anymore.
Setting the base URL by Rotativa shouldn't be necessary, as in my opinion you should set the base URL yourself in the HTML if your site needs it. In PR #92 an option is added to disable setting the base URL (setBaseUrl: false
), which should fix the issue.