내가 잘 작동 iTextSharp.Its를 사용하여 PDF에서 어떤 이미지를 표시하려고하지만 내 문제는, 아래 이미지처럼 실제 크기로 확대에서 일부 이미지가 표시이미지 표시 크기 문제
내가 노력 코드 디스플레이는에,
iTextSharp.text.Font fontH1 = new iTextSharp.text.Font(Currier, 18, iTextSharp.text.Font.BOLD);
Document doc1 = new Document();
string path1 = Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments);
path1 = path1 + "\\DOC\\Mathematicsquestions.pdf";
iTextSharp.text.Rectangle pageSize1 = doc1.PageSize;
PdfWriter pdf = PdfWriter.GetInstance(doc1, new FileStream(path1, FileMode.Create));
doc1.Open();
pdf.Open();
PdfPTable table = new PdfPTable(2);
//actual width of table in points
table.TotalWidth = 500f;
//fix the absolute width of the table
table.LockedWidth = true;
//relative col widths in proportions - 1/3 and 2/3
float[] widths = new float[] { 0.15f, 2.5f };
table.SetWidths(widths);
table.HorizontalAlignment = 0;
//leave a gap before and after the table
table.SpacingBefore = 0f;
table.SpacingAfter = 0f;
PdfPCell cell = new PdfPCell(new Phrase("MATHEMATICS", fontH1));
cell.Colspan = 2;
cell.Border = 0;
cell.HorizontalAlignment = 1;
table.AddCell(cell);
PdfPCell cell1 = new PdfPCell(new Phrase(" "));
cell1.Colspan = 2;
cell1.Border = 0;
cell1.HorizontalAlignment = 1;
table.AddCell(cell1);
for (int i = 0; i < mach.Count; i++)
{
string temsub = mach[i].ToString();
var quepaper1 = from fm in en.Entrance_jee where fm.En_Chapter == temsub select fm;
foreach (Entrance_jee re in quepaper1)
{
if (newsno == 0)
{
newsno = 1;
}
else
{
newsno = newsno + 1;
}
if (re.En_Isimage == true)
{
imgepath = path + re.En_Questionpage1 + ".png";
imgepath2 = path + re.En_Answer + ".png";
filename = System.IO.Path.GetFileName(imgepath);
filename2 = System.IO.Path.GetFileName(imgepath2);
decfile = decfile1 + "\\R1\\CF\\" + filename;
decfile2 = decfile1 + "\\R1\\CF\\" + filename2;
string status = encobj.DecryptFile(imgepath, decfile);
status = encobj.DecryptFile(imgepath2, decfile2);
if (status == "decrypted")
{
byte[] file = File.ReadAllBytes(decfile);
File.Delete(decfile);
iTextSharp.text.Image img1 = iTextSharp.text.Image.GetInstance(file);
byte[] file2 = File.ReadAllBytes(decfile2);
File.Delete(decfile2);
iTextSharp.text.Image img2 = iTextSharp.text.Image.GetInstance(file2);
//iTextSharp.text.pdf.PdfPCell imgCell1 = new iTextSharp.text.pdf.PdfPCell();
//imgCell1.AddElement(new Chunk(img2, 0, 0));
table.AddCell(newsno.ToString());
table.AddCell(img1);
table.AddCell(" ");
table.AddCell(img2);
}
}
else
{
table.AddCell(newsno.ToString());
table.AddCell(re.En_Questionpage1.ToString());
table.AddCell(" ");
table.AddCell(re.En_Answer.ToString());
}
}
}
doc1.Add(table);
doc1.Close();
업데이트 : 여기 내 orginal 한 이미지이며,
누군가 내가 잘못된 부분을 말해?
원본 이미지를 공유 할 수 있습니까? – mkl
@mkl 지금 내 업데이트를 확인하십시오. – MMMMS
@ 카미의 대답은 이미 문제를 나타냅니다. 처음에는 질문이 확대되지 않은 것 같았지만 게시 된 이미지는 질문 이미지의 오른쪽에 흰색 영역이 상당히 많이 있음을 보여주었습니다. 따라서 이미지는 이미 모든 셀 너비를 사용합니다. – mkl