[Date Prev][Date Next] [Thread Prev][Thread Next]
[Date Index] [Thread Index] [New search]

Re: Opening a PDF document from a program



> A programmer just asked me if it was possible to request Acrobat to open a
> document at a particular page from an application.

I investigated something similar a while back, and the following is what
I found out, when it comes to making FM hypertext links to a PDF page.
However, things may have changed since then; I distinctly remember someone
saying that you could use OLE or something like that to overcome the
problems in Windows.

Another user has tried xpdf instead of Acrobat and reported:
> with xpdf-1.00 you can open a pdf file at a named destination with
> xpdf somefile.pdf +M8.newlink.destination

------------------------------------------------------------
There is no way to specify a location to open a PDF file on
by calling the Acrobat Reader application (acrord32.exe).
There are no command-line options or API functions for this.
It is *possible* that you can do it by calling the "full"
Acrobat application (acrobat.exe), but I'm not sure, and
this would require all users to have the full Acrobat package.
So, if you need to open up the PDF file by directly calling
a free Acrobat application, it cannot be done.

However, it *is* possible to specify a location for a PDF
file if you take advantage of the Acrobat Reader plug-in for
a commercial web browser, e.g. Internet Explorer or Netscape.
This plug-in is normally installed automatically when you
install the free Acrobat Reader.
Thus, by calling a web browser and providing a URL to the
PDF file, you can specify a location to open the file on.
What happens is that the web browser recognizes the PDF file
extension, starts the Acrobat Reader plug-in, and displays
the PDF file within the browser window, at the location (if
any) specified by the URL. You should note that this process
can be somewhat slow, so don't expect short response times.

There is an important restriction: for the Windows version
of Internet Explorer, you can only get reliable results for
PDF files with specified locations by placing the PDF file
on an Intranet or the Internet, thus using a web URL of the
type "http://...";. If you try to use a file URL for a file
located on a local file system ("file://..."), you will get
invalid or unreliable results, due to the way IE is integrated
into the Windows operating system...
This restriction does *not* apply to Netscape or to non-
Windows versions of Internet Explorer. If you can assume
that users won't be using the Windows version of IE, then
you can safely use URL links to files on a local file system.

A "location" in a PDF file can be either a physical page
number of the PDF file, or a so-called "named destination"
defined in the PDF file. URLs for these cases look like:
.../filename.pdf#page=X
.../filename.pdf#destination
where "X" is the page number, and "destination" is the name
of a named destination (defined in the PDF file).
If the PDF file is generated from FrameMaker, an alternative
URL for the case of a page number is:
.../filename.pdf#P.X
where "P." is case-sensitive, and "X" is the page number.

If you don't want to be restricted by specifying page numbers
(which may change when the source document is edited), you
have to define named destinations and use them instead.
Named destinations can be added to an existing PDF file by
using the full Acrobat application (not the Reader), but
such manually added destinations are lost whenever the PDF
file is re-generated or replaced with a new version.

If you have access to the source file of the PDF and its
application, you can add named destinations to the source
file, which will be transferred to the PDF file. In the
case of FrameMaker, you would add hypertext markers using
the syntax "newlink destination". Unfortunately, such
destination names are somewhat mangled when a PDF file is
created from the FM file, according to the following:
* A hypertext marker with the text "newlink entrypoint" will
  become a destination named "M8.newlink.entrypoint" in a PDF
  created from it. If the file is part of a book file and a
  book PDF file is created, the destination will become
  "M#.8.newlink.entrypoint", where # is the ordinal number of
  the file in the book. The "M8." indicates the destination
  originated as a hypertext marker.
* Any spaces in the marker text are replaced by periods, and any
  underscores are removed ("my entry_point" => "my.entrypoint")

So, a URL for a named destination in an FM file may look like:
[http://|file://].../filename.pdf#M8.newlink.entrypoint


- - - - - - - - - - - - - - - - - - - - - - -
Thomas Michanek, FrameMaker/UNIX/MIF expert
Technical Writer, IAR Systems, Uppsala, Sweden
mailto:Thomas.Michanek@telia.com
http://go.to/framers/
- - - - - - - - - - - - - - - - - - - - - - -



** To unsubscribe, send a message to majordomo@omsys.com **
** with "unsubscribe framers" (no quotes) in the body.   **