iTextSharp를 사용하여 새로 만든 PDF 문서에 이미지를 삽입하려고합니다. 올바른 방법으로 처리 할 것인지 확실하지 않습니다. 이미지 객체를 만든 다음 페이지에 추가하려고 시도했지만 삽입 한 텍스트가 PDF 문서에 나타나더라도 이미지가 나타나지 않습니다.iTextSharp를 사용하여 PDF에 이미지 삽입
누구에게 아이디어가 있습니까?
public bool createPDF(string batchNumber, string userName, string path)
{
// step 1: creation of a document-object
Document myDocument = new Document(PageSize.A4.Rotate());
try
{
// step 2:
// Now create a writer that listens to this doucment and writes the document to desired Stream.
PdfWriter.GetInstance(myDocument, new FileStream(path, FileMode.Create));
// step 3: Open the document now using
myDocument.Open();
// step 4: Now add some contents to the document
// batch Header e.g. Batch Sheet
myDocument.Add(new Paragraph("Number: " + batchNumber));
myDocument.Add(new Paragraph("Created By: " + userName));
iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance("code39-barcode.png");
PdfPCell cell = new PdfPCell(logo);
myDocument.Add(cell);
}
catch (DocumentException de)
{
Console.Error.WriteLine(de.Message);
}
catch (IOException ioe)
{
Console.Error.WriteLine(ioe.Message);
}
// step 5: Remember to close the document
myDocument.Close();
return true;
}
안녕하세요. @maxisam에서 제공하는 리소스는 충분하지만 내 이해와 최고의 프로그래머라면 그림 이미지를 디스크 드라이브에서 읽을 수 있습니다. 그림이 byte []로 저장되어있는 데이터베이스 테이블에서 읽히는 경우? 리소스의 코드를 변경해야하는 경우 : https://www.mikesdotnetting.com/Article/87/iTextSharp-Working-with-images (소스 코드 샘플이 필요하면 알려주십시오) –