Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Jul 19, 2018 11:46 am

Hi,
Code: Select all
 Image emf = doc.SaveAsImage(0, Spire.Pdf.Graphics.PdfImageType.Metafile);

 Image emf = doc.SaveAsImage(0);


when I try to use the first SaveAsImage method in Azure Function App It's crashing, but when I use the second option It's working. It reneders a picture, but it's doing it in horrible quality.
If I use it locally(the first option) everything works like a charm, only in azure it's a difficulty. Is there any other option to scale an image without saving it first? :)

Thank You,

Ig

igsasa
 
Posts: 1
Joined: Thu Jul 19, 2018 11:35 am

Fri Jul 20, 2018 10:29 am

Hi igsasa,

Thanks for your post.
Sorry to tell that Spire.PDF does not support saving to Meta file on Azure. Here's a workaround, please refer to the below code.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(Server.MapPath("~/Data/Sample.pdf"));
System.Drawing.Image bmp = doc.SaveAsImage(0);
System.Drawing.Image zoomImg = new Bitmap((int)(bmp.Size.Width * 2), (int)(bmp.Size.Height * 2));
using (Graphics g = Graphics.FromImage(zoomImg))
{
g.ScaleTransform(2.0f, 2.0f);
g.DrawImage(bmp, new Rectangle(new Point(0, 0), bmp.Size), new Rectangle(new Point(0, 0), bmp.Size), GraphicsUnit.Pixel);
}
zoomImg.Save(Server.MapPath("~/Data/ResultImg.png"), ImageFormat.Png);
Sincerely,
Hogan
E-iceblue support team
User avatar

hogan.tang
 
Posts: 51
Joined: Tue Jul 03, 2018 1:43 am

Tue Jul 24, 2018 9:27 am

Dear igsasa,

Have your problem been solved? Your feedback Would be greatly appreciated.
Sincerely,
Hogan
E-iceblue support team
User avatar

hogan.tang
 
Posts: 51
Joined: Tue Jul 03, 2018 1:43 am

Return to Spire.PDF

cron