PDF의 특정 위치에 텍스트를 어떻게 배치합니까? 나는 약간의 검색을했지만 너무 좋은 것을 찾지 못했습니다. 나는 document.Add(new Paragraph("Date:" + DateTime.Now));
을 가지고 있으며 나는 pdf 파일의 특정 영역에 그 파일을 배치하려고합니다.iTextSharp를 사용하여 특정 위치에 단락을 배치하는 방법
내 코드 :
private void savePDF_Click(object sender, EventArgs e)
{
FileStream fileStream = new FileStream(nameTxtB.Text + "Repair.pdf", FileMode.Create, FileAccess.Write, FileShare.None);
Document document = new Document();
document.Open();
iTextSharp.text.Rectangle rectangle = new iTextSharp.text.Rectangle(PageSize.LETTER);
PdfWriter pdfWriter = PdfWriter.GetInstance(document, fileStream);
iTextSharp.text.Image r3tsLogo = iTextSharp.text.Image.GetInstance("rt3slogo.PNG"); //creates r3ts logo
iTextSharp.text.Image r3Info = iTextSharp.text.Image.GetInstance("R3 Information.PNG"); //creates r3 information text below r3ts logo
r3tsLogo.SetAbsolutePosition(document.PageSize.Width - 375 - 0f, document.PageSize.Height - 130 - 0f);
r3Info.SetAbsolutePosition(document.PageSize.Width - 365 - 0f, document.PageSize.Height - 170 - 0f); //higher the number in height the lower the place of text on paper
//less number will result in text more to right in width
//increase size of picture
r3tsLogo.ScalePercent(120);
r3Info.ScalePercent(65);
//---------------adds all images to pdf file ---------------------------------
document.Add(r3tsLogo);
document.Add(r3Info);
document.Add(new Paragraph("Date:" + DateTime.Now));
document.Close();
}
나는 문제가 이미지를 배치 아니라고 생각하지만, 위치' "날짜"... 검색하는 사람들을 위해 존재한다. 물론 이것은 이전에 여러 번 답변 된 질문이기도합니다. –