Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).


New Forum | Previous | Next | (P-PDF) Developers


Topic: How to control an increasing temp file
Conf: (P-PDF) Developers, Msg: 118032
From: fleury
Date: 8/31/2004 03:13 PM

Hello,

We have a program that was built to convert about three million tiff files to pdf. Yet the

program hangs after about 6,000 to 7,000 conversions. Upon investigation we discovered the

AcroApp object (Acrobat Pro 6.0) created some temp files, one of which will grow in size as the

program runs. Eventually, when the temp file reaches the size of the system pagefile the program

hangs. As a work around we tried modifying the program to do the following upon the completion of

each folder. (See examples below.)

1. Destroy the Acrobat objects
2. Delete the temp files
3. recreate the Acrobat objects

Unfortunately this didn't work, inside the program we got a 'permission denied' error and when

trying to manually delete the file from Explorer we got a error stating 'the file is in use by

another program'. The only way we were able to delete the temp files was to stop the 'exe'.

Would anyone know of a way to deal with this problem without having to stop the 'exe' or increase

the pagefile size?

Thanks in advance,


Bill


--- Original Code ---

Private Sub Convert_Tif_2_PDF()

Dim TifRoot As String
Dim PdfRoot As String
Dim TifFile As String
Dim PdfFile As String

TifRoot = "D:/Registry/Tiff"
PdfRoot = "D:/Registry/PDF"


Dim File As File
Dim Files As Files
Dim Fldr As Folder
Dim Fldrs As Folders

Set Fldr = FSO.GetFolder(TifRoot)
Set Fldrs = Fldr.SubFolders
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")

For Each Fldr In Fldrs
Set Files = Fldr.Files
CreateFldr (PdfRoot & "/" & Fldr.Name)
For Each File In Files
TifFile = FSO.BuildPath(Fldr.Path, File.Name)
PdfFile = PdfRoot & "/" & Fldr.Name & "/" & FSO.GetBaseName(File.ShortName) & ".pdf"
'
Call AVDoc.Open(TifFile, "")
Set AVDoc = AcroApp.GetActiveDoc
If AVDoc.IsValid Then
Set PDDoc = AVDoc.GetPDDoc
If PDDoc.Save(1 Or 4 Or 32, PdfFile) <> True Then
i = 1 / 0 ' Force error
End If
PDDoc.Close
End If
AVDoc.Close True
Next
Next

AcroApp.Exit

'Cleanup
Set PDDoc = Nothing
Set AVDoc = Nothing
Set AcroApp = Nothing
End Sub


--- Modified Code ---

Private Sub Convert_Tif_2_PDF()

Dim TifRoot As String
Dim PdfRoot As String
Dim TifFile As String
Dim PdfFile As String

TifRoot = "D:/Registry/Tiff"
PdfRoot = "D:/Registry/PDF"


Dim File As File
Dim Files As Files
Dim Fldr As Folder
Dim Fldrs As Folders

Set Fldr = FSO.GetFolder(TifRoot)
Set Fldrs = Fldr.SubFolders
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")

For Each Fldr In Fldrs
Set Files = Fldr.Files
CreateFldr (PdfRoot & "/" & Fldr.Name)
For Each File In Files
TifFile = FSO.BuildPath(Fldr.Path, File.Name)
PdfFile = PdfRoot & "/" & Fldr.Name & "/" & FSO.GetBaseName(File.ShortName) & ".pdf"
'
Call AVDoc.Open(TifFile, "")
Set AVDoc = AcroApp.GetActiveDoc
If AVDoc.IsValid Then
Set PDDoc = AVDoc.GetPDDoc
If PDDoc.Save(1 Or 4 Or 32, PdfFile) <> True Then
i = 1 / 0 ' Force error
End If
PDDoc.Close
End If
AVDoc.Close True
Next
' This block of code attempts to destroy the Acrobat objects,
' delete the temp files and then recreate the objects.
' Unfortunately it doesn't work. On both of the delete statements,
' it gives an error stating the file is in use by another program.
'
AcroApp.Exit
Set PDDoc = Nothing
Set AVDoc = Nothing
Set AcroApp = Nothing
On Error Resume Next
FSO.DeleteFile "C:\Documents and Settings\bill\Local Settings\Temp\*.tmp", True
Kill "C:\Documents and Settings\bill\Local Settings\Temp\*.tmp"
Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")
Next

AcroApp.Exit

'Cleanup
Set PDDoc = Nothing
Set AVDoc = Nothing
Set AcroApp = Nothing
End Sub


PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.