private Bitmap renPdfToBitmap(CACodecTools caTool, string pageFile, byte[] key, int pg, int dpi, float scal, int decodedPageIndex, Border border, bool isSinglePage)
        {
            System.Drawing.Color white = System.Drawing.Color.White;
            Bitmap aBitmap             = null;

            try
            {
                if (decodedPDFPages[decodedPageIndex] == null)
                {
                    decodedPDFPages[decodedPageIndex] = caTool.fileAESDecode(pageFile, key);
                }
            }
            catch (Exception ex)
            {
                decodedPDFPages[decodedPageIndex] = null;
                LogTool.Debug(ex);
            }
            try
            {
                PDFDoc pDFDoc = new PDFDoc();
                pDFDoc.Init("PVD20-M4IRG-QYZK9-MNJ2U-DFTK1-MAJ4L", "PDFX3$Henry$300604_Allnuts#");
                pDFDoc.OpenFromMemory(decodedPDFPages[decodedPageIndex], (uint)decodedPDFPages[decodedPageIndex].Length, 0);
                PXCV_Lib36.PXV_CommonRenderParameters aCommonRenderParams = prepareCommonRenderParameter(pDFDoc, dpi, pg, scal, 0, 0, border, isSinglePage);
                pDFDoc.DrawPageToDIBSection(IntPtr.Zero, pg, white, aCommonRenderParams, out aBitmap);
                pDFDoc.ReleasePageCachedData(pg, 1);
                pDFDoc.Delete();
                return(aBitmap);
            }
            catch (Exception ex2)
            {
                LogTool.Debug(ex2);
                return(aBitmap);
            }
        }
示例#2
0
        private Bitmap a(CACodecTools A_0, string A_1, byte[] A_2, int A_3, int A_4, float A_5, int A_6, Border A_7, bool A_8)
        {
            System.Drawing.Color white = System.Drawing.Color.White;
            Bitmap aBitmap             = null;

            try
            {
                if (decodedPDFPages[A_6] == null)
                {
                    decodedPDFPages[A_6] = A_0.fileAESDecode(A_1, A_2);
                }
            }
            catch (Exception ex)
            {
                decodedPDFPages[A_6] = null;
                throw ex;
            }
            try
            {
                PDFDoc pDFDoc = new PDFDoc();
                pDFDoc.Init("PVD20-M4IRG-QYZK9-MNJ2U-DFTK1-MAJ4L", "PDFX3$Henry$300604_Allnuts#");
                pDFDoc.OpenFromMemory(decodedPDFPages[A_6], (uint)decodedPDFPages[A_6].Length, 0);
                PXCV_Lib36.PXV_CommonRenderParameters aCommonRenderParams = a(pDFDoc, A_4, A_3, A_5, 0, 0, A_7, A_8);
                pDFDoc.DrawPageToDIBSection(IntPtr.Zero, A_3, white, aCommonRenderParams, out aBitmap);
                pDFDoc.ReleasePageCachedData(A_3, 1);
                pDFDoc.Delete();
                return(aBitmap);
            }
            catch (Exception ex2)
            {
                throw ex2;
            }
        }
示例#3
0
        //將 PDF ren 成 Bitmap (改用Thread的方式ren)
        private Bitmap renPdfToBitmap(string pageFile, byte[] key, int pg, int dpi, float scal, int decodedPageIndex, Border border, bool isSinglePage)
        {
            //Mutex mLoad = new Mutex(requestInitialOwnership, "LoadMutex", out loadMutexWasCreated);
            //if (!(requestInitialOwnership & loadMutexWasCreated))
            //{
            //    mLoad.WaitOne();
            //}

            System.Drawing.Color bgColor = System.Drawing.Color.White; //背景白色
            Bitmap bmp = null;

            if (decodedPDFPages[decodedPageIndex] == null) //如果此頁已經解密過,就直接拿來ren,不用再重新解密一次
            {
                try
                {
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        FileStream sourceStream = new FileStream(pageFile, FileMode.Open);
                        sourceStream.CopyTo(memoryStream);
                        decodedPDFPages[decodedPageIndex] = memoryStream.ToArray();
                    }
                }
                catch
                {
                    return(bmp);
                }
            }

            try
            {   //TODO: 改成把PDF實體拉出來變global的
                PDFDoc pdfDoc = new PDFDoc();
                pdfDoc.Init("PVD20-M4IRG-QYZK9-MNJ2U-DFTK1-MAJ4L", "PDFX3$Henry$300604_Allnuts#");
                pdfDoc.OpenFromMemory(decodedPDFPages[decodedPageIndex], (uint)decodedPDFPages[decodedPageIndex].Length, 0);
                PXCV_Lib36.PXV_CommonRenderParameters commonRenderParam = prepareCommonRenderParameter(pdfDoc, dpi, pg, scal, 0, 0, border, isSinglePage);
                pdfDoc.DrawPageToDIBSection(IntPtr.Zero, pg, bgColor, commonRenderParam, out bmp);
                pdfDoc.ReleasePageCachedData(pg, (int)PXCV_Lib36.PXCV_ReleaseCachedDataFlags.pxvrcd_ReleaseDocumentImages);
                pdfDoc.Delete();
            }
            catch (Exception e)
            {
                //throw e;
                LogTool.Debug(e);
            }
            //bmp.Save("c:\\Temp\\test.bmp");
            return(bmp);
        }
示例#4
0
        //將 PDF ren 成 Bitmap (改用Thread的方式ren)
        private Bitmap renPdfToBitmap(CACodecTools caTool, string pageFile, byte[] key, int pg, int dpi, float scal, int decodedPageIndex, Border border, bool isSinglePage)
        {
            System.Drawing.Color bgColor = System.Drawing.Color.White; //背景白色
            Bitmap bmp = null;

            try
            {
                if (this.decodedPDFPages[decodedPageIndex] == null) //如果此頁已經解密過,就直接拿來ren,不用再重新解密一次
                {
                    this.decodedPDFPages[decodedPageIndex] = caTool.fileAESDecode(pageFile, key);
                }
            }
            catch (Exception e)
            {
                //TODO: 萬一檔案解析失敗, 判定為壞檔, 重新下載
                this.decodedPDFPages[decodedPageIndex] = null;
                LogTool.Debug(e);
                //throw e;
            }

            try
            {   //TODO: 改成把PDF實體拉出來變global的
                PDFDoc pdfDoc = new PDFDoc();
                pdfDoc.Init("PVD20-M4IRG-QYZK9-MNJ2U-DFTK1-MAJ4L", "PDFX3$Henry$300604_Allnuts#");
                pdfDoc.OpenFromMemory(this.decodedPDFPages[decodedPageIndex], (uint)decodedPDFPages[decodedPageIndex].Length, 0);
                PXCV_Lib36.PXV_CommonRenderParameters commonRenderParam = prepareCommonRenderParameter(pdfDoc, dpi, pg, scal, 0, 0, border, isSinglePage);
                pdfDoc.DrawPageToDIBSection(IntPtr.Zero, pg, bgColor, commonRenderParam, out bmp);
                pdfDoc.ReleasePageCachedData(pg, (int)PXCV_Lib36.PXCV_ReleaseCachedDataFlags.pxvrcd_ReleaseDocumentImages);
                pdfDoc.Delete();
            }
            catch (Exception e)
            {
                LogTool.Debug(e);
                //throw e;
            }
            //bmp.Save("c:\\Temp\\test.bmp");
            return(bmp);
        }
        private Bitmap renPdfToBitmap(string pageFile, byte[] key, int pg, int dpi, float scal, int decodedPageIndex, Border border, bool isSinglePage)
        {
            System.Drawing.Color white = System.Drawing.Color.White;
            Bitmap aBitmap             = null;

            if (decodedPDFPages[decodedPageIndex] == null)
            {
                try
                {
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        FileStream fileStream = new FileStream(pageFile, FileMode.Open);
                        fileStream.CopyTo(memoryStream);
                        decodedPDFPages[decodedPageIndex] = memoryStream.ToArray();
                    }
                }
                catch
                {
                    return(aBitmap);
                }
            }
            try
            {
                PDFDoc pDFDoc = new PDFDoc();
                pDFDoc.Init("PVD20-M4IRG-QYZK9-MNJ2U-DFTK1-MAJ4L", "PDFX3$Henry$300604_Allnuts#");
                pDFDoc.OpenFromMemory(decodedPDFPages[decodedPageIndex], (uint)decodedPDFPages[decodedPageIndex].Length, 0);
                PXCV_Lib36.PXV_CommonRenderParameters aCommonRenderParams = prepareCommonRenderParameter(pDFDoc, dpi, pg, scal, 0, 0, border, isSinglePage);
                pDFDoc.DrawPageToDIBSection(IntPtr.Zero, pg, white, aCommonRenderParams, out aBitmap);
                pDFDoc.ReleasePageCachedData(pg, 1);
                pDFDoc.Delete();
                return(aBitmap);
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
                return(aBitmap);
            }
        }