0
웹 양식에서 pdf 텍스트를 추출하고 싶습니다. 다음은 완벽하게 작동하는 코드이지만 슬라이드의 프레임 사진이나 데이터가없는 무의미한 사진도 필요합니다. 검은 색 또는 흰색의 빈 사진을 의미합니다. 사진의 배경을 차지한다고 생각합니다.asp.net의 PDF에서 이미지 추출
PdfReader reader = new PdfReader(@"E:\Uni_Stuff\waleed 8th semester\DWDM\dwdm011.pdf");
PRStream pst;
PdfImageObject pio;
PdfObject po;
int n = reader.XrefSize; //number of objects in pdf document
try
{
for (int i = 0; i < n; i++)
{
po = reader.GetPdfObject(i); //get the object at the index i in the objects collection
if (po == null || !po.IsStream()) //object not found so continue
continue;
pst = (PRStream)po; //cast object to stream
PdfObject type = pst.Get(PdfName.SUBTYPE); //get the object type
//check if the object is the image type object
if (type != null && type.ToString().Equals(PdfName.IMAGE.ToString()))
{
pio = new PdfImageObject(pst); //get the image
byte[] imgdata = pio.GetImageAsBytes();
Image img = new Image();
img.ImageUrl = "data:image/jpeg;base64," + Convert.ToBase64String(imgdata);
PlaceHolder1.Controls.Add(img);
}
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
이제는 관련없는 사진 만 제외하고 싶습니다. 나는 데이터가있는 사진 만 원한다.