如何在pdf中显示整个图像 [英] how to display whole image in pdf

查看:116
本文介绍了如何在pdf中显示整个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中我使用pdf转换itextsharp.dll。所以我的图像转换成pdf但不是完整图像只有部分显示。所以我能做什么。所以请帮助我..

in my project i using pdf convert itextsharp.dll. so my image is convert into pdf but not full image only some part display .so what can i do. so please help me..

推荐答案

检查转换代码的高度和宽度属性。
Check the height and width attributes of the conversion code.


这里是我的代码< br $>






string fn1 = DateTime.Now.Day.ToString()+ DateTime.Now.Hour。 ToString()+ DateTime.Now.Minute.ToString()+ DateTime.Now.Second.ToString();

string strPdfFile = ConfigurationManager.ConnectionStrings [scanfilepath]。ConnectionString.ToString()+ fn1 + txtpdfname.Text +。pdf;



//textBox2.Text = strPdfFile;



iTextSharp.text.Document document = new iTextSharp.text.Document();

using(var stream = new FileStream(strPdfFile,FileMode.Create,FileAccess.Write,FileShare.None))

{

iTextSharp.text.pdf.PdfWriter.GetInstance(document,stream);

document.Open();

int i = 0;

foreach(扫描文件中的字符串strFileName)

{

if((bool)datagridscanedfiles.Rows [i] .Cells [0] .FormattedValue)

{

using(var imageStream = new FileStream(ConfigurationManager.ConnectionStrings [ scanfilepath] .ConnectionString.ToString()+ firstint [i] + strFileName,FileMode.Open,FileAccess.Read,FileShare.ReadWrite))

{

var image = iTextSharp.text.Image.GetInstance(imageStream);

document.Add(image);

document.NewPage();

} < br $> b $ b}



i ++;

}

document.Close();

FileInfo fsize = new FileInfo(strPdfFile);

pdffilesize = fsize.Length;

}



sendpdffile(strPdfFile,fn1,txtpdfname.Text,pdffilesize);

}

其他

MessageBox.Show(请输入姓名);

}

catch(例外ex)

{

MessageBox.Show(ex.Message,Error,MessageBoxButtons.OK,MessageBoxIcon.Error);

}

}
here is my code



string fn1 = DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
string strPdfFile = ConfigurationManager.ConnectionStrings["scanfilepath"].ConnectionString.ToString() + fn1 + txtpdfname.Text + ".pdf";

//textBox2.Text = strPdfFile;

iTextSharp.text.Document document = new iTextSharp.text.Document();
using (var stream = new FileStream(strPdfFile, FileMode.Create, FileAccess.Write, FileShare.None))
{
iTextSharp.text.pdf.PdfWriter.GetInstance(document, stream);
document.Open();
int i = 0;
foreach (string strFileName in scanfile)
{
if ((bool)datagridscanedfiles.Rows[i].Cells[0].FormattedValue)
{
using (var imageStream = new FileStream(ConfigurationManager.ConnectionStrings["scanfilepath"].ConnectionString.ToString() + firstint[i] + strFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var image = iTextSharp.text.Image.GetInstance(imageStream);
document.Add(image);
document.NewPage();
}
}

i++;
}
document.Close();
FileInfo fsize = new FileInfo(strPdfFile);
pdffilesize = fsize.Length;
}

sendpdffile(strPdfFile, fn1, txtpdfname.Text, pdffilesize);
}
else
MessageBox.Show("Please Enter Name");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}


这篇关于如何在pdf中显示整个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆