Memory Exception on PXC_SetCompression.

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics.

Moderators: Tracker Support, TrackerSupp-Daniel, Chris - Tracker Supp, Vasyl-Tracker Dev Team, Sean - Tracker, Andrew - Tracker Support, Tracker - Clarion Support, John - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software, Support Staff, moderators

Post Reply
adamf
User
Posts: 1
Joined: Wed Dec 31, 2014 5:21 pm

Memory Exception on PXC_SetCompression.

Post by adamf » Wed Dec 31, 2014 5:36 pm

System Info:
Windows Server 2012
VMWare Workstation 10
Fujitsu fi-6140 Scanner
Visual Studio Ultimate 2013

Software running on Sharepoint 2013 app.

pxclib30.dll version 3.6.0.118

See code below. When calling PXC_SetCompression the following exception is thrown:
An exception of type 'System.AccessViolationException' occurred in [ourname].dll but was not handled in user code. Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Code: Select all

        
    internal class PdfConverter32
    {
        #region Tracker v3 Dll Imports

        [DllImport("Tracker32\\pxclib30.dll")]
        public static extern int PXC_NewDocument(out int pdf, [MarshalAs(UnmanagedType.LPStr)]string key,
            [MarshalAs(UnmanagedType.LPStr)]string devCode);

        [DllImport("Tracker32\\pxclib30.dll")]
        public static extern int PXC_SetCompression(int pdf, bool bText, bool bAscii, PXC_CompressionType cColor,
            int jpegQual, PXC_CompressionType cIndexed, PXC_CompressionType cMono);
    }

------------------------------------------------------------------------

    public static void ConvertToPdf(string[] inputFiles, string outputFile)
        {
            int result = 0;
            int pdf = 0;
            int[] imgs = null;
            int imgCount = 0;
            double w = 0;
            double h = 0;
            int page = 0;
            int xRes, yRes;

            try
            {
                if (inputFiles == null || inputFiles.Length < 1) throw new Exception("No input tiff images specified for PDF conversion!");
                if (File.Exists(outputFile)) File.Delete(outputFile);

                //this key MUST be hard coded in here for security
                result = PXC_NewDocument(out pdf, TrackerConstants.KEY, TrackerConstants.DEVCODE);
                ValidateResult(result);
                PXC_SetCompression(pdf, false, false, PXC_CompressionType.ComprType_I_Auto, 75, PXC_CompressionType.ComprType_I_Auto, PXC_CompressionType.ComprType_M_Auto);
                
                // *** EXCEPTION OCCURS HERE ***

Ivan - Tracker Software
Site Admin
Posts: 3587
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Memory Exception on PXC_SetCompression.

Post by Ivan - Tracker Software » Fri Jan 02, 2015 7:17 pm

I suspect that function definition for PXC_SetCompression is not correct. Can you try to use this one?

Code: Select all

        public static extern int PXC_SetCompression(int pdf, int bText, int bAscii, PXC_CompressionType cColor,
            int jpegQual, PXC_CompressionType cIndexed, PXC_CompressionType cMono);
HTH

P.S. If your application is 64-bits, than you have to use int64 for the first parameter, and int32 for the rest.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.

Post Reply