-
original PDF file
TestForm_Lay.pdf (67.5 KB) -
converted png file
fea49634-e795-491a-8529-3ca9639bf800.PNG (86.4 KB)
image of bottom in pdf file is not created in png file.
- c# code
public bool SavePage(MemoryStream pageStream, string fileName, string companyId)
{
try
{
CloudBlob blob;
var imageProcess = new ImageProcess();
Stream pdfStream = new MemoryStream();
blob = blobContainer.GetBlobReference(fileName + ".PDF");
blob.DeleteIfExists();
blob.UploadFromStream(pageStream);
Document pdfDoc = new Document(pageStream);
Resolution resolution = new Resolution(100);
PngDevice pngDevice = new PngDevice(resolution);
Stream imageStream = new MemoryStream();
pngDevice.Process(pdfDoc.Pages[1], imageStream);
System.Drawing.Image image = System.Drawing.Image.FromStream(imageStream);
image.Save(imageStream, ImageFormat.Png);
imageStream.Seek(0, SeekOrigin.Begin);
blob = blobContainer.GetBlobReference(fileName + ".PNG");
blob.UploadFromStream(imageStream);
Stream imageThumbStream = new MemoryStream();
image.Save(imageThumbStream, ImageFormat.Gif);
imageThumbStream = imageProcess.CreateThumbnail(imageStream, 100, 100);
imageThumbStream.Seek(0, SeekOrigin.Begin);
blob = blobContainer.GetBlobReference(fileName + ".GIF");
blob.UploadFromStream(imageThumbStream);
imageThumbStream.Close();
return true;
}
catch (Exception)
{
return false;
}
}