How to download dynamic generated pdf file from server

I am trying to download pdf file from server on client computer. I am using "FDFACX.DLL" for generating dynamic pdf file. When I download this file then it is not opened in acrobat reader. On my system file is opened only in adobe acrobat and other system file is not downloaded.
Response.Clear();
        Response.Buffer=true ;
 
        FdfAppClass fdfAcX = new FdfAppClass();
        FdfDoc fdfAcXDoc = (FdfDoc)fdfAcX.FDFCreate();
        fdfAcXDoc.FDFSetFile(Server.MapPath("App_Data/Dealer_ULA_New10.pdf"));
 
       
        fdfAcXDoc.FDFSetValue("store_name", "S.P.L. Merchant", false);
        fdfAcXDoc.FDFSetValue("store_state", "L.A", false);
        fdfAcXDoc.FDFSetValue("store_entity", "Software Solutions", false);
       
        fdfAcXDoc.FDFSetValue("date", DateTime.Now.Date.ToString("dd/MM/yyyy"), false);
       
 Response.BinaryWrite((byte[])fdfAcXDoc.FDFSaveToBuf());
 Response.ContentType = "application/vnd.fdf";
fdfAcXDoc.FDFClose();
        Response.End();

Open in new window

Dealer-ULA-New10.pdf
teamsunarcAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amxCommented:
Try changing
Response.ContentType = "application/vnd.fdf";
to


Response.ContentType = "application/pdf";

Open in new window

0
teamsunarcAuthor Commented:
I have already tried this thing. because I am putting pdf with text box and dynamically storing textbox by value and want to download that pdf. So, let me know if any another solution you have to download  that pdf.
0
amxCommented:
have downloaded the latest version of the adobe pdf reader?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

thiyagukTech Lead Commented:
Please  use this as mime type        
Response.ContentType ="application/pdf"

for the list of Mime Time ,
Please
 Refer

http://www.w3schools.com/media/media_mimeref.asp


This is the complete Program listing.
 Response.Clear()
                    Response.AddHeader("content-disposition", "attachment;filename=" + strPath)
               
                    Response.ContentType = "application/pdf"
                    Response.TransmitFile(strPath)
                    Response.Flush()
                    Response.End()
0
teamsunarcAuthor Commented:
I am using adobe reader 8.0 and adobe acrobat 5.1. when pdf downloads then reader is opened and display nothing. but when I open this file in adobe acrobat then it is shown all text with dynamic data. but when attachment open on browser then reader does not show anything. one thing more when I downloads the pdf then its size shows only 1kb while the size of pdf is 88kb.
0
teamsunarcAuthor Commented:
This is the complete Program listing.
                    Response.Clear()
                    Response.AddHeader("content-disposition", "attachment;filename=" + strPath)
               
                    Response.ContentType = "application/pdf"
                    Response.TransmitFile(strPath)
                    Response.Flush()
                    Response.End()

The above code will not run according to my requirement because this code downloads the file which is placed on server but in my requirement pdf is fullfilled by dynamic text and then downloaded. So I am using Response.BinaryWrite(byte[]) function to download pdf file.  According to my code I am using fdfacx.dll to create dynamic pdf file and want to export this pdf to client.
Response.Clear();
        Response.Buffer=true ;
 
        FdfAppClass fdfAcX = new FdfAppClass();
        FdfDoc fdfAcXDoc = (FdfDoc)fdfAcX.FDFCreate();
        fdfAcXDoc.FDFSetFile(Server.MapPath("App_Data/Dealer_ULA_New10.pdf"));
 
       
        fdfAcXDoc.FDFSetValue("store_name", "S.P.L. Merchant", false);
        fdfAcXDoc.FDFSetValue("store_state", "L.A", false);
        fdfAcXDoc.FDFSetValue("store_entity", "Software Solutions", false);
       
        fdfAcXDoc.FDFSetValue("date", DateTime.Now.Date.ToString("dd/MM/yyyy"), false);
       
 Response.BinaryWrite((byte[])fdfAcXDoc.FDFSaveToBuf());
 Response.ContentType = "application/vnd.fdf";
fdfAcXDoc.FDFClose();
        Response.End();

Open in new window

0
amxCommented:
use thiyaguk code but replace the line

Response.BinaryWrite((byte[])fdfAcXDoc.FDFSaveToBuf());

with
Response.Write(fdfAcXDoc.FDFSaveToStr());

Open in new window

0
amxCommented:
Ignore my last comment, i think this will work:
Response.ContentType = "application/vnd.fdf"; 
 
byte[] myByte = (byte[])fdfAcXDoc.FDFSaveToBuf();
 
fdfAcXDoc.FDFClose();
 
Response.OutputStream.Write(myByte, 0, myByte.Length); 

Open in new window

0
teamsunarcAuthor Commented:
Thanks for above code but the pdf is downloaded on only my pc but when I download this pdf from other pc then it gives error like-

the file you are attempting to open contains comments or form data that are supposed to be placed on , C:\inetpub\demopdf\App_Data\Dealer_ULA.pdf . This document can not be found . it may have been moved or deleted . would you lke to browse to attempt to locate this document


0
amxCommented:
I think the problem is with this line:

fdfAcXDoc.FDFSetFile(Server.MapPath("App_Data/Dealer_ULA_New10.pdf"));
 
try replacing with something like this, making sure you replace the url to your server

FdfAcX_Doc.FDFSetFile("http://www.yourserver.com/test.pdf")

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
teamsunarcAuthor Commented:
Thanks for this solution. I was giving path of file with "App_Data". and fdfacx does not take file from by app_data. So when I changed it as you said. It is running fine.
Thanks once again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.