Doc SetInfo Function. Sets information about an object. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

Sets information about an object.

 

   
Syntax  

[C#]
void SetInfo(int id, string type, string info)
void SetInfo(int id, string type, int info)
void SetInfo(int id, string type, double info)
void SetInfo(int id, string type, DateTime info)

[Visual Basic]
Sub SetInfo(id As Integer, type As String, info As String)
Sub SetInfo(id As Integer, type As String, info As Integer)
Sub SetInfo(id As Integer, type As String, info As Double)
Sub SetInfo(id As Integer, type As String, info As DateTime)

 

   

Params
 
Name Description
id

The Object ID of the object to be modified.

type

The type of value to insert.

info The value to insert.
• The overloads taking integer/floating-point info converts this parameter to the string representation (numbers as used in PDF) in the invariant culture without creating a managed string object.
• The overload taking DateTime info converts this parameter to the string representation (PDF date string) so it is mostly used with the :Text object type.

 

   

Notes
 

In the same way as you can get information about aspects of a document using the GetInfo method you can modify aspects of the document using the SetInfo method.

Different types of object support different types of properties. For more detailed information see the Object Paths section of this document.

PDF objects are case sensitive so be sure you use the correct case.

 

   

Example
 

See Doc Properties Example for an example of using the overload taking DateTime info.

The following shows how to modify the document catalog to ensure that the PDF opens onto the second page rather than the first.

[C#]
Doc theDoc = new Doc();
theDoc.Read(Server.MapPath("../mypics/sample.pdf"));
int thePages = theDoc.GetInfoInt(theDoc.Root, "Pages");
int thePage2 = theDoc.GetInfoInt(thePages, "Page 2");
string theAction = "[ " + thePage2.ToString() + " 0 R /Fit ]";
theDoc.SetInfo(theDoc.Root, "/OpenAction", theAction);
theDoc.Save(Server.MapPath("docsetinfo.pdf"));
theDoc.Clear();

[Visual Basic]
Dim theDoc As Doc = New Doc()
theDoc.Read(Server.MapPath("../mypics/sample.pdf"))
Dim thePages As Integer = theDoc.GetInfoInt(theDoc.Root,"Pages")
Dim thePage2 As Integer = theDoc.GetInfoInt(thePages,"Page 2")
Dim theAction As String = "[ " + thePage2.ToString() + " 0 R /Fit ]"
theDoc.SetInfo(theDoc.Root, "/OpenAction", theAction)
theDoc.Save(Server.MapPath("docsetinfo.pdf"))
theDoc.Clear()

Open Actions. The way in which a PDF is displayed when opened is dependent on certain flags within the PDF itself. Here are some common combinations. For full details of how these work you should see the Adobe PDF Specification available from the Adobe web site.

To show outlines:

theDoc.SetInfo(theDoc.Root, "/PageMode", "/UseOutlines")

Or for thumbnails:

theDoc.SetInfo theDoc.Root, "/PageMode", "/UseThumbs"

To display two pages side by side:

theDoc.SetInfo(theDoc.Root, "/PageLayout", "/TwoColumnLeft")

To make the print dialog appear when the document is opened:

theDoc.SetInfo(theDoc.Root, "/OpenAction", "<< /Type /Action /S /Named /N /Print >>")

To open at 200% zoom onto the current page:

theDoc.SetInfo(theDoc.Root, "/OpenAction", "[ " + theDoc.Page.ToString() +" 0 R /XYZ null null 2 ]")

To fit the document width onto the current page:

theDoc.SetInfo(theDoc.Root, "/OpenAction", "[ " + theDoc.Page.ToString() + " 0 R /FitH " + theDoc.MediaBox.Height.ToString() + " ]")