PortFolioCreate(Int32,PdfPortFolioType) Method
In This Topic
Converts a common PDF document into a PDF Portfolio file. You need to specify the index of that embedded file you want to display on opening the PDF Portfolio and the view mode users can view the component files in.
Please note that your source PDF document must contain at least one embedded (attached) file, otherwise this method will fail. It is also not allowed to create a PDF Portfolio file if your source PDF document is PDF/A compliant.
Syntax
Parameters
- FirstFileToShowIdx
- The 0-based index of that embedded file, which is initially presented in the user interface on opening the PDF Portfolio. It must be a value from 0 to GdPicturePDF.GetEmbeddedFileCount-1.
- ViewMode
- A member of the PdfPortFolioType enumeration. Sets the view mode users can view the component files in.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
How to create a PDF Portfolio containing a collection of three files.
Dim caption As String = "Example: PortFolioCreate"
Dim gdpicturePDF As New GdPicturePDF()
'Creating a new common PDF file.
If (gdpicturePDF.NewPDF() <> GdPictureStatus.OK) OrElse (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter) <> GdPictureStatus.OK) Then
MessageBox.Show("The new PDF document can't be created.", caption)
Else
'Embedding the files into the created PDF file.
If (gdpicturePDF.EmbedFile("textfile.txt", "1st attachmment") <> GdPictureStatus.OK) OrElse (gdpicturePDF.EmbedFile("docfile.docx", "2nd attachment") <> GdPictureStatus.OK) OrElse (gdpicturePDF.EmbedFile("pdffile.pdf", "3rd attachment") <> GdPictureStatus.OK) Then
MessageBox.Show("The files can't be attached.", caption)
Else
'Creating a PDF Portfolio.
Dim status As GdPictureStatus = gdpicturePDF.PortFolioCreate(0, PdfPortFolioType.Detail)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("gdpicturepdf_portfolio.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The PDF Portfolio file has been created and saved successfully.", caption)
End If
Else
MessageBox.Show("The PortFolioCreate() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
gdpicturePDF.Dispose()
string caption = "Example: PortFolioCreate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Creating a new common PDF file.
if ((gdpicturePDF.NewPDF() != GdPictureStatus.OK) ||
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter) != GdPictureStatus.OK))
{
MessageBox.Show("The new PDF document can't be created.", caption);
}
else
{
//Embedding the files into the created PDF file.
if ((gdpicturePDF.EmbedFile("textfile.txt", "1st attachmment") != GdPictureStatus.OK) ||
(gdpicturePDF.EmbedFile("docfile.docx", "2nd attachment") != GdPictureStatus.OK) ||
(gdpicturePDF.EmbedFile("pdffile.pdf", "3rd attachment") != GdPictureStatus.OK))
{
MessageBox.Show("The files can't be attached.", caption);
}
else
{
//Creating a PDF Portfolio.
GdPictureStatus status = gdpicturePDF.PortFolioCreate(0, PdfPortFolioType.Detail);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("gdpicturepdf_portfolio.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The PDF Portfolio file has been created and saved successfully.", caption);
}
}
else
{
MessageBox.Show("The PortFolioCreate() method has failed with the status: " + status.ToString(), caption);
}
}
}
gdpicturePDF.Dispose();
Example
How to create a PDF Portfolio containing a collection of three files.
Dim caption As String = "Example: PortFolioCreate"
Dim gdpicturePDF As New GdPicturePDF()
'Creating a new common PDF file.
If (gdpicturePDF.NewPDF() <> GdPictureStatus.OK) OrElse (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter) <> GdPictureStatus.OK) Then
MessageBox.Show("The new PDF document can't be created.", caption)
Else
'Embedding the files into the created PDF file.
If (gdpicturePDF.EmbedFile("textfile.txt", "1st attachmment") <> GdPictureStatus.OK) OrElse (gdpicturePDF.EmbedFile("docfile.docx", "2nd attachment") <> GdPictureStatus.OK) OrElse (gdpicturePDF.EmbedFile("pdffile.pdf", "3rd attachment") <> GdPictureStatus.OK) Then
MessageBox.Show("The files can't be attached.", caption)
Else
'Creating a PDF Portfolio.
Dim status As GdPictureStatus = gdpicturePDF.PortFolioCreate(0, PdfPortFolioType.Detail)
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("gdpicturepdf_portfolio.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The PDF Portfolio file has been created and saved successfully.", caption)
End If
Else
MessageBox.Show("The PortFolioCreate() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
gdpicturePDF.Dispose()
string caption = "Example: PortFolioCreate";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Creating a new common PDF file.
if ((gdpicturePDF.NewPDF() != GdPictureStatus.OK) ||
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeLetter) != GdPictureStatus.OK))
{
MessageBox.Show("The new PDF document can't be created.", caption);
}
else
{
//Embedding the files into the created PDF file.
if ((gdpicturePDF.EmbedFile("textfile.txt", "1st attachmment") != GdPictureStatus.OK) ||
(gdpicturePDF.EmbedFile("docfile.docx", "2nd attachment") != GdPictureStatus.OK) ||
(gdpicturePDF.EmbedFile("pdffile.pdf", "3rd attachment") != GdPictureStatus.OK))
{
MessageBox.Show("The files can't be attached.", caption);
}
else
{
//Creating a PDF Portfolio.
GdPictureStatus status = gdpicturePDF.PortFolioCreate(0, PdfPortFolioType.Detail);
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("gdpicturepdf_portfolio.pdf") == GdPictureStatus.OK)
{
MessageBox.Show("The PDF Portfolio file has been created and saved successfully.", caption);
}
}
else
{
MessageBox.Show("The PortFolioCreate() method has failed with the status: " + status.ToString(), caption);
}
}
}
gdpicturePDF.Dispose();
See Also