Itextsharp - Name of PDF depending on variable

2

I currently have a code with iText to create PDF with a fixed address in this case:

PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream("C:/Atreus-Export/presupuesto.pdf", FileMode.Create));

My question is how can I make the PDF name depend on a variable. I've tried with:

PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream("C:/Atreus-Export/" + tb_name + ".pdf", FileMode.Create));

But I miss error when creating it:

  

System.NotSupportedException: "The provided format of the path is not supported"

    
asked by S.Carrillo 04.09.2018 в 14:34
source

1 answer

1

I think the same thing happened to me. What you have to do is put the chain first and save it in a variable String. And then you use that variable as a FileStream parameter. I do not know why but if you do it like now the system is confused with the spaces, quotes, etc ...

pdfName = "C:/Atreus-Export/" + tb_name + ".pdf"

PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(pdfName, FileMode.Create));
    
answered by 05.09.2018 в 00:26