Downloaded PDF in R - Corrupted File

717 Views Asked by At

I've been trying to download some pdfs in R, with the following code:

link <- paste0("http://","www.energisa.com.br/empresa/paginas/servicos-online/autoatendimento/extrato-segunda-via-publica-visualizacao.aspx?ano=2017&mes=9&cdc=6/681274-7&fatura=55152")

data_referencia <- seq(as.Date("2017-10-01"), length = 1, by = "-1 month")    
download.file(link, destfile = paste0("energisa_", data_referencia,".pdf"), mode = "wb")

Everything goes fine until I open the pdf file (error message pops-up):

enter image description here

I tried to change the "download.file()" parameter, but the problem persisted.

Can you help me out?

0

There are 0 best solutions below