i have a code which creates pdf using image (byte array[]) and from existing pdf written in gd picture 6
and i want to convert this code into gd picture 8
the following code is written in gdpicture 6:
Code: Select all
try
{
int ExportPDFID = ObjGdPictureImaging.PdfNewPdf(PdfFilePath);
DataSet DsDocumentPages = new DataSet();
using (ScanManagementService.ScanManagementClient ObjScanManagementClient = new ScanManagementService.ScanManagementClient())
{
DsDocumentPages = ObjScanManagementClient.ScanManagement_LoadDocumentPages(UserSecurity.GetConnString, UserSecurity.selectedfilecabinetname, DocumentId);
ObjScanManagementClient.Close();
}
if ((DsDocumentPages.Tables.Count > 0) && (DsDocumentPages.Tables[0].Rows.Count > 0))
{
for (int iCount = 0; iCount < DsDocumentPages.Tables[0].Rows.Count; iCount++)
{
string FilePath = DsDocumentPages.Tables[0].Rows[iCount]["FilePath"].ToString() + DsDocumentPages.Tables[0].Rows[iCount]["FileName"].ToString();
using (FileTransferService.FileTransferClient FT = new FileTransferService.FileTransferClient())
{
byte[] ImageData = FT.FileDownload(UserSecurity.selectedbankname, UserSecurity.selectedfilecabinetname, DsDocumentPages.Tables[0].Rows[iCount]["FileName"].ToString());
FT.Close();
if (DsDocumentPages.Tables[0].Rows[iCount]["FileName"].ToString().ToLower().Contains(".pdf"))
{
if (ObjGdViewer.DisplayFromByteArray(ref ImageData) == GdPictureStatus.OK)
{
int ImageID = ObjGdViewer.PdfRenderPageToGdPictureImage(300, 1);
ObjGdPictureImaging.PdfAddImageFromGdPictureImage(ExportPDFID, ImageID);
ObjGdPictureImaging.ReleaseGdPictureImage(ImageID);
}
}
else
{
int ImageID = ObjGdPictureImaging.CreateGdPictureImageFromByteArray(ref ImageData);
ObjGdPictureImaging.PdfAddImageFromGdPictureImage(ExportPDFID, ImageID);
ObjGdPictureImaging.ReleaseGdPictureImage(ImageID);
}
}
}
for (int iCount = 1; iCount <= DsDocumentPages.Tables[0].Rows.Count; iCount++)
{
ObjGdPictureImaging.PdfNewPage(ExportPDFID, ObjGdPictureImaging.PdfGetImageWidth(ExportPDFID, iCount), ObjGdPictureImaging.PdfGetImageHeight(ExportPDFID, iCount));
ObjGdPictureImaging.PdfDrawImage(ExportPDFID, iCount, 0, 0, ObjGdPictureImaging.PdfGetImageWidth(ExportPDFID, iCount), ObjGdPictureImaging.PdfGetImageHeight(ExportPDFID, iCount));
}
ObjGdPictureImaging.PdfEndPdf(ExportPDFID);
}
//Insert Activity Log
//gFunctions.SaveActivityLog("Scanned Document has been exported in multiPage as pdf successfully");
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
i'm able to convert "PdfRenderPageToGdPictureImage()","PdfRenderPageToGdPictureImage()" methos with help of gdpicturepdf class of version 8
but i facing problem in 'PdfNewPage()'and 'PdfDrawImage()' method
i found two methods for above to methods those are : InsertPage() and DrawImage()
but pdf is not created.
here is the code which i have converted in gd picture 8:
Code: Select all
try
{
//int ExportPDFID = ObjGdPictureImaging.PdfNewPdf(PdfFilePath);
int ExportPDFID = ObjGdPictureImaging.PdfOCRStart(PdfFilePath,true,"","","","","");
GdPicturePDF gdPDF = new GdPicturePDF();
gdPDF.SetLicenseNumber(ConfigurationSettings.AppSettings["LicenceKey"].ToString());
DataSet DsDocumentPages = new DataSet();
using (ScanManagementService.ScanManagementClient ObjScanManagementClient = new ScanManagementService.ScanManagementClient())
{
DsDocumentPages = ObjScanManagementClient.ScanManagement_LoadDocumentPages(UserSecurity.GetConnString, UserSecurity.selectedfilecabinetname, DocumentId);
ObjScanManagementClient.Close();
}
if ((DsDocumentPages.Tables.Count > 0) && (DsDocumentPages.Tables[0].Rows.Count > 0))
{
for (int iCount = 0; iCount < DsDocumentPages.Tables[0].Rows.Count; iCount++)
{
string FilePath = DsDocumentPages.Tables[0].Rows[iCount]["FilePath"].ToString() + DsDocumentPages.Tables[0].Rows[iCount]["FileName"].ToString();
using (FileTransferService.FileTransferClient FT = new FileTransferService.FileTransferClient())
{
byte[] ImageData = FT.FileDownload(UserSecurity.selectedbankname, UserSecurity.selectedfilecabinetname, DsDocumentPages.Tables[0].Rows[iCount]["FileName"].ToString());
FT.Close();
if (DsDocumentPages.Tables[0].Rows[iCount]["FileName"].ToString().ToLower().Contains(".pdf"))
{
if (ObjGdViewer.DisplayFromByteArray(ref ImageData) == GdPictureStatus.OK)
{
//gdPDF.SelectPage(iCount);
int ImageID= gdPDF.RenderPageToGdPictureImage(300, true);
ObjGdPictureImaging.PdfAddGdPictureImageToPdfOCR(ExportPDFID, ImageID, "eng", "", "");
//int ImageID = ObjGdViewer.PdfRenderPageToGdPictureImage(300, 1);
//ObjGdPictureImaging.PdfAddImageFromGdPictureImage(ExportPDFID, ImageID);
ObjGdPictureImaging.ReleaseGdPictureImage(iCount);
}
}
else
{
gdPDF.SelectPage(iCount);
int ImageID = ObjGdPictureImaging.CreateGdPictureImageFromByteArray(ref ImageData);
gdPDF.AddImageFromGdPictureImage(ImageID,true,true );
//GdPImaging.PdfAddImageFromGdPictureImage(ExportPDFID, ImageID);
ObjGdPictureImaging.ReleaseGdPictureImage(ImageID);
}
}
}
for (int iCount = 1; iCount <= DsDocumentPages.Tables[0].Rows.Count; iCount++)
{
gdPDF.SelectPage(iCount);
gdPDF.InsertPage(gdPDF.GetPageWidth(), gdPDF.GetPageHeight(), iCount);
gdPDF.DrawImage("", 0, 0, gdPDF.GetPageWidth(), gdPDF.GetPageHeight());
//ObjGdPictureImaging.PdfNewPage(ExportPDFID, ObjGdPictureImaging.PdfGetImageWidth(ExportPDFID, iCount), ObjGdPictureImaging.PdfGetImageHeight(ExportPDFID, iCount));
//ObjGdPictureImaging.PdfDrawImage(ExportPDFID, iCount, 0, 0, ObjGdPictureImaging.PdfGetImageWidth(ExportPDFID, iCount), ObjGdPictureImaging.PdfGetImageHeight(ExportPDFID, iCount));
}
ObjGdPictureImaging.PdfOCRStop(ExportPDFID);
}
//Insert Activity Log
//gFunctions.SaveActivityLog("Scanned Document has been exported in multiPage as pdf successfully");
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
}
plz reply.............
with regards
rackteam