Click here to Skip to main content
15,899,679 members
Home / Discussions / C#
   

C#

 
GeneralRe: Open Form From another Project with its Name Pin
Eddy Vluggen2-Aug-12 23:34
professionalEddy Vluggen2-Aug-12 23:34 
GeneralRe: Open Form From another Project with its Name Pin
a-erfani3-Aug-12 0:09
a-erfani3-Aug-12 0:09 
AnswerRe: Open Form From another Project with its Name Pin
Eddy Vluggen3-Aug-12 0:18
professionalEddy Vluggen3-Aug-12 0:18 
GeneralRe: Open Form From another Project with its Name Pin
Ed Hill _5_3-Aug-12 0:34
Ed Hill _5_3-Aug-12 0:34 
AnswerRe: Open Form From another Project with its Name Pin
Ed Hill _5_3-Aug-12 0:28
Ed Hill _5_3-Aug-12 0:28 
GeneralRe: Open Form From another Project with its Name Pin
Eddy Vluggen3-Aug-12 0:58
professionalEddy Vluggen3-Aug-12 0:58 
GeneralRe: Open Form From another Project with its Name Pin
a-erfani3-Aug-12 2:45
a-erfani3-Aug-12 2:45 
GeneralExtracting images from pdf without loosing image quality Pin
chanakamax2-Aug-12 23:00
chanakamax2-Aug-12 23:00 
Dear fiends my question is much long but please help me solve my problem.
i m completely stuck hear. Sigh | :sigh:
I m tried to extract images from pdf using itexsharp but when i extract them the images looks like convert to negative form, I think my pdf containing high quality images. I used following code sample for extract images from pdf.


private static List<system.drawing.image> ExtractImages(String PDFSourcePath)
{
List<system.drawing.image> ImgList = new List<system.drawing.image>();
try
{
RAFObj = new iTextSharp.text.pdf.RandomAccessFileOrArray(PDFSourcePath);
PDFReaderObj = new iTextSharp.text.pdf.PdfReader(RAFObj, null);
for (int i = 0; i <= PDFReaderObj.XrefSize - 1; i++)
{
PDFObj = PDFReaderObj.GetPdfObject(i);

if ((PDFObj != null) && PDFObj.IsStream())
{
PDFStremObj = (iTextSharp.text.pdf.PdfStream)PDFObj;
iTextSharp.text.pdf.PdfObject subtype = PDFStremObj.Get(iTextSharp.text.pdf.PdfName.SUBTYPE);

if ((subtype != null) && subtype.ToString() == iTextSharp.text.pdf.PdfName.IMAGE.ToString())
{
byte[] bytes = iTextSharp.text.pdf.PdfReader.GetStreamBytesRaw((iTextSharp.text.pdf.PRStream)PDFStremObj);

if ((bytes != null))
{
try
{
System.IO.MemoryStream MS = new System.IO.MemoryStream(bytes);
MS.Position = 0;
System.Drawing.Image ImgPDF = System.Drawing.Image.FromStream(MS, true, true);
//System.Drawing.Bitmap ImgPDF = (Bitmap)System.Drawing.Image.FromStream(MS, true, false);

ImgList.Add(ImgPDF);
MS.Flush();

}
catch (Exception)
{
}
}
}
}
}
PDFReaderObj.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return ImgList;
}





public static void WriteImageFile(string sourcePDFpath, string targetpath)
{
try
{

// Get a List of Image
List<system.drawing.image> ListImage = ExtractImages(sourcePDFpath);

for (int i = 0; i < ListImage.Count; i++)
{
try
{

System.Drawing.Imaging.EncoderParameters parms = new System.Drawing.Imaging.EncoderParameters(1);
parms.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Compression, 0);
System.Drawing.Imaging.ImageCodecInfo jpegEncoder = ImageCodecInfo.GetImageEncoders().Single(p => p.CodecName.Contains("JPEG"));
ListImage[i].Save(targetpath + "\\Image" + (i + 1).ToString().PadLeft(3, '0') + ".Jpeg", jpegEncoder, parms);

}
catch (Exception ex)
{
throw ex;
}
}

}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}

But this solution is not worked for my purpose. So i found a another program call 'pdfimages' is support to extract images from pdf, this exe extract images from pdf in .ppm format so i passed the command line argument to this exe and make exe to work and after the exe executed i convert ppm files to jpeg from my application.


This work for my task nicely. But i have another problem now. When i converted the image the quality of the image is reduced.



When extracting image from Pdf writer it shows.
Bit Depth : 32
Horizontal Resolution : 296dpi
Vertical Resolution : 296dpi


But my images it shows
Bit Depth : 24
Horizontal Resolution : 96dpi
Vertical Resolution : 96dpi


I need to extract images from pdf with the same quality, can anyone tell me a method for do my task...?
GeneralRe: Extracting images from pdf without loosing image quality Pin
BillWoodruff4-Aug-12 5:17
professionalBillWoodruff4-Aug-12 5:17 
GeneralRe: Extracting images from pdf without loosing image quality Pin
chanakamax7-Aug-12 18:28
chanakamax7-Aug-12 18:28 
QuestionRead GUID Pin
deepratna2-Aug-12 21:26
deepratna2-Aug-12 21:26 
AnswerRe: Read GUID Pin
Eddy Vluggen2-Aug-12 23:24
professionalEddy Vluggen2-Aug-12 23:24 
AnswerRe: Read GUID Pin
jschell4-Aug-12 7:22
jschell4-Aug-12 7:22 
QuestionPaypal for desktop application Pin
sharmaravi1232-Aug-12 19:55
sharmaravi1232-Aug-12 19:55 
AnswerRe: Paypal for desktop application Pin
Mycroft Holmes2-Aug-12 20:17
professionalMycroft Holmes2-Aug-12 20:17 
AnswerRe: Paypal for desktop application Pin
jschell4-Aug-12 7:25
jschell4-Aug-12 7:25 
GeneralRe: Paypal for desktop application Pin
sharmaravi1239-Aug-12 0:40
sharmaravi1239-Aug-12 0:40 
GeneralRe: Paypal for desktop application Pin
jschell10-Aug-12 12:15
jschell10-Aug-12 12:15 
QuestionHow to write and move text on image Pin
Member 37694462-Aug-12 16:46
Member 37694462-Aug-12 16:46 
GeneralRe: How to write and move text on image Pin
Eddy Vluggen2-Aug-12 20:49
professionalEddy Vluggen2-Aug-12 20:49 
AnswerRe: How to write and move text on image Pin
BillWoodruff4-Aug-12 5:11
professionalBillWoodruff4-Aug-12 5:11 
Questionsql table change notifications Pin
HimalR82-Aug-12 4:28
HimalR82-Aug-12 4:28 
AnswerRe: sql table change notifications Pin
BobJanova2-Aug-12 4:40
BobJanova2-Aug-12 4:40 
QuestionFinding value in a list Pin
Nathaniel Sumaya1-Aug-12 23:33
Nathaniel Sumaya1-Aug-12 23:33 
AnswerRe: Finding value in a list PinPopular
Ed Hill _5_1-Aug-12 23:44
Ed Hill _5_1-Aug-12 23:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.