Incorrect CRC16 value for ACE file

Hi,
I am trying to implement a Java app that will read ACE files. These are files that are compressed using an app such as WinAce.
I have looked at the ACE file structure documentation that says that the first 2 bytes holds the CRC 16-bit for the file header. The header is usually 54-bytes long. The first 2 bytes is the CRC-16. The next two bytes holds the length of important ACE file info. The next single byte up until the end of the header is the section that is read and the CRC is calculated from it. So, for example, if the total header is 55 bytes, the CRC is calculated from bytes 4 to the end 54 (as first byte is 0).
0      2           4             5                    ...                                54
|CRC16 | Length    |     00      |  IMPORTANT ACE FILE INFO (BYTES 4 to 54 USED IN CRC16) |
-------------------------------------------------------------------------------------------However, the CRC calculated by WinAce is "de 06" in hexadecimal and when I calculated the checksum I got "a2 94". I dont know why my checksum is incorrect.
Here is my entire class that calculates the checksum:
package org.ace.internals;
public class CRCDemo
// calculating 16-bit CRC
     * generator polynomial
    private static final int poly = 0x1021; /* x16 + x12 + x5 + 1 generator polynomial */
    /* 0x8408 used in European X.25 */
     * scrambler lookup table for fast computation.
    private static int[] crcTable = new int[256];
    static
        // initialise scrambler table
        for ( int i = 0; i < 256; i++ )
            int fcs = 0;
            int d = i << 8;
            for ( int k = 0; k < 8; k++ )
                if ( ((fcs ^ d) & 0x8000) != 0 )
                    fcs = ( fcs << 1 ) ^ poly;
                else
                    fcs = ( fcs << 1 );
                d <<= 1;
                fcs &= 0xffff;
            crcTable[i] = fcs;
     * Calc CRC with cmp method.
     * @param b byte array to compute CRC on
     * @return 16-bit CRC, signed
    public static short cmpCRC( byte[] b )
        // loop, calculating CRC for each byte of the string
        int work = 0xffff;
        for ( int i = 0; i < b.length; i++ )
            work = ( crcTable[( (work >> 8)) & 0xff] ^ ( work << 8 ) ^ ( b[i] & 0xff ) ) & 0xffff;
        return(short)work;
    public static void main(String[] args)
        //The relevant ACE header section that is used to calculate the CRC16
        byte[] bytes = new byte[]
            (byte)0x00, (byte)0x00, (byte)0x90, (byte)0x2a, (byte)0x2a, (byte)0x41,
            (byte)0x43, (byte)0x45, (byte)0x2a, (byte)0x2a, (byte)0x14, (byte)0x14,
            (byte)0x02, (byte)0x00, (byte)0xac, (byte)0x5a, (byte)0xe1, (byte)0x32,
            (byte)0x2b, (byte)0x0d, (byte)0x3e, (byte)0x23, (byte)0x00, (byte)0x00,
            (byte)0x00, (byte)0x00, (byte)0x16, (byte)0x2a, (byte)0x55, (byte)0x4e,
            (byte)0x52, (byte)0x45, (byte)0x47, (byte)0x49, (byte)0x53, (byte)0x54,
            (byte)0x45, (byte)0x52, (byte)0x45, (byte)0x44, (byte)0x20, (byte)0x56,
            (byte)0x45, (byte)0x52, (byte)0x53, (byte)0x49, (byte)0x4f, (byte)0x4e,
            (byte)0x2a
        CRCDemo crcdemo = new CRCDemo();
        short crc16bit = crcdemo.cmpCRC(bytes);
        System.out.println(Integer.toHexString(crc16bit));
}Any hints and code is much appreciated. Thanks.
Rizwan

Hi,
not sure if WinACE uses the same CRC algorithm and CRC seeds as WinZip.
But here's a utility class I've been using a long while, which generates the exact CRC values as Winzip.
regards,
Owen
import java.io.FileNotFoundException;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
public class CRC32
    protected static long []CRCTable;
    /* Initial Polynomial values may be choosen at random, in a 32-bit CRC algorithm
     * anything from 0 to 4294967295     ( ( 2 ^ 32 ) - 1 ).
     * However EDB88320 is the exact value used by PKZIP and ARJ, so we generate
     * identical checksums to them.  A nice touch to make testing easier.
    protected final static long CRC32_POLYNOMIAL = 0xEDB88320L;
    protected final static long INITIAL_CRC32    = 0xFFFFFFFFL;
    static
        CRCTable = new long[256];
        int i, j;
        long crc;
        for (i = 0; i <= 255; i++)
            crc = i;
            for (j = 8; j > 0; j--)
              if ( ( crc & 1 ) != 0 )
                  crc = ( crc >> 1 ) ^ CRC32_POLYNOMIAL;
              else
                  crc >>= 1;
            CRCTable[ i ] = crc;
    public static long getInitialCRC ( )
        return ( INITIAL_CRC32 );
    public static long calcFileCRC32 ( String filename ) throws Exception
        FileInputStream inputStream = new FileInputStream ( filename );
        CRC32InputStream checksumInputStream = new CRC32InputStream ( inputStream );
        long crc32 = calcFileCRC32 ( checksumInputStream );  // inputStream );
        // long crc32 = calcFileCRC32 ( inputStream );
        long checksum = checksumInputStream.getChecksum();
        System.out.println ("CRC32InputStream : " + Long.toHexString ( checksum ) );
        if ( inputStream != null )
             inputStream.close();
        return ( crc32 );
    public static long calcFileCRC32 ( InputStream inStream ) throws Exception
        long lCrc = INITIAL_CRC32;
        int iCount = 0;
        byte []buffer = new byte [ 4096 ];
        BufferedInputStream myFastReader = new BufferedInputStream ( inStream );
        while ( ( iCount = myFastReader.read ( buffer ) ) > 0 )
            // lCrc = calculateBufferCRC (buffer, iCount, lCrc);
            lCrc = calculateBufferCRC (buffer, 0, iCount, lCrc);
       lCrc ^= INITIAL_CRC32;
       return ( lCrc );
    public static long calcCRC32 ( String aStr )
        long lCrc = 0;
        if ( aStr != null )
            byte [] strBytes = aStr.getBytes(); // Warning : encoding scheme dependant
            if ( strBytes != null )
                lCrc = calculateBufferCRC ( strBytes, strBytes.length, 0xFFFFFFFFL );
        return ( lCrc );
    public static long updateCRC ( byte b, long lCrc )
        long temp1 = ( lCrc >> 8 ) & 0x00FFFFFFl;
        long temp2 = CRCTable [ ( (int) lCrc ^ b ) & 0xFF ];
        return ( temp1 ^ temp2 );
    public static long calculateBufferCRC ( byte []pcBuffer, int iCount, long lCrc )
        if ( iCount <= 0 )
             return ( lCrc );
        int pcIndex = 0;
        long temp1, temp2;
        while (iCount-- != 0)
            temp1 = ( lCrc >> 8 ) & 0x00FFFFFFl;
            temp2 = CRCTable [ ( (int) lCrc ^ pcBuffer[pcIndex++] ) & 0xFF ];
            lCrc = temp1 ^ temp2;
      return ( lCrc );
    public static long calculateBufferCRC ( byte []pcBuffer, int offset, int iCount, long lCrc )
        if ( iCount <= 0 )
             return ( lCrc );
        int pcIndex = offset;
        long temp1, temp2;
        while (iCount-- != 0)
            temp1 = ( lCrc >> 8 ) & 0x00FFFFFFl;
            temp2 = CRCTable [ ( (int) lCrc ^ pcBuffer[pcIndex++] ) & 0xFF ];
            lCrc = temp1 ^ temp2;
      return ( lCrc );
    public static void main ( String args[] )
        long crc;
        if ( args.length > 0 )
            for ( int i=0; i<args.length; i++ )
                try
                    // crc = calcCRC32 ( args[i] );
                    crc = calcFileCRC32 ( args[i] );
                    System.out.println ( i + " : " + crc + " ( " + Long.toHexString(crc) + " ) : " + args[i] );
                catch ( Exception e )
                    e.printStackTrace();
}

Similar Messages

  • Incorrect initial value for char 0FISCYEAR in i_t_range in DTP filter prog

    Gurus
    I need your help , I have searched all the threads but could not find anything which can help me resolve this issue.
    I have a filter in DTP as a routine to get the year from system date.
    The program is correct for syntex but when I trigger the DTP I am getting the following message , not sure what needs to be added to my programe.
    Incorrect initial value for characteristic 0FISCYEAR in i_t_range
    Message no. DBMAN889
    appreciate any help I can get to reoslve this ASAP.
    Thanks in advance

    Hi
    Pleae check if you have initialised with a NULL value . "blank/null" is indeed not a valid characteristic value for fiscal period. Fisc.per is of type NUMC which means all characters have to be numerical. The initial value should be "0000000" .
    Thanks,
    Rajesh.
    Please provide points to answers if you find them helpful

  • Incorrect initial value for characteristic 0fiscyear in i_t_range

    Hi,
    While extracting the data from the source DSO to Target I got an error message like '' Incorrect initial value for characteristic 0fiscyear in i_t_range".
    what is the step should i take to resolve this?
    Thanks in Advance.

    Gurus
    I have the same problem with my ABAP code written in DTP filter.
    Can anyone please help what needs to be done , I am getting this error when I try to load the data to cube.

  • How to set default value for html:file in struts

    hi
                   i am working on an application using struts situation is i am using the
    <html:file property="" /> to allow the user to upload file. but i need that a default file should be set so that even if the user donot click browse ie                the user wish to upload that default file the default file get uploaded on page submition.     Is it possible to set any default value for html:file ...if yes plz provide any suggestion or links how to achieve this.     thanks in advance

    www.google.com?q=STRUTS+DOCUMENTATION

  • Explain statspack values for tablespace & file IO

    10.2.0.2 aix 5.2 64bit
    in the Tablespace IO Stats & File IO Stats section of statspack and awr reports can someone help to clear up a little confusion I have with the value for AV Reads/s & AV Rd(ms). I'll reference some values I have from one of my reports over a 1 hour snap shot period, with the first three columns being reads, av rd/s, av rd(ms) respectively for both sections.
    For Tablespace IO I have the following.
    PRODGLDTAI
    466,879 130 3.9 1.0 8,443 2 0 0.0
    For File IO I have the following for each file within this tablespace.
    PRODGLDTAI /jdb10/oradata/jde/b7333/prodgldtai04.dbf
    113,530 32 2.6 1.0 1,302 0 0 0.0
    PRODGLDTAI /jdb14/oradata/jde/b7333/prodgldtai03.dbf
    107,878 30 1.6 1.0 1,898 1 0 0.0
    PRODGLDTAI /jdb5/oradata/jde/b7333/prodgldtai01.dbf
    114,234 32 5.8 1.0 2,834 1 0 0.0
    PRODGLDTAI /jdb5/oradata/jde/b7333/prodgldtai02.dbf
    131,237 36 5.2 1.0 2,409 1 0 0.0
    From this I can calculate that there were on average 129.68 reads every second for the tablespace and that matches what is listed. But where does the av rd(ms) come from? If there are 1000 milli-seconds in a second and there were 130 reads per second, doesn't that work out to 7.6 ms per read?
    What exactly is av rd(ms)? Is it how many milli-seconds it takes on average for 1 read? I've read in the Oracle Performance Tuning doc that it shouldn't be higher than 20. What exactly is this statistic? Also, we are currently looking at the purchase of a SAN and we were told that value shouldn't be above 10, is that just a matter of opinion? Would these values be kind of useless on tablespaces and datafiles that aren't very active over an hours period of time?

    10.2.0.2 aix 5.2 64bit
    in the Tablespace IO Stats & File IO Stats section of statspack and awr reports can someone help to clear up a little confusion I have with the value for AV Reads/s & AV Rd(ms). I'll reference some values I have from one of my reports over a 1 hour snap shot period, with the first three columns being reads, av rd/s, av rd(ms) respectively for both sections.
    For Tablespace IO I have the following.
    PRODGLDTAI
    466,879 130 3.9 1.0 8,443 2 0 0.0
    For File IO I have the following for each file within this tablespace.
    PRODGLDTAI /jdb10/oradata/jde/b7333/prodgldtai04.dbf
    113,530 32 2.6 1.0 1,302 0 0 0.0
    PRODGLDTAI /jdb14/oradata/jde/b7333/prodgldtai03.dbf
    107,878 30 1.6 1.0 1,898 1 0 0.0
    PRODGLDTAI /jdb5/oradata/jde/b7333/prodgldtai01.dbf
    114,234 32 5.8 1.0 2,834 1 0 0.0
    PRODGLDTAI /jdb5/oradata/jde/b7333/prodgldtai02.dbf
    131,237 36 5.2 1.0 2,409 1 0 0.0
    From this I can calculate that there were on average 129.68 reads every second for the tablespace and that matches what is listed. But where does the av rd(ms) come from? If there are 1000 milli-seconds in a second and there were 130 reads per second, doesn't that work out to 7.6 ms per read?
    What exactly is av rd(ms)? Is it how many milli-seconds it takes on average for 1 read? I've read in the Oracle Performance Tuning doc that it shouldn't be higher than 20. What exactly is this statistic? Also, we are currently looking at the purchase of a SAN and we were told that value shouldn't be above 10, is that just a matter of opinion? Would these values be kind of useless on tablespaces and datafiles that aren't very active over an hours period of time?

  • Can I use MD5 value for indexing files ?

    I would like to know if MD5 value for each unqiue file is also unique. I am wonder if U can use MD5 value of a file for indexing. Any suggestion ??

    I would like to know if MD5 value for each unqiue file
    is also unique.No, since the number of MD5 hashes is less than the number of possible files. Of course, if you don't have many files the probability of clashes is pretty low. There's some theory about this which you'll find in algorithms textbooks where they talk about hash tables.
    I am wonder if U can use MD5 value of
    a file for indexing. Any suggestion ??Why? Don't you want your index to tell you something about the contents of the file?

  • Reason to set MaxErrorCount along with Propogate value for Excel Files

    Hi,
    I had an ETL earlier which processed CSV files from a folder. The requirement was to load the error files into a Rejected folder but continue to process all the files from the source Folder. This requirement was satisfied by setting the value of the
    system variable "Propogate" in EventHandler section for DataFlowTask to "false".
    MaxErrorCount value for the ForEach Loop is having its default value as "1".
    When tested, it was working perfectly fine
    Now currently there is an Excel file as source having same requirement as above. But even when then variable "Propogate" was set to "false" as above, the execution was getting stopped when an error file was found.
    Later I found the below link :
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/0065b5c2-f633-4cbf-81f9-031d1ed25555/how-to-skip-wrong-excel-files-ignore-errors-on-ssis-foreach-task
    As mentioned in the link, I have done below changes
    1)Set MaxErrorCount for ForEachLoop to 1000
    2)"Propogate" variable is set to false
    Now this is working perfectly fine.
    Can you please let me know why did the setting of "Propogate" worked for CSV but did not work for Excel. For Excel files why was an additional setting for MaxErrorCount  was required.
    It would be very much helpful if I can get a detail information on the above
    Thanks,
    Raksha
    Raksha

    Hi Raksha,
    In you SSIS package, setting the Propagate system variable to False of the Event Handler prevents the Data Flow Task (DFT) propagating its failure to its parent container. For the ValidateMetadata property of a Data Flow Task Component, it doesn’t only affect
    the DFT at design time but also at runtime. During the Validation phase, a component is supposed to check to make sure that the cached metadata in the package is still in sync with the underlying table/view/query. If there is a mismatch, the component returns
    a special status (VS_NEEDSNEWMETADATA). When this happens at design-time, SSIS triggers a metadata refresh by calling ReinitializeMetadata(). At runtime, this results in an error.
    In your scenario, by setting the ValidateMetadata property to false, the error of the DFT is avoided, hence, you don’t need to set the MaxErrorCount to a value more than 1.
    For more information about how ValidateMetadate property works, please see Matt’s answer in the following thread:
    http://stackoverflow.com/questions/3297097/validateexternalmetadata-property-what-exactly-does-this-do 
    Regards,
    Mike Yin
    TechNet Community Support

  • White balance values for NEF file

    Hello
    I'm using Ligthroom 1.2 with nikon raw files (NEF) taken with D80 camera (firmware 1.01).
    The white balance is most of the time set to 5300K on my camera. But in LR, it always shows 4950K, with tint set to -1.
    I know there is some compatibility problems between LR and NEF files, but does anyone know if there is a solution (except of course applying systematically the right temperature in LR during import.)?
    Thanks
    Erwann

    I believe the issue is actually that Nikon encrypts the white balance in NEF files of recent cameras. If you
    google for it you'll find lots of links to all the problems this caused. Adobe and other RAW software developers have had to reengineer the encryption of this value in order to get a reasonable value and in order to not break the DMCA (draconian US anti-piracy law). Apparently, for some cameras the algorithm is not so good. The alternative for Adobe would have been to use Nikon's RAW rendering library, which for obvious reasons will never happen. The only software I am aware of that correctly reads NEF white balance for cameras after the D2X without using Nikon's libraries is dcraw/ufraw, but they can get away with cracking the encryption. This really is one of the dumber things Nikon ever did.

  • Monitor TPS value for Ace Module

    Hi Everyone,
    I recently installed the license ACE-SSL-05K-K9  on ACE10 with multicontext solution.
    The license provides 5000 Maximum number of SSL transactions per second (TPS).
    The customer would like to track this to find out the correct size and in the case of services https upgrade licenses.
    Can I do it so through particular output or it's necessary monitoring with snmp service? In the second case, can you tell me the oid string to use?
    In case the module should receive a higher number of connections to that provided by the license, what's the issue for new https connections?
    Regards
    Dino

    Hello Dino!
    You can go into the Admin-Context and use sh resource usage all. Watch out for the ssl-connections rate. But I dont know the OID for this. But you can look into Cisco's MIB browser.
    Cheers,
    Marko

  • [CS3 INX] Values for file type in LnkI attribute?

    I've poked around in the C++ headers and all the relevant documentation I can find but can't find any definition of the possible values for the "file type" field in the Link Info array in CS3 INX files.
    Anyone know here I can find the list of possible values?
    I'm generating INX files with links and need to be able to generate the appropriate values based on the link targets.
    Thanks,
    Eliot

    Hi
    Pls tell me how did you resolve this issue. I am also facing the same problem.
    Thanks
    Prakash

  • BUG: Info panel displays incorrect Hue values

    Recently, I've been doing a lot of work with color in Fireworks and came across the following bug, which appears to be a longstanding issue within the application. Rather than keeping it to myself, I figured I'd post it here in addition to submitting a bug report with Adobe. So here it is...
    Hue values displayed within the Info panel (in HSB mode) do not consistently match the values displayed in the Color Mixer panel—including basic colors such as pure Yellow, Cyan, and Magenta. The values are 1 degree off—most often below the Color Mixer value, but sometimes above (as with Magenta). This holds true whether using with the Eyedropper tool or the Color Picker swatches eyedropper, and whether sampling from the canvas or from swatches.
    For example, the following inconsistencies were observed when sampling the centermost horizontal strip within CS6's default Color Cubes swatches picker. Note that over 50% of these colors are affected by the issue.
    The Color Mixer seems to display the correct values, while the Info panel's values appear to be incorrect. Note that this issue affects the HSB mode only; the RGB and Hex values are consistent between both panels.
    This bug has been observed in Fireworks CS6, Fireworks CS5.1 and Fireworks 8 on Mac OS 10.6.8 (Snow Leopard).
    Here's the bug report submitted for this issue:
    Product name: Fireworks
    Product Version: 12.0.0.236
    Product Language: English
    Your operating system: Mac OS 10.6.8 (Intel-based)
    ******BUG******
    Concise problem statement: The Info panel displays incorrect Hue values for many colors—including pure Yellow, Cyan, and Magenta. The Hue values are usually 1 degree below the value displayed in the Color Mixer panel (e.g., 59 instead of 60 for Yellow) but sometimes 1 degree above (e.g., 301 instead of 300 for Magenta). This is true whether using the Eyedropper tool or the Color Picker swatches eyedropper, and whether sampling from the canvas or from swatches.
    Steps to reproduce bug:
    In an open Fireworks document, open the Info, Color Mixer, and Swatches panels. Within the Color Mixer and Info panels, set the color mode to HSB.
    Draw a Rectangle and set its fill to Yellow (#FFFF00) using the Color Picker.
    Observe the Hue values displayed in the Color Mixer and Info panels.
    Select the Eyedropper (I) tool, and sample the rectangle's fill color. Again, observe the Hue values displayed in both the Color Mixer and Info panels.
    Results: In both steps 3 and 4, the Hue value for pure Yellow (#ffff00) appears as 60 degrees in the Color Mixer panel but 59 degrees in the Info panel.
    Expected results: The Hue for pure Yellow (#ffff00) should appear as 60 degrees in both panels.
    Note that this issue affects the Info panel's HSB mode only; the RGB and Hex values are consistent between panels. Also note that this bug affects over 50% of the "pure" hues within CS6's Color Cubes swatches palette. For more info, see the following forum post:
    http://forums.adobe.com/thread/1083391
    This bug has been observed in Fireworks CS6, CS5.1 and FW8 on Mac OS 10.6.8 (Snow Leopard).

    I haven't done anything other than add my footage to the timeline. I have 2 layers (1 targa seq and 1 png seq). As I move my mouse from the Timeline to the Comp Panel, the color values flash for a split second and go away. If I press Opt+1 (2, 3, and 4) the Info Panel displays the color for that one pixel but the values go blank as soon as I move my mouse. This happens in the Comp Panel mostly. If I open a Footage or Layer Panel, sometimes the values show, sometimes not. Never had this issue in previous versions.

  • Default setting for deleting files, default setting for deleting files

    How can I change default value for deleting files from 'Keep file' to 'In waste basket' (sorry this is a translation from the German 'In den Papierkorb') meaning delete file from harddisk definitely.

    Thank you for your quick answer. Yes that's the place I am doing the job. And yes I do get a choice to choose between 'Delete from hard disk' or 'Delete from iTunes only'.
    But the 'Delete from iTunes only' is the default setting. I would like to change the default setting to 'Delete permanently (from hard disk too)'. This would enable me to work much quicker by using keys only (Del + Enter) without touching the mouse to change from 'Delete from iTunes only' to 'Delete permanently'.

  • Java returning incorrect values for width and height of a Tiff image

    I have some TIFF images (sorry, I cannot post them b/c of there confidential nature) that are returning the incorrect values for the width and height. I am using Image.getWidth(null) and have tried the relevant methods from BufferedImage. When I open the same files in external viewers (Irfanview, MS Office Document Imaging) they look fine and report the "correct" dimensions. When I re-save the files, my code works fine. Obviously, there is something wrong with the files, but why would the Java code fail and not the external viewers? Is there some way I can detect file problems?
    Here is the code, the relevant section is in the print() routine.
    * ImagePrinter.java
    * Created on Feb 27, 2008
    * Created by tso1207
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.print.PageFormat;
    import java.awt.print.PrinterException;
    import java.io.File;
    import java.io.IOException;
    import java.util.Iterator;
    import javax.imageio.ImageIO;
    import javax.imageio.ImageReader;
    import javax.imageio.stream.FileImageInputStream;
    import javax.imageio.stream.ImageInputStream;
    import com.shelter.io.FileTypeIdentifier;
    public class ImagePrinter extends FilePrintable
       private final ImageReader _reader;
       private final int _pageCount;
       private final boolean _isTiff;
       //for speed we will hold current page info in memory
       private Image _image = null;
       private int _imgWidth = 0;
       private int _imgHeight = 0;
       private int _currentPage = -1;
       public ImagePrinter(File imageFile) throws IOException
          super(imageFile);
          ImageInputStream fis = new FileImageInputStream(getFile());
          Iterator readerIter = ImageIO.getImageReaders(fis);
          ImageReader reader = null;
          while (readerIter.hasNext())
             reader = (ImageReader) readerIter.next();
          reader.setInput(fis);
          _reader = reader;
          int pageCount = 1;
          String mimeType = FileTypeIdentifier.getMimeType(imageFile, true);
          if (mimeType.equalsIgnoreCase("image/tiff"))
             _isTiff = true;
             pageCount = reader.getNumImages(true);
          else
             _isTiff = false;
          _pageCount = pageCount;
       public int print(java.awt.Graphics g, java.awt.print.PageFormat pf, int pageIndex)
          throws java.awt.print.PrinterException
          int drawX = 0, drawY = 0;
          double scaleRatio = 1;
          if (getCurrentPage() != (pageIndex - getPageOffset()))
             try
                setCurrentPage(pageIndex - getPageOffset());
                setImage(_reader.read(getCurrentPage()));
                setImgWidth(getImage().getWidth(null));
                setImgHeight(getImage().getHeight(null));
             catch (IndexOutOfBoundsException e)
                return NO_SUCH_PAGE;
             catch (IOException e)
                throw new PrinterException(e.getLocalizedMessage());
             if (!_isTiff && getImgWidth() > getImgHeight())
                pf.setOrientation(PageFormat.LANDSCAPE);
             else
                pf.setOrientation(PageFormat.PORTRAIT);
          Graphics2D g2 = (Graphics2D) g;
          g2.translate(pf.getImageableX(), pf.getImageableY());
          g2.setClip(0, 0, (int) pf.getImageableWidth(), (int) pf.getImageableHeight());
          scaleRatio =
             (double) ((getImgWidth() > getImgHeight())
                ? (pf.getImageableWidth() / getImgWidth())
                : (pf.getImageableHeight() / getImgHeight()));
          //check the scale ratio to make sure that we will not write something off the page
          if ((getImgWidth() * scaleRatio) > pf.getImageableWidth())
             scaleRatio = (pf.getImageableWidth() / getImgWidth());
          else if ((getImgHeight() * scaleRatio) > pf.getImageableHeight())
             scaleRatio = (pf.getImageableHeight() / getImgHeight());
          int drawWidth = getImgWidth();
          int drawHeight = getImgHeight();
          //center image
          if (scaleRatio < 1)
             drawX = (int) ((pf.getImageableWidth() - (getImgWidth() * scaleRatio)) / 2);
             drawY = (int) ((pf.getImageableHeight() - (getImgHeight() * scaleRatio)) / 2);
             drawWidth = (int) (getImgWidth() * scaleRatio);
             drawHeight = (int) (getImgHeight() * scaleRatio);
          else
             drawX = (int) (pf.getImageableWidth() - getImgWidth()) / 2;
             drawY = (int) (pf.getImageableHeight() - getImgHeight()) / 2;
          g2.drawImage(getImage(), drawX, drawY, drawWidth, drawHeight, null);
          g2.dispose();
          return PAGE_EXISTS;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since version XXX
        * @return
       public int getPageCount()
          return _pageCount;
       public void destroy()
          setImage(null);
          try
             _reader.reset();
             _reader.dispose();
          catch (Exception e)
          System.gc();
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since Mar 25, 2008
        * @return
       public Image getImage()
          return _image;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since Mar 25, 2008
        * @return
       public int getImgHeight()
          return _imgHeight;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since Mar 25, 2008
        * @return
       public int getImgWidth()
          return _imgWidth;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since Mar 25, 2008
        * @param image
       public void setImage(Image image)
          _image = image;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since Mar 25, 2008
        * @param i
       public void setImgHeight(int i)
          _imgHeight = i;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since Mar 25, 2008
        * @param i
       public void setImgWidth(int i)
          _imgWidth = i;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since Mar 25, 2008
        * @return
       public int getCurrentPage()
          return _currentPage;
        * <br><br>
        * Created By: TSO1207 - John Loyd
        * @since Mar 25, 2008
        * @param i
       public void setCurrentPage(int i)
          _currentPage = i;
    }Edited by: jloyd01 on Jul 3, 2008 8:26 AM

    Figured it out. The files have a different vertical and horizontal resolutions. In this case the horizontal resolution is 200 DPI and the vertical is 100 DPI. The imgage width and height values are based on those resolution values. I wrote a section of code to take care of the problem (at least for TIFF 6.0)
       private void setPageSize(int pageNum) throws IOException
          IIOMetadata imageMetadata = _reader.getImageMetadata(pageNum);
          //Get the IFD (Image File Directory) which is the root of all the tags
          //for this image. From here we can get all the tags in the image.
          TIFFDirectory ifd = TIFFDirectory.createFromMetadata(imageMetadata);
          double xPixles = ifd.getTIFFField(256).getAsDouble(0);
          double yPixles = ifd.getTIFFField(257).getAsDouble(0);
          double xRes = ifd.getTIFFField(282).getAsDouble(0);
          double yres = ifd.getTIFFField(283).getAsDouble(0);
          int resUnits = ifd.getTIFFField(296).getAsInt(0);
          double imageWidth = xPixles / xRes;
          double imageHeight = yPixles / yres;
          //if units are in CM convert ot inches
          if (resUnits == 3)
             imageWidth = imageWidth * 0.3937;
             imageHeight = imageHeight * 0.3937;
          //convert to pixles in 72 DPI
          imageWidth = imageWidth * 72;
          imageHeight = imageHeight * 72;
          setImgWidth((int) Math.round(imageWidth));
          setImgHeight((int) Math.round(imageHeight));
          setImgAspectRatio(imageWidth / imageHeight);
       }

  • Possible to set the Created_by column value for File Browse?

    I'm using database account authentication and then a user gets to upload a file. Then my stored procedure reads the file. I was investigating a problem, happened to search the apex_workspace_files view and noticed the created_by column is always set to APEX_PUBLIC_USER for the files my users upload. Is there some way I can set that value when they log in, so I can track who actually did the upload?
    Thanks,
    Stew

    Dimitri,
    I was just using the standard File Browse item, so getting the blob from the workspace view. Though I've seen notes here about loading to your own table, what I had seemed to work (and was done) fairly well. There were just these little features I wanted to use...
    Thanks for the suggestion.
    Dave, I'm not sure which stored procedure you're suggesting I add the apex_custom_auth.get_username value to? I hoped that the internal File Browse routine would pick up the get_username value automatically instead of the application definition Public User value.
    Thanks,
    Stew

  • I am trying to export the combained PDF based on BOOK opetion using below scripts. but i am getting following error message "Invalid value for parameter 'to' of method 'exportFile'. Expected File, but received 1952403524". anyone knows, please suggest me

    Dear ALL,
    i am trying to export the combained PDF based on BOOK opetion using below scripts. but i am getting following error message "Invalid value for parameter 'to' of method 'exportFile'. Expected File, but received 1952403524". anyone knows, please suggest me solutions.
    var myBookFileName ,myBookFileName_temp;
                    if ( myFolder != null )
                            var myFiles = [];
                            var myAllFilesList = myFolder.getFiles("*.indd");    
                            for (var f = 0; f < myAllFilesList.length; f++)
                                        var myFile = myAllFilesList[f]; 
                                        myFiles.push(myFile);
                            if ( myFiles.length > 0 )
                                        myBookFileName = myFolder + "/"+ myFolder.name + ".indb";
                                        myBookFileName_temp=myFolder.name ;
                                        myBookFile = new File( myBookFileName );
                                        myBook = app.books.add( myBookFile );  
                                       myBook.automaticPagination = false;
                                        for ( i=0; i < myFiles.length; i++ )
                                                   myBook.bookContents.add( myFiles[i] );             
                                        var pdfFile =File(File(myFolder).fsName + "\\"+myBookFileName_temp+"_WEB.pdf");
                                        var bookComps = myBook.bookContents;
                                        if (bookComps.length === 1)
                                                       bookComps = [bookComps];
                                         var myPDFExportPreset = app.pdfExportPresets.item("AER6");
                                        app.activeBook.exportFile(ExportFormat.PDF_TYPE,File("D:\\AER\\WEBPDF.pdf"),false,myPDFEx portPreset,bookComps);
                                      //myBook.exportFile (ExportFormat.pdfType, pdfFile, false);
                                      //myBook.exportFile(pdfFile, false, pdfPref, bookComps);
                                        myBook.close(SaveOptions.yes);      

    Change the below line:
    app.activeBook.exportFile(ExportFormat.PDF_TYPE,File("D:\\AER\\WEBPDF.pdf"),false,myPDFExp ortPreset,bookComps);
    to
    app.activeBook.exportFile(ExportFormat.PDF_TYPE,File("D:\\AER\\WEBPDF.pdf"),false,myPDFExp ortPreset);
    Vandy

Maybe you are looking for

  • ITunes/Computer will not recognize my iPod??

    I recently attempted to update my iPod Touch 3G to the newest update, and afterwards, my iPod only shows the screen that wants me to connect my iPod to iTunes b ut when I connect it to my computer, iTunes will not recognize it, and my computer says t

  • REGARDING hod id in hr-abap

    hi experts, with the help of logic applied on table hrp1001 and hrp1000 i got the hod id of a particular organizational unit ,what i want the what logic or function module will i use to get the list of employees working under that particular hod and

  • Selection issue 1px gap

    Hi, Hi , I have drawn a path using the pen tool in photoshop cs5  then I use 'command j'  to copy the selection to new layer, then I delete the selection from the back ground layer. This should look no different however I can see a 1 px gap between t

  • Cannot Download Oracle 9i client

    I get the 404 error when I click on any of the zip file links for the Oracle 9i client downloads. Is there a problem with the download availability? Thanks

  • Execute client for Session Bean without appClient

    Hi, I want to execute a standalone client for a Session Bean in a Application Server 8 platform but I don�t want to use the "appClient" script that is used in the J2EE 1.4 Tutorial. For example, for the Converter example I want to execute ConverterCl