File Access Denied trying to show a newly created PDF

If you are a C/C++/C# developer and have any questions about using our products from your application here is the place to post them.
Post Reply
Sgom84
Posts: 1
Joined: Tue Jul 09 2013

File Access Denied trying to show a newly created PDF

Post by Sgom84 »

Hello, I started using Amyuni PDF Creator (evaluation copy) and I have a problem. I'm developing a Windows Store App and I need to create a pdf and the showing it. If I try to do this on a page, when I try to load the pdf file I get a File Access Denied Exception. This problem happens only when I try to load a pdf I just created. Here is the code:

In the xaml I have put a PDFCreator control named "VisualizerPDFCreator".
In code-behind I do the following:

- creation part
_iacDocument = new IacDocument();
_iacDocument.SetLicenseKey() //here I set the license information
IacPage page = _iacDocument.GetPage(1);
_iacDocument.CurrentPage = _iacDocument.GetPage(1);
// I put some text in the pdf...the I save it
file = await ApplicationData.Current.LocalFolder.CreateFileAsync("temp1.pdf", CreationCollisionOption.OpenIfExists);

if (file != null)
{
using (var s = await file.OpenAsync(FileAccessMode.ReadWrite))
{
await _iacDocument.SaveAsync(s);

Debug.WriteLine(file.Path);
}
}

- visualization part
IacDocument iac = VisualizerPDFCreator.Document;
iac.SetLicenseKey() //license information...
StorageFile fileToLoad = await ApplicationData.Current.LocalFolder.GetFileAsync("temp1.pdf");
if (file != null)
{
using (var s = await file.OpenReadAsync())
{
await iac.OpenAsync(s, ""); //NOTE: if I use await I get the File Access Denied, if I don't use await I don't get an exception but a blank pdf is loaded instead of the correct pdf

iac.RotatePage(1, IacRotatePageOption.acRotatePageLeft);
}
}
Post Reply