Hi,
I have a question on renaming a pdf file in pdf Portfolio.
The code related is as follows:
foreach (var ans in answers)
{
if (ans.AnswerType.ToString() == “7”)
{
string AText = ans.AnswerText.ToString();
string attachName = AText + “-” + pid.ToString() + “-” + qid.ToString() + “-” + Session[“AcadYr”].ToString().Trim() + “.pdf”;
if (File.Exists(Server.MapPath("~/AttachmentsFiles/Program/" + attachName)) == true)
{
var fileAttach = Server.MapPath("~/AttachmentsFiles/Program/" + attachName);
FileSpecification FSAttach = new FileSpecification(fileAttach);
FSAttach.Description = AText;
//doc.Collection[idx].Name = “~/AttachmentsFiles/Program/” + idx.ToString() + attachName;
doc.Collection.Add(FSAttach);
//idx++;
}
}
}
I can’t change the pdf file names before I add those files. So what I have to do is to rename the pdf names after adding them in the portfolio. The reason to rename them is that Acrobat will order the files in portfolio automatically by name and I want the files to appear in the order they are added.
I tried to change the filenames after doc.Collection.Add(FSAttach) and it doesn’t work. But changing the filenames before doc.Collection.Add(FSAttach) like using FSAttach.Name = “XXX” results in not able to open the pdf file in portfolio(as name is changed so it can’t find the file).
Plz help me out! Thanks.