How to save PDF from a site in Azure Functions?

Asked

Viewed 42 times

2

I am developing an application where I will have to make a Crawler on a specific website.

The application will contain an endpoint to an Azure Function where Crawler will capture.

So far so good, however, we will have to save evidence that Rawler went through the site. We are thinking of saving a PDF with the screenshot, but as specified in the Azure Functions documentation, Selenium (which would be a good alternative) or Phantomjs do not work.

Another approach would be to download the content of the entire site in HTML and somehow process the HTML to generate a PDF with what was seen by Crawler.

I wonder if there is a library that works in Azure Functions to capture some URL and save to PDF.

Grateful.

  • Do you want to save the physical file inside Azure Functions? It would have to be saved in Azure Storage, correct?

1 answer

0

You can use the Itextsharp 7.

However, this is not such a simple task. Take a look at this link, in that response in the original Stackoverflow (use Google Translator if necessary).

Usually these conversions don’t turn out as well as you’d expect. However, if feasible you can build the pdf yourself using Itext methods. Logically it will not be the same as the original either, but depending on the content to be inserted in the pdf, it can serve.

See the Itext documentation here.

There are several tutorials on the internet too, like this one for example:

Basic PDF Creation Using iTextSharp - Part I

Itext works with Azure Functions because it works with .NetCore. Most libraries that deal with these things use. Netframework that only supports Azure Functions v1.

For this you need to pay attention to the issue of licenses, it is the most recent and paid versions of Itext that support .NetCore. The old ones are also in .NetFrameWork. But there is a third party adaptation, called iTextSharp.Lgplv2.Core. You can install it via Nuget.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.