|
//Create a new PDF document.
PdfDocument doc = new PdfDocument();
//Add a page to the document.
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
//Load the image
Stream imageStream = File.OpenRead("Autumn Leaves.jpg");
//Load the image from the stream
PdfBitmap image = new PdfBitmap(imageStream);
//Draw the image
graphics.DrawImage(image, 0, 0);
//Save the document.
doc.Save("Output.pdf");
//Close the document.
doc.Close(true); |
If it work you saved my life :P (3 days)
Thanks
|
public Stream LoadFromFile(string fileName)
{
string root = null;
if (Android.OS.Environment.IsExternalStorageEmulated)
{
root = Android.OS.Environment.ExternalStorageDirectory.ToString();
}
else
root = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
return System.IO.File.OpenRead(root+"/Syncfusion/"+fileName.ToString());
} |
|
public Stream LoadFromFile(string filename)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string filePath = Path.Combine(path, filename);
return System.IO.File.OpenRead(filePath)
} |
|
public stream LoadFromFile(string fileName)
{
LoadFile1(filename).Result;
}
public async Task<Stream> LoadFile1(string filename)
{
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile sampleFile = await storageFolder.GetFileAsync(filename);
Stream outStream = await sampleFile.OpenStreamForReadAsync();
return outStream;
} |