?
Solved

Does anyone know how to unload a pdf from a frame/webpage that is drawn by ceTe Dynamic PDF Merger?

Posted on 2009-04-23
4
Medium Priority
?
519 Views
Last Modified: 2012-05-06
I am experiencing some tricky session and frame behavior. I have a page A with a frame B in it. A session variable is passed from the main page A to the frame page B in order to display a pdf in the frame B. After the main page A is done passing the session variable to the frame page B I remove the variable from the session. When I leave the main page A and go back to the page C with the link to the main page A and then click a link to a second page D which is similar to page A. second main page D has a frame page E that is for some odd reason displaying the pdf from the first frame page B. I have tried everything
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LoadPrimaryQapPDF();
        }
    }
 
    protected void LoadPrimaryQapPDF()
    {
        string filepath = "";
 
        if (!String.IsNullOrEmpty(Session["file"].ToString()))
        {
            filepath = Session["file"].ToString();
        }
 
        if (!String.IsNullOrEmpty(filepath))
        {
            //Create a PDF document
            MergeDocument document = new MergeDocument(@filepath);
 
            // Create a page and add it to the document 
            ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page();
            document.Pages.Add(page);
 
            // Outputs the document to the current web page
            document.DrawToWeb();
 
            Session.Remove("file");
        }
    }
}

Open in new window

0
Comment
Question by:mjoseph23
  • 2
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
GeoffSutton earned 1500 total points
ID: 24311992
When A is calling B, is it setting the source for B?  If so, have you tried a querystring?  Also, have you tried Session["file"]=String.Empty; rather than Session.Remove("file");?
I have never used the ceTe Dynamic PDF.  I've always used an iFrame and set iFrame.Attribute("src")=documentPath; since I find it far simpler.  If user doesn't have Adobe installed then it provides a download for the PDF file, otherwise it displays on the page.  That said, I suspect the problem is in the session, not in the DynamicPDF manager.
0
 

Author Comment

by:mjoseph23
ID: 24318168
I have tried an empty string with the session. Currently I have a blank page hardcoded in the frame, but I did not think about using a query string in code behind. These are the steps I take to load the pdf. On Page A, the user uploads a file through the file upload control, then they can press buttons save or view. When they do that, page A takes the file location uploaded in the control and stores it in a session variable. Pressing the buttons causes some sort of postback on page B in the frame. When page B loads it takes the stored session variable containing the file location and passes it to the ceTe dynamic pdf generator then the generator draws the pdf on page B.

/***************page A******************/
 
    protected void btnView_Click(object sender, EventArgs e)
    {
        Session["file"] = "";
 
        //iframe1.Visible = false;
 
        if (FileUpload1.HasFile)
        {
            Label1.Text = "";
 
            string fileExt = System.IO.Path.GetExtension(FileUpload1.FileName);
 
            if (fileExt == ".pdf")
            {
                try
                {
                    //iframe1.Visible = true;
 
                    string file = FileUpload1.PostedFile.FileName.Substring(3, FileUpload1.PostedFile.FileName.Length - 3);
                    string appendedfile = "\\\\msgsap4n39r\\88mdg\\" + file;
 
                    Session["file"] = appendedfile;
 
                    FilePath.InnerHtml = Session["file"].ToString();
                }
                catch (Exception ex)
                {
                    Label1.Text = "Error: " + ex.Message.ToString();
                }
            }
            else
            {
                Label1.Text = "Only .pdf files allowed!";
            }
        }
        else
        {
            Label1.Text = "You have not specified a file.";
        }
    }
 
/**************page B*******************/
    protected void LoadPrimaryQapPDF()
    {
        string filepath = "";
 
        if (!String.IsNullOrEmpty(Session["file"].ToString()))
        {
            filepath = Session["file"].ToString();
        }
 
        if (!String.IsNullOrEmpty(filepath))
        {
            //Create a PDF document
            MergeDocument document = new MergeDocument(@filepath);
 
            // Create a page and add it to the document 
            ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page();
            document.Pages.Add(page);
 
            // Outputs the document to the current web page
            document.DrawToWeb(false);
 
            Session.Remove("file");
        }
    }

Open in new window

0
 
LVL 10

Expert Comment

by:GeoffSutton
ID: 24324063
I must admit then that I am a loss.  i would start by running some simple tests - What is session["file"] set to before you pass it from A, and when you receive it at B?  Rather than using session, how about javascript?  http://www.simiandesign.com/blog-fu/2005/08/javascript_acro.php  Use that to pass the value across then initiate a postback of some sort (session variables are not, I have found, incredibly reliable - I prefer querystrings, post variables or viewstate where possible).
0
 

Author Comment

by:mjoseph23
ID: 24328257
Yes, the query string solved the problem. Thanks!

iframe1.Attributes["src"] = "QapAppointmentLetterPDFBottom.aspx?file=" + appendedfile;
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question