|
Rank: Member Groups: Member
Joined: 8/5/2012 Posts: 12
|
Hi How can I save a pdf file to an other path with ASPXToPDF? I have tried:
Code: C#
ASPXToPDF1.RenderAsPDF("c:\\NSCTimesheet.pdf");
and
Code: C#
fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString() + "\\Timesheet\\NSCTimesheet.pdf";
ASPXToPDF1.RenderAsPDF(fileName);
How can I get it to work?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
|
|
Rank: Member Groups: Member
Joined: 8/5/2012 Posts: 12
|
I have allready looked at http://www.essentialobjects.com/doc/4/web/aspxtopdf.aspx#saveBut I can still not save a file to a library. I can change the filename as: ASPXToPDF1.RenderAsPDF("NSCTimesheet.pdf"); it works find. But when I treid to save to a other library/path it still save the file in the normel download library: myDocuments\Download \ How can I save a file on c:\filename.pdf? ASPXToPDF1.RenderAsPDF("c:\\NSCTimesheet.pdf"); does not work.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Read the documentation again. I don't believe you've read the documentation carefully. The code you posted is completely different than what's in the documentation, and you have not mentioned a single thing that the documentation tells you to do. You basically still have what's in your own head as if you have never read it at all.
We try our best to answer your question as fast as possible but you must follow what we tell you and put in a reasonable effort on your part. If you just ignore what we told you then what's the point for us to answer your question?
|
|
Rank: Member Groups: Member
Joined: 8/5/2012 Posts: 12
|
Sorry for that. I had only read chapter about "Change Save As File Name". Now I have read it all, but I can still not get it to work.
Code: C#
protected void Button1_Click(object sender, EventArgs e)
{
ASPXToPDF1.RenderAsPDF(false); // Call ASPXToPDF1_AfterRender
}
Code: C#
protected void ASPXToPDF1_AfterRender(object sender, EventArgs e)
{
//Cast the Result property to HtmlToPdfResult
HtmlToPdfResult result = (HtmlToPdfResult)ASPXToPDF1.Result;
string fileName;
fileName = "C:\\test.pdf";
result.PdfDocument.Save(fileName);
}
Have I misunderstood something in the code? ASPXToPDF1.RenderAsPDF(false); call ASPXToPDF1_AfterRender correct? In the document chapter "Before You Begin" you wirte, that EO.Pdf.dll and EO.pdf.Html.dll must be in the bin directory. EO.Pdf.dll (and EO.Web.dll) is in the bin directory, but I cannot find EO.Pdf.Html.dll file any where. Should it be here? C:\Program Files\Essential Objects\EO.Web Controls 2012\ where EO.Pdf.dll and EO.Web.dll are. There is also an EO.Web.NLib.dll file, should i put this file in the Bin?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi, Sorry about EO.Pdf.Html.dll. That is outdated. That file no longer exists so you do not need it. Just EO.Web.dll and EO.Pdf.dll. RenderAsPDF does not call AfterRender. AfterRender is an event of the ASPXToPDF control (just like Click event for a Button control). So you must hook up the event handler first. It would be something like this in your ASPX file:
Code: HTML/ASPX
<eo:ASPXToPDF AfterRender="ASPXToPDF1_AfterRender" ..... />
Once you have the event handler hooked up, it will be called. Thanks!
|
|
Rank: Member Groups: Member
Joined: 8/5/2012 Posts: 12
|
Of course. It works now :-)
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
You are welcome. Let us know if there is anything else.
|
|