How to Inlarge Images size in PDF without effecting the code
Sanjiv
5/22/2015 10:47 AM
|
---|
How to Inlarge images size in PDF.?
I am using this code. Without effecting the 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;
}
}
}
}
|
rammi
5/26/2015 10:49 AM
|
---|
Sorry, this is not related to CadLib in any way. Are you on the wrong server?
- Rammi
|
Sanjiv
5/27/2015 6:31 AM
|
---|
Sorry for wrong code..
I am new in CadLib.. My Question is when i am saving some shape in pdf its look small in shape. IS there any way to inlarge the pdf content..?
|
rammi
5/27/2015 11:24 AM
|
---|
Sorry, the code you included does not use any CadLib features at all.
When exporting a DxfModel or a layout using CadLib's PdfExporter class of course you can control the size of the output. When creating a DxfModel and inserting images you can control their size in the model. When you have loaded a model you can scan for DxfImage entities and enlarge their sizes prior to PDF export. The documentation and examples should help you here.
Furthermore I provided some PDF export tool methods here in the forum:
- Rammi
|
Sanjiv
5/27/2015 1:15 PM
|
---|
Thanks alot.. :)
|