The Save method saves a PDF document to any .NET stream
Public Function SaveAsync(filePath As String) As Windows.Foundation.IAsyncOperation(Of Boolean)
Public Function SaveAsync(filePath As String, option As AmyuniPDFCreator.IacFileSaveOption) As Windows.Foundation.IAsyncOperation(Of Boolean)
Public Function SaveAsync(file As Windows.Storage.StorageFile) As Windows.Foundation.IAsyncOperation(Of Boolean)
Public Function SaveAsync(file As Windows.Storage.StorageFile, option As AmyuniPDFCreator.IacFileSaveOption) As Windows.Foundation.IAsyncOperation(Of Boolean)
Public Function SaveAsync(stream As Windows.Storage.Streams.IRandomAccessStream) As Windows.Foundation.IAsyncOperation(Of Boolean)
Public Function SaveAsync(stream As Windows.Storage.Streams.IRandomAccessStream, option As AmyuniPDFCreator.IacFileSaveOption) As Windows.Foundation.IAsyncOperation(Of Boolean)
public Windows.Foundation.IAsyncOperation<bool> SaveAsync(string filePath);
public Windows.Foundation.IAsyncOperation<bool> SaveAsync(string filePath, AmyuniPDFCreator.IacFileSaveOption option);
public Windows.Foundation.IAsyncOperation<bool> SaveAsync(Windows.Storage.StorageFile file);
public Windows.Foundation.IAsyncOperation<bool> SaveAsync(Windows.Storage.StorageFile file, AmyuniPDFCreator.IacFileSaveOption option);
public Windows.Foundation.IAsyncOperation<bool> SaveAsync(Windows.Storage.Streams.IRandomAccessStream stream);
public Windows.Foundation.IAsyncOperation<bool> SaveAsync(Windows.Storage.Streams.IRandomAccessStream stream, AmyuniPDFCreator.IacFileSaveOption option);
public: Windows::Foundation::IAsyncOperation<bool>^ SaveAsync(String^ filePath);
public: Windows::Foundation::IAsyncOperation<bool>^ SaveAsync(String^ filePath, AmyuniPDFCreator::IacFileSaveOption option);
public: Windows::Foundation::IAsyncOperation<bool>^ SaveAsync(Windows::Storage::StorageFile^ file);
public: Windows::Foundation::IAsyncOperation<bool>^ SaveAsync(Windows::Storage::StorageFile^ file, AmyuniPDFCreator::IacFileSaveOption option);
>Windows::Foundation::IAsyncOperation<bool>^ SaveAsync(Windows::Storage::Streams::IRandomAccessStream ^stream);
Windows::Foundation::IAsyncOperation<bool>^ SaveAsync(Windows::Storage::Streams::IRandomAccessStream ^stream, AmyuniPDFCreator::IacFileSaveOption option);
Windows.Foundation.IAsyncOperation<Boolean> saveAsync(Windows.Storage.StorageFile file);
Windows.Foundation.IAsyncOperation<Boolean> saveAsync(Windows.Storage.Streams.IRandomAccessStream stream, AmyuniPDFCreator.IacFileSaveOption option);
filepath
File path where the PDF document will be saved.. This method overload can only be used with file paths where Windows Store applications have writing permissions, such as:
Windows.Storage.ApplicationData.Current.LocalFolder
ApplicationData.Current.TemporaryFolder
file
A WinRT StorageFile object that represents the file where the PDF document will be stored.
stream
A stream object where the PDF document will be stored.
option
Part of the document to save. The save option parameter is of type IacFileSaveOption.
IacFileSaveOption is defined as follows:
Option |
Value |
Description |
---|---|---|
acFileSaveAll |
0 |
Save document data and view. This option should be only used with PDF created by Amyuni PDF Creator. The document can be viewed with any PDF viewer and retains all design data. |
acFileSaveView |
1 |
Save only document view. The document can be viewed with any PDF viewer including Amyuni PDF Creator but all design data such as database connection, OLE objects, is lost. |
acFileSaveDesign |
2 |
Save only document data. The document can be opened, viewed and edited only with the Amyuni PDF Creator. It will show as blank pages in other viewers. |
acFileSaveDefault |
-1 |
Take the default Save option stored in the document object, i.e., one of the 3 options above. |
acFileSavePDFA_7 |
3 |
[Obsolete]. |
acFileSavePDFA |
4 |
Save document keeping the PDFALevel and PDFAConformance values from the original file. Otherwise, it will be marked as PDF/A-1b. However, this flag doesn't adjust the other requirements to be valid PDF/A like Embedding Fonts, etc, only the PDFALevel value. |
acFileSavePDF14 |
5 |
Save document PDF Specifications Version 1.4. |
acFileSavePDFUA
|
6 |
Save the file with XMP metadata compatible with PDF/UA |
This method launches an exception if the document cannot be saved.
For acFileSavePDFUA needs to set the PDFALevel to 1 (PDFA-1). This is for future development and support for higher versions of PDF/UA. So the same level attribute is used for PDF/A and PDF/UA.
We still need to set the ViewerPreferences and DocumentLanguage for PDF/UA, these will not be created automatically:
pdf.ObjectAttribute("Document", "ViewerPreferences") = "/DisplayDocTitle true"
pdf.ObjectAttribute("Document", "DocumentLanguage") = "en"
pdf.ObjectAttribute("Document", "FileSaveOption") = acFileSavePDFUA
IacDocument pdfDoc = new IacDocument();
// Set the license key
pdfDoc.SetLicenseKey("Company Name", "07EFCDAB0100...009EE2F79");
// Retrieving the first page
IacPage page = pdfDoc.GetPage(1);
pdfDoc.CurrentPage = pdfDoc.GetPage(1);
// Setting the document in design mode
pdfDoc.ReportState = AmyuniPDFCreator.IacReportState.acReportStateDesign;
// Creating a new text object
IacObject oText = page.CreateObject(
AmyuniPDFCreator.IacObjectType.acObjectTypeText, "acText1");
// Setting a few attributes to the new object
oText.Coordinates = new Windows.Foundation.Rect(1500, 1000, 6000, 500);
oText.AttributeByName("Text").Value = "This is a sample text";
oText.AttributeByName("TextFont").Value = "Arial, 18, 300, 0, 0";
oText.AttributeByName("TextColor").Value = 0xFAEBD7;
oText.AttributeByName("BorderWidth").Value = 2;
// Setting the document in visualization mode
pdfDoc.ReportState = IacReportState.acReportStateRun;
// Saving the file asynchronously
string tempPath = Windows.Storage.ApplicationData.Current.TemporaryFolder.Path;
bool result = await pdfDoc.SaveAsync(tempPath + "\\CreateTextObject.pdf", IacFileSaveOption.acFileSaveView);
if (result)
await (new Windows.UI.Popups.MessageDialog("File Saved!", "SaveAsync Sample")).ShowAsync();
else
await (new Windows.UI.Popups.MessageDialog("Test Failed!", "SaveAsync Sample")).ShowAsync();
IacDocument^ pdfDoc = ref new IacDocument();
// Set the license key
pdfDoc->SetLicenseKey(L"Company Name", L"07EFCDAB0100...009EE2F79");
// Retrieving the first page
IacPage^ page = pdfDoc->GetPage(1);
pdfDoc->CurrentPage = pdfDoc->GetPage(1);
// Setting the document in design mode
pdfDoc->ReportState = AmyuniPDFCreator::IacReportState::acReportStateDesign;
// Creating a new text object
IacObject^ oText = page->CreateObject(
AmyuniPDFCreator::IacObjectType::acObjectTypeText, "acText1");
// Setting a few attributes to the new object
oText->Coordinates = Windows::Foundation::Rect(1500, 1000, 6000, 500);
oText->AttributeByName("Text")->Value = "This is a sample text";
oText->AttributeByName("TextFont")->Value = "Arial, 18, 300, 0, 0";
oText->AttributeByName("TextColor")->Value = 0xFAEBD7;
oText->AttributeByName("BorderWidth")->Value = 2;
// Setting the document in visualization mode
pdfDoc->ReportState = IacReportState::acReportStateRun;
// Saving the file asynchronously
Platform::String^ tempPath = Windows::Storage::ApplicationData::Current->TemporaryFolder->Path;
task<bool> saveTask = create_task(pdfDoc->SaveAsync(tempPath + "\\CreateTextObject.pdf",
IacFileSaveOption::acFileSaveView));
saveTask.then( [pdfDoc,tempPath](bool result)
{
if (result)
(ref new Windows::UI::Popups::MessageDialog("File Saved!", "SaveAsync Sample"))->ShowAsync();
else
(ref new Windows::UI::Popups::MessageDialog("Test Failed!", "SaveAsync Sample"))->ShowAsync();
});
var pdfDoc = new AmyuniPDFCreator.IacDocument();
// Set the license key
pdfDoc.setLicenseKey( "Amyuni PDF Creator WinRT-UWP Evaluation", "07EFCDAB01000100...8063E02CA85CF1B87D" );
// Retrieving the first page
var page = pdfDoc.getPage(1);
pdfDoc.currentPage = pdfDoc.getPage(1);
// Setting the document in design mode
pdfDoc.reportState = AmyuniPDFCreator.IacReportState.acReportStateDesign;
// Creating a new text object
var oText = page.createObject(AmyuniPDFCreator.IacObjectType.acObjectTypeText, "acText");
// Setting a few attributes to the new object
oText.coordinates = { height: 1500, width: 2000, x: 3000, y: 500 };
oText.attributeByName("TextColor").value = 0xFAEBD7;
oText.attributeByName("TextFont").value = "Arial, 18, 300, 0, 0";
oText.attributeByName("BorderWidth").value = 2;
oText.attributeByName("Text").value = "This is a sample text";
// Setting the document in visualization mode
pdfDoc.ReportState = AmyuniPDFCreator.IacReportState.acReportStateRun;
// Saving the file asynchronously
var filePickerSave = new Windows.Storage.Pickers.FileSavePicker();
filePickerSave.fileTypeChoices.insert("PDF File", [".pdf"]);
filePickerSave.suggestedFileName = "CreateTextObject";
filePickerSave.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.documentsLibrary;
filePickerSave.pickSaveFileAsync().done(function (selectedFile){
if (selectedFile != undefined){
selectedFile.openAsync(Windows.Storage.FileAccessMode.readWrite).
then(function(outStream){
pdfDoc.saveAsync(outStream, AmyuniPDFCreator.IacFileSaveOption.acFileSaveView);
});
}
});