LEADTOOLS PDF (Leadtools.Pdf assembly)
LEAD Technologies, Inc

Convert Method

Example 





The 1-based number of the first page to be converted. Must be a value greater than or equal to 1.
The 1-based number of the last page to be converted. Must be a value greater than or equal to firstPageNumber and less than or equal to the total number of pages in the file. Use the special value of -1 to represents "last page in the file".
Name of the destination PDF file to be created. If the value of this parameter is null (Nothing in Visual Basic) then the file name set in FileName will be updated.
Converts the file associated with this PDFFile object to a different version using optional document properties and security options.
Syntax
public void Convert( 
   int firstPageNumber,
   int lastPageNumber,
   string destinationFileName
)
'Declaration
 
Public Sub Convert( _
   ByVal firstPageNumber As Integer, _
   ByVal lastPageNumber As Integer, _
   ByVal destinationFileName As String _
) 
'Usage
 
Dim instance As PDFFile
Dim firstPageNumber As Integer
Dim lastPageNumber As Integer
Dim destinationFileName As String
 
instance.Convert(firstPageNumber, lastPageNumber, destinationFileName)
public void Convert( 
   int firstPageNumber,
   int lastPageNumber,
   string destinationFileName
)
 function Leadtools.Pdf.PDFFile.Convert( 
   firstPageNumber ,
   lastPageNumber ,
   destinationFileName 
)
public:
void Convert( 
   int firstPageNumber,
   int lastPageNumber,
   String^ destinationFileName
) 

Parameters

firstPageNumber
The 1-based number of the first page to be converted. Must be a value greater than or equal to 1.
lastPageNumber
The 1-based number of the last page to be converted. Must be a value greater than or equal to firstPageNumber and less than or equal to the total number of pages in the file. Use the special value of -1 to represents "last page in the file".
destinationFileName
Name of the destination PDF file to be created. If the value of this parameter is null (Nothing in Visual Basic) then the file name set in FileName will be updated.
Remarks

To use this method, associate this PDFFile object with a valid PDF file and optional password. You can achieve this by either using the PDFFile(string fileName) or PDFFile(string fileName, string password) constructurs or set the file name and optional password directly into the FileName and Password properties. You do not need to call Load before using this method.

This method can be used to work on all or portion of the pages in a PDF file. To use all the pages of a document, pass 1 and -1 for firstPageNumber and lastPageNumber.

This method will use the following properties of this PDFFile object:

Example
 
Public Sub PDFFileConvertExample()
      Dim sourceFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD.pdf")
      Dim destinationFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "LEAD_15.pdf")

      Dim pdfFileObj As New PDFFile(sourceFileName)
      pdfFileObj.DocumentProperties = New PDFDocumentProperties()
      Dim properties As PDFDocumentProperties = pdfFileObj.DocumentProperties
      properties.Author = "Me"
      properties.Creator = "My Application"
      properties.Title = "My Document"
      properties.Producer = "LEAD"
      properties.Subject = "My Subject"
      properties.Keywords = "Keyword1 Keyword2"
      properties.Created = DateTime.Now
      properties.Modified = DateTime.Now

      pdfFileObj.CompatibilityLevel = PDFCompatibilityLevel.PDF15

      pdfFileObj.Convert(1, -1, destinationFileName)
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void PDFFileConvertExample()
   {
      string sourceFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD.pdf");
      string destinationFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_15.pdf");

      PDFFile pdfFile = new PDFFile(sourceFileName);
      pdfFile.DocumentProperties = new PDFDocumentProperties();
      PDFDocumentProperties properties = pdfFile.DocumentProperties;
      properties.Author = "Me";
      properties.Creator = "My Application";
      properties.Title = "My Document";
      properties.Producer = "LEAD";
      properties.Subject = "My Subject";
      properties.Keywords = "Keyword1 Keyword2";
      properties.Created = DateTime.Now;
      properties.Modified = DateTime.Now;

      pdfFile.CompatibilityLevel = PDFCompatibilityLevel.PDF15;

      pdfFile.Convert(1, -1, destinationFileName);
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PDFFile Class
PDFFile Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.