The MovePages method moves one or more pages to another location within the document.
public Function MovePages(pageNumber As Integer, pageCount As Integer, destination As Integer) As Boolean
public bool MovePages(int pageNumber, int pageCount, int destination)
public bool MovePages(int pageNumber, int pageCount, int destination)
Boolean MovePages(Number pageNumber, Number pageCount, Number destination)
pageNumber
Starting page.
pageCount
Number of pages to move.
destination
Where to place the moved pages.
True if the method call succeeded, False otherwise.
Member of AmyuniPDFCreator.IacDocument.
' fPDFCreator is the variable name of the Amyuni Xaml control that is placed
' on the user interface of the target Windows Store Application
Dim doc1 As AmyuniPDFCreator.IacDocument = fPDFCreator.Document
' Set the license key
doc1.SetLicenseKey("Amyuni PDF Creator WinRT-UWP Evaluation", "07EFCDAB01000100F280477A62560570D2805290D715A3744214C2755E1A174DABC5DF79946E4D3E88696CBF0724548B26CC8DE76773")
' Open a test file asyncronously, from one of the folders where
' a Windows Store Application has read access by default
Dim file As Windows.Storage.StorageFile = Await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("TestFile.pdf")
Dim result As Boolean = Await fPDFCreator.Document.OpenAsync(file, "")
If result Then
' Move the second page to the first position
doc1.MovePages(2, 1, 1)
Dim sampleName As String = "MovePages"
If result Then
' Saving the resulting file asyncronously, into one of the folders where
' a Windows Store Application has write access by default
Dim tempPath As String = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path
result = Await doc1.SaveAsync(System.IO.Path.Combine(tempPath, sampleName + "_result.pdf"))
If result Then
Await (New Windows.UI.Popups.MessageDialog(
sampleName + " Succedded!" + Environment.NewLine + System.IO.Path.Combine(tempPath, sampleName + "_result.pdf"),
sampleName + " Sample")).ShowAsync()
Else
Await (New Windows.UI.Popups.MessageDialog(sampleName + " Failed", sampleName + " Sample")).ShowAsync()
End If
Else
Await (New Windows.UI.Popups.MessageDialog(sampleName + " Failed", sampleName + " Sample")).ShowAsync()
End If
' Refresh the Xaml PDF Control
fPDFCreator.Refresh()
End If
// fPDFCreator is the variable name of the Amyuni Xaml control that is placed
// on the user interface of the target Windows Store Application
IacDocument doc1 = fPDFCreator.Document;
// Set the license key
doc1.SetLicenseKey("Amyuni PDF Creator WinRT-UWP Evaluation", "07EFCDAB01000100F280477A62560570D2805290D715A3744214C2755E1A174DABC5DF79946E4D3E88696CBF0724548B26CC8DE76773")
// Open a test file asyncronously, from one of the folders where
// a Windows Store Application has read access by default
StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("TestFile.pdf");
bool result = await doc1.OpenAsync(file, "");
if (result)
{
// Move the second page to the first position
doc1.MovePages(2, 1, 1);
string sampleName = "MovePages";
if (result)
{
// Saving the resulting file asyncronously, into one of the folders where
// a Windows Store Application has write access by default
string tempPath = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path;
result = await doc1.SaveAsync(System.IO.Path.Combine(tempPath, sampleName + "_result.pdf"));
if (result)
await (new Windows.UI.Popups.MessageDialog(
sampleName + " Succedded!" + Environment.NewLine + System.IO.Path.Combine(tempPath, sampleName + "_result.pdf"),
sampleName + " Sample")).ShowAsync();
else
await (new Windows.UI.Popups.MessageDialog(sampleName + " Failed", sampleName + " Sample")).ShowAsync();
}
else
await (new Windows.UI.Popups.MessageDialog(sampleName + " Failed", sampleName + " Sample")).ShowAsync();
// Refresh the control to view the changes
fPDFCreator.Refresh();
}
// fPDFCreator is the name of the Amyuni Xaml Control that should be
// placed on the user interface of a Windows Store Application
IacDocument^ doc1 = fPDFCreator->Document;
// Set the license key
doc1->SetLicenseKey( "Amyuni PDF Creator WinRT-UWP Evaluation", "07EFCDAB01000100F280477A62560570D2805290D715A3744214C2755E1A174DABC5DF79946E4D3E88696CBF0724548B26CC8DE76773");
// Open a test file asyncronously
concurrency::create_task(Windows::ApplicationModel::Package::Current->InstalledLocation->GetFileAsync("TestFile1.pdf")).
then([=](Windows::Storage::StorageFile^ file)
{
concurrency::create_task(doc1->OpenAsync(file, "")).
then([=](bool result)
{
if (result)
{
// Move the second page to the first position
doc1->MovePages(2, 1, 1);
// Display new first page
doc1->CurrentPageNumber = 1;
String^ sampleName = "MovePages";
if (result)
{
// Saving the resulting file asyncronously, into one of the folders where
// a Windows Store Application has write access by default
Platform::String^ tempPath = Windows::Storage::ApplicationData::Current->TemporaryFolder->Path;
create_task(doc1->SaveAsync( tempPath + "\\" + sampleName + "_result.pdf" ));
if (result)
{
String^ message = sampleName + " Succedded! \n";
message += (tempPath + "\\" + sampleName + "_result.pdf");
Windows::UI::Popups::MessageDialog^ dialog = ref new Windows::UI::Popups::MessageDialog( message, sampleName + " Sample");
create_task(dialog ->ShowAsync());
}
else
{
Windows::UI::Popups::MessageDialog^ dialog = ref new Windows::UI::Popups::MessageDialog(sampleName + " Failed", sampleName + " Sample");
create_task(dialog ->ShowAsync());
}
}
else
{
Windows::UI::Popups::MessageDialog^ dialog = ref new Windows::UI::Popups::MessageDialog(sampleName + " Failed", sampleName + " Sample");
create_task(dialog ->ShowAsync());
}
// Refresh the Xaml PDF Control
fPDFCreator->Refresh();
}
else
{
// Handle error
}
});
});
var doc1 = new AmyuniPDFCreator.IacDocument();
// Set the license key
doc1.setLicenseKey("Amyuni PDF Creator WinRT-UWP Evaluation", "07EFCDAB01000100F280477A62560570D2805290D715A3744214C2755E1A174DABC5DF79946E4D3E88696CBF0724548B26CC8DE76773");
// Open a test file asyncronously, from one of the folders where
// a Windows Store Application has read access by default
Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("TestFile.pdf").
then(function (file) {
// Get a stream object for the input file
file.openAsync(Windows.Storage.FileAccessMode.read).
then(function (inStream) {
// Open the PDF document from the file stream
doc1.openAsync(inStream, "").
then(function (result) {
if (result) {
// Move the second page to the first position
result = doc1.movePages(2, 1, 1);
var sampleName = "MovePages";
if (result) {
// Saving the resulting file asyncronously, into one of the folders where
// a Windows Store Application has write access by default
// Not all the overloads of the saveAsync method are available in Javascript
var temporaryFolder = Windows.Storage.ApplicationData.current.temporaryFolder;
temporaryFolder.getFileAsync(sampleName + "_output.pdf").
then(function (file) {
file.openAsync(Windows.Storage.FileAccessMode.readWrite).then(function (outStream) {
doc1.saveAsync(outStream).then(function (result) {
if (result)
(new Windows.UI.Popups.MessageDialog(sampleName + " Succedded! \n" + file.path, sampleName + " Sample")).showAsync();
else
(new Windows.UI.Popups.MessageDialog(sampleName + " Failed", sampleName + " Sample")).showAsync();
});
});
}, function (error) {
// The output file does not exist, let' s create a new one
temporaryFolder.createFileAsync(sampleName + "_output.pdf").
then(function (file) {
file.openAsync(Windows.Storage.FileAccessMode.readWrite).then(function (outStream) {
doc1.saveAsync(outStream).then(function (result) {
if (result)
(new Windows.UI.Popups.MessageDialog(sampleName + " Succedded! \n" + file.path, sampleName + " Sample")).showAsync();
else
(new Windows.UI.Popups.MessageDialog(sampleName + " Failed", sampleName + " Sample")).showAsync();
});
});
});
});
}
else
(new Windows.UI.Popups.MessageDialog(sampleName + " Failed", sampleName + " Sample")).showAsync();
}
});
});
});