Open
IPDFDocument4 :: General document management :: Common

See Also Example
Collapse All

This method opens an existing PDF document, reads and parses its contents.

Syntax

HRESULT Open (
BSTR fileName,
BSTR password
)
Parameters
fileName
Path to the PDF document to be opened

password
String containing the password

Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Remarks

This method clears all internal data before opening a document. If you want to save a previously created document, call SaveToFile or GetBuffer first.

When the document is opened, the current page will be the last page of
the existing PDF document.

When the document is opened, all of its properties (Author, Producer, Creator, Title, Subject and Keywords) are saved. You can change them later as needed.

Example

Opening an Existing PDF Document

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.Open('one.pdf', '');
PDF.NewPage;
font := PDF.AddFont('Arial', false, false, false, false, fcDefault);
PDF.UseFont(font, 10);
PDF.ShowTextAt(10, 10, 'This is a new page.');
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->Open("one.pdf", "");
PDF->NewPage();
long font = PDF->AddFont("Arial", false, false, false, false, fcDefault);
PDF->UseFont(font, 10)
PDF->ShowTextAt(10, 10, "This is a new page.");
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.Open("one.pdf", "");
PDF.NewPage();
long font = PDF.AddFont("Arial", false, false, false, false, FontCharset.fcDefault);
PDF.UseFont(font, 10)
PDF.ShowTextAt(10, 10, "This is a new page.");
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.Open "one.pdf", ""
PDF.NewPage
font = PDF.AddFont("Arial", False, False, False, False, 1) 'fcDefault
PDF.UseFont font, 10
PDF.ShowTextAt 10, 10, "This is a new page."
PDF.SaveToFile "test.pdf", true
Set PDF = nothing

See Also

Reference