problem with pdf report file generation

public boolean PDFProcess()
    {
        List 			    PDFFiles;
        ListEnumerator      PDFEnumerator;
        boolean             errors;
        filename            _from,_to,_temp, _name, _ext;
        container           _split;
        Bindata             _bin;
        DocuRef             docuref;
        custTable           custTable;
        DocuActionArchive   DocuActionArchive;
        System.IO.MemoryStream stream;
        System.IO.StreamWriter write;
        PDFFiles = VE005FilesTools::GetlistOfFiles(VEParameters.VE005Path2Read,VEParameters.VE005FileNameDocumentFilter);
        PDFEnumerator = PDFFiles.getEnumerator();
        while(PDFEnumerator.moveNext())
        {
            _from = PDFEnumerator.current();
            custTable = this.DecodePDF(_from);

            if (custTable)
            
            {
            
             docuref.clear();
                docuRef.RefRecId = custTable.recid;
                docuRef.RefTableId = custTable.TableId;
                docuRef.DocumentId = newGuid();
                docuref.RefCompanyId = curext();
                docuref.ActualCompanyId = curext();
                docuref.TypeId = VEParameters.VE005DocuTypeId;
                docuRef.insert();

                DocuActionArchive = docuAction::newDocuRef(docuref);
                DocuActionArchive.add(docuref,_from);
            
            
                _split = fileNameSplit(_from);
                _name = conPeek(_split,2);
                _ext = conPeek(_split,3);
                stream = new System.IO.MemoryStream();
                writer = new System.IO.StreamWriter(stream);
                writer.Write(_name);
                writer.Flush();
                docuref = DocumentManagement::attachFileToCommon(CustTable, VEParameters.VE005DocuTypeId, stream, _name+_ext, 'PDF', _name+_ext);
               
               
                if (this.move(_from,VEParameters.VE005Path2Backup))
                {
                    errors = true;
                }
            }
            else
            {
                if (this.move(_from,VEParameters.VE005Path2Errors))
                {
                    errors = true;
                }
            }
        }
        return errors;
    }
 i have batch process that generate pdf. But when i create it, i find it corrupted. Any suggestions for this code? thanks in advance

Related
Recommended