Why might an Advanced Zone Locator throw an Out of Memory error when the system is not actually out of memory?
QAID # 15011 Published
Question / Problem:
Why might an Advanced Zone Locator throw an Out of Memory
error when the system is not actually out of memory?
Answer / Solution:
This can occur if an Advanced Zone Locator (AZL) zone is off of the page from which it is trying to extract data. Usually the only reason that a zone would be off of the page is if the pages being processed are a different size or DPI than the reference image that was used to configure the locator, or, if the AZL zones were relocated in script and they are placed off of the page.
KTM 5.5 has been improved to handle these zones with invalid locations. In previous versions, if these situations cannot be avoided, the following function can be called from a script locator which runs before the AZL. It will move any zones with invalid locations and prevent the error.
'Prevent AZL Zones which might go off a page from causing an error 'Call this after any script that moves AZL zones and before the actual AZL 'It seems that this can cause the AZL to have alternatives with zeroed coordinates on PageNr -1 'The only implication is that script which uses these alternatives should 'check for valid values Public Sub FixAZLCoordinates(ByVal pXdoc As CscXDocument) Dim Rep As CscXDocRepresentation Set Rep = pXdoc.Representations(0) Dim iZone As Integer Dim oZone As CscXDocZone Dim iPage As Integer Dim NewZones() ReDim NewZones(0) 'go through zones (backwards so removing items is fine) For iZone = Rep.Zones.Count - 1 To 0 Step -1 Set oZone = Rep.Zones(iZone) 'go through pages For iPage = 0 To pXdoc.Pages.Count - 1 Dim ZoneIsOnThisPage As Boolean If oZone.PageNr=iPage Then ZoneIsOnThisPage = True Else ZoneIsOnThisPage = False End If If ZoneIsOnThisPage Then Dim ZoneOffPageTooFarRight As Boolean ZoneOffPageTooFarRight = (oZone.Left + oZone.Width)>pXdoc.Pages.ItemByIndex(iPage).Width Dim ZoneOffPageTooLow As Boolean ZoneOffPageTooLow = (oZone.Top + oZone.Height)>pXdoc.Pages.ItemByIndex(iPage).Height If ZoneOffPageTooFarRight Or ZoneOffPageTooLow Then 'Remove the zone (will not cause index problems because we are 'stepping through backwards) 'Trace "Removing Zone: '" & oZone.Name & ", TooRight/TooLow: " & ZoneOffPageTooFarRight & "/" & 'ZoneOffPageTooLow Rep.Zones.Remove(iZone) 'Create new zone with zeroed coordinates which will always be on the page Dim oZoneNew As CscXDocZone Set oZoneNew = New CscXDocZone oZoneNew.Name = oZone.Name oZoneNew.PageNr = oZone.PageNr oZoneNew.Left = 0 oZoneNew.Width = 0 oZoneNew.Top = 0 oZoneNew.Height = 0 'Add zone to array (we don't want to append it while we are ' still itterating though the zones) ReDim Preserve NewZones(UBound(NewZones)+1) Set NewZones(UBound(NewZones)) = oZoneNew End If End If Next Next 'Add the new zones Dim i As Integer Dim ZoneToAppend As CscXDocZone For i=0 To UBound(NewZones) If Not IsEmpty(NewZones(i)) Then Set ZoneToAppend=NewZones(i) 'Trace "Appending new zone: " & ZoneToAppend.Name Rep.Zones.Append ZoneToAppend End If Next End Sub
Applies to:
Product | Version | Category |
---|---|---|
AXPRO | 4.0 | Server |
AXPRO | 4.5 | Server |
AXPRO | 5.0 | Server |