i have tried to add images like JPG,BMP or PNG into new pdf file.
below are some steps
1. create new pdf file
2. select one image file like jpg or bmp or png
3. add that image into new pdf file
4. save new pdf file to specific path
when i tried to add image into new pdf using below code. result is blank pdf file without any image.
Code: Select all
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
oGdPictureImaging.SetLicenseNumberUpgrade("XXXX", "XXXX");
GdPicturePDF objPDF = new GdPicturePDF();
objPDF.SetLicenseNumber("XXXX");
/// create new empty pdf document
objPDF.NewPDF();
objPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
int imageID = oGdPictureImaging.CreateGdPictureImageFromFile("C://temp/image1.png");
oGdPictureImaging.ConvertTo1BppFast(imageID);
if (oGdPictureImaging.IsBitonal(imageID))
{
/// set compression for Bitonal image
objPDF.SetCompressionForBitonalImage(PdfCompression.PdfCompressionCCITT4);
}
else
{
/// set compression for Color image
objPDF.SetCompressionForColorImage(PdfCompression.PdfCompressionJPEG);
}
/// add image to newly created pdf file
objPDF.AddImageFromGdPictureImage(imageID, false, true);
oGdPictureImaging.ReleaseGdPictureImage(imageID);
if (!objPDF.SaveToFile("C://temp/NewPdfFile.pdf", PdfEncryption.PdfEncryptionNone, "", "", true, false, false, false, false, false, false, true).Equals(GdPictureStatus.OK))
{
}
Thanks in advance