Solved

Adobe Acrobat Reader PDF/FDF Merge and View

Posted on 2003-11-20
10
3,790 Views
Last Modified: 2010-08-05
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
**************************************************************************




0
Comment
Question by:tracymr
  • 4
  • 3
  • 3
10 Comments
 
LVL 1

Accepted Solution

by:
cavijayan earned 500 total points
ID: 9795898
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
 

Expert Comment

by:Natasja_
ID: 9795920
try

Response.ContentType ="application/pdf"
0
 
LVL 1

Expert Comment

by:cavijayan
ID: 9796153
Hi

using Response.ContentType ="application/pdf"  will only give you a error because of no proper PDF file structure ...
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

Expert Comment

by:Natasja_
ID: 9796489
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
 

Author Comment

by:tracymr
ID: 9796997
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
 

Author Comment

by:tracymr
ID: 9797043
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
 
LVL 1

Expert Comment

by:cavijayan
ID: 9797099
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
 

Expert Comment

by:Natasja_
ID: 9797280
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
 

Author Comment

by:tracymr
ID: 9797285
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
 

Author Comment

by:tracymr
ID: 9797488
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

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

733 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