Adobe Acrobat Reader PDF/FDF Merge and View

My goal is to prepopulate PDF forms with information that resides in a database via a web (ASP) platform.

In order to do this, I am merging a PDF template with a FDF file.  This part works.

The problem I am having is that I would prefer to launch the document in the Acrobat Reader stand alone program and instead the generated document is being launched in the reader plug-in for IE/Netscape.  If I can't get the document to launch in the stand-alone reader I'd like to not have the stand-alone reader launch at all and simply have the document loaded in the web browser plug-in.

'**************************************************************************
'--This sample launches the an empty instance of adobe acrobat reader and then opens the merged
'--document in a browser window with the form prepopulated

Set FdfAcX = Server.CreateObject("FdfApp.FdfApp")

' Create a blank FDF file
Set objFdf = FdfAcX.FDFCreate
objFdf.FDFSetValue "strLastName", strLastName, False
objFdf.FDFSetValue "strFirstName", strFirstName, False

objFdf.FDFSetFile "http://www.myweb.com/Content/DynamicForms/myfile.pdf"

' Save the file
Response.ContentType = "application/vnd.fdf"
Response.BinaryWrite objFdf.FDFSaveToBuf

' Close the file
objFdf.FDFClose
   
' Cleanup
Set objFdf = Nothing
Set FdfAcX = Nothing
**************************************************************************


'**************************************************************************
'--This sample only works in the server because of the physical file location of the PDF but launches in
'--Adobe Acrobat reader as desired.  I just wanted to show this example as a contrast to above
'--but that it offers the desired result

Set FdfAcX = Server.CreateObject("FdfApp.FdfApp")

' Create a blank FDF file
Set objFdf = FdfAcX.FDFCreate
objFdf.FDFSetValue "strLastName", strLastName, False
objFdf.FDFSetValue "strFirstName", strFirstName, False

objFdf.FDFSetFile "c:/DynamicPDFs/Content/DynamicForms/myfile.pdf"

' Save the file
Response.ContentType = "application/vnd.fdf"
Response.BinaryWrite objFdf.FDFSaveToBuf

' Close the file
objFdf.FDFClose
   
' Cleanup
Set objFdf = Nothing
Set FdfAcX = Nothing
**************************************************************************




tracymrAsked:
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.

cavijayanCommented:
I have faced this similar problem during my project, if the URL starts with http then IE/Netscape opens the PDF.

As you have said if you point it to harddisk the Acrobat reader will open it.Because Acrobat install plugin to make pdf can viewed via web browsers.

So, i think if its not a big issue in your project. Just leave it ...

As far as i know there is no proper known solution so far ...
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
Natasja_Commented:
try

Response.ContentType ="application/pdf"
0
cavijayanCommented:
Hi

using Response.ContentType ="application/pdf"  will only give you a error because of no proper PDF file structure ...
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Natasja_Commented:
Ok, here's how I do it .. the file will get displayed in the stand alone program :
the trick is to first write the pdf to a physical file, then call Response.WriteFile on that file

....
string rrnaam = GetFaktNaam(Session["klant"].ToString());

                  string theFile = FdfAcX_Doc.FDFSaveToStr();

                  FileStream fs = new FileStream( ExportFolder + rrnaam + ".pdf" , FileMode.OpenOrCreate, FileAccess.Write);
                  StreamWriter m_streamWriter = new StreamWriter(fs);
 
                  // Write to the file using StreamWriter class
                  m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
                  m_streamWriter.WriteLine(theFile);
                  m_streamWriter.Flush();
                  fs.Close();
                  //-------------------

                  FdfAcX_Doc.FDFClose();
                  Response.ContentType="Application/vnd.fdf";
                  Response.WriteFile(ExportFolder + rrnaam + ".pdf");
                  Response.End();
0
tracymrAuthor Commented:
Natasja_,
I do not have access to the methods and classes you mention.  I'm not using .Net  just straight up ASP on an IIS 5.0 server.  I should have mentioned that to begin with.

I don't necessarily *need* to have the PDF launch in the stand-alone reader, that is preferred.  However, if the PDF must launch in a browser window I'd rather not have adobe reader launch at all.  It doesn't appear to be providing any purpose.

Any other ideas?
0
tracymrAuthor Commented:
My wish list is this
1.  Open the PDF in the stand-alone reader

else

2.  Open the PDF in the browser and do not open the reader stand-alone

else
what I have now is
3.  Open the PDF in the browser and launch an empty instance of Acrobat reader.
0
cavijayanCommented:
I don't think it will open the empty instance of Acrobat reader? Are you sure? Bcoz i'm using IE 6 but i have never seen such thing before ...
0
Natasja_Commented:
do you mean that adobe acrobat (CREATOR, not the Free reader) is opened when you look at the FDF ? So you got 1 open window with your data, and an open empty Acrobat ?

Because that's normal, it doesn't happen on PC's where only the free reader is installed.
0
tracymrAuthor Commented:
I don't know why you haven't seen this behavior but I've tested this code..
**************************************************************************
'--This sample launches the an empty instance of adobe acrobat reader and then opens the merged
'--document in a browser window with the form prepopulated

Set FdfAcX = Server.CreateObject("FdfApp.FdfApp")

' Create a blank FDF file
Set objFdf = FdfAcX.FDFCreate
objFdf.FDFSetValue "strLastName", strLastName, False
objFdf.FDFSetValue "strFirstName", strFirstName, False

objFdf.FDFSetFile "http://www.myweb.com/Content/DynamicForms/myfile.pdf"

' Save the file
Response.ContentType = "application/vnd.fdf"
Response.BinaryWrite objFdf.FDFSaveToBuf

' Close the file
objFdf.FDFClose
   
' Cleanup
Set objFdf = Nothing
Set FdfAcX = Nothing
**************************************************************************

on several different machines and get the same result.  The back end is Windows 2000, IIS 5.0 and I've tested on a Windows 2000 Professional computer running IE 6, 2 windows XP machines running IE 6, and a Windows 98 machine running IE 6 and all have displayed the same behavior of launching an empty acrobat reader and then loading the PDF in a browser window.
0
tracymrAuthor Commented:
I really appreciate all the comments thus far.  

I have double checked that only the free reader is installed on my test machine just to verify that what I've said thus far is accurate.  It does happen on a machine where only the free reader is installed.  Again, what I end up with is an IE window with the pdf and an instance of Acrobat Reader with no document.
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
Web Development

From novice to tech pro — start learning today.