Welcome Guest Search | Active Topics | Sign In | Register

EO.pdf creating multiple documents? Options
David Harrison
Posted: Friday, May 14, 2021 8:26:24 AM
Rank: Newbie
Groups: Member

Joined: 8/28/2020
Posts: 5
hi support.

Windows 2016 std.

I have a basic single webpage that i'm printing to PDF.
On the live server, i have an original file that works fine.
I've copied this file to my development PC and made a new file with a simpler html layout.

This did initially have a problem on my PC to start with, where it was creating multiple PDF files until i stopped the IIS Application Pool. but seem to resolved it self. now working fine on my development PC.

I've copied this file to the live server, and it has the same fault. it just keeps creating the same PDF over and over until i crash out the app pool..
the original servers file still works fine, so i'm really confused as to what could be causing it?

any ideas?



Quote:


private void RunMakePDF()
{
Runtime.AddLicense("asdojkhasdijasdjiashdnhasjdkoh - bla.. really long key");
ASPXToPDF1.RenderAsPDF(false);

}

protected void ASPXToPDF1_BeforeRender(object sender, EventArgs e)
{

HtmlToPdfOptions pd = new HtmlToPdfOptions();
pd.VisibleElementIds = "DivPDFPrintable";
EO.Pdf.HtmlToPdf.Options.PageSize = PdfPageSizes.A4;

}

protected void ASPXToPDF1_AfterRender(object sender, EventArgs e)
{

HtmlToPdfResult result = EO.Pdf.HtmlToPdf.Result;


Int32 Appid = Common.QueryStringInt("appid");
string Timestamp = DateTime.Now.ToString().Replace(" ", "").Replace(":", "").Replace("/", "");
string outputFileName = @"\Equ_" + Appid + @"_" + Timestamp + @".pdf";
string outputPath = ConfigurationManager.AppSettings["LocalFilePath"].ToString() + "" + Appid;
string FullPath = outputPath + outputFileName;
if (!System.IO.Directory.Exists(outputPath))
{
System.IO.Directory.CreateDirectory(outputPath);
}

result.PdfDocument.Save(FullPath);

SaveFile(outputFileName, Appid.ToString(), "equ");
// Response.Redirect("index.aspx");
}

eo_support
Posted: Friday, May 14, 2021 9:13:52 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

Your code looks fine. You will want to check how often RenderAsPDF is called. Obviously every time it is called a new PDF file will be created, and depending on how your code is structured, it can be called a lot. For example, if the code is called every time the page is requested and you have a web crawler from a search engine keep hitting it, then you will get a lot of PDF file generated.

Thanks!
David Harrison
Posted: Friday, May 14, 2021 10:45:29 AM
Rank: Newbie
Groups: Member

Joined: 8/28/2020
Posts: 5
thanks for the quick reply.
its not on the internet, its an intranet application.
its only calling the instance once, what is weird is that i can see multiple files being created on the drive every few seconds, but its not running the SaveFile() method which writes an entry to the database.. its like its crashing out and restarting over and over..

Like I say, the same file works fine on my development PC, but not the server. thou i did have the problem on the dev pc initially.
very weird.
eo_support
Posted: Friday, May 14, 2021 12:11:07 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

You can debug this by setting a break point inside your ASPXToPDF1_AfterRender and see how often it is called and who called it. We do not have any logic to repeatly creating the PDF file, especially in your case the file location/name is directly controlled by your code. So you should be able to trace back from there to find out how it is triggered.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.