Solved

Adobe Acrobat Reader PDF/FDF Merge and View

Posted on 2003-11-20
10
3,802 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

707 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