By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,848 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,848 IT Pros & Developers. It's quick & easy.

Bit of a logic issue?

P: 46
I have a sub routine that I have written that is used to parse our documents that are faxed into our fax server. These documents have a barcode on them that is read by a java app that I wrote a while back. All of this works perfectly well.

However, one issue that I can't seem to get passed is when a certain set of documents has been parsed they are converted to pdf's and then merged into one pdf book. Now the next time a document comes in for that certain user/transaction/id I need to delete the previous merged document and re-merge all the documents again.

The first time I run the process on the document it works perfectly fine. I then get an issue when trying to run the process again on the doc to test the merging of the pdfs.

This is code I have thus far. It works perfectly fine if i remove the check to see if the file already exists. But I need the check to be in there because I cant merge the previously created merged foc in with the new one. As it would igve me duplicate pages.

And with out further need for stalling.
Expand|Select|Wrap|Line Numbers
  1.     sub agParse {
  2.         my $primer = barDecode($_[0]);
  3.  
  4.         # Clean up Primer;
  5.         $primer = leftStr(trim($primer),3,35);
  6.  
  7.  
  8.         # Check to see if complete doc exists. if it does, delete it;
  9.         if(-e "$config_vars{'storePath'} . '/adminDocs/tmp/' . trim($primer) . '-' . 'Complete.pdf'"){
  10.             unlink($config_vars{'storePath'} . '/adminDocs/tmp/' . trim($primer) . '-' . 'Complete.pdf');
  11.         }
  12.  
  13.         #my $outObj = $config_vars{'storePath'} . '/adminDocs/ag/' . trim($primer) . '/' . trim($primer) . '-' . timeFile();        
  14.         my $outObj = $config_vars{'storePath'} . '/adminDocs/tmp/' . trim($primer) . '-' . timeFile();    
  15.  
  16.         # Convert source file to a pdf
  17.         convert2PDF($_[0],$outObj);
  18.  
  19.         # Delete Source File
  20.         unlink($_[0]);
  21.  
  22.         # Create output pdf objects.
  23.         my $outPDF = $config_vars{'storePath'} . '/adminDocs/tmp/' . trim($primer) . '-' . 'Complete.pdf';
  24.  
  25.  
  26.         # Create input pdf object
  27.         my $inPDF = $config_vars{'storePath'} . '/adminDocs/tmp/';
  28.         # Create concatenated list of files in directory
  29.         $inPDF = concatDir($inPDF);        
  30.  
  31.         # Merge existing pdf documents into one pdf document.
  32.         mergePDF($outPDF,$inPDF);        
  33.     }
  34.  
Jan 17 '08 #1
Share this Question
Share on Google+
1 Reply


KevinADC
Expert 2.5K+
P: 4,059
This looks wrong:

Expand|Select|Wrap|Line Numbers
  1.         if(-e "$config_vars{'storePath'} . '/adminDocs/tmp/' . trim($primer) . '-' . 'Complete.pdf'"){
  2.  
The double-quotes at the beginning and end are killing the concatenation operator and treating the dot literally. Remove the double-quotes and it should work.
Jan 17 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.