How to Inlarge Images size in PDF without effecting the code

1
Sanjiv
5/22/2015 10:50 AM

How to Inlarge images size in PDF.?
I am using this code

public void AddImagetoPdf(string filename,string brandimage,string brand)
{
if (File.Exists(System.Web.Hosting.HostingEnvironment.MapPath("~/ClientBin/DWG/" + filename)))
{
try
{
using (FileStream fs = File.Open(System.Web.Hosting.HostingEnvironment.MapPath("~/ClientBin/DWG/" + filename), FileMode.Open, FileAccess.ReadWrite, FileShare.None))
{
fs.Close();
}
{

using (Stream inputPdfStream = new FileStream(GetPathFilename(filename), FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream inputImageStream = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/ClientBin/Images/logo1.bmp"), FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream inputImageStream1 = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/ClientBin/Images/"+brandimage), FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream inputImageStream2 = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/ClientBin/Images/logo3.bmp"), FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream outputPdfStream = new FileStream(System.Web.Hosting.HostingEnvironment.MapPath("~/ClientBin/DWG/" + "result.pdf"), FileMode.Create, FileAccess.Write, FileShare.None))
{
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
var pdfContentByte = stamper.GetOverContent(1);

Image image = Image.GetInstance(inputImageStream);
image.SetAbsolutePosition(30, 205);
image.ScaleAbsolute(60, 60);
pdfContentByte.AddImage(image);
if (brand.ToLower() != "kafko")
{
Image image01 = Image.GetInstance(inputImageStream1);
image01.SetAbsolutePosition(20, 80);
image01.ScaleAbsolute(150, 50);
pdfContentByte.AddImage(image01);
}
else

{
Image image1 = Image.GetInstance(inputImageStream1);
image1.SetAbsolutePosition(20, 100);
image1.ScaleAbsolute(150, 30);
pdfContentByte.AddImage(image1);
}
Image image2 = Image.GetInstance(inputImageStream2);
image2.SetAbsolutePosition(540, 30);
image2.ScaleAbsolute(90, 90);
pdfContentByte.AddImage(image2);
stamper.Close();

}
}
File.Delete(System.Web.Hosting.HostingEnvironment.MapPath("~/ClientBin/DWG/" + filename));
File.Move(System.Web.Hosting.HostingEnvironment.MapPath("~/ClientBin/DWG/" + "result.pdf"), System.Web.Hosting.HostingEnvironment.MapPath("~/ClientBin/DWG/" + filename));
loop++;


}
catch (Exception)
{
AddImagetoPdf(filename,brandimage,brand);
}
}
else
{
ProcessThreadCollection currentThreads = Process.GetCurrentProcess().Threads;
foreach (ProcessThread thread in currentThreads)
{
if (loop == 0)
{
thread.Dispose();
AddImagetoPdf(filename,brandimage,brand);
}
else
{
break;
}
}
}
}

1