Dies ist meine Funktion, die pdf in png Bild konvertiert, es ist ein Fehler auf werfen this line--> stream.WriteTo(Response.OutputStream); Ist da irgendetwas falsch??
protected void CreatePngFromPdf()
{
try
{
string PDFLocation = string.Format(@"\\XXXX\{0}\{1}\{2}.pdf", Yr, Loc.Substring(0, 4), Loc.Substring(4, 4));
Utilities.WebPDF.PDF WebPDF = new DocuvaultMVC.Utilities.WebPDF.PDF();
WebPDF.Credentials = new NetworkCredential(@"xyz", "xyz");
byte[] png = WebPDF.StreamPdfPageAsPngResize(PDFLocation,PageNumber, 612, 792);
MemoryStream ms = new MemoryStream(png);
MemoryStream stream = new MemoryStream();
int newWidth = 612;
int newHeight = 792;
System.Drawing.Image newImg = System.Drawing.Image.FromStream(ms);
Bitmap temp = new Bitmap(newWidth, newHeight, newImg.PixelFormat);
Graphics newImage = Graphics.FromImage(temp);
newImage.DrawImage(newImg, 0, 0, newWidth, newHeight);
newImg.Dispose();
temp.Save(stream, ImageFormat.Png);
stream.WriteTo(Response.OutputStream);
temp.Dispose();
stream.Dispose();
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
}