-1

Okay, so I'm rather new to this, sorry for my innocence and stupid question:

I'm using iText 7 to create a pdf file, with a very simple code, just to see if it works:

        string dest = @"C:\TestPdf.pdf";
        var writer = new PdfWriter(dest);
        var pdf = new PdfDocument(writer);
        var doc = new Document(pdf);
        doc.Add(new Paragraph("Testing one two"));
        doc.Close();

And it gives me an unhandled exception saying I do not have privileges required by the client. That pdf document is a nonexistant one, because I need my code to create a new one from scratch every time it runs. I'm sure I have administrative priviliges on the user, I double-checked. I realize this is probably a stupid question, but I'm really stuck here. Does anyone have an easy fix for this?

Thanks in advance!

  • if you want grant full permission use this [link](https://stackoverflow.com/questions/9108399/how-to-grant-full-permission-to-a-file-created-by-my-application-for-all-users) – arsham belivani Dec 18 '19 at 10:35

1 Answers1

2

This is happening because you're trying to write a document to your disk drive root folder, which requires administrator permissions. Try writing the file at another location or run your script as an administrator !

Laurent
  • 478
  • 7
  • 15